F_PC_0205.cs 44 KB

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