UU跑腿标准版

deptdeit.aspx.cs 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using HySoft.Common;
  8. namespace HySoft.BaseCallCenter.Web.sysmanage
  9. {
  10. public partial class deptdeit : System.Web.UI.Page
  11. {
  12. protected void Page_Load(object sender, EventArgs e)
  13. {
  14. if (!IsPostBack)
  15. {
  16. if (Request.QueryString["action"].ToString() == "Edit") {
  17. getDeptarmentinfo();
  18. }
  19. }
  20. }
  21. /// <summary>
  22. /// 初始化信息
  23. /// </summary>
  24. private void getDeptarmentinfo()
  25. {
  26. Model.T_Sys_Department deparmentionModel = new HySoft.BaseCallCenter.BLL.T_Sys_Department().GetModel(Convert.ToInt32(Request.QueryString["deptId"]));
  27. if (deparmentionModel != null) {
  28. txtDeptCode.Text = deparmentionModel.F_DeptCode;
  29. txtDeptName.Text = deparmentionModel.F_DeptName;
  30. txtPhone.Text = deparmentionModel.F_Telephone;
  31. txtMobile.Text = deparmentionModel.F_OtherPhone;
  32. txtEmail.Text = deparmentionModel.F_Email;
  33. txtF_Remark.Text = deparmentionModel.F_Remark;
  34. txtId.Value = deparmentionModel.F_DeptId.ToString();
  35. txtParthId.Value = deparmentionModel.F_ParentId.ToString();
  36. hfParthCode.Value = deparmentionModel.F_ParentCode.ToString();
  37. txtParthName.Value = deparmentionModel.F_ParentName.ToString();
  38. }
  39. }
  40. /// <summary>
  41. /// 保存单位部门信息
  42. /// </summary>
  43. /// <param name="sender"></param>
  44. /// <param name="e"></param>
  45. protected void btnSubmit_Click(object sender, EventArgs e)
  46. {
  47. try
  48. {
  49. int result = 0;
  50. HySoft.BaseCallCenter.Model.T_Sys_Department departmentModel = new Model.T_Sys_Department();
  51. HySoft.BaseCallCenter.BLL.T_Sys_Department departmentBll = new BLL.T_Sys_Department();
  52. if (Request.QueryString["action"].ToString() == "Add")
  53. {
  54. if (departmentBll.GetModel(Convert.ToInt32(Request.QueryString["deptFarth"])) != null)
  55. {
  56. departmentModel.F_ParentId = departmentBll.GetModel(Convert.ToInt32(Request.QueryString["deptFarth"])).F_DeptId;
  57. departmentModel.F_ParentName = departmentBll.GetModel(Convert.ToInt32(Request.QueryString["deptFarth"])).F_DeptName;
  58. departmentModel.F_ParentCode = departmentBll.GetModel(Convert.ToInt32(Request.QueryString["deptFarth"])).F_DeptCode;
  59. }
  60. }
  61. if (!string.IsNullOrEmpty(txtDeptCode.Text))
  62. {
  63. departmentModel.F_DeptCode = txtDeptCode.Text;
  64. }
  65. else {
  66. MessageBoxToWindow("部门编号不能为空!", "提示", "error");
  67. }
  68. if (!string.IsNullOrEmpty(txtDeptName.Text))
  69. {
  70. departmentModel.F_DeptName = txtDeptName.Text;
  71. }
  72. else {
  73. MessageBoxToWindow("部门名称不能为空!", "提示", "error");
  74. }
  75. departmentModel.F_Telephone = txtPhone.Text;
  76. departmentModel.F_OtherPhone = txtMobile.Text;
  77. departmentModel.F_Email = txtEmail.Text;
  78. departmentModel.F_Remark = txtF_Remark.Text;
  79. departmentModel.F_State = 0;
  80. if (Request.QueryString["action"].ToString() == "Add")
  81. {
  82. result = departmentBll.Add(departmentModel);
  83. if (result > 0)
  84. {
  85. MessageBoxToWindow("新增成功", "新增提示", "success");
  86. }
  87. else
  88. {
  89. MessageBoxToWindow("新增失败", "新增提示!", "error");
  90. }
  91. }
  92. if (Request.QueryString["action"].ToString() == "Edit") {
  93. departmentModel.F_DeptId =Convert.ToInt32(Request.QueryString["deptId"].ToString());
  94. departmentModel.F_ParentId = Convert.ToInt32(txtParthId.Value);
  95. departmentModel.F_ParentCode = hfParthCode.Value;
  96. departmentModel.F_ParentName = txtParthName.Value;
  97. if (departmentBll.Update(departmentModel))
  98. {
  99. MessageBoxToWindow("修改成功", "修改提示!", "success");
  100. }
  101. else
  102. {
  103. MessageBoxToWindow("修改失败", "修改提示!", "error");
  104. }
  105. }
  106. }
  107. catch (Exception ex){
  108. SysLog.WriteLog(ex);
  109. MessageBoxToWindow("异常提示!" + ex.Message, "提示", "catch");
  110. }
  111. }
  112. #region 弹出对话框
  113. /// <summary>
  114. /// 弹出对话框
  115. /// </summary>
  116. /// <param name="title"></param>
  117. /// <param name="content"></param>
  118. /// <param name="type"></param>
  119. public void MessageBoxToWindow(string title, string content, string type)
  120. {
  121. string script = "";
  122. switch (type)
  123. {
  124. case "error"://失败
  125. type = "error";
  126. script = "<script type='text/javascript'> $.ligerDialog.alert('" + title + "','" + content + "','" + type + "');</script>";
  127. break;
  128. case "success"://成功
  129. type = "info";
  130. script = "<script type='text/javascript'> $.ligerDialog.alert('" + title + "','" + content + "','" + type + "',CloseThis);</script>";
  131. break;
  132. case "catch"://异常
  133. type = "warning";
  134. script = "<script type='text/javascript'> $.ligerDialog.alert('" + title + "','" + content + "','" + type + "');</script>";
  135. break;
  136. default:
  137. type = "question";
  138. break;
  139. }
  140. ClientScript.RegisterClientScriptBlock(this.GetType(), "", script);
  141. }
  142. #endregion
  143. }
  144. }