华恒Mes鼎捷代码
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.

204 lines
7.8 KiB

5 months ago
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using DevExpress.XtraEditors;
  9. using ICSSoft.Base.Config.AppConfig;
  10. using System.Data.Linq;
  11. using System.Linq;
  12. using ICSSoft.Base.Language.Tool;
  13. using System.Reflection;
  14. using ICSSoft.Base.Config.DBHelper;
  15. using ICSSoft.Base.ReferForm;
  16. using ICSSoft.Base.Report;
  17. using ICSSoft.Base.ReferForm.AppReferForm;
  18. using ICSSoft.Frame.Data.Entity;
  19. using ICSSoft.Frame.Data.BLL;
  20. namespace ICSSoft.Frame.APP
  21. {
  22. public partial class FormICSOPAdd : DevExpress.XtraEditors.XtraForm
  23. {
  24. int flag;
  25. public FormICSOPAdd()
  26. {
  27. InitializeComponent();
  28. chargeFormState("Add");
  29. flag = 0;
  30. Init();
  31. }
  32. public FormICSOPAdd(string opcode)
  33. {
  34. InitializeComponent();
  35. chargeFormState("Edit");
  36. Init();
  37. SearchOPInfo(opcode);
  38. flag = 1;
  39. }
  40. private void chargeFormState(string state)
  41. {
  42. switch (state)
  43. {
  44. case "Add":
  45. txtOPCODE.Properties.ReadOnly = false;
  46. break;
  47. case "Edit":
  48. txtOPCODE.Properties.ReadOnly = true;
  49. break;
  50. }
  51. }
  52. public void SearchOPInfo(string opcode)
  53. {
  54. FormICSOPUIModel tbInfo = ICSOPBLL.SearchOPInfo(opcode, AppConfig.AppConnectString);
  55. txtOPCODE.Text = tbInfo.OPCODE;
  56. txtOPDESC.Text = tbInfo.OPDESC;
  57. txtOPCOLLECTION.Text = tbInfo.OPCOLLECTION;
  58. cbBCostCenter.Text = tbInfo.CostCenter;
  59. string OPControl = tbInfo.OPCONTROL;
  60. char[] c = OPControl.ToCharArray();
  61. try
  62. {
  63. #region
  64. //for (int i = 0; i < c.Length; i++)
  65. //{
  66. // if (c[i].Equals('1'))
  67. // checkedListBoxOPControl.SetItemChecked(i, true);
  68. // else
  69. // checkedListBoxOPControl.SetItemChecked(i, false);
  70. //}
  71. #endregion
  72. for (int i = 0; i < 4; i++)
  73. {
  74. if (c[i].Equals('1'))
  75. checkedListBoxOPControl.SetItemChecked(i, true);
  76. else
  77. checkedListBoxOPControl.SetItemChecked(i, false);
  78. }
  79. }
  80. catch (Exception ex)
  81. {
  82. throw ex;
  83. }
  84. }
  85. private void btnClose_Click(object sender, EventArgs e)
  86. {
  87. this.Close();
  88. this.DialogResult = DialogResult.Cancel;
  89. }
  90. private void can_Click(object sender, EventArgs e)
  91. {
  92. this.Close();
  93. this.DialogResult = DialogResult.Cancel;
  94. }
  95. private void save_Click(object sender, EventArgs e)
  96. {
  97. char[] c = { '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0' };
  98. try
  99. {
  100. if (txtOPCODE.Text.Trim() == "")
  101. {
  102. ICSBaseSimpleCode.AppshowMessageBox("工序代码不能为空");
  103. return;
  104. }
  105. if (txtOPCOLLECTION.Text.Trim() == "")
  106. {
  107. ICSBaseSimpleCode.AppshowMessageBox("数据收集方式不能为空");
  108. return;
  109. }
  110. if (flag == 0)
  111. {
  112. bool b = ICSOPBLL.IsIncluding(txtOPCODE.Text.Trim(), AppConfig.AppConnectString);
  113. if (!b)
  114. {
  115. ICSBaseSimpleCode.AppshowMessageBox("工序代码已经存在");
  116. return;
  117. }
  118. }
  119. FormICSOPUIModel tbInfo = new FormICSOPUIModel();
  120. tbInfo.OPCODE = txtOPCODE.Text;
  121. tbInfo.OPDESC = txtOPDESC.Text;
  122. tbInfo.OPCOLLECTION = txtOPCOLLECTION.Text;
  123. for (int i = 0; i < checkedListBoxOPControl.Items.Count; i++)
  124. {
  125. if (checkedListBoxOPControl.GetItemChecked(i))
  126. c[i] = '1';
  127. else
  128. c[i] = '0';
  129. }
  130. string OPControl = new string(c);
  131. tbInfo.OPCONTROL = OPControl;
  132. tbInfo.CostCenter = cbBCostCenter.Text;
  133. tbInfo.OpFrom = txtfrom.Text;
  134. ICSOPBLL.Add(tbInfo, AppConfig.AppConnectString);
  135. if (flag == 0)
  136. {
  137. ICSBaseSimpleCode.AppshowMessageBox("新增成功!");
  138. }
  139. else if (flag == 1)
  140. {
  141. ICSBaseSimpleCode.AppshowMessageBox("修改成功!");
  142. }
  143. }
  144. catch (Exception ex)
  145. {
  146. MessageBox.Show(ex.Message);
  147. }
  148. this.Close();
  149. this.DialogResult = DialogResult.Yes;
  150. }
  151. public void Init()
  152. {
  153. #region
  154. //checkedListBoxOPControl.Items.Add("OP_componentloading", "1.上料工序");
  155. //checkedListBoxOPControl.Items.Add("OP_testing", "2.测试工序");
  156. //checkedListBoxOPControl.Items.Add("OP_packing", "3.包装工序");
  157. //checkedListBoxOPControl.Items.Add("OP_ts", "4.维修工序");
  158. //checkedListBoxOPControl.Items.Add("OP_idtranslate", "3.序号转换工序");
  159. //checkedListBoxOPControl.Items.Add("OP_oqc", "5.OQC工序");
  160. //checkedListBoxOPControl.Items.Add("OP_spc", "7.SPC工序");
  161. //checkedListBoxOPControl.Items.Add("OP_deduct", "8.扣料工序");
  162. //checkedListBoxOPControl.Items.Add("OP_midistoutput", "9.中间产量工序");
  163. //checkedListBoxOPControl.Items.Add("OP_midistinput", "10.中间投入工序");
  164. //checkedListBoxOPControl.Items.Add("OP_ComponentDown", "11.下料工序");
  165. //checkedListBoxOPControl.Items.Add("OP_BurnIn", "12.Burn In工序");
  166. //checkedListBoxOPControl.Items.Add("OP_BurnOut", "13.Burn Out工序");
  167. //checkedListBoxOPControl.Items.Add("OP_Offline", "14.下线工序");
  168. #endregion
  169. checkedListBoxOPControl.Items.Add("OP_componentloading", "1.上料工序");
  170. checkedListBoxOPControl.Items.Add("OP_testing", "2.测试工序");
  171. checkedListBoxOPControl.Items.Add("OP_packing", "3.包装工序");
  172. checkedListBoxOPControl.Items.Add("OP_ts", "4.维修工序");
  173. #region
  174. //checkedListBoxOPControl.Items.Add("OP_idtranslate", "5.序号转换工序");
  175. //checkedListBoxOPControl.Items.Add("OP_oqc", "6.OQC工序");
  176. //checkedListBoxOPControl.Items.Add("OP_spc", "7.SPC工序");
  177. //checkedListBoxOPControl.Items.Add("OP_deduct", "8.扣料工序");
  178. //checkedListBoxOPControl.Items.Add("OP_midistoutput", "9.中间产量工序");
  179. //checkedListBoxOPControl.Items.Add("OP_midistinput", "10.中间投入工序");
  180. //checkedListBoxOPControl.Items.Add("OP_ComponentDown", "11.下料工序");
  181. //checkedListBoxOPControl.Items.Add("OP_BurnIn", "12.Burn In工序");
  182. //checkedListBoxOPControl.Items.Add("OP_BurnOut", "13.Burn Out工序");
  183. //checkedListBoxOPControl.Items.Add("OP_Offline", "14.下线工序");
  184. #endregion
  185. DataTable dt = ICSOPBLL.SearchData(AppConfig.AppConnectString);
  186. if (dt.Rows.Count > 0 && dt != null)
  187. {
  188. foreach (DataRow dr in dt.Rows)
  189. {
  190. cbBCostCenter.Items.Add(dr["EnumText"].ToString());
  191. }
  192. }
  193. }
  194. }
  195. }