ComBaseSplineCCtrl.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. using Core.Mes.Client.Comm.Tool;
  2. using Core.StlMes.Client.Qcm.BLL;
  3. using Core.StlMes.Client.Qcm.model;
  4. using CoreFS.CA06;
  5. using CoreFS.SA06;
  6. using Infragistics.Win.UltraWinGrid;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Data;
  10. using System.Drawing;
  11. using System.Linq;
  12. using System.Windows.Forms;
  13. namespace Core.StlMes.Client.Qcm.Control
  14. {
  15. public partial class ComBaseSplineCCtrl : UserControl
  16. {
  17. private ComBaseSplineCBLL _splineCBLL;
  18. private OpeBase _ob;
  19. public ComBaseSplineCCtrl(System.Windows.Forms.Control container, OpeBase ob)
  20. {
  21. InitializeComponent();
  22. this._ob = ob;
  23. _splineCBLL = new ComBaseSplineCBLL(ob);
  24. container.Controls.Add(this);
  25. this.Dock = DockStyle.Fill;
  26. this.BringToFront();
  27. EntityHelper.ShowGridCaption<ComBaseSplineCEntity>(ultraGrid1.DisplayLayout.Bands[0]);
  28. }
  29. public void Query(string eic, string validflag)
  30. {
  31. comBaseSplineCEntityBindingSource.DataSource = _splineCBLL.Query(eic, validflag);
  32. foreach (var row in ultraGrid1.Rows)
  33. {
  34. GridEdite(row);
  35. }
  36. }
  37. public void Query2(string eic)
  38. {
  39. comBaseSplineCEntityBindingSource.DataSource = _splineCBLL.Query2(eic);
  40. foreach (var row in ultraGrid1.Rows)
  41. {
  42. GridEdite(row);
  43. }
  44. }
  45. public void Clear()
  46. {
  47. comBaseSplineCEntityBindingSource.Clear();
  48. }
  49. public void ClearDataSource()
  50. {
  51. this.comBaseSplineCEntityBindingSource.Clear();
  52. }
  53. public void Save()
  54. {
  55. var rows = ultraGrid1.Rows.AsQueryable().Where(a => a.GetValue("Chk") == "True")
  56. .Select(a => EntityHelper.CopyEntity<ComBaseSplineCEntity>(a.ListObject)).ToList();
  57. foreach (var row in rows)
  58. {
  59. row.CreateName = CoreUserInfo.UserInfo.GetUserName();
  60. row.UpdateName = CoreUserInfo.UserInfo.GetUserName();
  61. }
  62. _splineCBLL.Save(rows);
  63. }
  64. public List<ComBaseSplineCEntity2> GetSaveParms()
  65. {
  66. ultraGrid1.UpdateData();
  67. var rows = ultraGrid1.Rows.AsQueryable().Where(a => a.GetValue("Chk") == "True");
  68. List<ComBaseSplineCEntity2> splineCEntitys = new List<ComBaseSplineCEntity2>();
  69. //.Select(a => EntityHelper.CopyEntity<ComBaseSplineCEntity>(a.ListObject)).ToList();
  70. foreach (var row in rows)
  71. {
  72. ComBaseSplineCEntity2 splineCEntity = EntityHelper.CopyEntity<ComBaseSplineCEntity2>(row.ListObject);
  73. if (splineCEntity.MinDSign != "" && splineCEntity.MinD == "")
  74. {
  75. MessageUtil.ShowWarning("请输入外径下限值!");
  76. row.SetCellActive("MinD");
  77. return null;
  78. }
  79. else if (splineCEntity.MinDSign == "" && splineCEntity.MinD != "")
  80. {
  81. MessageUtil.ShowWarning("请选择外径下限符号!");
  82. row.SetCellActive("MinDSign");
  83. return null;
  84. }
  85. else if (splineCEntity.MaxDSign != "" && splineCEntity.MaxD == "")
  86. {
  87. MessageUtil.ShowWarning("请输入外径上限值!");
  88. row.SetCellActive("MaxD");
  89. return null;
  90. }
  91. else if (splineCEntity.MaxDSign == "" && splineCEntity.MaxD != "")
  92. {
  93. MessageUtil.ShowWarning("请选择外径上限符号!");
  94. row.SetCellActive("MaxDSign");
  95. return null;
  96. }
  97. else if (splineCEntity.MinHSign != "" && splineCEntity.MinH == "")
  98. {
  99. MessageUtil.ShowWarning("请输入壁厚下限值!");
  100. row.SetCellActive("MinH");
  101. return null;
  102. }
  103. else if (splineCEntity.MinHSign == "" && splineCEntity.MinH != "")
  104. {
  105. MessageUtil.ShowWarning("请选择壁厚下限符号!");
  106. row.SetCellActive("MinHSign");
  107. return null;
  108. }
  109. else if (splineCEntity.MaxHSign != "" && splineCEntity.MaxH == "")
  110. {
  111. MessageUtil.ShowWarning("请输入壁厚上限值!");
  112. row.SetCellActive("MaxH");
  113. return null;
  114. }
  115. else if (splineCEntity.MaxHSign == "" && splineCEntity.MaxH != "")
  116. {
  117. MessageUtil.ShowWarning("请选择壁厚上限符号!");
  118. row.SetCellActive("MaxHSign");
  119. return null;
  120. }
  121. else if (splineCEntity.MinDSign == "=" && splineCEntity.MaxDSign != "")
  122. {
  123. MessageUtil.ShowWarning("外径下限符号为等号时,不能存在外径上限符号和外径上限值!");
  124. row.SetCellActive("MaxDSign");
  125. return null;
  126. }
  127. else if (splineCEntity.MinHSign == "=" && splineCEntity.MaxHSign != "")
  128. {
  129. MessageUtil.ShowWarning("壁厚下限符号为等号时,不能存在壁厚上限符号和壁厚上限值!");
  130. row.SetCellActive("MaxHSign");
  131. return null;
  132. }
  133. else if (splineCEntity.MinD != "" && splineCEntity.MaxD != ""
  134. && decimal.Parse(splineCEntity.MinD) >= decimal.Parse(splineCEntity.MaxD))
  135. {
  136. MessageUtil.ShowWarning("外径下限值不能大于等于外径上限值!");
  137. row.SetCellActive("MinD");
  138. return null;
  139. }
  140. else if (splineCEntity.MinH != "" && splineCEntity.MaxH != ""
  141. && decimal.Parse(splineCEntity.MinH) >= decimal.Parse(splineCEntity.MaxH))
  142. {
  143. MessageUtil.ShowWarning("壁厚下限值不能大于等于壁厚上限值!");
  144. row.SetCellActive("MinH");
  145. return null;
  146. }
  147. else if (splineCEntity.Formula != "" || splineCEntity.MinF != "" || splineCEntity.MinFSign != ""
  148. || splineCEntity.MaxF != "" || splineCEntity.MaxFSign != "")
  149. {
  150. string formula = splineCEntity.Formula.Replace("t", "0.01").Replace("D", "0.01");
  151. string formula2 = splineCEntity.Formula.Replace("t", "10000").Replace("D", "10000");
  152. if (splineCEntity.Formula == "")
  153. {
  154. MessageUtil.ShowWarning("请输入公式!");
  155. row.SetCellActive("Formula");
  156. return null;
  157. }
  158. else if (formula.CompileFormula() == null && formula2.CompileFormula() == null)
  159. {
  160. MessageUtil.ShowWarning("输入的公式不合法!");
  161. row.SetCellActive("Formula");
  162. return null;
  163. }
  164. else if (splineCEntity.MinF == "" && splineCEntity.MinFSign != "")
  165. {
  166. MessageUtil.ShowWarning("请输入公式下限值!");
  167. row.SetCellActive("MinF");
  168. return null;
  169. }
  170. else if (splineCEntity.MinF != "" && splineCEntity.MinFSign == "")
  171. {
  172. MessageUtil.ShowWarning("请输入公式下限符号!");
  173. row.SetCellActive("MinFSign");
  174. return null;
  175. }
  176. else if (splineCEntity.MaxF == "" && splineCEntity.MaxFSign != "")
  177. {
  178. MessageUtil.ShowWarning("请输入公式上限值!");
  179. row.SetCellActive("MaxF");
  180. return null;
  181. }
  182. else if (splineCEntity.MaxF != "" && splineCEntity.MaxFSign == "")
  183. {
  184. MessageUtil.ShowWarning("请输入公式上限符号!");
  185. row.SetCellActive("MaxFSign");
  186. return null;
  187. }
  188. else if (splineCEntity.Formula != "" && splineCEntity.MinF == "" && splineCEntity.MinFSign == ""
  189. && splineCEntity.MaxF == "" && splineCEntity.MaxFSign == "")
  190. {
  191. MessageUtil.ShowWarning("请输入公式下限符号!");
  192. row.SetCellActive("MinFSign");
  193. return null;
  194. }
  195. }
  196. else if (splineCEntity.MinF != "" && splineCEntity.MaxF != ""
  197. && decimal.Parse(splineCEntity.MinF) >= decimal.Parse(splineCEntity.MaxF))
  198. {
  199. MessageUtil.ShowWarning("公式下限值不能大于等于公式上限值!");
  200. row.SetCellActive("MinF");
  201. return null;
  202. }
  203. var steelCodes = row.GetValue("SteelCodes").Split(';').ToArray();
  204. //var steelDescs = row.GetValue("SteelDescs").Split(';').ToArray();
  205. splineCEntity.SplineCRSteel = new List<ComBaseSplineCRSteelEntity>();
  206. for (int i = 0; i < steelCodes.Length; i++)
  207. {
  208. if (steelCodes[i] == "") continue;
  209. splineCEntity.SplineCRSteel.Add(new ComBaseSplineCRSteelEntity()
  210. {
  211. Steelcode = steelCodes[i],
  212. CreateName = CoreUserInfo.UserInfo.GetUserName()
  213. });
  214. }
  215. var productCodes = row.GetValue("ProductCodes").Split(';').ToArray();
  216. //var productDescs = row.GetValue("ProductDescs").Split(';').ToArray();
  217. splineCEntity.SplineCRProduct = new List<ComBaseSplineCRProductEntity>();
  218. for (int i = 0; i < productCodes.Length; i++)
  219. {
  220. if (productCodes[i] == "") continue;
  221. splineCEntity.SplineCRProduct.Add(new ComBaseSplineCRProductEntity()
  222. {
  223. Produccode = productCodes[i],
  224. CreateName = CoreUserInfo.UserInfo.GetUserName()
  225. });
  226. }
  227. var stdCodes = row.GetValue("StdCode").Split(';').ToArray();
  228. //var stdNames = row.GetValue("StdName").Split(';').ToArray();
  229. splineCEntity.SplineCRStd = new List<ComBaseSplineCRStdEntity>();
  230. for (int i = 0; i < stdCodes.Length; i++)
  231. {
  232. if (stdCodes[i] == "") continue;
  233. splineCEntity.SplineCRStd.Add(new ComBaseSplineCRStdEntity()
  234. {
  235. StdCode = stdCodes[i]
  236. });
  237. }
  238. var modelCodes = row.GetValue("ModelCodes").Split('|').ToArray();
  239. //var modelNames = row.GetValue("ModelDescs").Split('|').ToArray();
  240. splineCEntity.SplineCRModel = new List<ComBaseSplineCRModelEntity>();
  241. for (int i = 0; i < modelCodes.Length; i++)
  242. {
  243. if (modelCodes[i] == "") continue;
  244. splineCEntity.SplineCRModel.Add(new ComBaseSplineCRModelEntity()
  245. {
  246. ModelCode = modelCodes[i]
  247. });
  248. }
  249. splineCEntity.CreateName = CoreUserInfo.UserInfo.GetUserName();
  250. splineCEntity.UpdateName = CoreUserInfo.UserInfo.GetUserName();
  251. splineCEntitys.Add(splineCEntity);
  252. }
  253. return splineCEntitys;
  254. }
  255. public void UpdateValidflag(string validflag)
  256. {
  257. var rows = ultraGrid1.Rows.AsQueryable().Where(a => a.GetValue("Chk") == "True")
  258. .Select(a => EntityHelper.CopyEntity<ComBaseSplineCEntity>(a.ListObject)).ToList();
  259. foreach (var row in rows)
  260. {
  261. row.DeleteName = CoreUserInfo.UserInfo.GetUserName();
  262. row.UpdateName = CoreUserInfo.UserInfo.GetUserName();
  263. }
  264. _splineCBLL.UpdateValidflag(rows, validflag);
  265. }
  266. private void ultraGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
  267. {
  268. e.Cell.Row.Update();
  269. GridEdite(e.Cell.Row);
  270. }
  271. private void GridEdite(UltraGridRow row)
  272. {
  273. if (row.GetValue("Chk") == "True")
  274. {
  275. foreach (UltraGridCell cell in row.Cells)
  276. {
  277. if (cell.Column.CellActivation == Activation.AllowEdit)
  278. {
  279. cell.Activation = Activation.AllowEdit;
  280. }
  281. }
  282. }
  283. else
  284. {
  285. foreach (UltraGridCell cell in row.Cells)
  286. {
  287. if (cell.Column.Key == "Chk") continue;
  288. if (cell.Column.CellActivation == Activation.AllowEdit)
  289. {
  290. cell.Activation = Activation.ActivateOnly;
  291. }
  292. }
  293. }
  294. }
  295. private void ultraTextEditor1_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  296. {
  297. var actRow = ultraGrid1.ActiveRow;
  298. if (ultraGrid1.ActiveCell.Column.Key == "StdName")
  299. {
  300. //this.Cursor = Cursors.WaitCursor;
  301. //ComBaseSplineCEntity splineCEntity = (ComBaseSplineCEntity)ultraGrid1.ActiveRow.ListObject;
  302. //DataTable dt = _splineCBLL.GetComBaseStd();
  303. //dt.Columns["STD_NAME"].Caption = "标准名称";
  304. //dt.Columns["STDSTYLE"].Caption = "标准类型";
  305. //BaseInfoPopup baseInfoPopup = new BaseInfoPopup(dt, "STD_NAME", "STD_CODE");
  306. //baseInfoPopup.LabelTextBox1.Caption = "标准名称";
  307. //baseInfoPopup.Shown += new EventHandler((c, d) =>
  308. //{
  309. // var row = baseInfoPopup.UltraGrid1.Rows.AsQueryable().Where(
  310. // a => a.GetValue("STD_CODE") == splineCEntity.StdCode).FirstOrDefault();
  311. // if (row != null)
  312. // {
  313. // row.Activate();
  314. // }
  315. //});
  316. //GridHelper.RefreshAndAutoSize(baseInfoPopup.UltraGrid1);
  317. //this.Cursor = Cursors.Default;
  318. //if (baseInfoPopup.ShowDialog() == DialogResult.OK)
  319. //{
  320. // ultraGrid1.ActiveRow.SetValue("StdCode", baseInfoPopup.ChoicedRow.GetValue("STD_CODE"));
  321. // ultraGrid1.ActiveRow.SetValue("StdName", baseInfoPopup.ChoicedRow.GetValue("STD_NAME"));
  322. //}
  323. this.Cursor = Cursors.WaitCursor;
  324. ComBaseStdChoice baseStdChoice = new ComBaseStdChoice(new string[] { "G", "X" }, actRow.GetValue("StdCode"), _ob);
  325. this.Cursor = Cursors.Default;
  326. if (baseStdChoice.ShowDialog() == DialogResult.OK)
  327. {
  328. actRow.SetValue("StdCode", baseStdChoice.ChoiceStdCodes);
  329. actRow.SetValue("StdName", baseStdChoice.ChoiceStdNames);
  330. }
  331. }
  332. else if (ultraGrid1.ActiveCell.Column.Key == "ProductDescs")
  333. {
  334. this.Cursor = Cursors.WaitCursor;
  335. PopupProductName popupProductName = new PopupProductName(actRow.GetValue("ProductCodes"), _ob);
  336. this.Cursor = Cursors.Default;
  337. if (popupProductName.ShowDialog() == DialogResult.OK)
  338. {
  339. actRow.SetValue("ProductCodes", popupProductName.ProductCodes);
  340. actRow.SetValue("ProductDescs", popupProductName.ProductNames);
  341. }
  342. }
  343. else if (ultraGrid1.ActiveCell.Column.Key == "SteelDescs")
  344. {
  345. FrmRepSteel frmRepSteel = new FrmRepSteel();
  346. frmRepSteel.Code = actRow.GetValue("SteelCodes");
  347. frmRepSteel.Ob1 = _ob;
  348. if (frmRepSteel.ShowDialog() == DialogResult.OK)
  349. {
  350. actRow.SetValue("SteelCodes", frmRepSteel.Code);
  351. actRow.SetValue("SteelDescs", frmRepSteel.Desc);
  352. }
  353. }
  354. else if (ultraGrid1.ActiveCell.Column.Key == "ModelDescs")
  355. {
  356. FrmModel frmModel = new FrmModel();
  357. frmModel.Code = actRow.GetValue("ModelCodes");
  358. frmModel.Desc = actRow.GetValue("ModelDescs");
  359. frmModel.FrmOb = _ob;
  360. if (frmModel.ShowDialog() == DialogResult.OK)
  361. {
  362. actRow.SetValue("ModelCodes", frmModel.Code);
  363. actRow.SetValue("ModelDescs", frmModel.Desc);
  364. }
  365. }
  366. }
  367. private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e)
  368. {
  369. if (e.Row.GetValue("Validflag") == "无效")
  370. {
  371. e.Row.Appearance.ForeColor = Color.Red;
  372. }
  373. }
  374. }
  375. }