版博士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.

пре 2 година
пре 1 година
пре 2 година
пре 2 година
пре 2 година
пре 1 година
пре 2 година
пре 1 година
пре 2 година
пре 1 година
пре 2 година
пре 2 година
пре 2 година
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. using MaiMuAOI.SysCtrl;
  2. using Models;
  3. using Newtonsoft.Json.Linq;
  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. namespace MaiMuAOI.SysUI.ProcessStep
  14. {
  15. public partial class StepListFrm : Form
  16. {
  17. private Service.StepService service = new Service.StepService();
  18. public StepListFrm()
  19. {
  20. InitializeComponent();
  21. UIStyle.SetUIStyle(this);
  22. this.uiTitel1.FatherForm = this;
  23. #region dataGridView设置
  24. dataGridView1.AutoGenerateColumns = false;//自动创建列
  25. dataGridView1.AllowUserToAddRows = dataGridView1.AllowUserToDeleteRows = false;//用户添加删除行
  26. dataGridView1.AllowUserToResizeRows = true;//用户调整行大小
  27. //dataGridView1.AllowUserToResizeColumns = false;//用户调整列大小
  28. //显示行号与列宽度自动调整
  29. dataGridView1.RowHeadersVisible = true;
  30. dataGridView1.RowHeadersWidth = 50;
  31. //dataGridView1.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders;//数据量过百绑定太变
  32. dataGridView1.RowPostPaint += (sender, e) =>//序号列头
  33. {
  34. SysMgr.showRowNum_onDataGrid_RowPostPaint(this.dataGridView1, sender, e);
  35. };
  36. dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
  37. #endregion
  38. this.tbSearch.Top = toolStrip1.Top + 15;
  39. }
  40. private void InitDataView(int selIndex = -1)
  41. {
  42. var list = service.GetListNav(0);
  43. tsslCount.Text = $"共 {list.Count} 条记录";
  44. int liIndex = 0;
  45. if (selIndex > 0) liIndex = selIndex;
  46. else if (this.dataGridView1.CurrentRow != null)
  47. liIndex = this.dataGridView1.CurrentRow.Index;
  48. dataGridView1.DataSource = new BindingSource(list, null);
  49. if (dataGridView1.Rows.Count > liIndex)
  50. dataGridView1.CurrentCell = dataGridView1[1, liIndex];
  51. }
  52. private void StepListFrm_Load(object sender, EventArgs e)
  53. {
  54. this.Cursor = Cursors.WaitCursor;
  55. InitDataView();
  56. this.Cursor = Cursors.Default;
  57. }
  58. private void tsbtnAdd_Click(object sender, EventArgs e)
  59. {
  60. StepSelectFrm stepSelectFrm = new StepSelectFrm();
  61. stepSelectFrm.ShowDialog();
  62. if (stepSelectFrm.ProcessSelect == 200)
  63. {
  64. //老流程
  65. StepInfoFrm frm = new StepInfoFrm();
  66. frm.ShowDialog();
  67. }
  68. else if (stepSelectFrm.ProcessSelect == 100)
  69. {
  70. //新流程
  71. StepProcessFrm frm = new StepProcessFrm();
  72. frm.ShowDialog();
  73. }
  74. InitDataView();
  75. }
  76. private void tsbtnDel_Click(object sender, EventArgs e)
  77. {
  78. try
  79. {
  80. if (this.dataGridView1.CurrentRow == null)
  81. return;
  82. var list = ((BindingSource)dataGridView1.DataSource).DataSource as List<Step>;
  83. int liIndex = this.dataGridView1.CurrentRow.Index;//获取当前选中行的索引
  84. if (service.InUse(list[liIndex].Id))
  85. throw new Exception("此流程已有产品在使用中,不可删除!");
  86. if (MessageBox.Show($"确认删除?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
  87. {
  88. if (!service.DelNav(list[liIndex]))
  89. throw new Exception("删除失败!");
  90. MessageBox.Show("删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  91. this.dataGridView1.Rows.RemoveAt(liIndex);
  92. if (this.dataGridView1.Rows.Count == 0)
  93. InitDataView();
  94. }
  95. }
  96. catch (Exception ex)
  97. {
  98. MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
  99. }
  100. }
  101. private void tsbtnClone_Click(object sender, EventArgs e)
  102. {
  103. if (this.dataGridView1.CurrentRow == null)
  104. {
  105. MessageBox.Show("请选择要克隆的流程!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  106. return;
  107. }
  108. var list = ((BindingSource)dataGridView1.DataSource).DataSource as List<Step>;
  109. int liIndex = this.dataGridView1.CurrentRow.Index;//获取当前选中行的索引
  110. Step newStep = new Step()
  111. {
  112. Code = list[liIndex].Code + "_clone",
  113. Name = $"{list[liIndex].Name} (克隆)",
  114. StartTimeIndex = list[liIndex].StartTimeIndex,
  115. ModifyUserCode = SysMgr.Instance.UserMgr.LoginUser.Code,
  116. CreateUserCode = SysMgr.Instance.UserMgr.LoginUser.Code,
  117. ProcessList = new List<StepProcess>(),
  118. ProcessType = list[liIndex].ProcessType,
  119. };
  120. foreach (var item in list[liIndex].ProcessList)
  121. {
  122. StepProcess sp;
  123. string spPrarms = "";
  124. if (item.ProcessCode == "Size")
  125. {
  126. if (item.ProcessParams.IndexOf("MapPath") > 0)
  127. {
  128. JObject jo = JObject.Parse(item.ProcessParams);//解析成json
  129. jo["MapPath"] = "";//修改需要的字段
  130. jo["GetPointList"] = null;
  131. spPrarms = Convert.ToString(jo);
  132. }
  133. else
  134. spPrarms = item.ProcessParams;
  135. }
  136. else
  137. spPrarms = item.ProcessParams;
  138. sp = new StepProcess()
  139. {
  140. Order = item.Order,
  141. ProcessCode = item.ProcessCode,
  142. ProcessName = item.ProcessName,
  143. ProcessParams = spPrarms,
  144. ModifyUserCode = SysMgr.Instance.UserMgr.LoginUser.Code,
  145. CreateUserCode = SysMgr.Instance.UserMgr.LoginUser.Code
  146. };
  147. newStep.ProcessList.Add(sp);
  148. }
  149. try
  150. {
  151. bool result = service.InsertNav(newStep);
  152. if (result)
  153. {
  154. MessageBox.Show("克隆成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  155. InitDataView(dataGridView1.Rows.Count);
  156. }
  157. else
  158. throw new Exception("克隆失败!");
  159. }
  160. catch (Exception ex)
  161. {
  162. MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
  163. }
  164. }
  165. private void tsbtnClose_Click(object sender, EventArgs e)
  166. {
  167. this.Close();
  168. }
  169. private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  170. {
  171. var list = ((BindingSource)dataGridView1.DataSource).DataSource as List<Step>;
  172. int liIndex = this.dataGridView1.CurrentRow.Index;//获取当前选中行的索引
  173. if (!SysMgr.Instance.IsCurrProdectIsDefect(list[liIndex]))
  174. {
  175. //新老流程判断
  176. if (list[liIndex].ProcessType == "快速流程")
  177. {
  178. StepProcessFrm frm = new StepProcessFrm(list[liIndex]);
  179. frm.ShowDialog(this);
  180. }
  181. else
  182. {
  183. StepInfoFrm frm = new StepInfoFrm(list[liIndex]);
  184. frm.ShowDialog(this);
  185. }
  186. InitDataView();
  187. }
  188. else
  189. {
  190. MessageBox.Show("当前流程正在测试!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  191. }
  192. }
  193. private void tbSearch_TextChanged(object sender, EventArgs e)
  194. {
  195. if (tbSearch.Text != "")
  196. {
  197. int count = 0;
  198. foreach (DataGridViewRow row in dataGridView1.Rows)
  199. {
  200. for (int i = 0; i < row.Cells.Count; i++)
  201. {
  202. if (row.Cells[i].Value != null && row.Cells[i].Value.ToString().Contains(tbSearch.Text))
  203. {
  204. count = count + 1;
  205. }
  206. }
  207. if (count == 0)
  208. {
  209. CurrencyManager cm = (CurrencyManager)BindingContext[dataGridView1.DataSource];
  210. cm.SuspendBinding(); //挂起数据绑定
  211. row.Visible = false;
  212. cm.ResumeBinding(); //恢复数据绑定
  213. }
  214. count = 0;
  215. }
  216. }
  217. else
  218. {
  219. for (int i = 0; i < dataGridView1.Rows.Count; i++)
  220. {
  221. dataGridView1.Rows[i].Visible = true;
  222. }
  223. }
  224. }
  225. }
  226. }