frmAddRequestLeave.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. using LYFZ.BLL;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Windows.Forms;
  7. namespace LYFZ.Software.MainBusiness.OAShopManagement
  8. {
  9. public class frmAddRequestLeave : LYFZ.Software.UI.OAShopManagement.frmAddRequestLeave
  10. {
  11. public frmAddRequestLeave(){
  12. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_DepartmentAndEmployee(this.comboBoxTreeViewEx1);
  13. this.btnRelease.Click += btnRelease_Click;
  14. this.btnClose.Click += btnClose_Click;
  15. this.Load += frmReleaseTask_Load;
  16. this.comboBoxTreeViewEx1.IsNodeMouseClick = true;
  17. this.btnSet.Click += btnSet_Click;
  18. cmbCategory.TreeView.NodeMouseClick += TreeView_NodeMouseClick;
  19. }
  20. void TreeView_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
  21. {
  22. TreeNode trNode = e.Node;
  23. int iNodeIndex =0;
  24. while(iNodeIndex<10)
  25. {
  26. if (trNode.Parent==null)
  27. {
  28. if (trNode.Name == BLL.BLL_ErpSystemCategory.GetSysTemCategoryCode(BLL.SysTemCategoryCodeType.事项类别).ToUpper())
  29. {
  30. SetFormDesignControl(false);
  31. }
  32. else if (trNode.Name == BLL.BLL_ErpSystemCategory.GetSysTemCategoryCode(BLL.SysTemCategoryCodeType.请假类别).ToUpper())
  33. {
  34. SetFormDesignControl(true);
  35. }
  36. break;
  37. }
  38. else
  39. {
  40. trNode = trNode.Parent;
  41. }
  42. iNodeIndex++;
  43. }
  44. }
  45. bool CheckTypeByLeave()
  46. {
  47. TreeNode trNode = cmbCategory.TreeView.SelectedNode;
  48. int iNodeIndex = 0;
  49. while (iNodeIndex < 10)
  50. {
  51. if (trNode.Parent == null)
  52. {
  53. if (trNode.Name == BLL.BLL_ErpSystemCategory.GetSysTemCategoryCode(BLL.SysTemCategoryCodeType.事项类别).ToUpper())
  54. {
  55. return false;
  56. }
  57. else if (trNode.Name == BLL.BLL_ErpSystemCategory.GetSysTemCategoryCode(BLL.SysTemCategoryCodeType.请假类别).ToUpper())
  58. {
  59. return true;
  60. }
  61. break;
  62. }
  63. else
  64. {
  65. trNode = trNode.Parent;
  66. }
  67. iNodeIndex++;
  68. }
  69. return false;
  70. }
  71. void btnSet_Click(object sender, EventArgs e)
  72. {
  73. LYFZ.Software.MainBusiness.InitialSet.FrmSystemSet frm = new LYFZ.Software.MainBusiness.InitialSet.FrmSystemSet();
  74. frm.TypeName = BLL.BLL_ErpSystemCategory.GetSysTemCategoryCode(BLL.SysTemCategoryCodeType.请假类别).ToUpper();
  75. frm.Version = "Version";
  76. if (frm.ShowDialog() == DialogResult.OK)
  77. {
  78. FinancialManagement.frmEditStatisticsProgram.LoadAllSystemCategory();
  79. FinancialManagement.frmEditStatisticsProgram.BindTreeView_SystemCategory( new string[]{
  80. BLL.BLL_ErpSystemCategory.GetSysTemCategoryCode(BLL.SysTemCategoryCodeType.事项类别).ToUpper(),
  81. BLL.BLL_ErpSystemCategory.GetSysTemCategoryCode(BLL.SysTemCategoryCodeType.请假类别).ToUpper()
  82. }
  83. ,
  84. this.cmbCategory.TreeView);
  85. }
  86. }
  87. BLL_ErpShopEvententry ctbll = new BLL_ErpShopEvententry();
  88. string _id = "";
  89. /// <summary>
  90. /// ID
  91. /// </summary>
  92. public string ID { get { return this._id; } set { this._id = value; } }
  93. Model.Model_ErpShopEvententry model = new Model.Model_ErpShopEvententry();
  94. void frmReleaseTask_Load(object sender, EventArgs e)
  95. {
  96. FinancialManagement.frmEditStatisticsProgram.BindTreeView_SystemCategory(new string[]{
  97. BLL.BLL_ErpSystemCategory.GetSysTemCategoryCode(BLL.SysTemCategoryCodeType.事项类别).ToUpper(),
  98. BLL.BLL_ErpSystemCategory.GetSysTemCategoryCode(BLL.SysTemCategoryCodeType.请假类别).ToUpper()
  99. }
  100. ,
  101. this.cmbCategory.TreeView);
  102. if (!string.IsNullOrEmpty(this.ID))
  103. {
  104. model = ctbll.GetModel(Convert.ToInt32(ID));
  105. FinancialManagement.frmEditStatisticsProgram.SetSelectItme(this.cmbCategory, model.Matter_Category);
  106. this.comboBoxTreeViewEx1.Text = frmMattersApply.UserIDToName(model.Matter_UpdateName);
  107. this.comboBoxTreeViewEx1.Tag = model.Matter_UpdateName;
  108. this.txtTitle.Text = model.Matter_Title;
  109. this.txtInfo.Text = model.Matter_content;
  110. this.dateTimePickerStar.Value = model.Matter_StarLeaveTime;
  111. this.dateTimePickerEnd.Value = model.Matter_EndLeaveTime;
  112. }
  113. SetFormDesignControl(false);
  114. }
  115. void SetFormDesignControl(bool b)
  116. {
  117. labelEx3.Visible = b;
  118. dateTimePickerStar.Visible = b;
  119. dateTimePickerEnd.Visible = b;
  120. labelEx6.Visible = b;
  121. if(b)
  122. {
  123. labelEx4.Location = new System.Drawing.Point(labelEx4.Location.X, 137);
  124. txtInfo.Location = new System.Drawing.Point(txtInfo.Location.X, 132);
  125. txtInfo.Size = new System.Drawing.Size(txtInfo.Size.Width, 214);
  126. btnRelease.Location = new System.Drawing.Point(btnRelease.Location.X, 352);
  127. btnClose.Location = new System.Drawing.Point(btnClose.Location.X, 352);
  128. }
  129. else
  130. {
  131. labelEx4.Location = new System.Drawing.Point(labelEx4.Location.X, 101);
  132. txtInfo.Location = new System.Drawing.Point(txtInfo.Location.X, 98);
  133. txtInfo.Size = new System.Drawing.Size(txtInfo.Size.Width, 247);
  134. btnRelease.Location = new System.Drawing.Point(btnRelease.Location.X, 352);
  135. btnClose.Location = new System.Drawing.Point(btnClose.Location.X, 352);
  136. }
  137. }
  138. void btnClose_Click(object sender, EventArgs e)
  139. {
  140. this.Close();
  141. }
  142. void btnRelease_Click(object sender, EventArgs e)
  143. {
  144. if (this.cmbCategory.TreeView.SelectedNode == null)
  145. {
  146. MessageBoxCustom.Show("请选申请请假类别");
  147. return;
  148. }
  149. if (string.IsNullOrEmpty(this.txtTitle.Text.Trim()))
  150. {
  151. MessageBoxCustom.Show("请输入申请请假主题");
  152. return;
  153. }
  154. if (this.comboBoxTreeViewEx1.Tag == null)
  155. {
  156. MessageBoxCustom.Show("请选申请请假审批人");
  157. return;
  158. }
  159. if (string.IsNullOrEmpty(this.txtInfo.Text.Trim()))
  160. {
  161. MessageBoxCustom.Show("请输入申请请假事由");
  162. return;
  163. }
  164. if (this.txtTitle.Text.Trim().Length > 100)
  165. {
  166. MessageBoxCustom.Show("申请请假主题不能超过100个字");
  167. return;
  168. }
  169. if (this.txtInfo.Text.Trim().Length > 200)
  170. {
  171. MessageBoxCustom.Show("申请请假事由不能超过200个字");
  172. return;
  173. }
  174. bool checkLeave = CheckTypeByLeave();
  175. if (checkLeave)
  176. {
  177. if (this.dateTimePickerStar.Value < SDateTime.Now.AddMinutes(-30))
  178. {
  179. MessageBoxCustom.Show("申请请假主开始时间不能为过去时间");
  180. return;
  181. }
  182. if (this.dateTimePickerStar.Value >= this.dateTimePickerEnd.Value)
  183. {
  184. MessageBoxCustom.Show("申请请假主开始时间不能小于终止时间");
  185. return;
  186. }
  187. }
  188. model.Matter_ID = LYFZ.WinAPI.CustomPublicMethod.GenerateId();
  189. model.Matter_UpdateName = comboBoxTreeViewEx1.Tag.ToString();
  190. model.Matter_content = txtInfo.Text.Trim();
  191. model.Matter_Title = this.txtTitle.Text.Trim();
  192. model.Matter_CreateDatetime = SDateTime.Now;
  193. model.Matter_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  194. model.Matter_Category = this.cmbCategory.TreeView.SelectedNode.Name;
  195. model.Matter_state = state.申请中.ToString();
  196. model.Matter_Type = 1;
  197. if (checkLeave)
  198. {
  199. model.Matter_StarLeaveTime = this.dateTimePickerStar.Value;
  200. model.Matter_EndLeaveTime = this.dateTimePickerEnd.Value;
  201. }
  202. //model.Matter_InstructedTime = LYFZ.WinAPI.CustomPublicMethod.GetNullDateTime();
  203. //model.Matter_LeadershipInstruction = "";
  204. model.Matter_opinion = "";
  205. model.Matter_UpdateDatetime = LYFZ.WinAPI.CustomPublicMethod.GetNullDateTime();
  206. if (model.ID > 0)
  207. {
  208. if (ctbll.Update(model))
  209. {
  210. System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(ShopEvententryPushMessage), model);
  211. MessageBoxCustom.Show("重新申请发送成功");
  212. this.DialogResult = System.Windows.Forms.DialogResult.OK;
  213. }
  214. else
  215. {
  216. MessageBoxCustom.Show("重新申请发送失败"); return;
  217. }
  218. }
  219. else
  220. {
  221. if (ctbll.Add(model))
  222. {
  223. System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(ShopEvententryPushMessage), model);
  224. MessageBoxCustom.Show("申请发送成功");
  225. this.DialogResult = System.Windows.Forms.DialogResult.OK;
  226. }
  227. else
  228. {
  229. MessageBoxCustom.Show("申请发送成功"); return;
  230. }
  231. }
  232. }
  233. /// <summary>
  234. /// 发布时推送消息
  235. /// </summary>
  236. void ShopEvententryPushMessage(object b)
  237. {
  238. try
  239. {
  240. if (b != null)
  241. {
  242. LYFZ.Model.Model_ErpShopEvententry eModel = (LYFZ.Model.Model_ErpShopEvententry)b;
  243. ctbll.ShopEvententryPushMessage(eModel);
  244. }
  245. }
  246. catch { }
  247. }
  248. }
  249. }