using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace HySoft.BaseCallCenter.Web.knowledgemanage { public partial class knowledgeclassAddandEdit : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Response.Expires = -1; if (!IsPostBack) { if (!string.IsNullOrEmpty(Request.QueryString["categoryid"])) { txtF_ParentId.Value = Request.QueryString["categoryid"].Trim(); } if (!string.IsNullOrEmpty(Request.QueryString["id"])) { Initialize(Request.QueryString["id"]); } } } #region 信息初始化 void Initialize(string id) { T_RepositoryCategory = new BLL.T_RepositoryCategory().GetModel(Convert.ToInt32(id)); } #endregion #region 公共属性 private Model.T_RepositoryCategory T_RepositoryCategory { get { Model.T_RepositoryCategory _model = new Model.T_RepositoryCategory(); if (txtF_CategoryId.Value.Trim() != "") { _model.F_CategoryId = Convert.ToInt32(txtF_CategoryId.Value.Trim()); } else { _model.F_CategoryId = 0; } _model.F_CategoryName = txtF_CategoryName.Text.Trim(); try { _model.F_ParentId = Convert.ToInt32(txtF_ParentId.Value.Trim()); } catch { _model.F_ParentId = 0; } try { _model.F_Sort = Convert.ToInt32(txtF_Sort.Text.Trim()); } catch { _model.F_Sort = 0; } if (_model.F_CreateOn == null) _model.F_CreateOn = DateTime.Now; _model.F_DeleteFlag = 0; return _model; } set { if (value != null) { this.txtF_CategoryId.Value = value.F_CategoryId.ToString(); this.txtF_ParentId.Value = value.F_ParentId.ToString(); this.txtF_CategoryName.Text = value.F_CategoryName; this.txtF_Sort.Text = value.F_Sort.ToString(); } } } #endregion #region 保存信息 private void SaveInfo() { try { if (!string.IsNullOrEmpty(Request.QueryString["action"])) { if (Request.QueryString["action"].Trim() == "Add") { int bl = new BLL.T_RepositoryCategory().Add(T_RepositoryCategory); if (bl > 0) { ClientScript.RegisterClientScriptBlock(this.GetType(), "", ""); } else { ClientScript.RegisterClientScriptBlock(this.GetType(), "", ""); } } if (Request.QueryString["action"].Trim() == "Modify") { bool bl = new BLL.T_RepositoryCategory().Update(T_RepositoryCategory); if (bl) { ClientScript.RegisterClientScriptBlock(this.GetType(), "", ""); } else { ClientScript.RegisterClientScriptBlock(this.GetType(), "", ""); } } } } catch { ClientScript.RegisterClientScriptBlock(this.GetType(), "", ""); } } #endregion protected void btnSubmit_Click(object sender, EventArgs e) { SaveInfo(); } } }