F_PC_0205.cs 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PC_0201.cs
  5. * 2.功能描述:生产线配置一览界面
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 王鑫 2015/03/27 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Data;
  12. using System.Drawing;
  13. using System.Windows.Forms;
  14. using Dongke.IBOSS.Basics.FlowSetting;
  15. using Dongke.IBOSS.PRD.Basics.BaseResources;
  16. using Dongke.IBOSS.PRD.Basics.DockPanel;
  17. using Dongke.IBOSS.PRD.Basics.Library;
  18. using Dongke.IBOSS.PRD.Client.CommonModule;
  19. using Dongke.IBOSS.PRD.Client.DataModels;
  20. using Dongke.IBOSS.PRD.WCF.DataModels;
  21. using Dongke.IBOSS.PRD.WCF.Proxys;
  22. using Dongke.IBOSS.PRD.WCF.Proxys.PCModuleService;
  23. namespace Dongke.IBOSS.PRD.Client.PCModule
  24. {
  25. /// <summary>
  26. /// 生产线配置一览界面
  27. /// </summary>
  28. public partial class F_PC_0205 : DockPanelBase
  29. {
  30. #region 成员变量
  31. // 窗体的单例模式
  32. private static F_PC_0205 _instance;
  33. // 当前选择的行
  34. private int _selectedRowIndex;
  35. #endregion
  36. #region 构造
  37. /// <summary>
  38. /// 单例模式,防止重复创建窗体
  39. /// </summary>
  40. public static F_PC_0205 Instance
  41. {
  42. get
  43. {
  44. if (_instance == null)
  45. {
  46. _instance = new F_PC_0205();
  47. }
  48. return _instance;
  49. }
  50. }
  51. /// <summary>
  52. /// 构造
  53. /// </summary>
  54. public F_PC_0205()
  55. {
  56. InitializeComponent();
  57. // 设置控件显示名称
  58. this.SetFromTitleInfo();
  59. }
  60. #endregion
  61. #region 事件
  62. /// <summary>
  63. /// 关闭窗体
  64. /// </summary>
  65. /// <param name="sender"></param>
  66. /// <param name="e"></param>
  67. private void F_PC_0201_FormClosed(object sender, FormClosedEventArgs e)
  68. {
  69. _instance = null;
  70. }
  71. /// <summary>
  72. /// 页面加载
  73. /// </summary>
  74. /// <param name="sender"></param>
  75. /// <param name="e"></param>
  76. private void F_PC_0201_Load(object sender, EventArgs e)
  77. {
  78. try
  79. {
  80. // 绑定权限
  81. FormPermissionManager.FormPermissionControl(this.Name, this,
  82. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  83. this.dgvLine.AutoGenerateColumns = false;
  84. this.dgvProcedure.AutoGenerateColumns = false;
  85. // 绑定数据源
  86. this.SelValueFlag.DataSource = CreateDataSource.GetValueFlagTable();
  87. // 默认选中有效数据
  88. object[] checkValueFlags = new object[] { Constant.INT_IS_ONE };
  89. this.SelValueFlag.SelectedValues = checkValueFlags;
  90. }
  91. catch (Exception ex)
  92. {
  93. // 对异常进行共通处理
  94. ExceptionManager.HandleEventException(this.ToString(),
  95. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  96. }
  97. }
  98. /// <summary>
  99. /// 新建
  100. /// </summary>
  101. /// <param name="sender"></param>
  102. /// <param name="e"></param>
  103. private void tsbtnAdd_Click(object sender, EventArgs e)
  104. {
  105. try
  106. {
  107. F_PC_0204 frmPC0204 = new F_PC_0204(Constant.FormMode.Add, 0, "", "", "", 1);
  108. DialogResult dialogResult = frmPC0204.ShowDialog();
  109. if (dialogResult.Equals(DialogResult.OK))
  110. {
  111. frmPC0204.Close();
  112. F_PC_0203 frmPC0203 = new F_PC_0203(Constant.FormMode.Edit, frmPC0204.LineID, frmPC0204.LineCode, frmPC0204.LineName, frmPC0204.Remarks, frmPC0204.ValueFlag);
  113. DialogResult dialogResult0203 = frmPC0203.ShowDialog();
  114. if (dialogResult0203.Equals(DialogResult.OK))
  115. {
  116. // 查询时先清空数据源
  117. this.dgvLine.DataSource = null;
  118. if (frmPC0203.IDList.Count == Constant.INT_IS_ZERO)
  119. {
  120. return;
  121. }
  122. int id = frmPC0203.IDList[0];
  123. DataSet resultData = (DataSet)DoAsync(() =>
  124. {
  125. return PCModuleProxy.Service.SearchProductionLine(
  126. new ProductionLineEntity() { ProductionLineID = id });
  127. });
  128. if (resultData != null && resultData.Tables.Count > Constant.INT_IS_ZERO)
  129. {
  130. this.dgvLine.DataSource = resultData.Tables[0];
  131. // 设置选中第一行
  132. if (this.dgvLine.RowCount > 0)
  133. {
  134. this._selectedRowIndex = Constant.INT_IS_ZERO;
  135. this.dgvLine.Rows[this._selectedRowIndex].Selected = true;
  136. }
  137. }
  138. }
  139. }
  140. }
  141. catch (Exception ex)
  142. {
  143. // 对异常进行共通处理
  144. ExceptionManager.HandleEventException(this.ToString(),
  145. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  146. }
  147. }
  148. /*注释掉编辑,原因:变更流程的属性修改不能在工序编辑画面直接修改,要打开流程图。20210302
  149. /// <summary>
  150. /// 编辑
  151. /// </summary>
  152. /// <param name="sender"></param>
  153. /// <param name="e"></param>
  154. private void tsbtnEdit_Click(object sender, EventArgs e)
  155. {
  156. try
  157. {
  158. if (this.dgvLine.CurrentCell == null)
  159. {
  160. return;
  161. }
  162. int id = int.Parse(this.dgvLine.Rows[this.dgvLine.CurrentCell.RowIndex].Cells["ProductionLineID"].Value.ToString());
  163. string lineCode = this.dgvLine.Rows[this.dgvLine.CurrentCell.RowIndex].Cells["ProductionLineCode"].Value.ToString();
  164. string lineName = this.dgvLine.Rows[this.dgvLine.CurrentCell.RowIndex].Cells["ProductionLineName"].Value.ToString();
  165. string remarks = this.dgvLine.Rows[this.dgvLine.CurrentCell.RowIndex].Cells["Remarks"].Value.ToString();
  166. int valueflag = int.Parse(this.dgvLine.Rows[this.dgvLine.CurrentCell.RowIndex].Cells["ValueFlag"].Value.ToString());
  167. F_PC_0204 frmPC0204 = new F_PC_0204(Constant.FormMode.Edit, id, lineCode, lineName, remarks, valueflag);
  168. DialogResult dialogResult = frmPC0204.ShowDialog();
  169. if (dialogResult.Equals(DialogResult.OK))
  170. {
  171. frmPC0204.Close();
  172. // 查询时先清空数据源
  173. this.dgvLine.DataSource = null;
  174. ProductionLineEntity line = new ProductionLineEntity();
  175. line.ProductionLineID = id;
  176. DataSet result = (DataSet)DoAsync(() =>
  177. {
  178. return PCModuleProxy.Service.SearchProductionLine(line);
  179. });
  180. if (result != null && result.Tables.Count > Constant.INT_IS_ZERO)
  181. {
  182. this.dgvLine.DataSource = result.Tables[0];
  183. if (result.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  184. {
  185. // 定位当前行
  186. if (this.dgvLine.Rows.Count > this._selectedRowIndex)
  187. {
  188. this.dgvLine.Rows[this._selectedRowIndex].Selected = true;
  189. this.dgvLine.CurrentCell =
  190. this.dgvLine.Rows[this._selectedRowIndex].Cells["ProductionLineCode"];
  191. }
  192. else if (this.dgvLine.Rows.Count <= this._selectedRowIndex)
  193. {
  194. this._selectedRowIndex = dgvLine.Rows.Count - 1;
  195. this.dgvLine.CurrentCell =
  196. this.dgvLine.Rows[this.dgvLine.Rows.Count - 1].Cells["ProductionLineCode"];
  197. this.dgvLine.Rows[dgvLine.Rows.Count - 1].Selected = true;
  198. }
  199. }
  200. else
  201. {
  202. // 清空明细中的数据
  203. this.dgvProcedure.DataSource = null;
  204. // 提示未查找到数据
  205. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  206. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  207. }
  208. }
  209. }
  210. }
  211. catch (Exception ex)
  212. {
  213. // 对异常进行共通处理
  214. ExceptionManager.HandleEventException(this.ToString(),
  215. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  216. }
  217. }
  218. */
  219. /// <summary>
  220. /// 查询
  221. /// </summary>
  222. /// <param name="sender"></param>
  223. /// <param name="e"></param>
  224. private void btnSearch_Click(object sender, EventArgs e)
  225. {
  226. try
  227. {
  228. #region 没有选择正常标示
  229. if (this.SelValueFlag.SelectedValues.Length == Constant.INT_IS_ZERO)
  230. {
  231. // 清空数据
  232. this.dgvLine.DataSource = null;
  233. this.dgvProcedure.DataSource = null;
  234. // 设置按钮可用状态
  235. this.SetButtonStatus();
  236. // 提示未查找到数据
  237. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  238. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  239. return;
  240. }
  241. #endregion
  242. ProductionLineEntity line = new ProductionLineEntity();
  243. #region 赋值
  244. if (!string.IsNullOrEmpty(this.txtLineCode.Text.Trim()))
  245. {
  246. line.ProductionLineCode = this.txtLineCode.Text.Trim();
  247. }
  248. if (!string.IsNullOrEmpty(this.txtLineName.Text.Trim()))
  249. {
  250. line.ProductionLineName = this.txtLineName.Text.Trim();
  251. }
  252. if (!string.IsNullOrEmpty(this.txtRemarks.Text.Trim()))
  253. {
  254. line.Remarks = this.txtRemarks.Text;
  255. }
  256. line.ValueFlags = this.SelValueFlag.SelectedValues;
  257. #endregion
  258. DataSet result = (DataSet)DoAsync(() =>
  259. {
  260. return PCModuleProxy.Service.SearchProductionLine(line);
  261. });
  262. if (result != null && result.Tables.Count > Constant.INT_IS_ZERO)
  263. {
  264. // 控制明细不查询
  265. this.Tag = false;
  266. this.dgvLine.DataSource = result.Tables[0];
  267. if (result.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  268. {
  269. // 定位当前行
  270. if (this.dgvLine.Rows.Count > this._selectedRowIndex)
  271. {
  272. this.dgvLine.Rows[this._selectedRowIndex].Selected = true;
  273. this.dgvLine.CurrentCell =
  274. this.dgvLine.Rows[this._selectedRowIndex].Cells["ProductionLineCode"];
  275. }
  276. else if (this.dgvLine.Rows.Count <= this._selectedRowIndex)
  277. {
  278. this._selectedRowIndex = dgvLine.Rows.Count - 1;
  279. this.dgvLine.CurrentCell =
  280. this.dgvLine.Rows[this.dgvLine.Rows.Count - 1].Cells["ProductionLineCode"];
  281. this.dgvLine.Rows[dgvLine.Rows.Count - 1].Selected = true;
  282. }
  283. this.Tag = true;
  284. // 查明细
  285. this.dgvLine_SelectionChanged(null, null);
  286. }
  287. else
  288. {
  289. // 清空明细中的数据
  290. this.dgvProcedure.DataSource = null;
  291. // 提示未查找到数据
  292. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  293. MessageBoxButtons.OK, MessageBoxIcon.Information);
  294. }
  295. }
  296. // 设置按钮可用状态
  297. this.SetButtonStatus();
  298. }
  299. catch (Exception ex)
  300. {
  301. // 对异常进行共通处理
  302. ExceptionManager.HandleEventException(this.ToString(),
  303. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  304. }
  305. }
  306. /// <summary>
  307. /// 行选中事件
  308. /// </summary>
  309. /// <param name="sender"></param>
  310. /// <param name="e"></param>
  311. private void dgvLine_SelectionChanged(object sender, EventArgs e)
  312. {
  313. try
  314. {
  315. // 在绑定总表时 不查询明细
  316. if (!Convert.ToBoolean(this.Tag)
  317. || this.dgvLine.CurrentCell == null)
  318. {
  319. return;
  320. }
  321. // 选中行时查询明细
  322. else
  323. {
  324. if (this.txtLineCode.ReadOnly)
  325. {
  326. return;
  327. }
  328. ProductionLineEntity line = new ProductionLineEntity();
  329. line.ProductionLineID = Convert.ToInt32(
  330. this.dgvLine.Rows[_selectedRowIndex].Cells["ProductionLineID"].Value);
  331. DataSet result = (DataSet)DoAsync(() =>
  332. {
  333. return PCModuleProxy.Service.SearchProductionLine(line);
  334. });
  335. // 绑定明细数据
  336. if (result != null && result.Tables.Count >= Constant.INT_IS_TWO)
  337. {
  338. this.dgvProcedure.DataSource = result.Tables[1];
  339. this.dgvProcedure.CurrentCell = null;
  340. }
  341. }
  342. }
  343. catch (Exception ex)
  344. {
  345. // 对异常进行共通处理
  346. ExceptionManager.HandleEventException(this.ToString(),
  347. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  348. }
  349. }
  350. /// <summary>
  351. /// 单元格选中
  352. /// </summary>
  353. /// <param name="sender"></param>
  354. /// <param name="e"></param>
  355. private void dgvLine_CellEnter(object sender, DataGridViewCellEventArgs e)
  356. {
  357. try
  358. {
  359. if (this.dgvLine.CurrentCell != null)
  360. {
  361. // 记录最后选择行
  362. this._selectedRowIndex = this.dgvLine.CurrentCell.RowIndex;
  363. // 设置工具条按钮可用状态
  364. this.SetButtonStatus();
  365. }
  366. }
  367. catch (Exception ex)
  368. {
  369. // 对异常进行共通处理
  370. ExceptionManager.HandleEventException(this.ToString(),
  371. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  372. }
  373. }
  374. /// <summary>
  375. /// 关闭窗体
  376. /// </summary>
  377. /// <param name="sender"></param>
  378. /// <param name="e"></param>
  379. private void tsbtnClose_Click(object sender, EventArgs e)
  380. {
  381. this.Close();
  382. }
  383. /// <summary>
  384. /// 自适应列宽
  385. /// </summary>
  386. /// <param name="sender"></param>
  387. /// <param name="e"></param>
  388. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  389. {
  390. this.dgvLine.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  391. this.dgvProcedure.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  392. }
  393. /// <summary>
  394. /// 双击单元格编辑
  395. /// </summary>
  396. /// <param name="sender"></param>
  397. /// <param name="e"></param>
  398. private void dgvLine_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  399. {
  400. try
  401. {
  402. //if (this.dgvLine.CurrentCell != null)
  403. //{
  404. // if (this.tsbtnEdit.Enabled)
  405. // {
  406. // this.tsbtnEdit_Click(sender, e);
  407. // }
  408. //}
  409. }
  410. catch (Exception ex)
  411. {
  412. // 对异常进行共通处理
  413. ExceptionManager.HandleEventException(this.ToString(),
  414. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  415. }
  416. }
  417. /// <summary>
  418. /// 停用
  419. /// </summary>
  420. /// <param name="sender"></param>
  421. /// <param name="e"></param>
  422. private void tsbtnDisable_Click(object sender, EventArgs e)
  423. {
  424. try
  425. {
  426. if (this.dgvLine.CurrentCell != null)
  427. {
  428. DialogResult dialogResult
  429. = MessageBox.Show(string.Format(Messages.MSG_CMN_Q002, "生产线配置", "停用"),
  430. this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
  431. if (dialogResult.Equals(DialogResult.No))
  432. {
  433. return;
  434. }
  435. int id = Convert.ToInt32(
  436. this.dgvLine.Rows[this._selectedRowIndex].Cells["ProductionLineID"].Value);
  437. // 停用
  438. int result = (int)DoAsync(() =>
  439. {
  440. return PCModuleProxy.Service.StopProductionLine(id, 0);
  441. });
  442. if (result > Constant.INT_IS_ZERO)
  443. {
  444. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "生产线配置", "停用"),
  445. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  446. // 刷新窗口数据
  447. this.btnSearch_Click(sender, e);
  448. }
  449. else if (result == (int)Constant.RETURN_IS_DATACHANGED)
  450. {
  451. MessageBox.Show(string.Format(Messages.MSG_CMN_W007, "执行操作的数据不是最新的,请关闭当前窗体,重新操作"),
  452. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  453. return;
  454. }
  455. else
  456. {
  457. MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "生产线配置", "停用"),
  458. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  459. return;
  460. }
  461. }
  462. }
  463. catch (Exception ex)
  464. {
  465. // 对异常进行共通处理
  466. ExceptionManager.HandleEventException(this.ToString(),
  467. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  468. }
  469. }
  470. /// <summary>
  471. /// 启用
  472. /// </summary>
  473. /// <param name="sender"></param>
  474. /// <param name="e"></param>
  475. private void tsbtnBegin_Click(object sender, EventArgs e)
  476. {
  477. try
  478. {
  479. if (this.dgvLine.CurrentCell != null)
  480. {
  481. DialogResult dialogResult
  482. = MessageBox.Show(string.Format(Messages.MSG_CMN_Q002, "生产线配置", "启用"),
  483. this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
  484. if (dialogResult.Equals(DialogResult.No))
  485. {
  486. return;
  487. }
  488. int id = Convert.ToInt32(
  489. this.dgvLine.Rows[this._selectedRowIndex].Cells["ProductionLineID"].Value);
  490. // 启用
  491. int result = (int)DoAsync(() =>
  492. {
  493. return PCModuleProxy.Service.StopProductionLine(id, 1);
  494. });
  495. if (result > Constant.INT_IS_ZERO)
  496. {
  497. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "生产线配置", "启用"),
  498. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  499. // 刷新窗口数据
  500. this.btnSearch_Click(sender, e);
  501. }
  502. else if (result == (int)Constant.RETURN_IS_DATACHANGED)
  503. {
  504. MessageBox.Show(string.Format(Messages.MSG_CMN_W007, "执行操作的数据不是最新的,请关闭当前窗体,重新操作"),
  505. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  506. return;
  507. }
  508. else
  509. {
  510. MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "生产线配置", "启用"),
  511. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  512. return;
  513. }
  514. }
  515. }
  516. catch (Exception ex)
  517. {
  518. // 对异常进行共通处理
  519. ExceptionManager.HandleEventException(this.ToString(),
  520. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  521. }
  522. }
  523. /// <summary>
  524. /// 复制并新建
  525. /// </summary>
  526. /// <param name="sender"></param>
  527. /// <param name="e"></param>
  528. private void tsbtnCopyAndNew_Click(object sender, EventArgs e)
  529. {
  530. if (this.dgvLine.CurrentCell == null)
  531. {
  532. return;
  533. }
  534. int id = int.Parse(this.dgvLine
  535. .Rows[this.dgvLine.CurrentCell.RowIndex].Cells["ProductionLineID"].Value.ToString());
  536. string lineCode = this.dgvLine.Rows[this.dgvLine.CurrentCell.RowIndex].Cells["ProductionLineCode"].Value.ToString();
  537. string lineName = this.dgvLine.Rows[this.dgvLine.CurrentCell.RowIndex].Cells["ProductionLineName"].Value.ToString();
  538. string remarks = this.dgvLine.Rows[this.dgvLine.CurrentCell.RowIndex].Cells["Remarks"].Value.ToString();
  539. int valueflag = int.Parse(this.dgvLine.Rows[this.dgvLine.CurrentCell.RowIndex].Cells["ValueFlag"].Value.ToString());
  540. F_PC_0204 frmPC0204 = new F_PC_0204(Constant.FormMode.CopyAndAdd, id, lineCode, lineName, remarks, valueflag);
  541. DialogResult dialogResult = frmPC0204.ShowDialog();
  542. if (dialogResult.Equals(DialogResult.OK))
  543. {
  544. frmPC0204.Close();
  545. F_PC_0203 frmPC0203 = new F_PC_0203(Constant.FormMode.CopyAndAdd, frmPC0204.LineID, frmPC0204.LineCode, frmPC0204.LineName, frmPC0204.Remarks, frmPC0204.ValueFlag);
  546. DialogResult dialogResult0203 = frmPC0203.ShowDialog();
  547. if (dialogResult0203.Equals(DialogResult.OK))
  548. {
  549. // 查询时先清空数据源
  550. this.dgvLine.DataSource = null;
  551. ProductionLineEntity line = new ProductionLineEntity();
  552. if (frmPC0203.IDList.Count > 0)
  553. {
  554. line.ProductionLineCode = frmPC0203.ProductionlineCode;
  555. }
  556. else
  557. {
  558. line.ProductionLineID = id;
  559. }
  560. DataSet result = (DataSet)DoAsync(() =>
  561. {
  562. return PCModuleProxy.Service.SearchProductionLine(line);
  563. });
  564. if (result != null && result.Tables.Count > Constant.INT_IS_ZERO)
  565. {
  566. this.dgvLine.DataSource = result.Tables[0];
  567. if (result.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  568. {
  569. // 定位当前行
  570. if (this.dgvLine.Rows.Count > this._selectedRowIndex)
  571. {
  572. this.dgvLine.Rows[this._selectedRowIndex].Selected = true;
  573. this.dgvLine.CurrentCell =
  574. this.dgvLine.Rows[this._selectedRowIndex].Cells["ProductionLineCode"];
  575. }
  576. else if (this.dgvLine.Rows.Count <= this._selectedRowIndex)
  577. {
  578. this._selectedRowIndex = dgvLine.Rows.Count - 1;
  579. this.dgvLine.CurrentCell =
  580. this.dgvLine.Rows[this.dgvLine.Rows.Count - 1].Cells["ProductionLineCode"];
  581. this.dgvLine.Rows[dgvLine.Rows.Count - 1].Selected = true;
  582. }
  583. }
  584. else
  585. {
  586. // 清空明细中的数据
  587. this.dgvProcedure.DataSource = null;
  588. // 提示未查找到数据
  589. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  590. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  591. }
  592. }
  593. }
  594. }
  595. }
  596. /// <summary>
  597. /// 清空条件
  598. /// </summary>
  599. /// <param name="sender"></param>
  600. /// <param name="e"></param>
  601. private void btnClearCondition_Click(object sender, EventArgs e)
  602. {
  603. this.txtLineCode.Text = "";
  604. this.txtRemarks.Text = "";
  605. this.txtLineName.Text = "";
  606. this.SelValueFlag.SelectedValues = new object[] { Constant.INT_IS_ONE };
  607. }
  608. /// <summary>
  609. /// 流程按钮事件
  610. /// </summary>
  611. /// <param name="sender"></param>
  612. /// <param name="e"></param>
  613. private void tsbtnFlowSetting_Click(object sender, EventArgs e)
  614. {
  615. if (this.dgvLine.CurrentCell == null)
  616. {
  617. return;
  618. }
  619. int id = int.Parse(this.dgvLine
  620. .Rows[this.dgvLine.CurrentCell.RowIndex].Cells["ProductionLineID"].Value.ToString());
  621. int? nodeno = null;
  622. int? procedureid = null;
  623. if (this.dgvProcedure.CurrentCell != null)
  624. {
  625. nodeno = int.Parse(this.dgvProcedure
  626. .Rows[this.dgvProcedure.CurrentCell.RowIndex].Cells["nodeno"].Value.ToString());
  627. procedureid = int.Parse(this.dgvProcedure
  628. .Rows[this.dgvProcedure.CurrentCell.RowIndex].Cells["procedureid"].Value.ToString());
  629. }
  630. string lineCode = this.dgvLine.Rows[this.dgvLine.CurrentCell.RowIndex].Cells["ProductionLineCode"].Value.ToString();
  631. string lineName = this.dgvLine.Rows[this.dgvLine.CurrentCell.RowIndex].Cells["ProductionLineName"].Value.ToString();
  632. string remarks = this.dgvLine.Rows[this.dgvLine.CurrentCell.RowIndex].Cells["Remarks"].Value.ToString();
  633. int valueflag = int.Parse(this.dgvLine.Rows[this.dgvLine.CurrentCell.RowIndex].Cells["ValueFlag"].Value.ToString());
  634. //if (nodeno != null)
  635. //{
  636. // EditProcedure(Convert.ToInt32(nodeno), Convert.ToInt32(id), Convert.ToInt32(procedureid));
  637. //}
  638. //else
  639. //{
  640. F_PC_0203 frmPC0203 = new F_PC_0203(Constant.FormMode.Edit, id, lineCode, lineName, remarks, valueflag);
  641. DialogResult dialogResult0203 = frmPC0203.ShowDialog();
  642. if (dialogResult0203.Equals(DialogResult.OK))
  643. {
  644. // 查询时先清空数据源
  645. this.dgvLine.DataSource = null;
  646. ProductionLineEntity line = new ProductionLineEntity();
  647. line.ProductionLineID = id;
  648. DataSet result = (DataSet)DoAsync(() =>
  649. {
  650. return PCModuleProxy.Service.SearchProductionLine(line);
  651. });
  652. if (result != null && result.Tables.Count > Constant.INT_IS_ZERO)
  653. {
  654. this.dgvLine.DataSource = result.Tables[0];
  655. if (result.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  656. {
  657. // 定位当前行
  658. if (this.dgvLine.Rows.Count > this._selectedRowIndex)
  659. {
  660. this.dgvLine.Rows[this._selectedRowIndex].Selected = true;
  661. this.dgvLine.CurrentCell =
  662. this.dgvLine.Rows[this._selectedRowIndex].Cells["ProductionLineCode"];
  663. }
  664. else if (this.dgvLine.Rows.Count <= this._selectedRowIndex)
  665. {
  666. this._selectedRowIndex = dgvLine.Rows.Count - 1;
  667. this.dgvLine.CurrentCell =
  668. this.dgvLine.Rows[this.dgvLine.Rows.Count - 1].Cells["ProductionLineCode"];
  669. this.dgvLine.Rows[dgvLine.Rows.Count - 1].Selected = true;
  670. }
  671. }
  672. else
  673. {
  674. // 清空明细中的数据
  675. this.dgvProcedure.DataSource = null;
  676. // 提示未查找到数据
  677. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  678. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  679. }
  680. }
  681. // }
  682. }
  683. }
  684. /// <summary>
  685. /// 工序单元格双击事件
  686. /// </summary>
  687. /// <param name="sender"></param>
  688. /// <param name="e"></param>
  689. private void dgvProcedure_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  690. {
  691. try
  692. {
  693. int ProductionLineID = int.Parse(this.dgvLine
  694. .Rows[this.dgvLine.CurrentCell.RowIndex].Cells["ProductionLineID"].Value.ToString());
  695. int? nodeno = null;
  696. int? procedureid = null;
  697. int? productionlineid = null;
  698. if (this.dgvProcedure.CurrentCell != null)
  699. {
  700. nodeno = int.Parse(this.dgvProcedure
  701. .Rows[this.dgvProcedure.CurrentCell.RowIndex].Cells["nodeno"].Value.ToString());
  702. procedureid = int.Parse(this.dgvProcedure
  703. .Rows[this.dgvProcedure.CurrentCell.RowIndex].Cells["procedureid"].Value.ToString());
  704. productionlineid = int.Parse(this.dgvProcedure
  705. .Rows[this.dgvProcedure.CurrentCell.RowIndex].Cells["procedurelineid"].Value.ToString());
  706. }
  707. EditProcedure(Convert.ToInt32(nodeno), Convert.ToInt32(productionlineid), Convert.ToInt32(procedureid));
  708. }
  709. catch (Exception ex)
  710. {
  711. // 对异常进行共通处理
  712. ExceptionManager.HandleEventException(this.ToString(),
  713. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  714. }
  715. }
  716. #endregion
  717. #region 私有方法
  718. /// <summary>
  719. /// 设置按钮可用状态
  720. /// </summary>
  721. private void SetButtonStatus()
  722. {
  723. if (this.dgvLine.CurrentCell != null)
  724. {
  725. int valueFlag = Convert.ToInt32(
  726. this.dgvLine.Rows[this._selectedRowIndex].Cells["ValueFlag"].Value);
  727. this.tsbtnCopyAndNew.Enabled = true;
  728. this.tsbtnFlowSetting.Enabled = true;
  729. if (valueFlag == Constant.INT_IS_ZERO)
  730. {
  731. //this.tsbtnEdit.Enabled = false;
  732. this.tsbtnDisable.Enabled = false;
  733. this.tsbtnBegin.Enabled = !this.tsbtnDisable.Enabled;
  734. this.tsbtnFlowSetting.Enabled = false;
  735. }
  736. else
  737. {
  738. //this.tsbtnEdit.Enabled = true;
  739. this.tsbtnDisable.Enabled = true;
  740. this.tsbtnBegin.Enabled = !this.tsbtnDisable.Enabled;
  741. this.tsbtnFlowSetting.Enabled = true;
  742. }
  743. }
  744. else
  745. {
  746. this.tsbtnCopyAndNew.Enabled = false;
  747. this.tsbtnFlowSetting.Enabled = false;
  748. }
  749. }
  750. /// <summary>
  751. /// 设置窗体按钮的文本信息
  752. /// </summary>
  753. private void SetFromTitleInfo()
  754. {
  755. // 窗体标题
  756. this.Text = FormTitles.F_PC_0201;
  757. // 按钮名称
  758. this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
  759. //this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
  760. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  761. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  762. this.tsbtnDisable.Text = ButtonText.TSBTN_DISABLE;
  763. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  764. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  765. }
  766. /// <summary>
  767. /// 编辑单个工序方法
  768. /// </summary>
  769. /// <param name="nodeno"></param>
  770. /// <param name="procedurelineid"></param>
  771. /// <param name="procedureid"></param>
  772. private void EditProcedure(int nodeno, int procedurelineid, int procedureid)
  773. {
  774. IBOSS.Basics.FlowSetting.FlowBox flowBox = new FlowBox();
  775. DataSet dsProductionDataSet = PCModuleProxy.Service.GetProductionLineDetail(procedurelineid);
  776. // 加载生产线信息
  777. DataTable lineTable = dsProductionDataSet.Tables["lineTable"];
  778. // 画图
  779. if (lineTable != null && lineTable.Rows.Count > 0)
  780. {
  781. flowBox.LoadFlow((byte[])(lineTable.Rows[0]["FlowXML"]));
  782. //this.OPTimeStamp = Convert.ToDateTime(lineTable.Rows[0]["OPTimeStamp"]);
  783. }
  784. // 加载工序信息
  785. DataRow[] dr1 = dsProductionDataSet.Tables["procedureTable"].Select("nodeno=" + nodeno);
  786. FlowNode node = null;
  787. foreach (FlowNode n in flowBox.AllNodes)
  788. {
  789. if (n.ItemID == nodeno)
  790. {
  791. node = n;
  792. break;
  793. }
  794. }
  795. if (dr1.Length > 0)
  796. {
  797. node.NodeImageType = Convert.ToInt32(dr1[0]["ProcedureModel"]);//工序模型为了给双击事件弹出对应的窗体
  798. //this.OPTimeStamp = Convert.ToDateTime(dr1[0]["OPTimeStamp"]);
  799. }
  800. if (dr1.Length > 0)
  801. {
  802. node.NodeImageType = Convert.ToInt32(dr1[0]["ProcedureModel"]);//工序模型为了给双击事件弹出对应的窗体
  803. }
  804. if (node.NodeImageType == 1)
  805. {
  806. if (Convert.ToInt32(dr1[0]["modeltype"]) == Constant.ProcedureModelType.IntoKiln.GetHashCode())
  807. {
  808. node.NodeImage = new Bitmap(this.GetType(), "images.入窑64-01.png");
  809. }
  810. else if (Convert.ToInt32(dr1[0]["modeltype"]) == Constant.ProcedureModelType.LoadCar.GetHashCode())
  811. {
  812. node.NodeImage = new Bitmap(this.GetType(), "images.装车64-01.png");
  813. }
  814. else if (Convert.ToInt32(dr1[0]["modeltype"]) == Constant.ProcedureModelType.UnloadCar.GetHashCode())
  815. {
  816. node.NodeImage = new Bitmap(this.GetType(), "images.卸车64-01.png");
  817. }
  818. else
  819. {
  820. node.NodeImage = new Bitmap(this.GetType(), "images.newflow.png");
  821. }
  822. }
  823. else
  824. {
  825. node.NodeImage = new Bitmap(this.GetType(), "images.newflowcheck.png");
  826. }
  827. if (Convert.ToInt32(dr1[0]["MustFlag"].ToString()) == 1)
  828. {
  829. node.CanSkip = true;
  830. }
  831. else
  832. {
  833. node.CanSkip = false;
  834. }
  835. node.Code = dr1[0]["ProcedureCode"].ToString();
  836. node.Name = dr1[0]["ProcedureName"].ToString();
  837. node.ShortName = dr1[0]["P_Name"].ToString();
  838. node.Remark = dr1[0]["Remarks"].ToString();
  839. ProcedureEntity procedureEntity = new ProcedureEntity();//工序
  840. procedureEntity.ProcedureID = Convert.ToInt32(dr1[0]["ProcedureID"].ToString());
  841. procedureEntity.ProcedureCode = dr1[0]["ProcedureCode"].ToString();
  842. procedureEntity.ProcedureName = dr1[0]["ProcedureName"].ToString();
  843. procedureEntity.PName = dr1[0]["P_Name"].ToString();
  844. procedureEntity.ProcedureModel = Convert.ToInt32(dr1[0]["ProcedureModel"].ToString());
  845. procedureEntity.ModelType = Convert.ToInt32(dr1[0]["modeltype"].ToString());
  846. procedureEntity.NodeType = Convert.ToInt32(dr1[0]["nodetype"].ToString());
  847. procedureEntity.MustFlag = Convert.ToInt32(dr1[0]["MustFlag"].ToString());
  848. procedureEntity.CollectType = Convert.ToInt32(dr1[0]["CollectType"].ToString());
  849. procedureEntity.PieceType = Convert.ToInt32(dr1[0]["PieceType"].ToString());
  850. procedureEntity.IsSpecialRework = Convert.ToInt32(dr1[0]["isspecialrework"].ToString());
  851. //xuwei add 2019-10-14
  852. procedureEntity.IsSemireWork = Convert.ToInt32(dr1[0]["isSemireWork"].ToString());
  853. //xuwei add 2019-12-12
  854. if (dr1[0]["SemiGoodsLevel"] != null) procedureEntity.SemiGoodsLevel = dr1[0]["SemiGoodsLevel"].ToString();
  855. //xuwei add 2020-01-02
  856. procedureEntity.IsGlazeChange = Convert.ToInt32(dr1[0]["isGlazeChange"].ToString());
  857. procedureEntity.OrganizationID = Convert.ToInt32(dr1[0]["OrganizationID"].ToString());
  858. procedureEntity.Remarks = dr1[0]["Remarks"].ToString();
  859. procedureEntity.NodeNo = Convert.ToInt32(dr1[0]["NodeNo"]);
  860. procedureEntity.ProductionLineID = Convert.ToInt32(dr1[0]["ProductionLineID"]);
  861. procedureEntity.OPTimeStamp = Convert.ToDateTime(dr1[0]["OPTimeStamp"]);
  862. procedureEntity.MissPriority = Convert.ToInt32(dr1[0]["misspriority"]);
  863. procedureEntity.DisplayNo = Convert.ToInt32(dr1[0]["DisplayNo"]);
  864. procedureEntity.UnDo = Convert.ToInt32(dr1[0]["UnDoFlag"]);
  865. procedureEntity.DeliverType = Convert.ToInt32(dr1[0]["DeliverType"]);
  866. procedureEntity.BarCodePrintCopies = Convert.ToInt32(dr1[0]["BarCodePrintCopies"]);
  867. procedureEntity.BarCodeFlag = Convert.ToInt32(dr1[0]["BarCodeFlag"]);
  868. procedureEntity.PrintType = Convert.ToInt32(dr1[0]["PrintType"]);
  869. //成检工序 add xiacm 2022-10-12
  870. if(!string.IsNullOrEmpty(dr1[0]["FinishedCheckProcedureID"] + ""))
  871. {
  872. procedureEntity.FinishedCheckProcedureID = Convert.ToInt32(dr1[0]["FinishedCheckProcedureID"]);
  873. }
  874. else
  875. {
  876. procedureEntity.FinishedCheckProcedureID = -1;
  877. }
  878. //if (dr1[0]["LogoID"] != DBNull.Value)
  879. //{
  880. // procedureEntity.LogoID = Convert.ToInt32(dr1[0]["LogoID"]);
  881. //}
  882. // 对应产品信息
  883. DataRow[] goodsRows = dsProductionDataSet.Tables["procedureGoodsTable"].Select("NodeNo =" + nodeno);
  884. if (goodsRows != null && goodsRows.Length > 0)
  885. {
  886. procedureEntity.ProcedureGoodsTable = goodsRows.CopyToDataTable();
  887. procedureEntity.ProcedureGoodsTable.TableName = "procedureGoodsTable";
  888. }
  889. else
  890. {
  891. procedureEntity.ProcedureGoodsTable = dsProductionDataSet.Tables["procedureGoodsTable"].Clone();
  892. }
  893. // 工序对应工号表
  894. DataRow[] userRows = dsProductionDataSet.Tables["procedureUserTable"].Select("NodeNo =" + nodeno);
  895. if (userRows != null && userRows.Length > 0)
  896. {
  897. procedureEntity.ProcedureUserTable = userRows.CopyToDataTable();
  898. procedureEntity.ProcedureUserTable.TableName = "procedureUserTable";
  899. }
  900. else
  901. {
  902. procedureEntity.ProcedureUserTable = dsProductionDataSet.Tables["procedureUserTable"].Clone();
  903. }
  904. // 工序对应缺陷表(在检验工序中能检验出来的缺陷。)
  905. DataRow[] defectRows = dsProductionDataSet.Tables["procedureDefectTable"].Select("NodeNo =" + nodeno);
  906. if (defectRows != null && defectRows.Length > 0)
  907. {
  908. procedureEntity.ProcedureDefectTable = defectRows.CopyToDataTable();
  909. procedureEntity.ProcedureDefectTable.TableName = "procedureDefectTable";
  910. }
  911. else
  912. {
  913. procedureEntity.ProcedureDefectTable = dsProductionDataSet.Tables["procedureDefectTable"].Clone();
  914. }
  915. // 生产工序对应缺陷表
  916. DataRow[] defectProcedureJobsRows = dsProductionDataSet.Tables["defectProcedureJobsTable"].Select("NodeNo =" + nodeno);
  917. if (defectProcedureJobsRows != null && defectProcedureJobsRows.Length > 0)
  918. {
  919. procedureEntity.DefectProcedureJobsTable = defectProcedureJobsRows.CopyToDataTable();
  920. procedureEntity.DefectProcedureJobsTable.TableName = "defectProcedureJobsTable";
  921. }
  922. else
  923. {
  924. procedureEntity.DefectProcedureJobsTable = dsProductionDataSet.Tables["defectProcedureJobsTable"].Clone();
  925. }
  926. // 工序对应窑炉
  927. DataRow[] kilnRows = dsProductionDataSet.Tables["procedureKilnTable"].Select("NodeNo =" + nodeno);
  928. if (kilnRows != null && kilnRows.Length > 0)
  929. {
  930. procedureEntity.ProcedureKilnTable = kilnRows.CopyToDataTable();
  931. procedureEntity.ProcedureKilnTable.TableName = "procedureKilnTable";
  932. }
  933. else
  934. {
  935. procedureEntity.ProcedureKilnTable = dsProductionDataSet.Tables["procedureKilnTable"].Clone();
  936. }
  937. // 成检工序 add xiacm 2022-10-12
  938. DataRow[] drfin = dsProductionDataSet.Tables["procedureTable"].Select("PROCEDUREID IN(12, 59, 105)");
  939. procedureEntity.FinishedCheckProcedureTable = drfin.CopyToDataTable();
  940. node.TagNonSerialized = procedureEntity;
  941. ProductionLineEntity line = new ProductionLineEntity();
  942. line.ProductionLineID = procedureEntity.ProductionLineID;
  943. if (node.NodeImageType == 2)
  944. {
  945. F_PC_0206 frm0206 = new F_PC_0206(node, flowBox, true);
  946. frm0206.ShowDialog();
  947. if (frm0206.DialogResult == DialogResult.OK)
  948. {
  949. flowBox.SaveFlow();
  950. DataSet result = (DataSet)DoAsync(() =>
  951. {
  952. return PCModuleProxy.Service.SearchProductionLine(line);
  953. });
  954. // 绑定明细数据
  955. if (result != null && result.Tables.Count >= Constant.INT_IS_TWO)
  956. {
  957. this.dgvProcedure.DataSource = result.Tables[1];
  958. this.dgvProcedure.CurrentCell = null;
  959. }
  960. }
  961. }
  962. else
  963. {
  964. F_PC_0207 frm0207 = new F_PC_0207(node, flowBox, true);
  965. frm0207.ShowDialog();
  966. if (frm0207.DialogResult == DialogResult.OK)
  967. {
  968. flowBox.SaveFlow();
  969. DataSet result = (DataSet)DoAsync(() =>
  970. {
  971. return PCModuleProxy.Service.SearchProductionLine(line);
  972. });
  973. // 绑定明细数据
  974. if (result != null && result.Tables.Count >= Constant.INT_IS_TWO)
  975. {
  976. this.dgvProcedure.DataSource = result.Tables[1];
  977. this.dgvProcedure.CurrentCell = null;
  978. }
  979. }
  980. }
  981. }
  982. #endregion
  983. }
  984. }