版博士V2.0程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

132 lines
4.7 KiB

  1. using Models;
  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.Threading.Tasks;
  10. using System.Windows.Forms;
  11. namespace AssistClient
  12. {
  13. public partial class FrmStepList : Form
  14. {
  15. Service.StepService service=new Service.StepService();
  16. public FrmStepList()
  17. {
  18. InitializeComponent();
  19. dataGridView1.AutoGenerateColumns = false;
  20. }
  21. private void initDataView()
  22. {
  23. var list = service.GetListNav(1);
  24. tsslCount.Text = $"共 {list.Count} 条记录";
  25. dataGridView1.DataSource = new BindingSource(list, null);
  26. }
  27. private void FrmStepList_Load(object sender, EventArgs e)
  28. {
  29. initDataView();
  30. }
  31. private void tsbtnAdd_Click(object sender, EventArgs e)
  32. {
  33. FrmStepInfo frm = new FrmStepInfo();
  34. frm.ShowDialog();
  35. initDataView();
  36. }
  37. private void tsbtnDel_Click(object sender, EventArgs e)
  38. {
  39. try
  40. {
  41. if(this.dataGridView1.CurrentRow==null)
  42. return;
  43. var list = ((BindingSource)dataGridView1.DataSource).DataSource as List<Step>;
  44. int liIndex = this.dataGridView1.CurrentRow.Index;//获取当前选中行的索引
  45. if (service.InUse(list[liIndex].Id))
  46. throw new Exception("此流程已有产品在使用中,不可删除!");
  47. if (MessageBox.Show($"确认删除?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
  48. {
  49. if (!service.DelNav(list[liIndex]))
  50. throw new Exception("删除失败!");
  51. MessageBox.Show("删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  52. initDataView();
  53. }
  54. }
  55. catch (Exception ex)
  56. {
  57. MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
  58. }
  59. }
  60. private void tsbtnClone_Click(object sender, EventArgs e)
  61. {
  62. if (this.dataGridView1.CurrentRow == null)
  63. {
  64. MessageBox.Show("请选择要克隆的流程!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  65. return;
  66. }
  67. var list = ((BindingSource)dataGridView1.DataSource).DataSource as List<Step>;
  68. int liIndex = this.dataGridView1.CurrentRow.Index;//获取当前选中行的索引
  69. Step newStep = new Step()
  70. {
  71. Tag = 1,
  72. Code = list[liIndex].Code + "_clone",
  73. Name = $"{list[liIndex].Name} (克隆)",
  74. StartTimeIndex = list[liIndex].StartTimeIndex,
  75. ModifyUserCode = Config.loginUser.Code,
  76. CreateUserCode = Config.loginUser.Code,
  77. ProcessList = new List<StepProcess>()
  78. };
  79. foreach(var item in list[liIndex].ProcessList)
  80. {
  81. newStep.ProcessList.Add(new StepProcess()
  82. {
  83. Order = item.Order,
  84. ProcessCode=item.ProcessCode,
  85. ProcessName = item.ProcessName,
  86. ProcessParams=item.ProcessParams,
  87. ModifyUserCode = Config.loginUser.Code,
  88. CreateUserCode = Config.loginUser.Code
  89. });
  90. }
  91. try
  92. {
  93. bool result = service.InsertNav(newStep);
  94. if (result)
  95. {
  96. MessageBox.Show("克隆成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  97. initDataView();
  98. }
  99. else
  100. throw new Exception("克隆失败!");
  101. }
  102. catch (Exception ex)
  103. {
  104. MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
  105. }
  106. }
  107. private void tsbtnClose_Click(object sender, EventArgs e)
  108. {
  109. this.Close();
  110. }
  111. private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  112. {
  113. var list = ((BindingSource)dataGridView1.DataSource).DataSource as List<Step>;
  114. int liIndex = this.dataGridView1.CurrentRow.Index;//获取当前选中行的索引
  115. FrmStepInfo frm = new FrmStepInfo(list[liIndex]);
  116. frm.ShowDialog(this);
  117. initDataView();
  118. }
  119. }
  120. }