F_PM_2502.cs 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764
  1. /*******************************************************************************
  2. * Copyright(c) 2017 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PM_2502.cs
  5. * 2.功能描述:回收计件
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 王鑫 2017/7/20 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Data;
  13. using System.Windows.Forms;
  14. using Dongke.IBOSS.PRD.Basics.BaseControls;
  15. using Dongke.IBOSS.PRD.Basics.BaseResources;
  16. using Dongke.IBOSS.PRD.Client.CommonModule;
  17. using Dongke.IBOSS.PRD.WCF.DataModels;
  18. using Dongke.IBOSS.PRD.WCF.Proxys;
  19. using Dongke.IBOSS.PRD.WCF.Proxys.PMModuleService;
  20. using Dongke.IBOSS.PRD.WCF.Proxys.SystemModuleService;
  21. namespace Dongke.IBOSS.PRD.Client.PMModule
  22. {
  23. /// <summary>
  24. /// 回收计件
  25. /// </summary>
  26. public partial class F_PM_2502 : FormBase
  27. {
  28. #region 成员变量
  29. // 工序ID
  30. private int _procedureID;
  31. // 工序实体类
  32. ProcedureEntity _procedureDataEntity;
  33. // 生产数据实体类
  34. List<ProductionDataEntity> _productionDataEntity = new List<ProductionDataEntity>();
  35. // 数据源Table
  36. private DataTable _dataSourceTable = null;
  37. // 添加行数据源
  38. private DataTable _collectType = null;
  39. // 生产工号
  40. private int _userID = -1;
  41. // 生产编号
  42. private string _userCode;
  43. // 生产名称
  44. private string _userName;
  45. #endregion
  46. #region 属性
  47. /// <summary>
  48. /// 绑定GridView数据源
  49. /// </summary>
  50. public DataTable DataSourceTable
  51. {
  52. set
  53. {
  54. _dataSourceTable = value;
  55. }
  56. get
  57. {
  58. if (_dataSourceTable == null)
  59. {
  60. _dataSourceTable = new DataTable();
  61. _dataSourceTable.Columns.Add("BarCode");
  62. _dataSourceTable.Columns.Add("GoodsCode");
  63. _dataSourceTable.Columns.Add("GoodsName");
  64. _dataSourceTable.Columns.Add("ProductionLineCode");
  65. _dataSourceTable.Columns.Add("ProcedureModel");
  66. _dataSourceTable.Columns.Add("ModelType");
  67. _dataSourceTable.Columns.Add("PieceType");
  68. _dataSourceTable.Columns.Add("IsReworked");
  69. _dataSourceTable.Columns.Add("IsPublicBody");
  70. _dataSourceTable.Columns.Add("OrganizationName");
  71. _dataSourceTable.Columns.Add("Remarks");
  72. _dataSourceTable.Columns.Add("UserCode");
  73. _dataSourceTable.Columns.Add("UserID");
  74. _dataSourceTable.Columns.Add("BarCodeUserCode");
  75. _dataSourceTable.Columns.Add("MouldCode");
  76. _dataSourceTable.Columns.Add("GroutingUserCode");
  77. _dataSourceTable.Columns.Add("GroutingNum");
  78. _dataSourceTable.Columns.Add("GroutingDate", typeof(DateTime));
  79. _dataSourceTable.Columns.Add("LogoID");
  80. _dataSourceTable.Columns.Add("LogoCodeName");
  81. return _dataSourceTable;
  82. }
  83. else
  84. {
  85. return _dataSourceTable;
  86. }
  87. }
  88. }
  89. /// <summary>
  90. /// 提交数据源
  91. /// </summary>
  92. public DataTable DataSourceCollectTypeTable
  93. {
  94. set
  95. {
  96. _collectType = value;
  97. }
  98. get
  99. {
  100. if (_collectType == null)
  101. {
  102. _collectType = new DataTable();
  103. _collectType.TableName = "collectType";
  104. _collectType.Columns.Add("BarCode");
  105. _collectType.Columns.Add("IsPublicBody");
  106. _collectType.Columns.Add("UserID");
  107. _collectType.Columns.Add("UserCode");
  108. _collectType.Columns.Add("UserName");
  109. _collectType.Columns.Add("LogoID");
  110. return _collectType;
  111. }
  112. else
  113. {
  114. return _collectType;
  115. }
  116. }
  117. }
  118. /// <summary>
  119. /// 生产工号
  120. /// </summary>
  121. public int UserID
  122. {
  123. set
  124. {
  125. _userID = value;
  126. }
  127. get
  128. {
  129. return _userID;
  130. }
  131. }
  132. /// <summary>
  133. /// 生产编号
  134. /// </summary>
  135. public string UserCode
  136. {
  137. set
  138. {
  139. _userCode = value;
  140. }
  141. get
  142. {
  143. return _userCode;
  144. }
  145. }
  146. /// <summary>
  147. /// 用户名称
  148. /// </summary>
  149. public string UserName
  150. {
  151. set
  152. {
  153. _userName = value;
  154. }
  155. get
  156. {
  157. return _userName;
  158. }
  159. }
  160. #endregion
  161. #region 构造函数
  162. public F_PM_2502()
  163. {
  164. InitializeComponent();
  165. }
  166. public F_PM_2502(int procedureID, string fromTitle)
  167. {
  168. InitializeComponent();
  169. this._procedureID = procedureID;
  170. this.Text = fromTitle;
  171. this.tsbtnDelete.Text = ButtonText.TSBTN_DELETE;
  172. //自动适应列宽
  173. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  174. //关闭
  175. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  176. this.btnSave.Text = ButtonText.BTN_SAVE;
  177. this.btnCancel.Text = ButtonText.BTN_CANCEL;
  178. }
  179. #endregion
  180. #region 事件
  181. /// <summary>
  182. /// 窗体关闭事件
  183. /// </summary>
  184. /// <param name="sender"></param>
  185. /// <param name="e"></param>
  186. private void btnClose_Click(object sender, EventArgs e)
  187. {
  188. this.Close();
  189. }
  190. /// <summary>
  191. /// 窗体关闭事件
  192. /// </summary>
  193. /// <param name="sender"></param>
  194. /// <param name="e"></param>
  195. private void tsbtnClose_Click(object sender, EventArgs e)
  196. {
  197. this.Close();
  198. }
  199. /// <summary>
  200. /// 条形码按键事件
  201. /// </summary>
  202. /// <param name="sender"></param>
  203. /// <param name="e"></param>
  204. private void txtBarcode_KeyPress(object sender, KeyPressEventArgs e)
  205. {
  206. try
  207. {
  208. if (this.txtBarcode.ReadOnly)
  209. {
  210. return;
  211. }
  212. if ((int)e.KeyChar == 13) // 按了回车键
  213. {
  214. if (this.txtUserCode.Text.Trim() == string.Empty)
  215. {
  216. this.txtUserCode.Focus();
  217. this.txtBarcode.Text = string.Empty;
  218. return;
  219. }
  220. if (this.txtBarcode.Text.Trim() == string.Empty)
  221. {
  222. this.txtBarcode.Focus();
  223. return;
  224. }
  225. DataRow[] drRows = this.DataSourceTable.Select("BarCode='" + this.txtBarcode.Text.Trim() + "'");
  226. if (drRows.Length == Constant.INT_IS_ZERO)
  227. {
  228. // 校验条码 获取校验条码信
  229. DataSet dsCheckBarcode = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  230. {
  231. return PMModuleProxy.Service.CheckRecydingFlagBarcode(this._procedureID, this.txtBarcode.Text.Trim());
  232. }));
  233. if (dsCheckBarcode != null && dsCheckBarcode.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  234. {
  235. if (dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString() != string.Empty)
  236. {
  237. // 表示有错误
  238. MessageBox.Show(string.Format(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString(), this.txtBarcode.Text.Trim(), "产品条码"),
  239. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  240. this.txtBarcode.Focus();
  241. this.txtBarcode.SelectAll();
  242. return;
  243. }
  244. else
  245. {
  246. int PublicNormal = (int)Constant.PublicBodyFlag.No;
  247. // 生产数据实体
  248. ProductionDataEntity procedureDataEntity = new ProductionDataEntity();
  249. procedureDataEntity.Barcode = txtBarcode.Text.Trim(); // 产品条码
  250. procedureDataEntity.CentralizedBatchNo = System.Guid.NewGuid().ToString();// 集中采集批次号
  251. procedureDataEntity.ProductionLineID = this._procedureDataEntity.ProductionLineID;// 生产线ID
  252. procedureDataEntity.ProductionLineCode = this._procedureDataEntity.ProductionlineCode;// 生产编码
  253. procedureDataEntity.ProductionLineName = this._procedureDataEntity.ProductionlineName;// 生产名称
  254. procedureDataEntity.CompleteProcedureID = this._procedureID;// 工序ID
  255. procedureDataEntity.ProcedureCode = this._procedureDataEntity.ProcedureCode;// 工序编码
  256. procedureDataEntity.ProcedureName = this._procedureDataEntity.ProcedureName;// 工序名称
  257. procedureDataEntity.ProcedureModel = Convert.ToInt32(this._procedureDataEntity.ProcedureModel);// 工序模型
  258. procedureDataEntity.ModelType = this._procedureDataEntity.ModelType;// 工序模型类别
  259. procedureDataEntity.PieceType = Convert.ToInt32(this._procedureDataEntity.PieceType);// 计件模式
  260. procedureDataEntity.IsReworked = Convert.ToInt32(this._procedureDataEntity.IsSpecialRework); // 是否是返工
  261. procedureDataEntity.NodeType = Convert.ToInt32(this._procedureDataEntity.NodeType); // 工序结点类型
  262. procedureDataEntity.IsPublicBody = PublicNormal;
  263. procedureDataEntity.OrganizationID = this._procedureDataEntity.OrganizationID; // 组织机构
  264. procedureDataEntity.GoodsID = Convert.ToInt32(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsID.ToString()]);
  265. procedureDataEntity.GoodsCode = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsCode.ToString()].ToString();
  266. procedureDataEntity.GoodsName = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsName.ToString()].ToString();
  267. procedureDataEntity.UserID = UserID;
  268. procedureDataEntity.UserCode = UserCode;
  269. procedureDataEntity.UserName = UserName;
  270. procedureDataEntity.ValueFlag = 1;
  271. procedureDataEntity.Remarks = this._procedureDataEntity.Remarks;
  272. if(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoID.ToString()].ToString()!="")
  273. {
  274. procedureDataEntity.LogoID = Convert.ToInt32(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoID.ToString()]);
  275. }
  276. if (this._procedureDataEntity.CollectType == (int)Constant.ProcedureCollectType.SinglePoint) // 单点采集 直接保存
  277. {
  278. this.CollectTypeTwo(procedureDataEntity,dsCheckBarcode);
  279. }
  280. else
  281. {
  282. this.CollectTypeOne(procedureDataEntity, Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserCode); // 集中采集
  283. }
  284. this.txtBarcode.Text = string.Empty;
  285. this.txtBarcode.Focus();
  286. }
  287. }
  288. }
  289. else
  290. {
  291. this.txtBarcode.Text = "";
  292. }
  293. }
  294. }
  295. catch (Exception ex)
  296. {
  297. // 对异常进行共通处理
  298. ExceptionManager.HandleEventException(this.ToString(),
  299. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  300. }
  301. }
  302. /// <summary>
  303. /// 窗体加载事件
  304. /// </summary>
  305. /// <param name="sender"></param>
  306. /// <param name="e"></param>
  307. private void F_PM_2002_Load(object sender, EventArgs e)
  308. {
  309. try
  310. {
  311. this.dgvProduction.AutoGenerateColumns = false;
  312. this.dgvProduction.DataSource = DataSourceTable;
  313. // 加载权限
  314. FormPermissionManager.FormPermissionControl(this.Name, this,
  315. Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
  316. Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  317. // 获取工序明细数据
  318. ProcedureEntity procedureDataEntity = (ProcedureEntity)DoAsync(new BaseAsyncMethod(() =>
  319. {
  320. return PMModuleProxy.Service.GetProcedureDataEntityByID(this._procedureID);
  321. }));
  322. this._procedureDataEntity = procedureDataEntity;
  323. // 设置控件禁用或启用
  324. SetControlEnable();
  325. this.txtUserCode.Focus();
  326. }
  327. catch (Exception ex)
  328. {
  329. // 对异常进行共通处理
  330. ExceptionManager.HandleEventException(this.ToString(),
  331. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  332. }
  333. }
  334. /// <summary>
  335. /// 删除按钮事件
  336. /// </summary>
  337. /// <param name="sender"></param>
  338. /// <param name="e"></param>
  339. private void tsbtnDelete_Click(object sender, EventArgs e)
  340. {
  341. if (this.dgvProduction.CurrentCell != null)
  342. {
  343. this.DataSourceTable.Rows[this.dgvProduction.CurrentCell.RowIndex].Delete();
  344. }
  345. }
  346. /// <summary>
  347. /// 保存按钮事件
  348. /// </summary>
  349. /// <param name="sender"></param>
  350. /// <param name="e"></param>
  351. private void btnSave_Click(object sender, EventArgs e)
  352. {
  353. try
  354. {
  355. this.DataSourceTable.AcceptChanges();
  356. this.DataSourceCollectTypeTable.Clear();
  357. if (this.DataSourceTable.Rows.Count > Constant.INT_IS_ZERO)
  358. {
  359. foreach (DataRow drproductionData in this.DataSourceTable.Rows)
  360. {
  361. DataRow drCollectType = DataSourceCollectTypeTable.NewRow();
  362. drCollectType["BarCode"] = drproductionData["BarCode"];
  363. drCollectType["IsPublicBody"] = drproductionData["IsPublicBody"];
  364. drCollectType["UserID"] = UserID;
  365. drCollectType["UserCode"] = UserCode;
  366. drCollectType["UserName"] = UserName;
  367. drCollectType["LogoID"] = drproductionData["LogoID"];
  368. DataSourceCollectTypeTable.Rows.Add(drCollectType);
  369. }
  370. DataTable returnRow = (DataTable)DoAsync(new BaseAsyncMethod(() =>
  371. {
  372. return PMModuleProxy.Service.AddWorkPiece(this._procedureID, DataSourceCollectTypeTable);
  373. }));
  374. if (returnRow.Rows.Count <= Constant.INT_IS_ZERO)
  375. {
  376. // 提示信息
  377. MessageBox.Show(Messages.MSG_PM_W012,
  378. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  379. }
  380. else
  381. {
  382. if (string.IsNullOrEmpty(returnRow.Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString()))//成功
  383. {
  384. // 提示信息
  385. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "新增" + this.Text, "保存"),
  386. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  387. }
  388. else
  389. {
  390. // 提示信息
  391. MessageBox.Show(string.Format(returnRow.Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString()),
  392. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  393. return;
  394. }
  395. }
  396. this.txtBarcode.Text = "";
  397. this._productionDataEntity.Clear();
  398. this.DataSourceTable.Rows.Clear();
  399. if (this._procedureDataEntity.CollectType == (int)Constant.ProcedureCollectType.Togather)
  400. {
  401. this.txtUserCode.Text = "";
  402. this.txtUserCode.Focus();
  403. this.txtUserCode.ReadOnly = false;
  404. }
  405. else
  406. {
  407. this.txtBarcode.Focus();
  408. }
  409. }
  410. }
  411. catch (Exception ex)
  412. {
  413. // 对异常进行共通处理
  414. ExceptionManager.HandleEventException(this.ToString(),
  415. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  416. }
  417. }
  418. /// <summary>
  419. /// 控件数据校验时发生
  420. /// </summary>
  421. /// <param name="sender"></param>
  422. /// <param name="e"></param>
  423. private void txtUserCode_Validating(object sender, System.ComponentModel.CancelEventArgs e)
  424. {
  425. try
  426. {
  427. if (txtUserCode.Text.Trim() == string.Empty) // 如果未添加数据,则此项获取焦点
  428. {
  429. this.txtUserCode.IsMustInput = true;
  430. this.txtUserCode.SelectAll();
  431. e.Cancel = true;
  432. return;
  433. }
  434. else
  435. {
  436. SUserEntity userEntity = new SUserEntity();
  437. userEntity.UserCode = this.txtUserCode.Text.Trim();
  438. // 此工号是否能生产工序
  439. CheckProcedureUserResult MsgCheckProcedureUser = (CheckProcedureUserResult)DoAsync(new BaseAsyncMethod(() =>
  440. {
  441. return PMModuleProxy.Service.CheckProcedureUser(this._procedureID, this.txtUserCode.Text.Trim());
  442. }));
  443. if (MsgCheckProcedureUser != null)
  444. {
  445. if (MsgCheckProcedureUser.ErrMsg != null)
  446. {
  447. MessageBox.Show(MsgCheckProcedureUser.ErrMsg,
  448. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  449. this.txtUserCode.SelectAll();
  450. e.Cancel = true;
  451. return;
  452. }
  453. if (UserID != -Constant.INT_IS_ONE)
  454. {
  455. if (MsgCheckProcedureUser.UserID != UserID)
  456. {
  457. btnSave_Click(sender, e);
  458. }
  459. }
  460. UserID = Convert.ToInt32(MsgCheckProcedureUser.UserID);
  461. UserCode = MsgCheckProcedureUser.UserCode;
  462. UserName = MsgCheckProcedureUser.UserName;
  463. this.txtUserCode.ReadOnly = true;
  464. }
  465. }
  466. }
  467. catch (Exception ex)
  468. {
  469. // 对异常进行共通处理
  470. ExceptionManager.HandleEventException(this.ToString(),
  471. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  472. }
  473. }
  474. /// <summary>
  475. /// 自动适应列宽
  476. /// </summary>
  477. /// <param name="sender"></param>
  478. /// <param name="e"></param>
  479. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  480. {
  481. this.dgvProduction.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  482. }
  483. /// <summary>
  484. /// 窗体关闭时事件
  485. /// </summary>
  486. /// <param name="sender"></param>
  487. /// <param name="e"></param>
  488. private void F_PM_2002_FormClosing(object sender, FormClosingEventArgs e)
  489. {
  490. if (this.btnSave.Visible)
  491. {
  492. try
  493. {
  494. this.DataSourceTable.AcceptChanges();
  495. this.DataSourceCollectTypeTable.Clear();
  496. if (this.DataSourceTable.Rows.Count > Constant.INT_IS_ZERO)
  497. {
  498. DialogResult result = MessageBox.Show(Messages.MSG_CMN_Q001, this.Text,
  499. MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
  500. if (result == DialogResult.Yes)
  501. {
  502. // 保存数据
  503. btnSave_Click(sender, e);
  504. }
  505. else if (result == DialogResult.Cancel)
  506. {
  507. e.Cancel = true;
  508. }
  509. }
  510. }
  511. catch (Exception ex)
  512. {
  513. // 对异常进行共通处理
  514. ExceptionManager.HandleEventException(this.ToString(),
  515. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  516. }
  517. }
  518. }
  519. /// <summary>
  520. /// 鼠标单击事件
  521. /// </summary>
  522. /// <param name="sender"></param>
  523. /// <param name="e"></param>
  524. private void txtUserCode_MouseClick(object sender, MouseEventArgs e)
  525. {
  526. if (this.txtUserCode.Text.Trim() != string.Empty)
  527. {
  528. this.txtUserCode.SelectAll();
  529. }
  530. }
  531. /// <summary>
  532. /// 生产工号回车事件
  533. /// </summary>
  534. /// <param name="sender"></param>
  535. /// <param name="e"></param>
  536. private void txtUserCode_KeyPress(object sender, KeyPressEventArgs e)
  537. {
  538. if ((int)e.KeyChar == 13) // 按了回车键
  539. {
  540. this.txtBarcode.Focus();
  541. }
  542. }
  543. #endregion
  544. #region 私有方法
  545. /// <summary>
  546. /// 设置控件禁用或启用
  547. /// </summary>
  548. private void SetControlEnable()
  549. {
  550. if (this._procedureDataEntity != null)
  551. {
  552. this.txtCollectType.Text = this._procedureDataEntity.CollectType == (int)Constant.ProcedureCollectType.SinglePoint ? "单点采集" : "集中采集";
  553. if (this._procedureDataEntity.CollectType == (int)Constant.ProcedureCollectType.Togather)
  554. {
  555. this.txtUserCode.Enabled = true;
  556. this.tsbtnDelete.Visible = true;
  557. this.tsbtnDelete.Enabled = true;
  558. this.btnSave.Visible = true;
  559. }
  560. else
  561. {
  562. this.txtUserCode.Enabled = true;
  563. this.txtUserCode.ReadOnly = true;
  564. this.dgvProduction.ReadOnly = true;
  565. // 此工号是否能生产工序
  566. CheckProcedureUserResult checkProcedureUser = (CheckProcedureUserResult)DoAsync(new BaseAsyncMethod(() =>
  567. {
  568. return PMModuleProxy.Service.CheckProcedureUser(this._procedureID,
  569. Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserCode);
  570. }));
  571. if (checkProcedureUser != null)
  572. {
  573. if (!string.IsNullOrEmpty(checkProcedureUser.ErrMsg))
  574. {
  575. // 此工号不允许生产工序
  576. MessageBox.Show(checkProcedureUser.ErrMsg,
  577. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  578. this.Close();
  579. return;
  580. }
  581. }
  582. UserID = checkProcedureUser.UserID;
  583. UserCode = checkProcedureUser.UserCode;
  584. UserName = checkProcedureUser.UserName;
  585. }
  586. this.txtUserCode.Text = UserCode;
  587. }
  588. }
  589. /// <summary>
  590. /// 单点采集模式
  591. /// </summary>
  592. /// <param name="procedureDataEntity"></param>
  593. private void CollectTypeTwo(ProductionDataEntity procedureDataEntity, DataSet dsGroutingProduct)
  594. {
  595. try
  596. {
  597. #region 单点采集
  598. // 添加行就可以 并保存
  599. // 保存到数据库
  600. DataSourceCollectTypeTable.Rows.Clear();
  601. DataRow drCollectType = DataSourceCollectTypeTable.NewRow();
  602. drCollectType["BarCode"] = procedureDataEntity.Barcode;
  603. drCollectType["IsPublicBody"] = procedureDataEntity.IsPublicBody;
  604. drCollectType["UserID"] = UserID;
  605. drCollectType["UserCode"] = UserCode;
  606. drCollectType["UserName"] = UserName;
  607. DataSourceCollectTypeTable.Rows.Add(drCollectType);
  608. DataTable returnString = (DataTable)DoAsync(new BaseAsyncMethod(() =>
  609. {
  610. return PMModuleProxy.Service.AddWorkPiece(this._procedureID, DataSourceCollectTypeTable);
  611. }
  612. ));
  613. if (returnString.Rows.Count <= Constant.INT_IS_ZERO)
  614. {
  615. // 提示信息
  616. MessageBox.Show(Messages.MSG_PM_W012,
  617. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  618. return;
  619. }
  620. else
  621. {
  622. if (string.IsNullOrEmpty(returnString.Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString()))//成功
  623. {
  624. // 单点采集成功后不需要提示
  625. }
  626. else
  627. {
  628. // 提示信息
  629. MessageBox.Show(string.Format(returnString.Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString()),
  630. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  631. return;
  632. }
  633. }
  634. // 由产品条码获取注浆信息
  635. //DataSet dsGroutingProduct = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  636. //{
  637. // return PMModuleProxy.Service.GetGroutingProducttByBarCode(procedureDataEntity.Barcode);
  638. //}));
  639. DataRow dr = this.DataSourceTable.NewRow();
  640. dr["BarCode"] = procedureDataEntity.Barcode;
  641. dr["GoodsCode"] = procedureDataEntity.GoodsCode;
  642. dr["GoodsName"] = procedureDataEntity.GoodsName;
  643. dr["ProductionLineCode"] = procedureDataEntity.ProductionLineCode;
  644. dr["ProcedureModel"] = procedureDataEntity.ProcedureModel == (int)Constant.ProcedureModel.Piece ? "计数模型" : "检验模型";
  645. dr["ModelType"] = procedureDataEntity.ModelType;
  646. dr["PieceType"] = procedureDataEntity.PieceType == (int)Constant.ProcedurePieceType.NoPiece ? "不计件"
  647. : "同工种策略";
  648. dr["IsReworked"] = procedureDataEntity.IsReworked == (int)Constant.SpecialReworkFlag.Yes ? "是" : "否";
  649. dr["IsPublicBody"] = procedureDataEntity.IsPublicBody;
  650. dr["OrganizationName"] = string.Empty;
  651. dr["Remarks"] = procedureDataEntity.Remarks;
  652. dr["UserCode"] = this.txtUserCode.Text.Trim();
  653. dr["BarCodeUserCode"] = dsGroutingProduct.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()]; //Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserCode;
  654. dr["MouldCode"] = dsGroutingProduct.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_mouldCode.ToString()];
  655. dr["GroutingUserCode"] = dsGroutingProduct.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()];
  656. dr["GroutingNum"] = dsGroutingProduct.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingNum.ToString()];
  657. dr["IsPublicBody"] = dsGroutingProduct.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_ispublicbodyTrach.ToString()].ToString() != "1" ? 0 : 1;
  658. dr["GroutingDate"] = Convert.ToDateTime(dsGroutingProduct.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingdate.ToString()]);
  659. dr["LogoID"]= dsGroutingProduct.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoID.ToString()];
  660. dr["LogoCodeName"] = dsGroutingProduct.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoCode.ToString()] + "[" + dsGroutingProduct.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoName.ToString()] + "]";
  661. this.DataSourceTable.Rows.Add(dr);
  662. this.dgvProduction.CurrentCell = null;
  663. this.dgvProduction.Rows[dgvProduction.RowCount - 1].Selected = true;
  664. this.dgvProduction.CurrentCell = this.dgvProduction.Rows[dgvProduction.RowCount - 1].Cells[0];
  665. #endregion
  666. }
  667. catch (Exception ex)
  668. {
  669. throw ex;
  670. }
  671. }
  672. /// <summary>
  673. ///集中采集模式
  674. /// </summary>
  675. /// <param name="procedureDataEntity"></param>
  676. private void CollectTypeOne(ProductionDataEntity procedureDataEntity, string barCodeUserCode)
  677. {
  678. try
  679. {
  680. #region 集中采集
  681. DataRow[] drRows = this.DataSourceTable.Select("BarCode='" + procedureDataEntity.Barcode + "'");
  682. if (drRows.Length > Constant.INT_IS_ZERO)
  683. {
  684. this.txtBarcode.Text = "";
  685. return;
  686. }
  687. // 由产品条码获取注浆信息
  688. DataSet dsGroutingProduct = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  689. {
  690. return PMModuleProxy.Service.GetGroutingProducttByBarCode(procedureDataEntity.Barcode);
  691. }));
  692. DataRow dr = this.DataSourceTable.NewRow();
  693. dr["BarCode"] = procedureDataEntity.Barcode;
  694. dr["GoodsCode"] = procedureDataEntity.GoodsCode;
  695. dr["GoodsName"] = procedureDataEntity.GoodsName;
  696. dr["ProductionLineCode"] = procedureDataEntity.ProductionLineCode;
  697. dr["ProcedureModel"] = procedureDataEntity.ProcedureModel == (int)Constant.ProcedureModel.Piece ? "计数模型" : "检验模型";
  698. dr["ModelType"] = procedureDataEntity.ModelType;
  699. dr["PieceType"] = procedureDataEntity.PieceType == (int)Constant.ProcedurePieceType.NoPiece ? "不计件"
  700. : "同工种策略";
  701. dr["IsReworked"] = procedureDataEntity.IsReworked == (int)Constant.SpecialReworkFlag.Yes ? "是" : "否";
  702. dr["IsPublicBody"] = procedureDataEntity.IsPublicBody;
  703. dr["OrganizationName"] = string.Empty;
  704. dr["Remarks"] = procedureDataEntity.Remarks;
  705. dr["UserCode"] = this.txtUserCode.Text.Trim();
  706. dr["UserID"] = procedureDataEntity.UserID;
  707. dr["BarCodeUserCode"] = dsGroutingProduct.Tables[0].Rows[0]["GroutingUserCode"];// barCodeUserCode;
  708. dr["MouldCode"] = dsGroutingProduct.Tables[0].Rows[0]["MouldCode"];
  709. dr["GroutingUserCode"] = dsGroutingProduct.Tables[0].Rows[0]["GroutingUserCode"];
  710. dr["GroutingNum"] = dsGroutingProduct.Tables[0].Rows[0]["GroutingNum"];
  711. dr["IsPublicBody"] = dsGroutingProduct.Tables[0].Rows[0]["IsPublicBodyTrach"].ToString() != "1" ? 0 : 1;
  712. dr["GroutingDate"] = Convert.ToDateTime(dsGroutingProduct.Tables[0].Rows[0]["GroutingDate"]);
  713. dr["LogoID"] = dsGroutingProduct.Tables[0].Rows[0]["LogoID"];
  714. dr["LogoCodeName"] = dsGroutingProduct.Tables[0].Rows[0]["LogoCode"] + "[" + dsGroutingProduct.Tables[0].Rows[0]["LogoName"] + "]";
  715. this.DataSourceTable.Rows.Add(dr);
  716. this.dgvProduction.CurrentCell = null;
  717. this.dgvProduction.Rows[dgvProduction.RowCount - 1].Selected = true;
  718. this.dgvProduction.CurrentCell = this.dgvProduction.Rows[dgvProduction.RowCount - 1].Cells[0];
  719. #endregion
  720. }
  721. catch (Exception ex)
  722. {
  723. throw ex;
  724. }
  725. }
  726. #endregion
  727. }
  728. }