温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:WO@BIZ第一季1.2版源码
当前文件:
WOBIZ/admin/ProductCat.aspx.cs,打开代码结构图
WOBIZ/admin/ProductCat.aspx.cs,打开代码结构图1using System; 2
using System.Data; 3
using System.Configuration; 4
using System.Collections; 5
using System.Web; 6
using System.Web.Security; 7
using System.Web.UI; 8
using System.Web.UI.WebControls; 9
using System.Web.UI.WebControls.WebParts; 10
using System.Web.UI.HtmlControls; 11
using WoNextDll.commen; 12
using WoNextDll.component; 13
using WoNextDll.Handler; 14
using WoNextDll.Data; 15
16
public partial class admin_ProductCat : System.Web.UI.Page 17
{ 18
protected void Page_Load(object sender, EventArgs e) 19
{ 20
if (Session["_AdminID"] == null) 21
{ 22
Response.Write("<script>top.location.href='admin_login.aspx';</script>"); 23
} 24
else 25
{ 26
if (!IsPostBack) 27
{ 28
string str = "select * from WO_ProType"; 29
bind(str); 30
} 31
} 32
} 33
34
protected void bind(string sql) 35
{ 36
Jpage1.JDataType = "2"; 37
Jpage1.Jconnstr = MyDB.GetMsSqlConnStr(); 38
Jpage1.Jselect = sql; // 查询语句 39
Jpage1.Jsortfield = "orderid asc,id asc";//排序方式 40
Jpage1.JControl = "Dlist"; 41
Jpage1.DataBind();//绑定数据 42
} 43
44
protected void Dlist_RowCommand(object sender, GridViewCommandEventArgs e) 45
{ 46
if (e.CommandName == "lbdel") 47
{ 48
int deleteid = int.Parse(e.CommandArgument.ToString()); 49
Han_ProType han = new Han_ProType(); 50
Han_ProTags ptag = new Han_ProTags(); 51
//先得到这个类别下有没有小类 52
ProType pro = han.GetproType(deleteid); 53
if (pro.Fromtypeid == 0) //说明是大类,先找出小类 54
{ 55
DataSet ds = MyDB.GetDataSet("select * from WO_ProType where fromtypeid=" + deleteid + ""); 56
if (ds.Tables[0].Rows.Count > 0) 57
{ 58
DataSet ds2 = new DataSet(); 59
for (int i = 0; i < ds.Tables[0].Rows.Count; i++) 60
{ 61
//先根据小类编号找到这个类别下的所有宝贝 62
ds2 = MyDB.GetDataSet("select * from Wo_ProInfo where ctypeid='" + ds.Tables[0].Rows[i]["id"].ToString() + "'"); 63
if (ds2.Tables[0].Rows.Count > 0) //这个类别有宝贝 64
{ 65
for (int ii = 0; ii < ds2.Tables[0].Rows.Count; ii++) 66
{ 67
//先删除这个宝贝的标签 68
bool b = ptag.DelProTags(int.Parse(ds2.Tables[0].Rows[ii]["id"].ToString())); 69
if (!b) 70
{ 71
Response.Write(Function.msgbox("删除出现错误,请重新删除!", "ProductCat.aspx", 1, 0)); 72
Response.End(); 73
} 74
//再删除类别下的宝贝和宝贝评论 75
b = MyDB.DelPKeyAndCKey("Wo_ProInfo", "Wo_ProRevert", "id", "proid", ds2.Tables[0].Rows[ii]["id"].ToString()); 76
if (!b) 77
{ 78
Response.Write(Function.msgbox("删除出现错误,请重新删除!", "ProductCat.aspx", 1, 0)); 79
Response.End(); 80
} 81
} 82
} 83
//再把自己这个类别删除了 84
string str = "delete from Wo_ProType where id=" + ds.Tables[0].Rows[i]["id"].ToString(); 85
MyDB.ExecSql(str); 86
87
} 88
} 89
//小类删除完了,删除大类 90
string s = "delete from Wo_ProType where id=" + deleteid; 91
MyDB.ExecSql(s); 92
Response.Write(Function.msgbox("删除成功!", "ProductCat.aspx", 1, 0)); 93
Response.End(); 94
} 95
else //说明是小类 96
{ 97
//先根据小类编号找到这个类别下的所有宝贝 98
DataSet ds3 = MyDB.GetDataSet("select * from Wo_ProInfo where ctypeid='" + deleteid.ToString() + "'"); 99
if (ds3.Tables[0].Rows.Count > 0) //这个类别有宝贝 100
{ 101
for (int ii = 0; ii < ds3.Tables[0].Rows.Count; ii++) 102
{ 103
//先删除这个宝贝的标签 104
bool b = ptag.DelProTags(int.Parse(ds3.Tables[0].Rows[ii]["id"].ToString())); 105
if (!b) 106
{ 107
Response.Write(Function.msgbox("删除出现错误,请重新删除!", "ProductCat.aspx", 1, 0)); 108
Response.End(); 109
} 110
//再删除类别下的宝贝和宝贝评论 111
b = MyDB.DelPKeyAndCKey("Wo_ProInfo", "Wo_ProRevert", "id", "proid", ds3.Tables[0].Rows[ii]["id"].ToString()); 112
if (!b) 113
{ 114
Response.Write(Function.msgbox("删除出现错误,请重新删除!", "ProductCat.aspx", 1, 0)); 115
Response.End(); 116
} 117
} 118
} 119
//再把自己这个类别删除了 120
string str = "delete from Wo_ProType where id=" + deleteid.ToString(); 121
MyDB.ExecSql(str); 122
Response.Write(Function.msgbox("删除成功!", "ProductCat.aspx", 1, 0)); 123
Response.End(); 124
} 125
} 126
} 127
protected void Dlist_RowDataBound(object sender, GridViewRowEventArgs e) 128
{ 129
if (e.Row.RowType == DataControlRowType.DataRow) 130
{ 131
int typeid = int.Parse(e.Row.Cells[2].Text); 132
if (typeid == 0) 133
{ 134
e.Row.Cells[2].Text = "此类是大类"; 135
} 136
else 137
{ 138
Han_ProType han = new Han_ProType(); 139
string typename = han.GetFromTypeName(typeid); 140
e.Row.Cells[2].Text = typename; 141
} 142
} 143
} 144
protected void Button1_Click(object sender, EventArgs e) 145
{ 146
Response.Redirect("AddProCat.aspx?Flag=Add"); 147
Response.End(); 148
} 149
} 150





}
}