| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using HySoft.Common;
- using System.Data;
- namespace HySoft.BaseCallCenter.Web.qualitymanage
- {
- public partial class indexedit : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- if (!string.IsNullOrEmpty(Request.QueryString["id"]))
- {
- InitObj(Request.QueryString["id"].Trim());
- }
- if (!string.IsNullOrEmpty(Request.QueryString["categoryid"]))
- {
- txtF_CategoryId.Value = Request.QueryString["categoryid"].Trim();
- }
- }
- }
- void InitObj(string id)
- {
- try
- {
- T_QC_IndexBaseObj = new BLL.T_QC_IndexBase().GetModel(Convert.ToInt32(id));
- }
- catch (Exception ex)
- {
- }
- }
- private Model.T_QC_IndexBase T_QC_IndexBaseObj
- {
- get
- {
- Model.T_QC_IndexBase model = new Model.T_QC_IndexBase();
- if (Request.QueryString["otype"].Trim() == "modify")
- {
- model.F_IndexId = Convert.ToInt32(Request.QueryString["id"].Trim());
- }
- else
- {
- model.F_IndexId = 0;
- }
- try
- {
- model.F_CategoryId = Convert.ToInt32(txtF_CategoryId.Value.Trim());
- }
- catch
- {
- }
- try
- {
- model.F_Score = Convert.ToInt32(txtF_Score.Text.Trim());
- }
- catch
- {
- }
- try
- {
- model.F_Sort = Convert.ToInt32(txtF_Sort.Text.Trim());
- }
- catch
- {
- }
- model.F_Title = txtF_Title.Text.Trim();
- model.F_Remark = txtF_Remark.Text.Trim();
- model.F_CreateOn = DateTime.Now;
- try
- {
- LoginUser p_LoginUser = new LoginUser(this.Context);
- model.F_CreateBy = p_LoginUser.UserID;
- }
- catch { }
- model.F_DeleteFlag = 0;
- return model;
- }
- set
- {
- if (value != null)
- {
- this.txtF_IndexId.Value = value.F_IndexId.ToString();
- this.txtF_CategoryId.Value = value.F_CategoryId.ToString();
- this.txtF_Score.Text = value.F_Score.ToString();
- this.txtF_Title.Text = value.F_Title;
- this.txtF_Remark.Text = value.F_Remark;
- this.txtF_Sort.Text = value.F_Sort.ToString();
- }
- }
- }
- protected void btnSubmit_Click(object sender, EventArgs e)
- {
- try
- {
- if (Request.QueryString["otype"] == "new")
- {
- if (new BLL.T_QC_IndexBase().Add(T_QC_IndexBaseObj) > 0)
- {
- try
- {
- SetScoreByCategory(this.txtF_CategoryId.Value);
- }
- catch
- { }
- MessageBoxToWindow("新增成功", "新增提示", "success");
- }
- else
- {
- MessageBoxToWindow("新增失败", "新增提示!", "error");
- }
- }
- if (Request.QueryString["otype"] == "modify")
- {
- if (new BLL.T_QC_IndexBase().Update(T_QC_IndexBaseObj))
- {
- try
- {
- SetScoreByCategory(this.txtF_CategoryId.Value);
- }
- catch
- { }
- MessageBoxToWindow("修改成功", "修改提示!", "success");
- }
- else
- {
- MessageBoxToWindow("修改失败!", "修改提示!", "error");
- }
- }
- }
- catch
- {
- MessageBoxToWindow("保存失败!", "保存提示!", "error");
- }
- }
- private void SetScoreByCategory(string categoryid)
- {
- DataTable dt = new DataTable();
- try
- {
- Model.T_QC_IndexCategory model = new BLL.T_QC_IndexCategory().GetModel(Convert.ToInt32(categoryid));
- if (model != null)
- {
- string parentid = model.F_ParentId.ToString();
- dt = new BLL.T_QC_IndexBase().GetList("F_DeleteFlag=0 and (F_CategoryId=" + model.F_CategoryId + " or F_CategoryId in (select F_CategoryId from T_QC_IndexCategory where F_ParentId=" + categoryid + " )) ").Tables[0];
- int score=0;
- for(int i=0;i<dt.Rows.Count;i++)
- {
- score+=Convert.ToInt32(dt.Rows[i]["F_Score"].ToString().Trim());
- }
- model.F_Expand1 = score.ToString();
- if (new BLL.T_QC_IndexCategory().Update(model))
- {
- if (parentid != "0")
- {
- SetScoreByCategory(parentid);
- }
- }
- }
- }
- catch { }
- finally
- {
- dt.Clear();
- dt.Dispose();
- }
- }
- #region 弹出对话框
- /// <summary>
- /// 弹出对话框
- /// </summary>
- /// <param name="title"></param>
- /// <param name="content"></param>
- /// <param name="type"></param>
- public void MessageBoxToWindow(string title, string content, string type)
- {
- string script = "";
- switch (type)
- {
- case "error"://失败
- type = "error";
- script = "<script type='text/javascript'> $.ligerDialog.alert('" + title + "','" + content + "','" + type + "');</script>";
- break;
- case "success"://成功
- type = "info";
- script = "<script type='text/javascript'> $.ligerDialog.alert('" + title + "','" + content + "','" + type + "',CloseThis);</script>";
- break;
- case "catch"://异常
- type = "warning";
- script = "<script type='text/javascript'> $.ligerDialog.alert('" + title + "','" + content + "','" + type + "');</script>";
- break;
- default:
- type = "question";
- break;
- }
- ClientScript.RegisterClientScriptBlock(this.GetType(), "", script);
- }
- #endregion
- }
- }
|