| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- using HySoft.Common;
- 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.telmanage
- {
- public partial class ReasonAddandEdit : 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)
- {
- Model.T_Call_Reason T_Reason = new BLL.T_Call_Reason().GetModel(Convert.ToInt32(id));
- this.txtF_ReasonId.Value = T_Reason.F_ReasonID.ToString();
- txtF_ParentId.Value = T_Reason.F_ParentID.ToString();
- hidpid.Value = T_Reason.F_ParentID.ToString();
- this.txtF_ReasonName.Text = T_Reason.F_ReasonName;
- //if (T_Reason.F_SType.ToString() != "")
- // this.drpF_SType.SelectedValue = T_Reason.F_SType.ToString();
- //else
- // this.drpF_SType.SelectedValue = "0";
- }
- #endregion
-
- #region 保存信息
- private void SaveInfo()
- {
- try
- {
- if (!string.IsNullOrEmpty(Request.QueryString["action"]))
- {
- Model.T_Call_Reason T_Reason = new Model.T_Call_Reason();
- #region
- if (Request.QueryString["action"].Trim() == "Modify")
- {
- T_Reason = new BLL.T_Call_Reason().GetModel(Convert.ToInt32(Request.QueryString["id"]));
- }
- T_Reason.F_ReasonName = txtF_ReasonName.Text.Trim();
- try
- {
- T_Reason.F_ParentID = Convert.ToInt32(txtF_ParentId.Value.Trim());
- }
- catch
- {
- T_Reason.F_ParentID = 0;
- }
- //try
- //{
- // T_Reason.F_SType = Convert.ToInt32(drpF_SType.SelectedValue);
- //}
- //catch
- //{
- // T_Reason.F_SType = 1;
- //}
- T_Reason.F_SType = 1;
- if (!hidpid.Value.Trim().Equals(txtF_ParentId.Value.Trim()))
- {
- if (T_Reason.F_ParentID > 0)
- {
- Model.T_Call_Reason pModel = new Model.T_Call_Reason();
- pModel = new BLL.T_Call_Reason().GetModel(T_Reason.F_ParentID.Value);
- T_Reason.F_Layer = pModel.F_Layer + 1;//目录级别为父级别+1
- T_Reason.F_ParentName = pModel.F_ReasonName;
- if (pModel.F_AllPID != "")
- {
- T_Reason.F_AllPID = pModel.F_AllPID + "," + pModel.F_ReasonID.ToString();
- T_Reason.F_AllPName = pModel.F_AllPName + "-" + pModel.F_ReasonName;
- }
- else
- {
- T_Reason.F_AllPID = pModel.F_ReasonID.ToString();
- T_Reason.F_AllPName = pModel.F_ReasonName;
- }
- }
- else
- {
- T_Reason.F_Layer = 1;
- T_Reason.F_ParentName = "";
- T_Reason.F_AllPID = "";
- T_Reason.F_AllPName = "";
- }
- }
- #endregion
- if (Request.QueryString["action"].Trim() == "Add")
- {
- LoginUser loginUser = new LoginUser(Context);
- T_Reason.F_ISChildren = 0;
- T_Reason.F_CreateBy = loginUser.UserID;
- T_Reason.F_CreateByCode = loginUser.UserCode;
- T_Reason.F_CreateByName = loginUser.UserName;
- T_Reason.F_CreateOn = DateTime.Now;
- T_Reason.F_DeleteFlag = 0;
- int bl = new BLL.T_Call_Reason().Add(T_Reason);
- if (bl > 0)
- {
- if (T_Reason.F_ParentID > 0)
- {
- new BLL.T_Call_Reason().UpdateCHILD(T_Reason.F_ParentID.Value, 1);
- }
- ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>SaveInfo('success')</script>");
- }
- else
- {
- ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>SaveInfo('warn')</script>");
- }
- }
- if (Request.QueryString["action"].Trim() == "Modify")
- {
- bool bl = new BLL.T_Call_Reason().Update(T_Reason);
- if (bl)
- {
- if (!hidpid.Value.Trim().Equals(txtF_ParentId.Value.Trim()))
- {
- if (T_Reason.F_ParentID > 0)
- {//此父级的子集数量+1
- new BLL.T_Call_Reason().UpdateCHILD(T_Reason.F_ParentID.Value, 1);
- }
- if (hidpid.Value.Trim() != "" && hidpid.Value.Trim() != "0")
- {//此父级的子集数量-1
- new BLL.T_Call_Reason().UpdateCHILD(int.Parse(hidpid.Value.Trim()), 2);
- }
- }
- ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>SaveInfo('success')</script>");
- }
- else
- {
- ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>SaveInfo('warn')</script>");
- }
- }
- }
- }
- catch
- {
- ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>SaveInfo('error')</script>");
- }
- }
- #endregion
- protected void btnSubmit_Click(object sender, EventArgs e)
- {
- SaveInfo();
- }
- }
- }
|