frmReleaseTask.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.Data.SqlClient;
  10. using System.Web.UI.WebControls;
  11. namespace LYFZ.Software.MainBusiness.OAShopManagement
  12. {
  13. public class frmReleaseTask : LYFZ.Software.UI.OAShopManagement.frmReleaseTask
  14. {
  15. LYFZ.BLL.BLL_ErpShopAssignmente ambll = new BLL.BLL_ErpShopAssignmente();
  16. //当前登录者的ID
  17. string strUserID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  18. public frmReleaseTask()
  19. {
  20. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_DepartmentAndEmployee(this.comboBoxTreeViewEx1);
  21. this.btnClose.Click += btnClose_Click;
  22. this.btnUpdate.Click += btnUpdate_Click;
  23. this.Load += frmReleaseTask_Load;
  24. }
  25. /// <summary>
  26. /// 更改数据
  27. /// </summary>
  28. /// <param name="sender"></param>
  29. /// <param name="e"></param>
  30. void btnUpdate_Click(object sender, EventArgs e)
  31. {
  32. if (this.txtTitle.Text.Trim().Length <= 0)
  33. {
  34. MessageBoxCustom.Show("请输入任务主题");
  35. return;
  36. }
  37. if (this.txtTitle.Text.Trim().Length >100)
  38. {
  39. MessageBoxCustom.Show("入任务主题不能超过100个字");
  40. return;
  41. }
  42. if (this.comboBoxType.Text.Trim().Length <= 0)
  43. {
  44. MessageBoxCustom.Show("选择任务优先级");
  45. return;
  46. }
  47. if (this.dateTimePickerEx1.DateValue.Trim().Length <= 0)
  48. {
  49. MessageBoxCustom.Show("输入任务完成期限");
  50. return;
  51. }
  52. if (this.comboBoxTreeViewEx1.Text.Trim().Length <= 0 || this.txtInfo.Text.Trim().Length <= 0)
  53. {
  54. MessageBoxCustom.Show("请选择办理人和输入任务内容!");
  55. return;
  56. }
  57. else
  58. {
  59. LYFZ.Model.Model_ErpShopAssignmente model = null;
  60. if (TaskRow != null)
  61. {
  62. model = ambll.GetModel(Convert.ToInt32(TaskRow.Cells["ID"].Value));
  63. }
  64. else {
  65. model = new Model.Model_ErpShopAssignmente();
  66. }
  67. model.Agt_ID = LYFZ.WinAPI.CustomPublicMethod.GenerateId();
  68. model.Agt_CompleteStatus = 0;
  69. model.Agt_Priority = (int)(frmTaskAssigned.Priority)Enum.Parse(typeof(frmTaskAssigned.Priority), this.comboBoxType.SelectedItem.ToString());
  70. model.Agt_PublishName = strUserID;
  71. model.Agt_PublishTime = SDateTime.Now;
  72. model.Agt_ManageName = this.comboBoxTreeViewEx1.Tag.ToString().Trim();
  73. model.Agt_Content = this.txtInfo.Text.Trim();
  74. model.Agt_Deadlines = Convert.ToDateTime(this.dateTimePickerEx1.DateValue.Trim());
  75. model.Agt_TaskTopic = this.txtTitle.Text.Trim();
  76. model.Agt_CreateName = strUserID;
  77. bool saveOk = false;
  78. if (model.ID > 0)
  79. {
  80. model.Agt_UpdateDatetime = SDateTime.Now;
  81. saveOk = ambll.Update(model);
  82. }
  83. else {
  84. model.Agt_CreateDatetime = SDateTime.Now;
  85. saveOk = ambll.Add(model);
  86. }
  87. if (saveOk)
  88. {
  89. System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(TaskAssignedPushMessage), model);
  90. MessageBoxCustom.Show("操作成功");
  91. this.DialogResult = System.Windows.Forms.DialogResult.OK;
  92. }
  93. else
  94. {
  95. MessageBoxCustom.Show("操作失败");
  96. }
  97. }
  98. }
  99. /// <summary>
  100. /// 发布时推送消息
  101. /// </summary>
  102. void TaskAssignedPushMessage(object b)
  103. {
  104. try
  105. {
  106. if (b != null)
  107. {
  108. LYFZ.Model.Model_ErpShopAssignmente eModel = (LYFZ.Model.Model_ErpShopAssignmente)b;
  109. ambll.TaskAssignedPushMessage(eModel);
  110. }
  111. }
  112. catch { }
  113. }
  114. /// <summary>
  115. /// 窗体加载
  116. /// </summary>
  117. /// <param name="sender"></param>
  118. /// <param name="e"></param>
  119. void frmReleaseTask_Load(object sender, EventArgs e)
  120. {
  121. this.comboBoxType.Items.Clear();
  122. this.comboBoxType.Items.AddRange(Enum.GetNames(typeof(frmTaskAssigned.Priority)));
  123. if (_TaskRow != null)
  124. {
  125. this.txtTitle.Text = _TaskRow.Cells[1].Value.ToString();
  126. this.comboBoxType.SelectedItem = _TaskRow.Cells[3].Value.ToString();//LYFZ.Software.MainBusiness.DoorCityProcess.ListItem.TextFindByValue(this.comboBoxType, _TaskRow.Cells[3].Value.ToString());
  127. this.dateTimePickerEx1.DateValue = _TaskRow.Cells[7].Value.ToString();
  128. this.comboBoxTreeViewEx1.Tag = _TaskRow.Cells[6].Tag;
  129. this.comboBoxTreeViewEx1.TextFindTag(_TaskRow.Cells[6].Value.ToString());
  130. this.txtInfo.Text = _TaskRow.Cells[2].Value.ToString();
  131. this.btnUpdate.Visible = true;
  132. }
  133. }
  134. DataGridViewRow _TaskRow = null;
  135. /// <summary>
  136. /// 当前任务DataGridViewRow数据
  137. /// </summary>
  138. public DataGridViewRow TaskRow
  139. {
  140. get { return _TaskRow; }
  141. set { _TaskRow = value; }
  142. }
  143. void btnClose_Click(object sender, EventArgs e)
  144. {
  145. this.Close();
  146. }
  147. }
  148. }