CraftOrdDesignStdGicCtrl.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using Core.StlMes.Client.SaleOrder.BLL;
  10. using CoreFS.CA06;
  11. using Core.Mes.Client.Comm.Tool;
  12. using Infragistics.Win.UltraWinEditors;
  13. using Core.Mes.Client.Comm.Server;
  14. using Core.StlMes.Client.Qcm;
  15. using Infragistics.Win.UltraWinGrid;
  16. using CoreFS.SA06;
  17. using Infragistics.Win;
  18. using Core.Mes.Client.Comm.Control;
  19. namespace Core.StlMes.Client.SaleOrder.Control
  20. {
  21. public partial class CraftOrdDesignStdGicCtrl : UserControl
  22. {
  23. private CraftOrdDesignStdGicBLL _designStdGicBLL;
  24. private CraftOrdDesignMscPlBLL _designMscPlBLL;
  25. private CraftOrdDesignMscPlPrcBLL _designMscPlPrcBLL;
  26. UltraComboEditor MscUce = new UltraComboEditor(); //MSC下拉框
  27. UltraComboEditor StationUce = new UltraComboEditor(); //工序点下拉框
  28. UltraComboEditor StdUce = new UltraComboEditor(); //标准下拉框
  29. UltraComboEditor cmbProBigType = new UltraComboEditor();
  30. UltraComboEditor Gics = new UltraComboEditor();
  31. private OpeBase _ob;
  32. public CraftOrdDesignStdGicCtrl(System.Windows.Forms.Control container, OpeBase ob)
  33. {
  34. InitializeComponent();
  35. _ob = ob;
  36. _designStdGicBLL = new CraftOrdDesignStdGicBLL(ob);
  37. _designMscPlBLL = new CraftOrdDesignMscPlBLL(ob);
  38. _designMscPlPrcBLL = new CraftOrdDesignMscPlPrcBLL(ob);
  39. container.Controls.Add(this);
  40. this.Dock = DockStyle.Fill;
  41. LoadBaseData();
  42. }
  43. private void LoadBaseData()
  44. {
  45. //---子表工序点名称--------
  46. this.Controls.Add(MscUce);
  47. MscUce.Visible = false;
  48. this.Controls.Add(StationUce);
  49. StationUce.Visible = false;
  50. this.Controls.Add(Gics);
  51. Gics.Visible = false;
  52. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreComMscStdProcess.getStation", null, _ob);
  53. StationUce.DataSource = dt;
  54. StationUce.DisplayMember = "STATION_DESC";
  55. StationUce.ValueMember = "STATION_CODE";
  56. QcmBaseQuery.BindColumn(StationUce, "StationCode", entityGrid1.DisplayLayout.Bands[0]);
  57. }
  58. /// <summary>
  59. /// 查询质量设计加工
  60. /// </summary>
  61. /// <param name="designStdGicEntity"></param>
  62. public void Query(CraftOrdDesignStdGicEntity designStdGicEntity)
  63. {
  64. this.CraftOrdDesignStdGicEntityBindingSource.DataSource = _designStdGicBLL.Query(designStdGicEntity);
  65. }
  66. private string designKey = "";
  67. private string[] _parms;
  68. /// <summary>
  69. /// 查询质量设计加工
  70. /// </summary>
  71. /// <param name="designStdGicEntity"></param>
  72. public void QueryByDesignKeyGic(string[] parms)
  73. {
  74. designKey = parms[0];
  75. _parms = parms;
  76. List<CraftOrdDesignStdGicEntity> data = _designStdGicBLL.QueryByDesignKeyGic(parms);
  77. var list = data.Select(p=>p.Gic).Distinct().ToList();
  78. if (list.Count > 1)
  79. {
  80. Gics.DataSource = list;
  81. QcmBaseQuery.BindColumn(Gics, "Gic", entityGrid1.DisplayLayout.Bands[0]);
  82. }
  83. this.CraftOrdDesignStdGicEntityBindingSource.DataSource = data;
  84. //UltraComboEditor cmb = new UltraComboEditor();
  85. foreach (var row in entityGrid1.Rows)
  86. {
  87. GridEdite(row);
  88. if (row.GetValue("CraftSource") == "0")
  89. {
  90. row.Cells["Chk"].Value = null;
  91. row.Cells["Chk"].Activation = Activation.ActivateOnly;
  92. row.Update();
  93. }
  94. //if (cmb.ValueList.FindString(row.GetValue("Gic")) == -1)
  95. //{
  96. // cmb.ValueList.ValueListItems.Add(row.GetValue("Gic"));
  97. //}
  98. }
  99. entityGrid1.UpdateData();
  100. //cmb.DisplayStyle = EmbeddableElementDisplayStyle.WindowsVista;
  101. //entityGrid1.DisplayLayout.Bands[0].Columns["Gic"].EditorComponent = cmb;
  102. //entityGrid1.DisplayLayout.Bands[0].Columns["Gic"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
  103. }
  104. public void Clear()
  105. {
  106. this.CraftOrdDesignStdGicEntityBindingSource.Clear();
  107. }
  108. public void Save()
  109. {
  110. List<CraftOrdDesignStdGicEntity> parms = new List<CraftOrdDesignStdGicEntity>();
  111. var rows = entityGrid1.Rows.Where(a => a.GetValue("Chk") == "True");
  112. foreach (var row in rows)
  113. {
  114. var parm = EntityHelper.CopyEntity<CraftOrdDesignStdGicEntity>(row.ListObject);
  115. if (parm.MscPline == "")
  116. {
  117. MessageUtil.ShowWarning("请选择制程!");
  118. row.SetCellActive("MscPline");
  119. return;
  120. }
  121. //if (parm.ProcessDescC2 == "")
  122. //{
  123. // MessageUtil.ShowWarning("请选择二级工序!");
  124. // row.SetCellActive("ProcessDescC2");
  125. // return;
  126. //}
  127. if (parm.Gic == "")
  128. {
  129. MessageUtil.ShowWarning("请选择加工索引码!");
  130. row.SetCellActive("Gic");
  131. return;
  132. }
  133. if (parm.StationCode.Equals(""))
  134. {
  135. MessageUtil.ShowWarning("请选择工序点名称!");
  136. return;
  137. }
  138. if (parm.ValueText == "" && parm.ValueNum == null)
  139. {
  140. MessageUtil.ShowWarning("文本值和数值必须输入一个!");
  141. return;
  142. }
  143. if (parm.ValueText != "" && parm.ValueNum != null)
  144. {
  145. MessageUtil.ShowWarning("文本值和数值只能输入一个!");
  146. return;
  147. }
  148. parm.CreateName = CoreUserInfo.UserInfo.GetUserName();
  149. parm.UpdateName = CoreUserInfo.UserInfo.GetUserName();
  150. parm.DeleteName = CoreUserInfo.UserInfo.GetUserName();
  151. parm.DesginKey = designKey;
  152. parm.SpeclFl = "2";
  153. parms.Add(parm);
  154. }
  155. if (MessageUtil.ShowYesNoAndQuestion("是否确认保存?") == DialogResult.No)
  156. {
  157. return;
  158. }
  159. _designStdGicBLL.Save(parms);
  160. MessageUtil.ShowTips("保存成功!");
  161. QueryByDesignKeyGic(_parms);
  162. }
  163. public void Delete()
  164. {
  165. List<CraftOrdDesignStdGicEntity> parms = new List<CraftOrdDesignStdGicEntity>();
  166. var rows = entityGrid1.Rows.Where(a => a.GetValue("Chk") == "True");
  167. foreach (var row in rows)
  168. {
  169. var parm = EntityHelper.CopyEntity<CraftOrdDesignStdGicEntity>(row.ListObject);
  170. parm.CreateName = CoreUserInfo.UserInfo.GetUserName();
  171. parm.UpdateName = CoreUserInfo.UserInfo.GetUserName();
  172. parm.DeleteName = CoreUserInfo.UserInfo.GetUserName();
  173. parm.SpeclFl = "2";
  174. parm.DesginKey = designKey;
  175. parms.Add(parm);
  176. }
  177. _designStdGicBLL.Delete(parms);
  178. }
  179. private void GridEdite(UltraGridRow row)
  180. {
  181. if (row.GetValue("Chk") == "True")
  182. {
  183. foreach (UltraGridCell cell in row.Cells)
  184. {
  185. if (cell.Column.CellActivation == Activation.AllowEdit)
  186. {
  187. cell.Activation = Activation.AllowEdit;
  188. }
  189. }
  190. }
  191. else
  192. {
  193. foreach (UltraGridCell cell in row.Cells)
  194. {
  195. if (cell.Column.Key == "Chk") continue;
  196. if (cell.Column.CellActivation == Activation.AllowEdit)
  197. {
  198. cell.Activation = Activation.ActivateOnly;
  199. }
  200. }
  201. }
  202. }
  203. private void entityGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
  204. {
  205. entityGrid1.UpdateData();
  206. GridEdite(e.Cell.Row);
  207. }
  208. private void entityGrid1_AfterRowInsert(object sender, RowEventArgs e)
  209. {
  210. e.Row.Cells["ProcessCdoe"].Value = "G";
  211. e.Row.Cells["ProcessDesc"].Value = "加工";
  212. e.Row.Cells["CraftSource"].Value = "1";
  213. e.Row.Cells["SpeclFl"].Value = "2";
  214. }
  215. private void ultraTextEditor1_EditorButtonClick(object sender, EditorButtonEventArgs e)
  216. {
  217. UltraGridRow row = entityGrid1.ActiveRow;
  218. string key = entityGrid1.ActiveCell.Column.Key;
  219. if (key == "MscPline")
  220. {
  221. DataTable dt = _designMscPlBLL.QueryMscPlineProcess(designKey);
  222. dt.Columns["MSC_PLINE"].Caption = "制程号";
  223. dt.Columns["WHOLE_BACKLOG"].Caption = "全程途径码";
  224. dt.Columns["WHOLE_BACKLOG_DESC"].Caption = "全程途径描述";
  225. dt.Columns["PROCESS_DESC"].Caption = "工序";
  226. dt.Columns["PROCESS_DESC_C"].Caption = "二级工序";
  227. dt.Columns["GIC"].Caption = "加工内控索引码";
  228. DataTable dtNew = dt.Clone();
  229. foreach (DataRow dr in dt.Rows)
  230. {
  231. string[] gics = dr["GIC"].ToString().Split(',');
  232. foreach (string gic in gics)
  233. {
  234. DataRow drNew = dtNew.NewRow();
  235. drNew["MSC_PLINE"] = dr["MSC_PLINE"];
  236. drNew["WHOLE_BACKLOG"] = dr["WHOLE_BACKLOG"];
  237. drNew["WHOLE_BACKLOG_DESC"] = dr["WHOLE_BACKLOG_DESC"];
  238. drNew["PROCESS_DESC"] = dr["PROCESS_DESC"];
  239. drNew["PROCESS_DESC_C"] = dr["PROCESS_DESC_C"];
  240. drNew["PROCESS_CODE"] = dr["PROCESS_CODE"];
  241. drNew["PROCESS_CODE_C"] = dr["PROCESS_CODE_C"];
  242. drNew["GIC"] = gic.Trim();
  243. dtNew.Rows.Add(drNew);
  244. }
  245. }
  246. BaseInfoPopup popup = new BaseInfoPopup(dtNew, "MSC_PLINE", "CIC", "SIC", "DIC", "WIC", "PIC", "PROCESS_CODE", "PROCESS_CODE_C");
  247. GridHelper.RefreshAndAutoSize(popup.UltraGrid1);
  248. popup.LabelTextBox1.Caption = "制程号";
  249. if (popup.ShowDialog() == DialogResult.OK)
  250. {
  251. row.SetValue("MscPline", popup.ChoicedRow.GetValue("MSC_PLINE"));
  252. row.SetValue("ProcessDescC2", popup.ChoicedRow.GetValue("PROCESS_DESC_C"));
  253. row.SetValue("ProcessCodeC", popup.ChoicedRow.GetValue("PROCESS_CODE_C"));
  254. row.SetValue("ProcessDesc", popup.ChoicedRow.GetValue("PROCESS_DESC"));
  255. row.SetValue("ProcessCode", popup.ChoicedRow.GetValue("PROCESS_CODE"));
  256. row.SetValue("Gic", popup.ChoicedRow.GetValue("GIC"));
  257. }
  258. }
  259. else if (key == "ProcessDescC2")
  260. {
  261. string mscPline = entityGrid1.ActiveRow.GetValue("MscPline");
  262. DataTable dt = _designMscPlPrcBLL.queryProcess(designKey, mscPline);
  263. dt.Columns["PROCESS_DESC"].Caption = "工序";
  264. dt.Columns["PROCESS_DESC_C"].Caption = "二级工序";
  265. BaseInfoPopup popup = new BaseInfoPopup(dt, "PROCESS_DESC_C", "PROCESS_CODE", "PROCESS_CODE_C");
  266. popup.LabelTextBox1.Caption = "二级工序";
  267. if (popup.ShowDialog() == DialogResult.OK)
  268. {
  269. row.SetValue("ProcessDescC2", popup.ChoicedRow.GetValue("PROCESS_DESC_C"));
  270. row.SetValue("ProcessCodeC", popup.ChoicedRow.GetValue("PROCESS_CODE_C"));
  271. row.SetValue("ProcessDesc", popup.ChoicedRow.GetValue("PROCESS_DESC"));
  272. row.SetValue("ProcessCode", popup.ChoicedRow.GetValue("PROCESS_CODE"));
  273. }
  274. }
  275. else if (key == "Gic")
  276. {
  277. string mscPline = entityGrid1.ActiveRow.GetValue("MscPline");
  278. string processCode = entityGrid1.ActiveRow.GetValue("ProcessCode");
  279. DataTable dt = _designMscPlPrcBLL.queryProcessNkIndex(designKey, mscPline, processCode);
  280. dt.Columns["GIC"].Caption = "加工内控索引码";
  281. BaseInfoPopup popup = new BaseInfoPopup(dt, "GIC", "CIC", "SIC", "DIC", "WIC", "PIC");
  282. popup.LabelTextBox1.Caption = "加工内控索引码";
  283. if (popup.ShowDialog() == DialogResult.OK)
  284. {
  285. row.SetValue("Gic", popup.ChoicedRow.GetValue("GIC"));
  286. }
  287. }
  288. }
  289. }
  290. }