温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:破竹CMS4.0免安装版源码
当前文件:
PozhuCMS/admin/Categories/Rates.aspx.cs,打开代码结构图
PozhuCMS/admin/Categories/Rates.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 Pozhu.CMS.Rates; 12
using Pozhu.CMS.Categories; 13
using Pozhu.Sites; 14
using Pozhu.UI.Utilities; 15
using Pozhu.CMS.Web; 16
17
public partial class admin_Categories_Rates : AdminPageBase 18
{ 19
protected void Page_Load(object sender, EventArgs e) 20
{ 21
if (!Page.IsPostBack) 22
{ 23
this.BindRates(); 24
} 25
} 26
27
void BindRates() 28
{ 29
string path = CategoryPath.CheckRepairPath(Request.QueryString["path"]); 30
int siteID = SiteController.GetCurrentSite().SiteID; 31
32
Category c = CategoryController.GetCategory(siteID, path); 33
34
this.rptRates.DataSource = RateController.GetRateItems(c.CategoryID); 35
this.rptRates.DataBind(); 36
} 37
38
protected void rptRates_ItemCommand(object source, RepeaterCommandEventArgs e) 39
{ 40
string path = CategoryPath.CheckRepairPath(Request.QueryString["path"]); 41
int siteID = SiteController.GetCurrentSite().SiteID; 42
Category category = CategoryController.GetCategory(siteID, path); 43
44
string commandName = e.CommandName; 45
if (e.Item.ItemType == ListItemType.Header) 46
{ 47
if (commandName == "add") 48
{ 49
RateItem rate = new RateItem(); 50
rate.CategoryID = category.CategoryID; 51
rate.Name = ((TextBox)e.Item.FindControl("tbName")).Text; 52
rate.Value = Convert.ToInt32(((TextBox)e.Item.FindControl("tbValue")).Text); 53
RateController.CreateRateItem(rate); 54
BindRates(); 55
} 56
} 57
else if ((e.Item.ItemType == ListItemType.Item) || e.Item.ItemType == ListItemType.AlternatingItem) 58
{ 59
if (commandName == "cancel") 60
{ 61
Response.Redirect(Request.RawUrl); 62
} 63
else if (commandName == "delete") 64
{ 65
RateController.DeleteRateItem(Convert.ToInt32(e.CommandArgument.ToString())); 66
BindRates(); 67
} 68
else if (commandName == "edit") 69
{ 70
e.Item.FindControl("lbtnEdit").Visible = false; 71
e.Item.FindControl("lbtnUpdate").Visible = true; 72
e.Item.FindControl("lbtnDelete").Visible = false; 73
e.Item.FindControl("lbtnCancel").Visible = true; 74
e.Item.FindControl("lblName").Visible = false; 75
e.Item.FindControl("tbName").Visible = true; 76
e.Item.FindControl("lblValue").Visible = false; 77
e.Item.FindControl("tbValue").Visible = true; 78
} 79
else if (commandName == "update") 80
{ 81
RateItem rate = RateController.GetRateItem(Convert.ToInt32(e.CommandArgument.ToString())); 82
rate.Name = ((TextBox)e.Item.FindControl("tbName")).Text; 83
rate.Value = Convert.ToInt32(((TextBox)e.Item.FindControl("tbValue")).Text); 84
RateController.UpdateRateItem(rate); 85
86
Response.Redirect(Request.RawUrl); 87
} 88
} 89
} 90
protected void rptRates_ItemDataBound(object sender, RepeaterItemEventArgs e) 91
{ 92
if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem)) 93
{ 94
Label lblPath = (Label)e.Item.FindControl("lblPath"); 95
LinkButton lbtnDelete = ((LinkButton)e.Item.FindControl("lbtnDelete")); 96
97
lblPath.Text = CategoryController.GetCategory(((RateItem)e.Item.DataItem).CategoryID).Path; 98
99
100
ClientAPI.AddButtonConfirm(lbtnDelete, string.Format("确定删除此关联吗?")); 101
} 102
} 103
} 104





}
}