C#的商品分类,商品修 改删除

| |
[不指定 2008/05/21 18:08 | by Else ]

<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="utf-8"%>
<%@ Register TagPrefix="MM" Namespace="DreamweaverCtrls" Assembly="DreamweaverCtrls,version=1.0.0.0,publicKeyToken=836f606ede05d46a,culture=neutral" %>
<MM:Insert
runat="server"
CommandText='<%# "INSERT INTO dbo.cuku_cat (catname, catlist, catcont) VALUES (?, ?, ?)" %>'
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSettings["MM_CONNECTION_STRING_conn"] %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSettings["MM_CONNECTION_DATABASETYPE_conn"] %>'
Expression='<%# Request.Form["MM_insert"] == "form2" && Request.Form["id"]=="" && Request.Form["catname"]!="" %>'
CreateDataSet="false"
SuccessURL='<%# "adminproducts.aspx?act=class" %>'
FailureURL='<%# "adminproducts.aspx?act=class" %>'
Debug="true"
>
  <Parameters>
    <Parameter Name="@catname" Value='<%# ((Request.Form["catname"] != null) && (Request.Form["catname"].Length > 0)) ? Request.Form["catname"] : "" %>' Type="VarChar" />
    <Parameter Name="@catlist" Value='<%# ((Request.Form["catlist"] != null) && (Request.Form["catlist"].Length > 0)) ? Request.Form["catlist"] : "" %>' Type="Integer" />
    <Parameter Name="@catcont" Value='<%# ((Request.Form["catcont"] != null) && (Request.Form["catcont"].Length > 0)) ? Request.Form["catcont"] : "" %>' Type="VarChar" />
  </Parameters>
</MM:Insert>

<MM:Update
runat="server"
CommandText='<%# "UPDATE dbo.cuku_cat SET catcont=?, catlist=?, catname=? WHERE id=?" %>'
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSettings["MM_CONNECTION_STRING_conn"] %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSettings["MM_CONNECTION_DATABASETYPE_conn"] %>'
Expression='<%# Request.Form["MM_update"] == "form2" && Request.Form["id"]!="" %>'
CreateDataSet="false"
SuccessURL='<%# "adminproducts.aspx?act=class" %>'
Debug="true"
>

  <Parameters>
    <Parameter Name="@catcont" Value='<%# ((Request.Form["catcont"] != null) && (Request.Form["catcont"].Length > 0)) ? Request.Form["catcont"] : "" %>' Type="VarChar" />
    <Parameter Name="@catlist" Value='<%# ((Request.Form["catlist"] != null) && (Request.Form["catlist"].Length > 0)) ? Request.Form["catlist"] : "" %>' Type="Integer" />
    <Parameter Name="@catname" Value='<%# ((Request.Form["catname"] != null) && (Request.Form["catname"].Length > 0)) ? Request.Form["catname"] : "" %>' Type="VarChar" />
    <Parameter Name="@id" Value='<%# ((Request.Form["id"] != null) && (Request.Form["id"].Length > 0)) ? Request.Form["id"] : "" %>' Type="Integer" />
  </Parameters>
</MM:Update>



<MM:Delete
runat="server"
CommandText='<%# "DELETE FROM dbo.cuku_cat WHERE id=?" %>'
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSettings["MM_CONNECTION_STRING_conn"] %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSettings["MM_CONNECTION_DATABASETYPE_conn"] %>'
Expression='<%# ((Request.QueryString["act"] == "del") && (Request.QueryString["do"]=="class")) %>'
CreateDataSet="false"
SuccessURL='<%# "adminproducts.aspx?act=class" %>'
FailureURL='<%# "adminproducts.aspx?act=class" %>'
Debug="true"
><Parameters>
  <Parameter Name="@id" Value='<%# ((Request.QueryString["id"] != null) && (Request.QueryString["id"].Length > 0)) ? Request.QueryString["id"] : "" %>' Type="Integer" />  
</Parameters>
</MM:Delete>

<!--插入产品-->
<MM:Insert
runat="server"
CommandText='<%# "INSERT INTO dbo.cuku_products (prodoucts, catid, content, recom, uptop, isnew, cont, pic) VALUES (?, ?, ?, ?, ?, ?, ?, ?)" %>'
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSettings["MM_CONNECTION_STRING_conn"] %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSettings["MM_CONNECTION_DATABASETYPE_conn"] %>'
Expression='<%# Request.Form["MM_insert"] == "form1" && Request.Form["id"].Trim()=="" %>'
CreateDataSet="false"
SuccessURL='<%# "adminproducts.aspx" %>'
FailureURL='<%# "adminproducts.aspx?act=add" %>'
Debug="true"
><Parameters>
  <Parameter Name="@prodoucts" Value='<%# ((Request.Form["prodoucts"] != null) && (Request.Form["prodoucts"].Length > 0)) ? Request.Form["prodoucts"] : "" %>' Type="VarChar" />  
  <Parameter Name="@catid" Value='<%# ((Request.Form["catid"] != null) && (Request.Form["catid"].Length > 0)) ? Request.Form["catid"] : "" %>' Type="Integer" />  
  <Parameter Name="@content" Value='<%# ((Request.Form["content"] != null) && (Request.Form["content"].Length > 0)) ? Request.Form["content"] : "" %>' Type="VarChar" />  
  <Parameter Name="@recom" Value='<%# ((Request.Form["recom"] != null) && (Request.Form["recom"].Length > 0)) ? Request.Form["recom"] : "" %>' Type="Boolean" />  
  <Parameter Name="@uptop" Value='<%# ((Request.Form["uptop"] != null) && (Request.Form["uptop"].Length > 0)) ? Request.Form["uptop"] : "" %>' Type="Boolean" />  
  <Parameter Name="@isnew" Value='<%# ((Request.Form["isnew"] != null) && (Request.Form["isnew"].Length > 0)) ? Request.Form["isnew"] : "" %>' Type="Boolean" />  
  <Parameter Name="@cont" Value='<%# ((Request.Form["cont"] != null) && (Request.Form["cont"].Length > 0)) ? Request.Form["cont"] : "" %>' Type="VarChar" />  
  <Parameter Name="@pic" Value='<%# ((Request.Form["pic"] != null) && (Request.Form["pic"].Length > 0)) ? Request.Form["pic"] : "" %>' Type="VarChar" />  
</Parameters>
</MM:Insert>
<MM:Update
runat="server"
CommandText='<%# "UPDATE dbo.cuku_products SET cont=?, content=?, isnew=?, recom=?, catid=?, pic=?, prodoucts=?, uptop=? WHERE id=?" %>'
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSettings["MM_CONNECTION_STRING_conn"] %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSettings["MM_CONNECTION_DATABASETYPE_conn"] %>'
Expression='<%# Request.Form["MM_update"] == "form1" && Request.Form["id"].Trim()!="" %>'
CreateDataSet="false"
SuccessURL='<%# "adminproducts.aspx" %>'
Debug="true"
>
  <Parameters>
    <Parameter Name="@cont" Value='<%# ((Request.Form["cont"] != null) && (Request.Form["cont"].Length > 0)) ? Request.Form["cont"] : "" %>' Type="VarChar" />
    <Parameter Name="@content" Value='<%# ((Request.Form["content"] != null) && (Request.Form["content"].Length > 0)) ? Request.Form["content"] : "" %>' Type="VarChar" />
    <Parameter Name="@isnew" Value='<%# ((Request.Form["isnew"] != null) && (Request.Form["isnew"].Length > 0)) ? Request.Form["isnew"] : "" %>' Type="Boolean" />
    <Parameter Name="@recom" Value='<%# ((Request.Form["recom"] != null) && (Request.Form["recom"].Length > 0)) ? Request.Form["recom"] : "" %>' Type="Boolean" />
    <Parameter Name="@catid" Value='<%# ((Request.Form["catid"] != null) && (Request.Form["catid"].Length > 0)) ? Request.Form["catid"] : "" %>' Type="Integer" />
    <Parameter Name="@pic" Value='<%# ((Request.Form["pic"] != null) && (Request.Form["pic"].Length > 0)) ? Request.Form["pic"] : "" %>' Type="VarChar" />
    <Parameter Name="@prodoucts" Value='<%# ((Request.Form["prodoucts"] != null) && (Request.Form["prodoucts"].Length > 0)) ? Request.Form["prodoucts"] : "" %>' Type="VarChar" />
    <Parameter Name="@uptop" Value='<%# ((Request.Form["uptop"] != null) && (Request.Form["uptop"].Length > 0)) ? Request.Form["uptop"] : "" %>' Type="Boolean" />
    <Parameter Name="@id" Value='<%# ((Request.Form["id"] != null) && (Request.Form["id"].Length > 0)) ? Request.Form["id"] : "" %>' Type="Integer" />
  </Parameters>
</MM:Update>



<MM:DataSet
id="rs"
runat="Server"
IsStoredProcedure="false"
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSettings["MM_CONNECTION_STRING_conn"] %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSettings["MM_CONNECTION_DATABASETYPE_conn"] %>'
CommandText='<%# "SELECT * FROM dbo.cuku_cat ORDER BY id DESC" %>'
Debug="true"
></MM:DataSet>
<MM:DataSet
id="editrs"
runat="Server"
IsStoredProcedure="false"
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSettings["MM_CONNECTION_STRING_conn"] %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSettings["MM_CONNECTION_DATABASETYPE_conn"] %>'
CommandText='<%# "SELECT * FROM dbo.cuku_cat WHERE id = ?" %>'
Debug="true"
>
  <Parameters>
    <Parameter  Name="@id"  Value='<%# ((Request.QueryString["id"] != null) && (Request.QueryString["id"].Length > 0)) ? Request.QueryString["id"] : "" %>'  Type="Integer"   />
  </Parameters>
</MM:DataSet>
<MM:DataSet
id="pds"
runat="Server"
IsStoredProcedure="false"
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSettings["MM_CONNECTION_STRING_conn"] %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSettings["MM_CONNECTION_DATABASETYPE_conn"] %>'
CommandText='<%# "SELECT *  FROM dbo.cuku_products,dbo.cuku_cat  WHERE dbo.cuku_cat.id = dbo.cuku_products.catid  ORDER BY dbo.cuku_products.id desc" %>'
CurrentPage='<%# ((Request.QueryString["pds_CurrentPage"] != null) && (Request.QueryString["pds_CurrentPage"].Length > 0)) ? Int32.Parse(Request.QueryString["pds_CurrentPage"]) : 0     %>'
PageSize="20"
Debug="true"
></MM:DataSet>

<MM:DataSet
id="editpds"
runat="Server"
IsStoredProcedure="false"
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSettings["MM_CONNECTION_STRING_conn"] %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSettings["MM_CONNECTION_DATABASETYPE_conn"] %>'
CommandText='<%# "SELECT *  FROM dbo.cuku_products  WHERE id = ?" %>'
Expression='<%# Myac=="add"  %>'
Debug="true"
>
  <Parameters>
    <Parameter  Name="@id"  Value='<%# ((Request.QueryString["id"] != null) && (Request.QueryString["id"].Length > 0)) ? Request.QueryString["id"] : "" %>'  Type="Integer"   />    </Parameters>
</MM:DataSet>
<MM:PageBind runat="server" PostBackBind="true" />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>产品管理</title>
<link href="images/admin.css" rel="stylesheet" type="text/css" />
</head>
<body>
<script>
function del(ids,what)
{
  if(confirm("你确定要删除吗?")){
    window.location.href="?act=del&do="+what+"&id="+ids;
  }else{
    return
  }

}
</script>
<script runat="server">
private string myac;  
public string Myac
{
  get { return this.myac; }
  set { this.myac = value; }
}

public string Checked(string chkstr)
{
  return chkstr=="True" ? "checked=\"checked\"":"";
}  

public void Page_Load(Object Src, EventArgs E)
{
  
  if (Request.QueryString["act"]== null)
  {
    
  Myac="go";
  }
  
  else
  {
   Myac=Request.QueryString["act"].Trim();
  }
}
</script>
<mm:if runat="server" expression='<%# Myac=="go" %>'>
  <contentstemplate>
    <table width="600" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
      <tr>
        <td height="25" colspan="5" background="images/bg_lead.png">&nbsp;&nbsp;产品管理</td>
      </tr>
      <tr>
        <td width="6%" align="center" bgcolor="#CCEAFA">编号</td>
        <td width="25%" align="center" bgcolor="#CCEAFA">产品名称</td>
        <td width="23%" align="center" bgcolor="#CCEAFA">分类</td>
        <td width="23%" align="center" bgcolor="#CCEAFA">属性</td>
        <td width="23%" align="center" bgcolor="#CCEAFA">管理</td>
      </tr>
      <ASP:Repeater runat="server" DataSource='<%# pds.DefaultView %>'>
        <ItemTemplate>
          <tr>
            <td height="21" align="center" bgcolor="#CCEAFA"><%# pds.FieldValue("id", Container) %></td>
            <td bgcolor="#CCEAFA"><%# pds.FieldValue("prodoucts", Container) %></td>
            <td bgcolor="#CCEAFA"><%# pds.FieldValue("catname", Container) %></td>
            <td bgcolor="#CCEAFA"><%# pds.FieldValue("isnew", Container) %><%# pds.FieldValue("recom", Container) %><%# pds.FieldValue("isnew", Container) %></td>
            <td align="center" bgcolor="#CCEAFA"><a href="?act=add&amp;id=<%# pds.FieldValue("id", Container) %>">修改</a> <a href="javascript:del('<%# pds.FieldValue("id", Container) %>','pro')">删除</a></td>
          </tr>
        </ItemTemplate>
      </ASP:Repeater>
      <tr>
        <td colspan="5" align="center" bgcolor="#CCEAFA">首页 上一页 下一页  末页</td>
      </tr>
    </table>
  </contentstemplate>
</mm:if>
<mm:if runat="server" expression='<%# Myac=="add" %>'  >
  <contentstemplate>
    <form action="" method='POST' enctype="multipart/form-data" name='form1' id="form1" runat='server'>
      <table width="600" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#FFFFFF">
        <tr>
          <td height="27" colspan="2" background="images/bg_lead.png" bgcolor="#EFF9FE">&nbsp;&nbsp;修改/添加商品</td>
        </tr>
        <tr>
          <td width="121" height="23" align="center" bgcolor="#CCEAFA">产品名称</td>
          <td width="479" bgcolor="#CCEAFA"><label>
            <input name="prodoucts" type="text" id="prodoucts" value="<%# editpds.FieldValue("prodoucts", Container) %>" />
            <input name="id" type="hidden" id="id" value="<%# editpds.FieldValue("id", Container) %>" />
          </label></td>
        </tr>
        <tr>
          <td height="23" align="center" bgcolor="#CCEAFA">产品分类</td>
          <td bgcolor="#CCEAFA">
          
            <select name="catid" id="catid">
      <ASP:Repeater runat="server" DataSource='<%# rs.DefaultView %>'>
        <ItemTemplate>
              <option value="<%# rs.FieldValue("id", Container) %>"><%# rs.FieldValue("catname", Container) %></option>
        </ItemTemplate>
       </ASP:Repeater>
            </select>
          </td>
        </tr>
        <tr>
          <td height="23" align="center" bgcolor="#CCEAFA">商品图片</td>
          <td bgcolor="#CCEAFA"><label>
            <input name="pic" type="text" id="pic" value="<%# editpds.FieldValue("pic", Container) %>" />
          </label></td>
        </tr>
        <tr>
          <td height="23" align="center" bgcolor="#CCEAFA">上传图片</td>
          <td bgcolor="#CCEAFA"><label>
            <input type="file" name="fileField" id="fileField" />
          </label></td>
        </tr>
        <tr>
          <td height="23" align="center" bgcolor="#CCEAFA">说 明</td>
          <td bgcolor="#CCEAFA"><input name="cont" type="text" id="cont" value="<%# editpds.FieldValue("cont", Container) %>" /></td>
        </tr>
        <tr>
          <td height="23" align="center" bgcolor="#CCEAFA">商品属性</td>
          <td bgcolor="#CCEAFA"><label>
            <input name="isnew" type="checkbox" id="isnew" value="true" <%# Checked(editpds.FieldValue("isnew", Container))%> />
            新商品
            <input name="recom" type="checkbox" id="recom" value="true" <%# Checked(editpds.FieldValue("recom", Container))%>/>
            推荐
            <input name="uptop" type="checkbox" id="uptop" value="true" <%# Checked(editpds.FieldValue("uptop", Container))%>/>
            置顶
</label></td>
        </tr>
        <tr>
          <td height="23" align="center" bgcolor="#CCEAFA">介 绍</td>
          <td bgcolor="#CCEAFA"><label>
            <textarea name="content" id="content" cols="45" rows="5"><%# editpds.FieldValue("content", Container) %></textarea>
            </label></td>
        </tr>
        <tr>
          <td height="23" align="center" bgcolor="#CCEAFA">&nbsp;</td>
          <td bgcolor="#CCEAFA"><label for="button"></label>
            <input type="submit" name="button" id="button" value="提交" />
            <label>
            <input type="reset" name="button2" id="button2" value="重设" />
            <input name="button3" type="button" id="button3" onclick="history.go(-1)" value="返回" />
            </label></td>
        </tr>
      </table>
      <input type="hidden" name="MM_insert" value="form1" />
      <input type="hidden" name="MM_update" value="form1" />
    </form>
  </contentstemplate>
</mm:if>
<mm:if runat="server" expression='<%# Myac=="class" %>'  >
  <contentstemplate>
    <table width="387" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#FFFFFF">
      <tr>
        <td height="25" colspan="5" align="center" background="images/bg_lead.png">&nbsp;&nbsp;分类列表</td>
      </tr>
      <tr>
        <td width="27" height="23" align="center" bgcolor="#CCEAFA">编号</td>
        <td width="79" align="center" bgcolor="#CCEAFA">分类名称</td>
        <td width="30" align="center" bgcolor="#CCEAFA">顺序</td>
        <td width="175" align="center" bgcolor="#CCEAFA">说明</td>
        <td width="60" align="center" bgcolor="#CCEAFA">管理</td>
      </tr>
      <ASP:Repeater runat="server" DataSource='<%# rs.DefaultView %>'>
        <ItemTemplate>
          <tr>
            <td height="23" align="center" bgcolor="#CCEAFA">&nbsp;<%# rs.FieldValue("id", Container) %></td>
            <td align="center" bgcolor="#CCEAFA"><%# rs.FieldValue("catname", Container) %></td>
            <td align="center" bgcolor="#CCEAFA"><%# rs.FieldValue("catlist", Container) %></td>
            <td bgcolor="#CCEAFA"><%# rs.FieldValue("catcont", Container) %></td>
            <td bgcolor="#CCEAFA"><a href="?act=class&amp;id=<%# rs.FieldValue("id", Container) %>">修改</a> <a href="javascript:del('<%# rs.FieldValue("id", Container) %>','class');">删除</a></td>
          </tr>
        </ItemTemplate>
      </ASP:Repeater>
    </table>
    <form runat='server' id="form2" name='form2' method='POST' action="">
      <table width="387" border="0" align="center" cellpadding="3" cellspacing="1">
        <tr>
          <td height="25" colspan="2" background="images/bg_lead.png">&nbsp;&nbsp;产品分类添加</td>
        </tr>
        <tr>
          <td width="100" align="center">分类名称</td>
          <td width="272"><label>
            <input name="catname" type="text" id="catname" value="<%# editrs.FieldValue("catname", Container) %>" />
            <input name="id" type="hidden" id="id" value="<%# editrs.FieldValue("id", Container) %>" />
            </label></td>
        </tr>
        <tr>
          <td align="center">分类顺序</td>
          <td><input name="catlist" type="text" id="catlist" value="<%# editrs.FieldValue("catlist", Container) %>" /></td>
        </tr>
        <tr>
          <td align="center">分类说明</td>
          <td><input name="catcont" type="text" id="catcont" value="<%# editrs.FieldValue("catcont", Container) %>" /></td>
        </tr>
        <tr>
          <td align="center">&nbsp;</td>
          <td><label>
            <input type="submit" name="button4" id="button4" value="提交" />
            <input type="reset" name="button5" id="button5" value="重置" />
            <input type="button" name="button6" id="button6" value="返回" />
            </label></td>
        </tr>
      </table>
      <input type="hidden" name="MM_insert" value="form2" />
      <input type="hidden" name="MM_update" value="form2" />
    </form>
  </contentstemplate>
</mm:if>
</body>
</html>


作者:Else 's Blog
地址:http://www.aixq.com/post/1039/
版权所有。转载时必须链接形式注明作者和原始出处及本声明!
  • 中查看更多“C#的商品分类,商品修 改删除”相关内容
  • 中查看更多“C#的商品分类,商品修 改删除”相关内容
  • 中查看更多“C#的商品分类,商品修 改删除”相关内容
  • 中查看更多“C#的商品分类,商品修 改删除”相关内容
  • 中查看更多“C#的商品分类,商品修 改删除”相关内容
  • 中查看更多“C#的商品分类,商品修 改删除”相关内容
  • Tags:
    代码 程序 编程 | 评论(0) | 引用(0) | 阅读(630)
    发表评论
    表情
    emotemotemotemotemot
    emotemotemotemotemot
    emotemotemotemotemot
    emotemotemotemotemot
    emotemotemotemotemot
    打开HTML
    打开UBB
    打开表情
    隐藏
    昵称   密码   游客无需密码
    网址   电邮   [注册]