frmTaskAssigned.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. using LYFZ.DAL;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Windows.Forms;
  10. using System.Collections;
  11. using System.IO;
  12. using LYFZ.ComponentLibrary;
  13. using LYFZ.Helper;
  14. namespace LYFZ.Software.MainBusiness.OAShopManagement
  15. {
  16. public class frmTaskAssigned : LYFZ.Software.UI.OAShopManagement.frmTaskAssigned
  17. {
  18. string strUserID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  19. LYFZ.BLL.BLL_ErpShopAssignmente ambll = new BLL.BLL_ErpShopAssignmente();
  20. /// <summary>
  21. /// 当前任务状态
  22. /// </summary>
  23. CompleteStatus currentCompleteStatus = CompleteStatus.新任务;
  24. /// <summary>
  25. /// 任务处理人角色类型
  26. /// </summary>
  27. TeskType currentTeskType = TeskType.办理人;
  28. ComponentLibrary.DataGridViewEx currentTaskView = null;
  29. public frmTaskAssigned(string Parameters)
  30. : this()
  31. {
  32. if (Parameters.Trim() == TeskType.发布人.ToString())
  33. {
  34. currentTeskType = TeskType.发布人;
  35. this.tbMain.TabPages.Remove(this.tpReceivingTask);
  36. }
  37. else
  38. {
  39. currentTeskType = TeskType.办理人;
  40. this.tbMain.TabPages.Remove(this.tpPublishingTasks);
  41. }
  42. }
  43. public frmTaskAssigned()
  44. {
  45. this.tbMain.SelectedIndexChanged += tbMain_SelectedIndexChanged;
  46. //发布任务
  47. this.btnAddTask.Click += btnAddTask_Click;
  48. //任务处理
  49. this.btnTaskSummary.Click += btnTaskSummary_Click;
  50. this.btnReply.Click += btnReply_Click;
  51. //删除任务
  52. this.btndel.Click += btndel_Click;
  53. //关闭
  54. this.btnClose.Click += btnClose_Click;
  55. this.dgvMyTaskView.CellDoubleClick += dgvMyTaskView_CellDoubleClick;
  56. this.dgvTaskView.CellDoubleClick += dgvTaskView_CellDoubleClick;
  57. this.ucPagerEx1.EventPaging += ucMyPagerEx_EventPaging;
  58. this.ucMyPagerEx.EventPaging += ucMyPagerEx_EventPaging;
  59. this.Load += frmTaskAssigned_Load;
  60. if (LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.TasksAssigned, CustomAttributes.OperatingAuthority.Delete))
  61. {
  62. this.btndel.Enabled = true;
  63. }
  64. else
  65. {
  66. this.btndel.Enabled = false;
  67. }
  68. if (LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.TasksAssigned, CustomAttributes.OperatingAuthority.Add))
  69. {
  70. this.btnAddTask.Enabled = true;
  71. }
  72. else
  73. {
  74. this.btnAddTask.Enabled = false;
  75. }
  76. this.btnReply.Enabled = false;
  77. this.rdoNewTask.Click += rdoRadioButton_Click;
  78. this.rdoExecutionIngTask.Click += rdoRadioButton_Click;
  79. this.rdoCompletedTask.Click += rdoRadioButton_Click;
  80. this.rdoterminationTask.Click += rdoRadioButton_Click;
  81. this.rdoMyNewTask.Click += rdoRadioButton_Click;
  82. this.rdoMyExecutionIngTask.Click += rdoRadioButton_Click;
  83. this.rdoMyCompletedTask.Click += rdoRadioButton_Click;
  84. this.rdoMyTerminationTask.Click += rdoRadioButton_Click;
  85. }
  86. void btnReply_Click(object sender, EventArgs e)
  87. {
  88. if (this.dgvTaskView.CurrentRow != null)
  89. {
  90. frmTeskView frm = new frmTeskView();
  91. frm.MyTeskType = this.currentTeskType;
  92. frm.TeskRow = this.dgvTaskView.Rows[this.dgvTaskView.CurrentRow.Index];
  93. if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  94. {
  95. RefreshingBind();
  96. }
  97. }
  98. else
  99. {
  100. MessageBoxCustom.Show("请选中你要处理的任务!");
  101. }
  102. }
  103. void rdoRadioButton_Click(object sender, EventArgs e)
  104. {
  105. ComponentLibrary.RadioButtonEx rdoBtn = (ComponentLibrary.RadioButtonEx)sender;
  106. if (rdoBtn.Checked)
  107. {
  108. this.currentCompleteStatus = (CompleteStatus)Convert.ToInt32(rdoBtn.Tag);
  109. }
  110. if (this.currentTeskType == TeskType.发布人)
  111. {
  112. if (this.currentCompleteStatus == CompleteStatus.新任务 || this.currentCompleteStatus == CompleteStatus.执行中)
  113. {
  114. this.btnReply.Enabled = false;
  115. }
  116. else {
  117. this.btnReply.Enabled = true;
  118. }
  119. this.ucPagerEx1.Bind();
  120. }
  121. else {
  122. this.ucMyPagerEx.Bind();
  123. }
  124. }
  125. /// <summary>
  126. /// 接收任务/新任务双击列表事件
  127. /// </summary>
  128. /// <param name="sender"></param>
  129. /// <param name="e"></param>
  130. void dgvMyTaskView_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  131. {
  132. if (e.RowIndex >= 0 && e.ColumnIndex >= 0)
  133. {
  134. if (this.dgvMyTaskView.CurrentRow != null)
  135. {
  136. frmTeskView frm1 = new frmTeskView();
  137. frm1.MyTeskType = this.currentTeskType;
  138. frm1.TeskRow = this.dgvMyTaskView.Rows[this.dgvMyTaskView.CurrentRow.Index];
  139. if (frm1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  140. {
  141. RefreshingBind();
  142. }
  143. }
  144. }
  145. }
  146. /// <summary>
  147. /// 加载事件
  148. /// </summary>
  149. /// <param name="sender"></param>
  150. /// <param name="e"></param>
  151. void frmTaskAssigned_Load(object sender, EventArgs e)
  152. {
  153. BindData();
  154. }
  155. /// <summary>
  156. /// 新任务双击列表事件
  157. /// </summary>
  158. /// <param name="sender"></param>
  159. /// <param name="e"></param>
  160. void dgvTaskView_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  161. {
  162. if (this.dgvTaskView.Rows.Count > 0)
  163. {
  164. if (this.dgvTaskView.CurrentRow.Index >= 0 && this.dgvTaskView.CurrentCell.ColumnIndex >= 0)
  165. {
  166. if (this.dgvTaskView.CurrentRow != null)
  167. {
  168. if (this.currentCompleteStatus == CompleteStatus.新任务 || this.currentCompleteStatus == CompleteStatus.无法完成)
  169. {
  170. frmReleaseTask frm = new frmReleaseTask();
  171. frm.TaskRow = this.dgvTaskView.Rows[this.dgvTaskView.CurrentRow.Index];
  172. if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  173. {
  174. RefreshingBind();
  175. }
  176. }
  177. else {
  178. MessageBoxCustom.Show("“执行中”和“已完成”的任务不可修改");
  179. }
  180. }
  181. }
  182. }
  183. }
  184. /// <summary>
  185. /// 关闭窗体
  186. /// </summary>
  187. /// <param name="sender"></param>
  188. /// <param name="e"></param>
  189. void btnClose_Click(object sender, EventArgs e)
  190. {
  191. this.Close();
  192. }
  193. /// <summary>
  194. /// 删除
  195. /// </summary>
  196. /// <param name="sender"></param>
  197. /// <param name="e"></param>
  198. void btndel_Click(object sender, EventArgs e)
  199. {
  200. try
  201. {
  202. if (this.dgvTaskView.CurrentRow.Index >= 0 && this.dgvTaskView.CurrentCell.ColumnIndex >= 0)
  203. {
  204. if (this.dgvTaskView.CurrentRow != null)
  205. {
  206. if (MessageBoxCustom.Show("你确定要删除吗?", "删除提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
  207. {
  208. if (ambll.Delete(ambll.GetModel(Convert.ToInt32(dgvTaskView.CurrentRow.Cells["ID"].Value))))
  209. {
  210. MessageBoxCustom.Show("删除成功!");
  211. this.dgvTaskView.Rows.Remove(this.dgvTaskView.CurrentRow);
  212. }
  213. else
  214. {
  215. MessageBoxCustom.Show("删除失败!");
  216. }
  217. }
  218. }
  219. else
  220. {
  221. MessageBoxCustom.Show("请选中你要删除的数据!");
  222. }
  223. }
  224. }
  225. catch (Exception ex)
  226. {
  227. MessageBoxCustom.Show(ex.Message);
  228. }
  229. }
  230. /// <summary>
  231. /// 处理任务
  232. /// </summary>
  233. /// <param name="sender"></param>
  234. /// <param name="e"></param>
  235. void btnTaskSummary_Click(object sender, EventArgs e)
  236. {
  237. if (this.dgvMyTaskView.CurrentRow != null)
  238. {
  239. frmTeskView frm = new frmTeskView();
  240. frm.MyTeskType = this.currentTeskType;
  241. frm.TeskRow = this.dgvMyTaskView.Rows[this.dgvMyTaskView.CurrentRow.Index];
  242. if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  243. {
  244. RefreshingBind();
  245. }
  246. }
  247. else {
  248. MessageBoxCustom.Show("请选中你要处理的任务!");
  249. }
  250. }
  251. /// <summary>
  252. /// 发布
  253. /// </summary>
  254. /// <param name="sender"></param>
  255. /// <param name="e"></param>
  256. void btnAddTask_Click(object sender, EventArgs e)
  257. {
  258. frmReleaseTask frm = new frmReleaseTask();
  259. if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
  260. RefreshingBind();
  261. }
  262. }
  263. /// <summary>
  264. /// 绑定数据
  265. /// </summary>
  266. /// <param name="ucPager"></param>
  267. private void ucPagerExBind(UCPager.ucPagerEx ucPager)
  268. {
  269. if (currentTeskType == TeskType.发布人)
  270. {
  271. this.currentTaskView = this.dgvTaskView;
  272. }
  273. else {
  274. this.currentTaskView = this.dgvMyTaskView;
  275. }
  276. ucPager.PageCurrent = 1;
  277. ucPager.PageSize = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetPageSize();//3;分页条数
  278. ucPager.Bind();
  279. }
  280. /// <summary>
  281. /// 画分页1
  282. /// </summary>
  283. /// <param name="e"></param>
  284. /// <returns></returns>
  285. private int ucMyPagerEx_EventPaging(UCPager.EventPagingArg e)
  286. {
  287. string filterName = "Agt_ManageName";
  288. LYFZ.UCPager.PageData pageData = new LYFZ.UCPager.PageData();
  289. if (this.currentTeskType == TeskType.发布人)
  290. {
  291. filterName = "Agt_PublishName";
  292. pageData.PageIndex = this.ucPagerEx1.PageCurrent;
  293. pageData.PageSize = this.ucPagerEx1.PageSize;
  294. }
  295. else {
  296. filterName = "Agt_ManageName";
  297. pageData.PageIndex = this.ucMyPagerEx.PageCurrent;
  298. pageData.PageSize = this.ucMyPagerEx.PageSize;
  299. }
  300. pageData.TableName = "tb_ErpShopAssignmente";//表名
  301. pageData.QueryCondition = filterName + "='" + strUserID + "' and Agt_CompleteStatus = '" + ((int)this.currentCompleteStatus).ToString() + "'";//查询条件
  302. pageData.QueryFieldName = "ID,Agt_Priority,Agt_PublishName,Agt_PublishTime,Agt_Content,Agt_ManageName,Agt_CompleteTime,Agt_CompleteStatus,Agt_Summary,Agt_Revert,Agt_TaskTopic,Agt_Deadlines";//查询字段
  303. pageData.OrderStr = "ID";
  304. pageData.OrderType = 1;
  305. DataTable dt = new DataTable();
  306. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  307. {
  308. dt = pageData.QueryDataTable().Tables[0];
  309. });
  310. try
  311. {
  312. this.currentTaskView.Rows.Clear();
  313. for (int i = 0; i < dt.Rows.Count; i++)
  314. {
  315. DataGridViewRow row1 = new DataGridViewRow();
  316. row1.CreateCells(this.currentTaskView);
  317. row1.Cells[0].Value = dt.Rows[i]["ID"].ToString();
  318. string Agt_TaskTopic = "无主题";
  319. if (dt.Rows[i]["Agt_TaskTopic"] != null && !string.IsNullOrEmpty(dt.Rows[i]["Agt_TaskTopic"].ToString().Trim()))
  320. {
  321. Agt_TaskTopic = dt.Rows[i]["Agt_TaskTopic"].ToString();
  322. }
  323. row1.Cells[1].Value = Agt_TaskTopic;
  324. row1.Cells[2].Value = dt.Rows[i]["Agt_Content"].ToString();
  325. row1.Cells[3].Value = ((Priority)Convert.ToInt32(dt.Rows[i]["Agt_Priority"])).ToString();
  326. row1.Cells[4].Value = LYFZ.DAL.DAL_ErpUser.SimpleUserDataTable.Rows.Find(dt.Rows[i]["Agt_PublishName"].ToString())["User_Name"].ToString().Trim();
  327. row1.Cells[5].Value = LYFZ.Command.Command_Validate.DateTimeToString(dt.Rows[i]["Agt_PublishTime"], "yyyy-MM-dd HH:mm");
  328. string Agt_ManageName = "";
  329. DataRow dtRow = LYFZ.DAL.DAL_ErpUser.SimpleUserDataTable.Rows.Find(dt.Rows[i]["Agt_ManageName"].ToString());
  330. if (dtRow != null)
  331. {
  332. Agt_ManageName = dtRow["User_Name"].ToString().Trim();
  333. }
  334. row1.Cells[6].Value = Agt_ManageName;
  335. row1.Cells[6].Tag = dt.Rows[i]["Agt_ManageName"].ToString();
  336. row1.Cells[7].Value = LYFZ.Command.Command_Validate.DateTimeToString(dt.Rows[i]["Agt_Deadlines"], "yyyy-MM-dd HH:mm");
  337. row1.Cells[8].Value = ((CompleteStatus)Convert.ToInt32(dt.Rows[i]["Agt_CompleteStatus"])).ToString();
  338. row1.Cells[9].Value = LYFZ.Command.Command_Validate.DateTimeToString(dt.Rows[i]["Agt_CompleteTime"], "yyyy-MM-dd HH:mm");
  339. row1.Cells[10].Value = dt.Rows[i]["Agt_Summary"].ToString();//任务总结
  340. row1.Cells[11].Value = dt.Rows[i]["Agt_Revert"].ToString();//发布人回复
  341. this.currentTaskView.Rows.Add(row1);
  342. }
  343. }
  344. catch (Exception ex)
  345. {
  346. MessageBoxCustom.Show("绑定数据时出错:" + ex.Message);
  347. }
  348. try
  349. {
  350. e.CurrentPager.TbDataSource = dt;
  351. }
  352. catch { }
  353. this.currentTaskView.ClearSelection();
  354. return pageData.TotalCount;
  355. }
  356. void RefreshingBind()
  357. {
  358. if (this.currentTeskType == TeskType.发布人)
  359. {
  360. ucPagerExBind(this.ucPagerEx1);
  361. }
  362. else {
  363. ucPagerExBind(this.ucMyPagerEx);
  364. }
  365. }
  366. // private delegate void UpdateControl();
  367. /// <summary>
  368. /// 选项卡
  369. /// </summary>
  370. /// <param name="sender"></param>
  371. /// <param name="e"></param>
  372. void tbMain_SelectedIndexChanged(object sender, EventArgs e)
  373. {
  374. switch (this.tbMain.SelectedIndex)
  375. {
  376. case 0:
  377. this.currentTeskType = TeskType.发布人;
  378. break;
  379. case 1:
  380. this.currentTeskType = TeskType.办理人;
  381. break;
  382. }
  383. BindData();
  384. }
  385. void BindData()
  386. {
  387. bool b;
  388. if (this.currentTeskType == TeskType.发布人)
  389. {
  390. b = LYFZ.Software.MainBusiness.VersionControl.StaticVersion.UIFunctionVersion(VersionControl.VersionFunctionEnum.店务管理发布任务);
  391. if (!b)
  392. {
  393. this.Close();
  394. return;
  395. }
  396. ucPagerExBind(this.ucPagerEx1);
  397. }
  398. else {
  399. b = LYFZ.Software.MainBusiness.VersionControl.StaticVersion.UIFunctionVersion(VersionControl.VersionFunctionEnum.店务管理我的任务);
  400. if (!b)
  401. {
  402. this.Close();
  403. return;
  404. }
  405. ucPagerExBind(this.ucMyPagerEx);
  406. }
  407. }
  408. public enum CompleteStatus
  409. {
  410. 新任务 = 0,
  411. 执行中 = 1,
  412. 已完成 = 2,
  413. 无法完成 = 3
  414. }
  415. public enum Priority
  416. {
  417. 高 = 0,
  418. 中 = 1,
  419. 低 = 2
  420. }
  421. }
  422. }