CraftOrdDesignStdWicCtrl.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  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.StlMes.Client.Qcm;
  14. using Core.Mes.Client.Comm.Server;
  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 CraftOrdDesignStdWicCtrl : UserControl
  22. {
  23. private CraftOrdDesignStdWicBLL _designStdWicBLL;
  24. private CraftOrdDesignMscPlBLL _designMscPlBLL;
  25. private CraftOrdDesignMscPlPrcBLL _designMscPlPrcBLL;
  26. private OpeBase _ob;
  27. UltraComboEditor Wics = new UltraComboEditor();
  28. public CraftOrdDesignStdWicCtrl(System.Windows.Forms.Control container, OpeBase ob)
  29. {
  30. InitializeComponent();
  31. _ob = ob;
  32. _designStdWicBLL = new CraftOrdDesignStdWicBLL(ob);
  33. _designMscPlBLL = new CraftOrdDesignMscPlBLL(ob);
  34. _designMscPlPrcBLL = new CraftOrdDesignMscPlPrcBLL(ob);
  35. container.Controls.Add(this);
  36. this.Dock = DockStyle.Fill;
  37. LoadBaseData();
  38. }
  39. private void LoadBaseData()
  40. {
  41. UltraComboEditor ultraComPsc = new UltraComboEditor();
  42. UltraComboEditor ultraComProcess = new UltraComboEditor();
  43. UltraComboEditor ultraComJG = new UltraComboEditor();
  44. UltraComboEditor cmbProBigType = new UltraComboEditor();
  45. this.Controls.Add(ultraComPsc);
  46. this.Controls.Add(ultraComProcess);
  47. this.Controls.Add(ultraComJG);
  48. this.Controls.Add(cmbProBigType);
  49. ultraComPsc.Visible = false;
  50. ultraComProcess.Visible = false;
  51. ultraComJG.Visible = false;
  52. cmbProBigType.Visible = false;
  53. this.Controls.Add(Wics);
  54. Wics.Visible = false;
  55. //绑定数据源 产品规范描述
  56. QcmBaseCommon.InitDropUltraComEditor(ultraComPsc, "com.steering.pss.qcm.ComBaseQuery.getPsc", "PscDesc", _ob, false);
  57. //不可编辑
  58. UltraComboEditor cmbWtr = new UltraComboEditor();
  59. cmbWtr.DropDownListWidth = -1;
  60. this.Controls.Add(cmbWtr);
  61. cmbWtr.Visible = false;
  62. ClsBaseInfo.FillWtrExpress(cmbWtr, _ob, true);
  63. entityGrid1.DisplayLayout.Bands[0].Columns["Formula"].EditorComponent = cmbWtr;
  64. entityGrid1.DisplayLayout.Bands[0].Columns["Formula"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
  65. QcmBaseQuery.NitializeProductBigType(cmbProBigType, false, _ob);
  66. ClsBaseInfo.SetComboItemHeight(cmbProBigType);
  67. }
  68. /// <summary>
  69. /// 查询质量设计水压
  70. /// </summary>
  71. /// <param name="designStdWicEntity"></param>
  72. public void Query(CraftOrdDesignStdWicEntity designStdWicEntity)
  73. {
  74. this.CraftOrdDesignStdWicEntityBindingSource.DataSource = _designStdWicBLL.Query(designStdWicEntity);
  75. }
  76. private string designKey = "";
  77. private string[] _parms;
  78. /// <summary>
  79. /// 查询质量设计水压
  80. /// </summary>
  81. /// <param name="designStdWicEntity"></param>
  82. public void QueryByDesignKeyWic(string[] parms)
  83. {
  84. designKey = parms[0];
  85. _parms = parms;
  86. var data = _designStdWicBLL.QueryByDesignKeyWic(parms);
  87. var list = data.Select(p => p.Wic).Distinct().ToList();
  88. if (list.Count > 1)
  89. {
  90. Wics.DataSource = data.Select(p => p.Wic).Distinct().ToList();
  91. QcmBaseQuery.BindColumn(Wics, "Wic", entityGrid1.DisplayLayout.Bands[0]);
  92. }
  93. this.CraftOrdDesignStdWicEntityBindingSource.DataSource = data;
  94. //UltraComboEditor cmb = new UltraComboEditor();
  95. foreach (var row in entityGrid1.Rows)
  96. {
  97. GridEdite(row);
  98. if (row.GetValue("CraftSource") == "0")
  99. {
  100. row.Cells["Chk"].Value = null;
  101. row.Cells["Chk"].Activation = Activation.ActivateOnly;
  102. row.Update();
  103. }
  104. //if (cmb.ValueList.FindString(row.GetValue("Wic")) == -1)
  105. //{
  106. // cmb.ValueList.ValueListItems.Add(row.GetValue("Wic"));
  107. //}
  108. }
  109. //cmb.DisplayStyle = EmbeddableElementDisplayStyle.WindowsVista;
  110. //entityGrid1.DisplayLayout.Bands[0].Columns["Wic"].EditorComponent = cmb;
  111. //entityGrid1.DisplayLayout.Bands[0].Columns["Wic"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
  112. }
  113. public void Clear()
  114. {
  115. this.CraftOrdDesignStdWicEntityBindingSource.Clear();
  116. }
  117. public void Save()
  118. {
  119. List<CraftOrdDesignStdWicEntity> parms = new List<CraftOrdDesignStdWicEntity>();
  120. var rows = entityGrid1.Rows.Where(a => a.GetValue("Chk") == "True");
  121. foreach (var row in rows)
  122. {
  123. var parm = EntityHelper.CopyEntity<CraftOrdDesignStdWicEntity>(row.ListObject);
  124. if (parm.MscPline == "")
  125. {
  126. MessageUtil.ShowWarning("请选择制程!");
  127. row.SetCellActive("MscPline");
  128. return;
  129. }
  130. //if (parm.ProcessDescC == "")
  131. //{
  132. // MessageUtil.ShowWarning("请选择二级工序!");
  133. // row.SetCellActive("ProcessDescC");
  134. // return;
  135. //}
  136. if (parm.Wic == "")
  137. {
  138. MessageUtil.ShowWarning("请选择水压索引码!");
  139. row.SetCellActive("Wic");
  140. return;
  141. }
  142. if (parm.PressureY == "" && parm.Pressure == "" && parm.Formula == "")
  143. {
  144. MessageUtil.ShowWarning("请输入试验压力或者试验压力公式");
  145. return;
  146. }
  147. string formula = parm.Formula.Replace("f", "1").Replace("YS", "1").Replace("TS", "1").Replace("D", "2").Replace("t", "1");
  148. if (!parm.Formula.Equals("") && formula.CompileFormula() == null)
  149. {
  150. MessageUtil.ShowWarning("公式不合法,请重新输入");
  151. return;
  152. }
  153. if (parm.SaveTime.Equals(""))
  154. {
  155. MessageUtil.ShowWarning("请输入保压时间");
  156. return;
  157. }
  158. if ((parm.Pressure != "" || parm.PressureY != "") && parm.Formula != "")
  159. {
  160. if (parm.GetMaxvalue == null && parm.GetMinvalue == null)
  161. {
  162. MessageUtil.ShowWarning("请选择取大值或取小值");
  163. return;
  164. }
  165. }
  166. parm.CreateName = CoreUserInfo.UserInfo.GetUserName();
  167. parm.UpdateName = CoreUserInfo.UserInfo.GetUserName();
  168. parm.DeleteName = CoreUserInfo.UserInfo.GetUserName();
  169. parm.SpeclFl = "2";
  170. parm.DesginKey = designKey;
  171. parms.Add(parm);
  172. }
  173. if (MessageUtil.ShowYesNoAndQuestion("是否确认保存?") == DialogResult.No)
  174. {
  175. return;
  176. }
  177. _designStdWicBLL.Save(parms);
  178. MessageUtil.ShowTips("保存成功!");
  179. QueryByDesignKeyWic(_parms);
  180. }
  181. public void Delete()
  182. {
  183. List<CraftOrdDesignStdWicEntity> parms = new List<CraftOrdDesignStdWicEntity>();
  184. var rows = entityGrid1.Rows.Where(a => a.GetValue("Chk") == "True");
  185. foreach (var row in rows)
  186. {
  187. var parm = EntityHelper.CopyEntity<CraftOrdDesignStdWicEntity>(row.ListObject);
  188. parm.CreateName = CoreUserInfo.UserInfo.GetUserName();
  189. parm.UpdateName = CoreUserInfo.UserInfo.GetUserName();
  190. parm.DeleteName = CoreUserInfo.UserInfo.GetUserName();
  191. parm.SpeclFl = "2";
  192. parm.DesginKey = designKey;
  193. parms.Add(parm);
  194. }
  195. _designStdWicBLL.Delete(parms);
  196. }
  197. private void GridEdite(UltraGridRow row)
  198. {
  199. if (row.GetValue("Chk") == "True")
  200. {
  201. foreach (UltraGridCell cell in row.Cells)
  202. {
  203. if (cell.Column.CellActivation == Activation.AllowEdit)
  204. {
  205. cell.Activation = Activation.AllowEdit;
  206. }
  207. }
  208. }
  209. else
  210. {
  211. foreach (UltraGridCell cell in row.Cells)
  212. {
  213. if (cell.Column.Key == "Chk") continue;
  214. if (cell.Column.CellActivation == Activation.AllowEdit)
  215. {
  216. cell.Activation = Activation.ActivateOnly;
  217. }
  218. }
  219. }
  220. }
  221. private void entityGrid1_CellChange(object sender, CellEventArgs e)
  222. {
  223. entityGrid1.UpdateData();
  224. GridEdite(e.Cell.Row);
  225. if (e.Cell.Column.Key == "PressureY")
  226. {
  227. if (e.Cell.Value.ToString() != "")
  228. {
  229. //英制压力转公制压力系数为0.00689476
  230. e.Cell.Row.Cells["Pressure"].Value = Math.Round(double.Parse(e.Cell.Value.ToString()) * 0.00689476, 2);
  231. }
  232. else
  233. {
  234. e.Cell.Row.Cells["Pressure"].Value = 0;
  235. }
  236. }
  237. else if (e.Cell.Column.Key == "Pressure")
  238. {
  239. if (e.Cell.Value.ToString() != "")
  240. {
  241. if (double.Parse(e.Cell.Value.ToString()) > 6894.76)
  242. {
  243. MessageUtil.ShowWarning("公制压力上限为68900");
  244. e.Cell.Row.Cells["Pressure"].Value = 6894.76;
  245. }
  246. //公制压力转英制压力系数为14.5
  247. e.Cell.Row.Cells["PressureY"].Value = Math.Round(double.Parse(e.Cell.Value.ToString()) / 0.00689476, 2);
  248. }
  249. else
  250. {
  251. e.Cell.Row.Cells["PressureY"].Value = 0;
  252. }
  253. }
  254. }
  255. private void entityGrid1_AfterRowInsert(object sender, RowEventArgs e)
  256. {
  257. e.Row.Cells["GetMaxvalue"].Value = true;
  258. e.Row.Cells["GetMinvalue"].Value = false;
  259. e.Row.Cells["CraftSource"].Value = "1";
  260. e.Row.Cells["SpeclFl"].Value = "2";
  261. }
  262. private void ultraTextEditor1_EditorButtonClick(object sender, EditorButtonEventArgs e)
  263. {
  264. UltraGridRow row = entityGrid1.ActiveRow;
  265. string key = entityGrid1.ActiveCell.Column.Key;
  266. if (key == "MscPline")
  267. {
  268. DataTable dt = _designMscPlBLL.QueryMscPlineProcess(designKey);
  269. dt.Columns["MSC_PLINE"].Caption = "制程号";
  270. dt.Columns["WHOLE_BACKLOG"].Caption = "全程途径码";
  271. dt.Columns["WHOLE_BACKLOG_DESC"].Caption = "全程途径描述";
  272. dt.Columns["PROCESS_DESC"].Caption = "工序";
  273. dt.Columns["PROCESS_DESC_C"].Caption = "二级工序";
  274. dt.Columns["WIC"].Caption = "水压内控索引码";
  275. DataTable dtNew = dt.Clone();
  276. foreach (DataRow dr in dt.Rows)
  277. {
  278. string[] wics = dr["WIC"].ToString().Split(',');
  279. foreach (string wic in wics)
  280. {
  281. DataRow drNew = dtNew.NewRow();
  282. drNew["MSC_PLINE"] = dr["MSC_PLINE"];
  283. drNew["WHOLE_BACKLOG"] = dr["WHOLE_BACKLOG"];
  284. drNew["WHOLE_BACKLOG_DESC"] = dr["WHOLE_BACKLOG_DESC"];
  285. drNew["PROCESS_DESC"] = dr["PROCESS_DESC"];
  286. drNew["PROCESS_DESC_C"] = dr["PROCESS_DESC_C"];
  287. drNew["PROCESS_CODE"] = dr["PROCESS_CODE"];
  288. drNew["PROCESS_CODE_C"] = dr["PROCESS_CODE_C"];
  289. drNew["WIC"] = wic.Trim();
  290. dtNew.Rows.Add(drNew);
  291. }
  292. }
  293. BaseInfoPopup popup = new BaseInfoPopup(dtNew, "MSC_PLINE", "CIC", "SIC", "DIC", "PIC", "GIC", "PROCESS_CODE", "PROCESS_CODE_C");
  294. GridHelper.RefreshAndAutoSize(popup.UltraGrid1);
  295. popup.LabelTextBox1.Caption = "制程号";
  296. if (popup.ShowDialog() == DialogResult.OK)
  297. {
  298. row.SetValue("MscPline", popup.ChoicedRow.GetValue("MSC_PLINE"));
  299. row.SetValue("ProcessDescC", popup.ChoicedRow.GetValue("PROCESS_DESC_C"));
  300. row.SetValue("ProcessCodeC", popup.ChoicedRow.GetValue("PROCESS_CODE_C"));
  301. row.SetValue("ProcessDesc", popup.ChoicedRow.GetValue("PROCESS_DESC"));
  302. row.SetValue("ProcessCode", popup.ChoicedRow.GetValue("PROCESS_CODE"));
  303. row.SetValue("Wic", popup.ChoicedRow.GetValue("WIC"));
  304. }
  305. }
  306. else if (key == "ProcessDescC")
  307. {
  308. string mscPline = entityGrid1.ActiveRow.GetValue("MscPline");
  309. DataTable dt = _designMscPlPrcBLL.queryProcess(designKey, mscPline);
  310. dt.Columns["PROCESS_DESC"].Caption = "工序";
  311. dt.Columns["PROCESS_DESC_C"].Caption = "二级工序";
  312. BaseInfoPopup popup = new BaseInfoPopup(dt, "PROCESS_DESC_C", "PROCESS_CODE", "PROCESS_CODE_C");
  313. popup.LabelTextBox1.Caption = "二级工序";
  314. if (popup.ShowDialog() == DialogResult.OK)
  315. {
  316. row.SetValue("ProcessDescC", popup.ChoicedRow.GetValue("PROCESS_DESC_C"));
  317. row.SetValue("ProcessCodeC", popup.ChoicedRow.GetValue("PROCESS_CODE_C"));
  318. row.SetValue("ProcessDesc", popup.ChoicedRow.GetValue("PROCESS_DESC"));
  319. row.SetValue("ProcessCode", popup.ChoicedRow.GetValue("PROCESS_CODE"));
  320. }
  321. }
  322. else if (key == "Wic")
  323. {
  324. string mscPline = entityGrid1.ActiveRow.GetValue("MscPline");
  325. string processCode = entityGrid1.ActiveRow.GetValue("ProcessCode");
  326. DataTable dt = _designMscPlPrcBLL.queryProcessNkIndex(designKey, mscPline, processCode);
  327. dt.Columns["WIC"].Caption = "水压内控索引码";
  328. BaseInfoPopup popup = new BaseInfoPopup(dt, "WIC", "PIC", "SIC", "DIC", "CIC", "GIC");
  329. popup.LabelTextBox1.Caption = "水压内控索引码";
  330. if (popup.ShowDialog() == DialogResult.OK)
  331. {
  332. row.SetValue("Wic", popup.ChoicedRow.GetValue("WIC"));
  333. }
  334. }
  335. }
  336. }
  337. }