using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace Web.Admin.course { public partial class AddCourseCountType : System.Web.UI.Page { BLL.CTypeBLL ctb = new BLL.CTypeBLL(); protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if(Request["id"]!=null) { var cc = ctb.GetInfo(Convert.ToInt32(Request["id"].ToString())); txtName.Text = cc.TypeName; txtTitle.Text = cc.TypeTitle; txtSort.Text = cc.TypeSort.ToString(); txtImgUrl.Value = cc.TypeIco; txtDescribe.Text = cc.TypeDescribe; txtImgUrl1.Value = cc.TypeIcoActivation; } } } protected void btnSubmit_Click(object sender, EventArgs e) { Models.CTypeInfo cc = new Models.CTypeInfo(); cc.TypeName = txtName.Text.Trim(); cc.TypeTitle = txtTitle.Text.Trim(); cc.TypeSort = Convert.ToInt32(txtSort.Text); cc.TypeIco = txtImgUrl.Value; cc.TypeDescribe = txtDescribe.Text.Trim(); cc.TypeIcoActivation = txtImgUrl1.Value; if (Request["id"] != null) { cc.TypeId = int.Parse(Request["Id"]); if (Edit(cc)) { string msbox = "parent.jsprint(\"编辑成功\", \"CourseCountTypeList.aspx\", \"Success\")"; ClientScript.RegisterClientScriptBlock(Page.GetType(), "JsPrint", msbox, true); } } else { if(Add(cc)) { string msbox = "parent.jsprint(\"添加成功\", \"CourseCountTypeList.aspx\", \"Success\")"; ClientScript.RegisterClientScriptBlock(Page.GetType(), "JsPrint", msbox, true); } } } public bool Add(Models.CTypeInfo cc) { var i = ctb.Add(cc); return i>0; } public bool Edit(Models.CTypeInfo cc) { var i = ctb.Update(cc); return i>0; } } }