FrmUpdatePriority.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. using CCWin.SkinClass;
  2. using DevComponents.DotNetBar;
  3. using SyntacticSugar;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.ComponentModel;
  7. using System.Data;
  8. using System.Drawing;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using System.Windows.Forms;
  13. using WCS_Client.UC;
  14. using WCS_Client.Utility;
  15. namespace WCS_Client.Frm
  16. {
  17. public partial class FrmUpdatePriority : Office2007Form
  18. {
  19. DataRow dr = null; DataTable dt = null;
  20. public FrmUpdatePriority(DataTable datarow)
  21. {
  22. InitializeComponent();
  23. dt = datarow;
  24. int maxPriority = 0;
  25. for (int i = 0; i < dt.Rows.Count; i++)
  26. {
  27. var pr = dt.Rows[i]["Priority"].ToInt32();
  28. if (pr > maxPriority)
  29. {
  30. maxPriority = pr;
  31. }
  32. }
  33. nudPriority.Value = maxPriority;
  34. }
  35. private void btnCancel_Click(object sender, EventArgs e)
  36. {
  37. this.Close();
  38. }
  39. private void btnSave_Click(object sender, EventArgs e)
  40. {
  41. if (string.IsNullOrEmpty(txtReason.Text))
  42. {
  43. MessageBox.Show("请输入原因");
  44. return;
  45. }
  46. var result = MessageUtil.ShowYesNoAndWarning(string.Format("确定要变更优先级吗?"));
  47. if (result == DialogResult.Yes)
  48. {
  49. //dt = dt.Clone();
  50. string res = "";
  51. for (int i = 0; i < dt.Rows.Count; i++)
  52. {
  53. var dr = dt.Rows[i];
  54. var task_no = Convert.ToInt32(dr["ID"].ToString());
  55. int priority = nudPriority.Value.ToInt32();
  56. res = TryCachHelper.TryTranExecute((db) =>
  57. {
  58. var task = db.Queryable<WCS_TASK>().First(v => v.ID == task_no);
  59. if (task == null)
  60. {
  61. throw new Exception(string.Format("未查询到WCS任务[{0}]信息", task_no));
  62. }
  63. else
  64. {
  65. if (db.Updateable<WCS_TASK>()
  66. .UpdateColumns(it => new WCS_TASK
  67. {
  68. Priority = priority,
  69. UPDATEUSER = CurrentHelper.User.Use_Name,
  70. UPDATETIME = DateTime.Now
  71. })
  72. .Where(v => v.ID == task_no).ExecuteCommand() < 0)
  73. {
  74. throw new Exception(string.Format("WCS任务[{0}]调整优先级失败", task_no));
  75. }
  76. //string msg = string.Format("任务[{0}]调整优先级为[{1}]成功。", task_no, priority);
  77. }
  78. });
  79. if (string.IsNullOrWhiteSpace(res))
  80. {
  81. //res = string.Format("任务[{0}]调整优先级[{1}]成功。", task_no.ToString(), priority);
  82. }
  83. }
  84. MessageBox.Show(res);
  85. //string massge = BaseWorkflow.UpdateTaskPriority(Convert.ToInt32(lbltask_no.Text.Trim()), (int)nudPriority.Value);
  86. //MessageUtil.ShowTips(res);
  87. this.Close();
  88. }
  89. }
  90. }
  91. }