FrmTubeRolling.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514
  1. using Core.Mes.Client.Comm.Control;
  2. using Core.Mes.Client.Comm.Server;
  3. using CoreFS.CA06;
  4. using Infragistics.Win.UltraWinGrid;
  5. using System;
  6. using System.Collections;
  7. using System.Data;
  8. using System.Drawing;
  9. using System.Windows.Forms;
  10. namespace Core.StlMes.Client.Qcm
  11. {
  12. public partial class FrmTubeRolling : FrmBase
  13. {
  14. public FrmTubeRolling()
  15. {
  16. InitializeComponent();
  17. }
  18. private void FrmTubeRolling_Load(object sender, EventArgs e)
  19. {
  20. BindCmbProLineInfo();
  21. BindCmbKType();
  22. BindCmbGGType();
  23. cmbProLineInfo.SelectedIndex = 0;
  24. cmbKType.SelectedIndex = 0;
  25. cmbGGType.SelectedIndex = 0;
  26. }
  27. /// <summary>
  28. /// 获取管坯规格描述
  29. /// </summary>
  30. private void BindCmbGGType()
  31. {
  32. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreTubeRolling.GetGGType", null, this.ob);
  33. cmbGGType.DataSource = dt;
  34. cmbGGType.DisplayMember = "SPEC_NAME";
  35. cmbGGType.ValueMember = "SPEC_CODE";
  36. }
  37. /// <summary>
  38. /// 绑定孔型描述
  39. /// </summary>
  40. private void BindCmbKType()
  41. {
  42. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreTubeRolling.GetKType", null, this.ob);
  43. cmbKType.DataSource = dt;
  44. cmbKType.DisplayMember = "BASENAME";
  45. cmbKType.ValueMember = "BASECODE";
  46. }
  47. /// <summary>
  48. /// 绑定产线描述
  49. /// </summary>
  50. private void BindCmbProLineInfo()
  51. {
  52. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreTubeRolling.GetProLineInfo", null, this.ob);
  53. cmbProLineInfo.DataSource = dt;
  54. cmbProLineInfo.DisplayMember = "PLINE_NAME";
  55. cmbProLineInfo.ValueMember = "PLINE_CODE";
  56. }
  57. /// <summary>
  58. /// 重写基类代码
  59. /// </summary>
  60. /// <param name="sender"></param>
  61. /// <param name="ToolbarKey"></param>
  62. public override void ToolBar_Click(object sender, string ToolbarKey)
  63. {
  64. switch (ToolbarKey)
  65. {
  66. case "doQuery":
  67. doQuery();
  68. break;
  69. case "doAdd":
  70. doAdd();
  71. break;
  72. case "doModify":
  73. doModify();
  74. break;
  75. case "doDelete":
  76. this.doDeleteOrResume(true);
  77. break;
  78. case "doResume":
  79. this.doDeleteOrResume(false);
  80. break;
  81. case "Close":
  82. this.Close();
  83. break;
  84. }
  85. }
  86. /// <summary>
  87. /// 非空项验证
  88. /// </summary>
  89. /// <returns></returns>
  90. private bool ValidInput()
  91. {
  92. //if (string.IsNullOrEmpty(cmbProLineInfo.Text.Trim()))
  93. //{
  94. // MessageBox.Show("请输入产线描述!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  95. // return false;
  96. //}
  97. return true;
  98. }
  99. /// <summary>
  100. /// 新增
  101. /// </summary>
  102. private void doAdd()
  103. {
  104. if (ValidInput())
  105. {
  106. try
  107. {
  108. //判断产线、孔型、管坯规格是否唯一PLINE_CODE,PASS_CODE,SPEC_CODE
  109. string plineCode = cmbProLineInfo.Value.ToString();
  110. string passCode = cmbKType.Value.ToString();
  111. string specCode = cmbGGType.Value.ToString();
  112. string plineText = cmbProLineInfo.Text.Trim();
  113. string passText = cmbKType.Text.Trim();
  114. string specText = cmbGGType.Text.Trim();
  115. if (isOnly(plineCode, passCode, specCode))
  116. {
  117. MessageBox.Show("产线描述\"" + plineText + "\"、孔型描述\"" + passText + "\"、管坯规格描述\"" + specText + "\"已存在,请重新选择!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  118. return;
  119. }
  120. ArrayList parm = new ArrayList();
  121. //string modelCode = GridHelper.AutoCode(this.dataTable1);
  122. parm.Add(plineCode);
  123. parm.Add(plineText);
  124. parm.Add(passCode);
  125. parm.Add(passText);
  126. parm.Add(specCode);
  127. parm.Add(specText);
  128. parm.Add(this.UserInfo.GetUserName());
  129. parm.Add(txtMemo.Text);
  130. CoreClientParam ccp = new CoreClientParam();
  131. ccp.ServerName = "com.steering.pss.qcm.CoreTubeRolling";
  132. ccp.MethodName = "doAdd";
  133. ccp.ServerParams = new object[] { parm };
  134. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  135. if (ccp.ReturnCode == -1) return;
  136. doQuery();
  137. //高亮显示新增的数据
  138. Infragistics.Win.UltraWinGrid.UltraGridRow row = null;
  139. for (int i = 0; i < ultraGrid2.Rows.Count; i++)
  140. {
  141. row = ultraGrid2.Rows[i];
  142. if (row.Cells["PLINE_CODE"].Value.ToString().Equals(plineCode) && row.Cells["PASS_CODE"].Value.ToString().Equals(passCode) && row.Cells["SPEC_CODE"].Value.ToString().Equals(specCode))
  143. {
  144. row.Activate();
  145. break;
  146. }
  147. }
  148. }
  149. catch (Exception ex)
  150. {
  151. MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  152. }
  153. }
  154. }
  155. /// <summary>
  156. /// 修改
  157. /// </summary>
  158. private void doModify()
  159. {
  160. if (ultraGrid2.ActiveRow == null)
  161. {
  162. MessageBox.Show("请选择需要修改的数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  163. return;
  164. }
  165. string validflagStr = ultraGrid2.ActiveRow.Cells["VALIDFLAG"].Value.ToString();
  166. //无效数据不允许修改
  167. if ("0".Equals(validflagStr))
  168. {
  169. MessageBox.Show("无效数据不支持修改操作。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  170. return;
  171. }
  172. if (ValidInput())
  173. {
  174. ArrayList parm = new ArrayList();
  175. //string modelCode = ultraGrid2.ActiveRow.Cells["PLINE_CODE"].Value.ToString();
  176. //判断产线、孔型、管坯规格是否唯一
  177. string plineCode = cmbProLineInfo.Value.ToString();
  178. string passCode = cmbKType.Value.ToString();
  179. string specCode = cmbGGType.Value.ToString();
  180. //获取名称,用于提示信息。
  181. string plineText = cmbProLineInfo.Text.Trim();
  182. string passText = cmbKType.Text.Trim();
  183. string specText = cmbGGType.Text.Trim();
  184. //依据修改之前的数据作为条件
  185. string proLineInfoTitle = ultraGrid2.ActiveRow.Cells["PLINE_CODE"].Value.ToString();
  186. string kTypeTitle = ultraGrid2.ActiveRow.Cells["PASS_CODE"].Value.ToString();
  187. string ggTypeTitle = ultraGrid2.ActiveRow.Cells["SPEC_CODE"].Value.ToString();
  188. //判断是否只修改了备注。
  189. if (!plineCode.Equals(proLineInfoTitle) || !passCode.Equals(kTypeTitle) || !specCode.Equals(ggTypeTitle))
  190. {
  191. if (isOnly(plineCode, passCode, specCode))
  192. {
  193. MessageBox.Show("产线描述\"" + plineText + "\"、孔型描述\"" + passText + "\"、管坯规格描述\"" + specText + "\"已存在,请重新选择!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  194. return;
  195. }
  196. }
  197. //确认修改吗?
  198. if (MessageBox.Show("是否确认修改选中的数据!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  199. {
  200. return;
  201. }
  202. parm.Add(plineCode);
  203. parm.Add(plineText);
  204. parm.Add(passCode);
  205. parm.Add(passText);
  206. parm.Add(specCode);
  207. parm.Add(specText);
  208. parm.Add(this.UserInfo.GetUserName());
  209. parm.Add(txtMemo.Text.Trim());
  210. //添加条件
  211. parm.Add(proLineInfoTitle);
  212. parm.Add(kTypeTitle);
  213. parm.Add(ggTypeTitle);
  214. CoreClientParam ccp = new CoreClientParam();
  215. ccp.ServerName = "com.steering.pss.qcm.CoreTubeRolling";
  216. ccp.MethodName = "doModify";
  217. ccp.ServerParams = new object[] { parm };
  218. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  219. if (ccp.ReturnCode == -1) return;
  220. doQuery();
  221. //高亮显示新增的数据
  222. Infragistics.Win.UltraWinGrid.UltraGridRow row = null;
  223. for (int i = 0; i < ultraGrid2.Rows.Count; i++)
  224. {
  225. row = ultraGrid2.Rows[i];
  226. if (row.Cells["PLINE_CODE"].Value.ToString().Equals(plineCode) && row.Cells["PASS_CODE"].Value.ToString().Equals(passCode) && row.Cells["SPEC_CODE"].Value.ToString().Equals(specCode))
  227. {
  228. row.Activate();
  229. break;
  230. }
  231. }
  232. }
  233. }
  234. /// <summary>
  235. /// 验证产线、孔型、管坯规格是否唯一
  236. /// </summary>
  237. /// <param name="proLineInfo"></param>
  238. /// <param name="kType"></param>
  239. /// <param name="ggType"></param>
  240. /// <returns></returns>
  241. private bool isOnly(string proLineInfo, string kType, string ggType)
  242. {
  243. DataTable dt = new DataTable();
  244. dt = ServerHelper.GetData("com.steering.pss.qcm.CoreTubeRolling.isOnly", new Object[] { proLineInfo, kType, ggType }, this.ob);
  245. if (dt.Rows.Count > 0)
  246. {
  247. return true;
  248. }
  249. else
  250. {
  251. return false;
  252. }
  253. }
  254. /// <summary>
  255. /// 判断产品规格代码是否已存在
  256. /// </summary>
  257. /// <returns></returns>
  258. private bool isGGType(string ggType)
  259. {
  260. DataTable dt = new DataTable();
  261. dt = ServerHelper.GetData("com.steering.pss.qcm.CoreTubeRolling.isGGType", new Object[] { ggType }, this.ob);
  262. if (dt.Rows.Count > 0)
  263. {
  264. return true;
  265. }
  266. else
  267. {
  268. return false;
  269. }
  270. }
  271. /// <summary>
  272. /// 判断孔型代码是否已存在
  273. /// </summary>
  274. /// <returns></returns>
  275. private bool isKType(string kType)
  276. {
  277. DataTable dt = new DataTable();
  278. dt = ServerHelper.GetData("com.steering.pss.qcm.CoreTubeRolling.isKType", new Object[] { kType }, this.ob);
  279. if (dt.Rows.Count > 0)
  280. {
  281. return true;
  282. }
  283. else
  284. {
  285. return false;
  286. }
  287. }
  288. /// <summary>
  289. /// 判断产线代码是否已存在
  290. /// </summary>
  291. /// <returns></returns>
  292. private bool isProLineInfo(string proLineInfo)
  293. {
  294. DataTable dt = new DataTable();
  295. dt = ServerHelper.GetData("com.steering.pss.qcm.CoreTubeRolling.isProLineInfo", new Object[] { proLineInfo }, this.ob);
  296. if (dt.Rows.Count > 0)
  297. {
  298. return true;
  299. }
  300. else
  301. {
  302. return false;
  303. }
  304. }
  305. /// <summary>
  306. /// 查询
  307. /// </summary>
  308. private void doQuery()
  309. {
  310. bool validFlag = chkValid.Checked;
  311. string titleName = txtTitleName.Text.Trim();
  312. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreTubeRolling.getLineList", new Object[] { validFlag, titleName }, this.ob);
  313. GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true);
  314. //不同颜色区分是否有效数据
  315. Infragistics.Win.UltraWinGrid.UltraGridRow row = null;
  316. for (int i = 0; i < ultraGrid2.Rows.Count; i++)
  317. {
  318. row = ultraGrid2.Rows[i];
  319. if (!row.Cells["VALIDFLAG"].Value.ToString().Equals("1"))
  320. {
  321. row.Appearance.ForeColor = Color.Red;
  322. }
  323. else
  324. {
  325. row.Appearance.ForeColor = Color.Black;
  326. }
  327. }
  328. //列自适应
  329. GridHelper.RefreshAndAutoSizeExceptRows(ultraGrid2, new UltraGridColumn[] {
  330. ultraGrid2.DisplayLayout.Bands[0].Columns["MEMO"]
  331. });
  332. }
  333. /// <summary>
  334. /// GRID ROW激活时信息带至编辑区
  335. /// </summary>
  336. /// <param name="sender"></param>
  337. /// <param name="e"></param>
  338. private void ultraGrid2_AfterRowActivate(object sender, EventArgs e)
  339. {
  340. Infragistics.Win.UltraWinGrid.UltraGridRow row = ultraGrid2.ActiveRow;
  341. if (row != null)
  342. {
  343. //PLINE_CODE,PLINE_NAME,PASS_CODE,PASS_NAME,SPEC_CODE,SPEC_NAME
  344. cmbProLineInfo.Value = row.Cells["PLINE_CODE"].Value.ToString();
  345. cmbKType.Value = row.Cells["PASS_CODE"].Value.ToString();
  346. cmbGGType.Value = row.Cells["SPEC_CODE"].Value.ToString();
  347. txtMemo.Text = row.Cells["MEMO"].Value.ToString();
  348. }
  349. }
  350. /// <summary>
  351. /// 作废或恢复
  352. /// </summary>
  353. /// <param name="isDelete">true作废 false恢复</param>
  354. private void doDeleteOrResume(bool isDelete)
  355. {
  356. if (ultraGrid2.ActiveRow == null)
  357. {
  358. MessageBox.Show("请选择需要" + (isDelete ? "作废" : "恢复") + "的数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  359. return;
  360. }
  361. string validflagStr = ultraGrid2.ActiveRow.Cells["VALIDFLAG"].Value.ToString();
  362. //无效数据不允许作废
  363. if ("0".Equals(validflagStr))
  364. {
  365. if (isDelete)
  366. {
  367. MessageBox.Show("无效数据不支持作废操作。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  368. return;
  369. }
  370. }
  371. else
  372. {
  373. //有效数据不允许恢复
  374. if (!isDelete)
  375. {
  376. MessageBox.Show("有效数据不支持恢复操作。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  377. return;
  378. }
  379. }
  380. ArrayList param = new ArrayList();
  381. string plineCode = ultraGrid2.ActiveRow.Cells["PLINE_CODE"].Value.ToString();
  382. string passCode = ultraGrid2.ActiveRow.Cells["PASS_CODE"].Value.ToString();
  383. string specCode = ultraGrid2.ActiveRow.Cells["SPEC_CODE"].Value.ToString();
  384. //作废必须结合产线代码、孔型代码、轧管规格代码
  385. param.Add(plineCode);
  386. param.Add(passCode);
  387. param.Add(specCode);
  388. if (param.Count > 0 && MessageBox.Show("是否确认" + (isDelete ? "作废" : "恢复") + "选中的数据!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
  389. {
  390. try
  391. {
  392. int count = ServerHelper.SetData("com.steering.pss.qcm.CoreTubeRolling.deleteLineInfo", new Object[] { param, UserInfo.GetUserName(), isDelete }, this.ob);
  393. if (count > 0)
  394. {
  395. doQuery();
  396. Infragistics.Win.UltraWinGrid.UltraGridRow rowD = null;
  397. for (int i = 0; i < ultraGrid2.Rows.Count; i++)
  398. {
  399. rowD = ultraGrid2.Rows[i];
  400. if (plineCode.Equals(rowD.Cells["PLINE_CODE"].Value.ToString()) &&
  401. passCode.Equals(rowD.Cells["PASS_CODE"].Value.ToString()) &&
  402. specCode.Equals(rowD.Cells["SPEC_CODE"].Value.ToString()))
  403. {
  404. rowD.Activate();
  405. break;
  406. }
  407. }
  408. }
  409. }
  410. catch (Exception ex)
  411. {
  412. MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  413. }
  414. }
  415. }
  416. }
  417. }