F_PM_0302.cs 61 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PM_0302.cs
  5. * 2.功能描述:新建标准、坯库计件
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 王鑫 2014/09/23 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.Client.Controls.FormCommon;
  18. using Dongke.IBOSS.PRD.WCF.DataModels;
  19. using Dongke.IBOSS.PRD.WCF.Proxys;
  20. using Dongke.IBOSS.PRD.WCF.Proxys.PMModuleService;
  21. using Dongke.IBOSS.PRD.WCF.Proxys.SystemModuleService;
  22. using Dongke.WinForm.Utilities;
  23. namespace Dongke.IBOSS.PRD.Client.PMModule
  24. {
  25. /// <summary>
  26. /// 新建标准、坯库计件
  27. /// </summary>
  28. public partial class F_PM_0302 : FormBase
  29. {
  30. #region 成员变量
  31. // 工序ID
  32. private int _procedureID;
  33. // 工序实体类
  34. ProcedureEntity _procedureDataEntity;
  35. // 生产数据实体类
  36. List<ProductionDataEntity> _productionDataEntity = new List<ProductionDataEntity>();
  37. // 数据源Table
  38. private DataTable _dataSourceTable = null;
  39. // 添加行数据源
  40. private DataTable _collectType = null;
  41. // 生产工号
  42. private int _userID = -1;
  43. // 生产编号
  44. private string _userCode;
  45. // 生产名称
  46. private string _userName;
  47. // 是否有商标
  48. private int? _isLogo = null;
  49. // 是否有商标编码
  50. private string _isLogoCode = "";
  51. // 是否有商标名称
  52. private string _isLogoName = "";
  53. // 1.产成品交接是否限制同商标
  54. private string _isEnable_S_PM_011 = "0";
  55. // 2.产成品交接是否限制同型号
  56. private string _isEnable_S_PM_012 = "0";
  57. // 3.产成品交接是否限制每板装板数量(必须先启用限制同型号);
  58. private string _isEnable_S_PM_013 = "0";
  59. // 最大限制数量
  60. private int _maxPlateLimitNum = 0;
  61. // 最大限制数量新
  62. private int _maxPlateLimitNumNew = 0;
  63. // 产品型号
  64. private string _goodsID = null;
  65. private string _goodsCode = null;
  66. private string _goodsModelForCheck = null;
  67. // 商标ID
  68. private string _logoID = null;
  69. private string _logoName = null;
  70. #endregion
  71. #region 属性
  72. /// <summary>
  73. /// 绑定GridView数据源
  74. /// </summary>
  75. public DataTable DataSourceTable
  76. {
  77. set
  78. {
  79. _dataSourceTable = value;
  80. }
  81. get
  82. {
  83. if (_dataSourceTable == null)
  84. {
  85. _dataSourceTable = new DataTable();
  86. _dataSourceTable.Columns.Add("BarCode");
  87. _dataSourceTable.Columns.Add("GoodsCode");
  88. _dataSourceTable.Columns.Add("GoodsName");
  89. _dataSourceTable.Columns.Add("ProductionLineCode");
  90. _dataSourceTable.Columns.Add("ProcedureModel");
  91. _dataSourceTable.Columns.Add("ModelType");
  92. _dataSourceTable.Columns.Add("PieceType");
  93. _dataSourceTable.Columns.Add("IsReworked");
  94. _dataSourceTable.Columns.Add("IsPublicBody");
  95. _dataSourceTable.Columns.Add("OrganizationName");
  96. _dataSourceTable.Columns.Add("Remarks");
  97. _dataSourceTable.Columns.Add("UserCode");
  98. _dataSourceTable.Columns.Add("UserID");
  99. _dataSourceTable.Columns.Add("BarCodeUserCode");
  100. _dataSourceTable.Columns.Add("MouldCode");
  101. _dataSourceTable.Columns.Add("GroutingUserCode");
  102. _dataSourceTable.Columns.Add("GroutingNum");
  103. _dataSourceTable.Columns.Add("GroutingDate", typeof(DateTime));
  104. _dataSourceTable.Columns.Add("LogoID");
  105. _dataSourceTable.Columns.Add("LogoCodeName");
  106. _dataSourceTable.Columns.Add("BanMa", typeof(string));
  107. return _dataSourceTable;
  108. }
  109. else
  110. {
  111. return _dataSourceTable;
  112. }
  113. }
  114. }
  115. /// <summary>
  116. /// 提交数据源
  117. /// </summary>
  118. public DataTable DataSourceCollectTypeTable
  119. {
  120. set
  121. {
  122. _collectType = value;
  123. }
  124. get
  125. {
  126. if (_collectType == null)
  127. {
  128. _collectType = new DataTable();
  129. _collectType.TableName = "collectType";
  130. _collectType.Columns.Add("BarCode");
  131. //_collectType.Columns.Add("IsPublicBody");
  132. _collectType.Columns.Add("UserID");
  133. _collectType.Columns.Add("UserCode");
  134. _collectType.Columns.Add("UserName");
  135. _collectType.Columns.Add("LogoID");
  136. _collectType.Columns.Add("BanMa", typeof(string));
  137. return _collectType;
  138. }
  139. else
  140. {
  141. return _collectType;
  142. }
  143. }
  144. }
  145. /// <summary>
  146. /// 生产工号
  147. /// </summary>
  148. public int UserID
  149. {
  150. set
  151. {
  152. _userID = value;
  153. }
  154. get
  155. {
  156. return _userID;
  157. }
  158. }
  159. /// <summary>
  160. /// 生产编号
  161. /// </summary>
  162. public string UserCode
  163. {
  164. set
  165. {
  166. _userCode = value;
  167. }
  168. get
  169. {
  170. return _userCode;
  171. }
  172. }
  173. /// <summary>
  174. /// 用户名称
  175. /// </summary>
  176. public string UserName
  177. {
  178. set
  179. {
  180. _userName = value;
  181. }
  182. get
  183. {
  184. return _userName;
  185. }
  186. }
  187. #endregion
  188. #region 构造函数
  189. public F_PM_0302()
  190. {
  191. InitializeComponent();
  192. }
  193. public F_PM_0302(int procedureID, string fromTitle)
  194. {
  195. InitializeComponent();
  196. this._procedureID = procedureID;
  197. this.Text = fromTitle;
  198. this.tsbtnDelete.Text = ButtonText.TSBTN_DELETE;
  199. //自动适应列宽
  200. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  201. //关闭
  202. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  203. this.btnSave.Text = ButtonText.BTN_SAVE;
  204. this.btnCancel.Text = ButtonText.BTN_CLOSE;
  205. }
  206. #endregion
  207. #region 事件
  208. /// <summary>
  209. /// 窗体关闭事件
  210. /// </summary>
  211. /// <param name="sender"></param>
  212. /// <param name="e"></param>
  213. private void btnClose_Click(object sender, EventArgs e)
  214. {
  215. this.Close();
  216. }
  217. /// <summary>
  218. /// 窗体关闭事件
  219. /// </summary>
  220. /// <param name="sender"></param>
  221. /// <param name="e"></param>
  222. private void tsbtnClose_Click(object sender, EventArgs e)
  223. {
  224. this.Close();
  225. }
  226. /// <summary>
  227. /// 条形码按键事件
  228. /// </summary>
  229. /// <param name="sender"></param>
  230. /// <param name="e"></param>
  231. private void txtBarcode_KeyPress(object sender, KeyPressEventArgs e)
  232. {
  233. try
  234. {
  235. if (this.txtBarcode.ReadOnly)
  236. {
  237. return;
  238. }
  239. if ((int)e.KeyChar == 13) // 按了回车键
  240. {
  241. if (this.txtUserCode.Text.Trim() == string.Empty)
  242. {
  243. this.txtUserCode.Focus();
  244. this.txtBarcode.Text = string.Empty;
  245. return;
  246. }
  247. if (this.txtBarcode.Text.Trim() == string.Empty)
  248. {
  249. this.txtBarcode.Focus();
  250. return;
  251. }
  252. DataRow[] drRows = this.DataSourceTable.Select("BarCode='" + this.txtBarcode.Text.Trim() + "'");
  253. if (drRows.Length == Constant.INT_IS_ZERO)
  254. {
  255. // 限制装板数量 add by chenxy 2018-02-27 begin
  256. if (string.IsNullOrEmpty(txtBanMa.Text))
  257. {
  258. if (this._maxPlateLimitNum > 0 && this.DataSourceTable.Rows.Count > this._maxPlateLimitNum)
  259. {
  260. MessageBox.Show("超过最大装板数量【" + this._maxPlateLimitNum + "】",
  261. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  262. this.txtBarcode.Focus();
  263. this.txtBarcode.SelectAll();
  264. return;
  265. }
  266. }
  267. else
  268. {
  269. if (this._maxPlateLimitNumNew > 0 && this.DataSourceTable.Rows.Count > this._maxPlateLimitNumNew)
  270. {
  271. MessageBox.Show("超过最大装板数量【" + this._maxPlateLimitNumNew + "】",
  272. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  273. this.txtBarcode.Focus();
  274. this.txtBarcode.SelectAll();
  275. return;
  276. }
  277. }
  278. // 限制装板数量 add by chenxy 2018-02-27 end
  279. if (this._procedureDataEntity.CollectType == (int)Constant.ProcedureCollectType.Togather)
  280. {
  281. // 校验条码 获取校验条码信
  282. DataSet dsCheckBarcode = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  283. {
  284. return PMModuleProxy.Service.CheckBarcode(this._procedureID, this.txtBarcode.Text.Trim());
  285. }));
  286. if (dsCheckBarcode != null && dsCheckBarcode.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  287. {
  288. if (dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString() != string.Empty)
  289. {
  290. // 表示有错误
  291. //MessageBox.Show(string.Format(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString(), this.txtBarcode.Text.Trim(), "产品条码"),
  292. // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  293. //this.txtBarcode.Focus();
  294. //this.txtBarcode.SelectAll();
  295. //return;
  296. if (dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_missFlag.ToString()].ToString() == "0")
  297. {
  298. // 表示有错误
  299. MessageBox.Show(string.Format(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString(), this.txtBarcode.Text.Trim(), "产品条码"),
  300. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  301. }
  302. else
  303. {
  304. S_CMN_020 frmscmn020 = new S_CMN_020(Convert.ToInt32(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_missFlag.ToString()])
  305. , dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString());
  306. frmscmn020.ShowDialog();
  307. }
  308. this.txtBarcode.Focus();
  309. this.txtBarcode.SelectAll();
  310. return;
  311. }
  312. else
  313. {
  314. ////是否弹出贴标窗口
  315. //if (this._isLogo != 0)
  316. //{
  317. // F_PM_2118 frm2118 = new F_PM_2118(Convert.ToInt32(this._isLogo));
  318. // frm2118.ShowDialog();
  319. // // if (frm2118.DialogResult == DialogResult.OK)
  320. // //{
  321. // this._isLogo = frm2118.LogoID;
  322. // this._isLogoCode = frm2118.LogoCode;
  323. // this._isLogoName = frm2118.LogoName;
  324. // //}
  325. //}
  326. //else
  327. //{
  328. if (dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoID.ToString()].ToString() != "")
  329. {
  330. this._isLogo = Convert.ToInt32(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoID.ToString()]);
  331. this._isLogoCode = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoCode.ToString()].ToString();
  332. this._isLogoName = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoName.ToString()].ToString();
  333. }
  334. // //看看之前工序有没有设置商标
  335. //}
  336. // 集中采集的结束工序(包装装板)验证参数(商标、型号、数量) add by chenxy 2018-02-27 begin
  337. // 集中采集的结束工序(包装装板)验证参数(商标、型号、数量)
  338. if (this._procedureDataEntity.NodeType == 3)
  339. {
  340. // 第一个条码 获取系统参数
  341. if (this.DataSourceTable.Rows.Count == 0)
  342. {
  343. this._logoID = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoID.ToString()].ToString();
  344. this._logoName = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoName.ToString()].ToString();
  345. this._goodsID = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsID.ToString()].ToString();
  346. this._goodsCode = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsCode.ToString()].ToString();
  347. this._goodsModelForCheck = dsCheckBarcode.Tables[0].Rows[0]["goodsModelForCheck"].ToString();
  348. ClientRequestEntity cre = new ClientRequestEntity();
  349. cre.NameSpace = "FinishedLoadingCar";
  350. cre.Name = "GetSetting";
  351. cre.Properties["GoodsID"] = this._goodsID;
  352. ServiceResultEntity sre = PMModuleProxyNew.Service.HandleRequest(cre);
  353. if (sre.Status == Constant.ServiceResultStatus.Success)
  354. {
  355. foreach (DataRow item in sre.Data.Tables[0].Rows)
  356. {
  357. if (item["settingcode"].ToString() == "S_PM_011")
  358. {
  359. this._isEnable_S_PM_011 = item["settingvalue"].ToString();
  360. }
  361. else if (item["settingcode"].ToString() == "S_PM_012")
  362. {
  363. this._isEnable_S_PM_012 = item["settingvalue"].ToString();
  364. }
  365. else if (item["settingcode"].ToString() == "S_PM_013")
  366. {
  367. this._isEnable_S_PM_013 = item["settingvalue"].ToString();
  368. }
  369. }
  370. }
  371. // 设置装板数量
  372. if (this._isEnable_S_PM_013 == "1" && this._isEnable_S_PM_012 == "1" && !string.IsNullOrEmpty(dsCheckBarcode.Tables[0].Rows[0]["PlateLimitNum"]+""))
  373. {
  374. this._maxPlateLimitNum = Convert.ToInt32(dsCheckBarcode.Tables[0].Rows[0]["PlateLimitNum"]);
  375. this._maxPlateLimitNumNew = Convert.ToInt32(dsCheckBarcode.Tables[0].Rows[0]["PlateLimitNumNew"]);
  376. }
  377. else
  378. {
  379. this._maxPlateLimitNum = 0;
  380. this._maxPlateLimitNumNew = 0;
  381. }
  382. }
  383. // 后续条码
  384. else
  385. {
  386. #region 启用限制同商标
  387. if (this._isEnable_S_PM_011 == "1")
  388. {
  389. if (dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoID.ToString()].ToString()
  390. != this._logoID)
  391. {
  392. MessageBox.Show("此产品【" + this.txtBarcode.Text.Trim() + "】的商标【"
  393. + dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoName.ToString()]
  394. + "】与此批次商标【" + this._logoName + "】不同,不能进行该操作。",
  395. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  396. this.txtBarcode.Focus();
  397. this.txtBarcode.SelectAll();
  398. return;
  399. }
  400. }
  401. #endregion
  402. #region 启用限制同型号
  403. if (this._isEnable_S_PM_012 == "1")
  404. {
  405. if (dsCheckBarcode.Tables[0].Rows[0]["goodsModelForCheck"].ToString()
  406. != this._goodsModelForCheck)
  407. {
  408. MessageBox.Show("此产品【" + this.txtBarcode.Text.Trim() + "】的型号【"
  409. + dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsCode.ToString()]
  410. + "】与此批次型号【" + this._goodsCode + "】不同,不能进行该操作。 ",
  411. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  412. this.txtBarcode.Focus();
  413. this.txtBarcode.SelectAll();
  414. return;
  415. }
  416. }
  417. #endregion
  418. }
  419. }
  420. // 集中采集的结束工序(包装装板)验证参数(商标、型号、数量) add by chenxy 2018-02-27 end
  421. int PublicNormal = (int)Constant.PublicBodyFlag.No;
  422. // 生产数据实体
  423. ProductionDataEntity procedureDataEntity = new ProductionDataEntity();
  424. procedureDataEntity.Barcode = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_barcode.ToString()].ToString();// txtBarcode.Text.Trim(); // 产品条码
  425. procedureDataEntity.CentralizedBatchNo = System.Guid.NewGuid().ToString().ToUpper();// 集中采集批次号
  426. procedureDataEntity.ProductionLineID = this._procedureDataEntity.ProductionLineID;// 生产线ID
  427. procedureDataEntity.ProductionLineCode = this._procedureDataEntity.ProductionlineCode;// 生产编码
  428. procedureDataEntity.ProductionLineName = this._procedureDataEntity.ProductionlineName;// 生产名称
  429. procedureDataEntity.CompleteProcedureID = this._procedureID;// 工序ID
  430. procedureDataEntity.ProcedureCode = this._procedureDataEntity.ProcedureCode;// 工序编码
  431. procedureDataEntity.ProcedureName = this._procedureDataEntity.ProcedureName;// 工序名称
  432. procedureDataEntity.ProcedureModel = Convert.ToInt32(this._procedureDataEntity.ProcedureModel);// 工序模型
  433. procedureDataEntity.ModelType = this._procedureDataEntity.ModelType;// 工序模型类别
  434. procedureDataEntity.PieceType = Convert.ToInt32(this._procedureDataEntity.PieceType);// 计件模式
  435. procedureDataEntity.IsReworked = Convert.ToInt32(this._procedureDataEntity.IsSpecialRework); // 是否是返工
  436. procedureDataEntity.NodeType = Convert.ToInt32(this._procedureDataEntity.NodeType); // 工序结点类型
  437. procedureDataEntity.IsPublicBody = PublicNormal;
  438. procedureDataEntity.OrganizationID = this._procedureDataEntity.OrganizationID; // 组织机构
  439. procedureDataEntity.GoodsID = Convert.ToInt32(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsID.ToString()]);
  440. procedureDataEntity.GoodsCode = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsCode.ToString()].ToString();
  441. procedureDataEntity.GoodsName = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsName.ToString()].ToString();
  442. procedureDataEntity.UserID = UserID;
  443. procedureDataEntity.UserCode = UserCode;
  444. procedureDataEntity.UserName = UserName;
  445. procedureDataEntity.ValueFlag = 1;
  446. procedureDataEntity.Remarks = this._procedureDataEntity.Remarks;
  447. //procedureDataEntity.LogoID = this._isLogo;
  448. if (this._procedureDataEntity.CollectType == (int)Constant.ProcedureCollectType.SinglePoint) // 单点采集 直接保存
  449. {
  450. this.CollectTypeTwo(procedureDataEntity, dsCheckBarcode);
  451. }
  452. else
  453. {
  454. this.CollectTypeOne(procedureDataEntity, Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserCode, dsCheckBarcode); // 集中采集
  455. }
  456. this.txtBarcode.Text = string.Empty;
  457. this.txtBarcode.Focus();
  458. }
  459. }
  460. }
  461. else
  462. {
  463. //单点采集
  464. int PublicNormal = (int)Constant.PublicBodyFlag.No;
  465. // 生产数据实体
  466. ProductionDataEntity procedureDataEntity = new ProductionDataEntity();
  467. procedureDataEntity.Barcode = txtBarcode.Text.Trim(); // 产品条码
  468. procedureDataEntity.CentralizedBatchNo = System.Guid.NewGuid().ToString().ToUpper();// 集中采集批次号
  469. procedureDataEntity.ProductionLineID = this._procedureDataEntity.ProductionLineID;// 生产线ID
  470. procedureDataEntity.ProductionLineCode = this._procedureDataEntity.ProductionlineCode;// 生产编码
  471. procedureDataEntity.ProductionLineName = this._procedureDataEntity.ProductionlineName;// 生产名称
  472. procedureDataEntity.CompleteProcedureID = this._procedureID;// 工序ID
  473. procedureDataEntity.ProcedureCode = this._procedureDataEntity.ProcedureCode;// 工序编码
  474. procedureDataEntity.ProcedureName = this._procedureDataEntity.ProcedureName;// 工序名称
  475. procedureDataEntity.ProcedureModel = Convert.ToInt32(this._procedureDataEntity.ProcedureModel);// 工序模型
  476. procedureDataEntity.ModelType = this._procedureDataEntity.ModelType;// 工序模型类别
  477. procedureDataEntity.PieceType = Convert.ToInt32(this._procedureDataEntity.PieceType);// 计件模式
  478. procedureDataEntity.IsReworked = Convert.ToInt32(this._procedureDataEntity.IsSpecialRework); // 是否是返工
  479. procedureDataEntity.NodeType = Convert.ToInt32(this._procedureDataEntity.NodeType); // 工序结点类型
  480. procedureDataEntity.IsPublicBody = PublicNormal;
  481. procedureDataEntity.OrganizationID = this._procedureDataEntity.OrganizationID; // 组织机构
  482. //procedureDataEntity.GoodsID = Convert.ToInt32(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsID.ToString()]);
  483. //procedureDataEntity.GoodsCode = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsCode.ToString()].ToString();
  484. //procedureDataEntity.GoodsName = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsName.ToString()].ToString();
  485. procedureDataEntity.UserID = UserID;
  486. procedureDataEntity.UserCode = UserCode;
  487. procedureDataEntity.UserName = UserName;
  488. procedureDataEntity.ValueFlag = 1;
  489. procedureDataEntity.Remarks = this._procedureDataEntity.Remarks;
  490. procedureDataEntity.LogoID = this._isLogo;
  491. #region 单点采集
  492. // 添加行就可以 并保存
  493. // 保存到数据库
  494. DataSourceCollectTypeTable.Rows.Clear();
  495. DataRow drCollectType = DataSourceCollectTypeTable.NewRow();
  496. drCollectType["BarCode"] = procedureDataEntity.Barcode;
  497. //drCollectType["IsPublicBody"] = dsGroutingProduct.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_ispublicbody.ToString()].ToString() != "1" ? 0 : 1;
  498. drCollectType["UserID"] = UserID;
  499. drCollectType["UserCode"] = UserCode;
  500. drCollectType["UserName"] = UserName;
  501. DataSourceCollectTypeTable.Rows.Add(drCollectType);
  502. DataTable returnString = (DataTable)DoAsync(new BaseAsyncMethod(() =>
  503. {
  504. return PMModuleProxy.Service.AddWorkPiece(this._procedureID, DataSourceCollectTypeTable);
  505. }
  506. ));
  507. if (returnString.Rows.Count <= Constant.INT_IS_ZERO)
  508. {
  509. // 提示信息
  510. MessageBox.Show(Messages.MSG_PM_W012,
  511. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  512. return;
  513. }
  514. else
  515. {
  516. if (string.IsNullOrEmpty(returnString.Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString()))//成功
  517. {
  518. this.txtBarcode.Text = "";
  519. // 单点采集成功后不需要提示
  520. // 提示信息
  521. //MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "新增" + this.Text, "保存"),
  522. // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  523. }
  524. else
  525. {
  526. if (returnString.Rows[0][Constant.BarCodeResultTableColumns.out_missFlag.ToString()].ToString() == "0")
  527. {
  528. // 表示有错误
  529. MessageBox.Show(string.Format(returnString.Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString(), this.txtBarcode.Text.Trim(), "产品条码"),
  530. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  531. }
  532. else
  533. {
  534. S_CMN_020 frmscmn020 = new S_CMN_020(Convert.ToInt32(returnString.Rows[0][Constant.BarCodeResultTableColumns.out_missFlag.ToString()])
  535. , returnString.Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString());
  536. frmscmn020.ShowDialog();
  537. }
  538. this.txtBarcode.Focus();
  539. this.txtBarcode.SelectAll();
  540. return;
  541. //// 提示信息
  542. //MessageBox.Show(string.Format(returnString.Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString()),
  543. // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  544. //return;
  545. }
  546. }
  547. DataRow dr = this.DataSourceTable.NewRow();
  548. dr["BarCode"] = returnString.Rows[0][Constant.BarCodeResultTableColumns.out_barcode.ToString()];// procedureDataEntity.Barcode;
  549. dr["GoodsCode"] = returnString.Rows[0][Constant.BarCodeResultTableColumns.out_goodsCode.ToString()]; //procedureDataEntity.GoodsCode;
  550. dr["GoodsName"] = returnString.Rows[0][Constant.BarCodeResultTableColumns.out_goodsName.ToString()];// procedureDataEntity.GoodsName;
  551. dr["ProductionLineCode"] = procedureDataEntity.ProductionLineCode;
  552. dr["ProcedureModel"] = procedureDataEntity.ProcedureModel == (int)Constant.ProcedureModel.Piece ? "计数模型" : "检验模型";
  553. dr["ModelType"] = procedureDataEntity.ModelType;
  554. dr["PieceType"] = procedureDataEntity.PieceType == (int)Constant.ProcedurePieceType.NoPiece ? "不计件"
  555. : "同工种策略";
  556. dr["IsReworked"] = procedureDataEntity.IsReworked == (int)Constant.SpecialReworkFlag.Yes ? "是" : "否";
  557. //dr["IsPublicBody"] = procedureDataEntity.IsPublicBody;
  558. dr["OrganizationName"] = string.Empty;
  559. dr["Remarks"] = procedureDataEntity.Remarks;
  560. dr["UserCode"] = this.txtUserCode.Text.Trim();
  561. dr["BarCodeUserCode"] = returnString.Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()]; //Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserCode;
  562. dr["MouldCode"] = returnString.Rows[0][Constant.BarCodeResultTableColumns.out_mouldCode.ToString()];
  563. dr["GroutingUserCode"] = returnString.Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()];
  564. dr["GroutingNum"] = returnString.Rows[0][Constant.BarCodeResultTableColumns.out_groutingNum.ToString()];
  565. dr["IsPublicBody"] = returnString.Rows[0][Constant.BarCodeResultTableColumns.out_ispublicbody.ToString()].ToString() != "1" ? 0 : 1;
  566. dr["GroutingDate"] = Convert.ToDateTime(returnString.Rows[0][Constant.BarCodeResultTableColumns.out_groutingdate.ToString()]);
  567. dr["LogoID"] = this._isLogo;
  568. // dr["LogoCodeName"] = this._isLogoCode + "[" + this._isLogoName + "]";
  569. dr["LogoCodeName"] = returnString.Rows[0][Constant.BarCodeResultTableColumns.out_logoName.ToString()] + "[" + returnString.Rows[0][Constant.BarCodeResultTableColumns.out_logoCode.ToString()] + "]";
  570. this.DataSourceTable.Rows.Add(dr);
  571. this.dgvProduction.CurrentCell = null;
  572. this.dgvProduction.Rows[dgvProduction.RowCount - 1].Selected = true;
  573. this.dgvProduction.CurrentCell = this.dgvProduction.Rows[dgvProduction.RowCount - 1].Cells[0];
  574. #endregion
  575. #region 打印条码
  576. if (this._procedureDataEntity.BarCodePrintCopies > 0)
  577. {
  578. bool result = Dongke.IBOSS.PRD.Client.Controls.F_MST_012006.PrintBarcode(
  579. procedureDataEntity.Barcode,
  580. this._procedureDataEntity.BarCodePrintCopies,
  581. this);
  582. }
  583. #endregion
  584. }
  585. }
  586. else
  587. {
  588. this.txtBarcode.Text = "";
  589. }
  590. }
  591. }
  592. catch (Exception ex)
  593. {
  594. // 对异常进行共通处理
  595. ExceptionManager.HandleEventException(this.ToString(),
  596. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  597. }
  598. }
  599. /// <summary>
  600. /// 窗体加载事件
  601. /// </summary>
  602. /// <param name="sender"></param>
  603. /// <param name="e"></param>
  604. private void F_PM_0302_Load(object sender, EventArgs e)
  605. {
  606. try
  607. {
  608. this.dgvProduction.AutoGenerateColumns = false;
  609. this.dgvProduction.DataSource = DataSourceTable;
  610. // 加载权限
  611. FormPermissionManager.FormPermissionControl(this.Name, this,
  612. Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
  613. Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  614. // 获取工序明细数据
  615. ProcedureEntity procedureDataEntity = (ProcedureEntity)DoAsync(new BaseAsyncMethod(() =>
  616. {
  617. return PMModuleProxy.Service.GetProcedureDataEntityByID(this._procedureID);
  618. }));
  619. this._procedureDataEntity = procedureDataEntity;
  620. // 设置控件禁用或启用
  621. SetControlEnable();
  622. //// 是否有商标
  623. //int logoid = (int)DoAsync(new BaseAsyncMethod(() =>
  624. //{
  625. // return PMModuleProxy.Service.GetLogoID(this._procedureID);
  626. //}));
  627. //this._isLogo = logoid;
  628. }
  629. catch (Exception ex)
  630. {
  631. // 对异常进行共通处理
  632. ExceptionManager.HandleEventException(this.ToString(),
  633. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  634. }
  635. }
  636. /// <summary>
  637. /// 删除按钮事件
  638. /// </summary>
  639. /// <param name="sender"></param>
  640. /// <param name="e"></param>
  641. private void tsbtnDelete_Click(object sender, EventArgs e)
  642. {
  643. if (this.dgvProduction.CurrentCell != null)
  644. {
  645. this.DataSourceTable.Rows[this.dgvProduction.CurrentCell.RowIndex].Delete();
  646. }
  647. }
  648. /// <summary>
  649. /// 保存按钮事件
  650. /// </summary>
  651. /// <param name="sender"></param>
  652. /// <param name="e"></param>
  653. private void btnSave_Click(object sender, EventArgs e)
  654. {
  655. try
  656. {
  657. this.DataSourceTable.AcceptChanges();
  658. // 限制装板数量 add by chenxy 2018-02-27 begin
  659. if (string.IsNullOrEmpty(txtBanMa.Text.Trim()))
  660. {
  661. if (this._maxPlateLimitNum > 0 && this.DataSourceTable.Rows.Count != this._maxPlateLimitNum)
  662. {
  663. MessageBox.Show("未达到装板数量【" + this._maxPlateLimitNum + "】",
  664. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  665. return;
  666. }
  667. }
  668. else
  669. {
  670. if (this._maxPlateLimitNumNew > 0 && this.DataSourceTable.Rows.Count != this._maxPlateLimitNumNew)
  671. {
  672. MessageBox.Show("未达到装板数量【" + this._maxPlateLimitNumNew + "】",
  673. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  674. return;
  675. }
  676. }
  677. // 限制装板数量 add by chenxy 2018-02-27 end
  678. this.DataSourceCollectTypeTable.Clear();
  679. if (this.DataSourceTable.Rows.Count > Constant.INT_IS_ZERO)
  680. {
  681. foreach (DataRow drproductionData in this.DataSourceTable.Rows)
  682. {
  683. DataRow drCollectType = DataSourceCollectTypeTable.NewRow();
  684. drCollectType["BarCode"] = drproductionData["BarCode"];
  685. // drCollectType["IsPublicBody"] = drproductionData["IsPublicBody"].ToString() != "1" ? 0 : 1;
  686. drCollectType["UserID"] = UserID;
  687. drCollectType["UserCode"] = UserCode;
  688. drCollectType["UserName"] = UserName;
  689. drCollectType["LogoID"] = drproductionData["LogoID"];
  690. drCollectType["BanMa"] = txtBanMa.Text.Trim();
  691. DataSourceCollectTypeTable.Rows.Add(drCollectType);
  692. }
  693. DataTable returnRow = (DataTable)DoAsync(new BaseAsyncMethod(() =>
  694. {
  695. return PMModuleProxy.Service.AddWorkPiece(this._procedureID, DataSourceCollectTypeTable);
  696. }));
  697. if (returnRow.Rows.Count <= Constant.INT_IS_ZERO)
  698. {
  699. // 提示信息
  700. MessageBox.Show(Messages.MSG_PM_W012,
  701. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  702. }
  703. else
  704. {
  705. if (string.IsNullOrEmpty(returnRow.Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString()))//成功
  706. {
  707. // 提示信息
  708. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "新增" + this.Text, "保存"),
  709. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  710. }
  711. else
  712. {
  713. // 提示信息
  714. MessageBox.Show(string.Format(returnRow.Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString()),
  715. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  716. return;
  717. }
  718. }
  719. txtBanMa.Text = "";
  720. this.txtBarcode.Text = "";
  721. this._productionDataEntity.Clear();
  722. this.DataSourceTable.Rows.Clear();
  723. if (this._procedureDataEntity.CollectType == (int)Constant.ProcedureCollectType.Togather)
  724. {
  725. this.txtUserCode.Text = "";
  726. this.txtUserCode.Focus();
  727. this.txtUserCode.ReadOnly = false;
  728. }
  729. else
  730. {
  731. this.txtBarcode.Focus();
  732. }
  733. this._maxPlateLimitNum = 0;
  734. this._maxPlateLimitNumNew = 0;
  735. this._logoID = null;
  736. this._logoName = null;
  737. this._goodsID = null;
  738. this._goodsCode = null;
  739. this._goodsModelForCheck = null;
  740. #region 打印条码
  741. if (this._procedureDataEntity.BarCodePrintCopies > 0)
  742. {
  743. foreach (DataRow item in DataSourceCollectTypeTable.Rows)
  744. {
  745. bool result = Dongke.IBOSS.PRD.Client.Controls.F_MST_012006.PrintBarcode(
  746. item["Barcode"].ToString(),
  747. this._procedureDataEntity.BarCodePrintCopies,
  748. this);
  749. }
  750. }
  751. #endregion
  752. }
  753. }
  754. catch (Exception ex)
  755. {
  756. // 对异常进行共通处理
  757. ExceptionManager.HandleEventException(this.ToString(),
  758. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  759. }
  760. }
  761. /// <summary>
  762. /// 控件数据校验时发生
  763. /// </summary>
  764. /// <param name="sender"></param>
  765. /// <param name="e"></param>
  766. private void txtUserCode_Validating(object sender, System.ComponentModel.CancelEventArgs e)
  767. {
  768. try
  769. {
  770. if (txtUserCode.Text.Trim() == string.Empty) // 如果未添加数据,则此项获取焦点
  771. {
  772. this.txtUserCode.IsMustInput = true;
  773. this.txtUserCode.SelectAll();
  774. e.Cancel = true;
  775. return;
  776. }
  777. else if (!this.txtUserCode.ReadOnly)
  778. {
  779. SUserEntity userEntity = new SUserEntity();
  780. userEntity.UserCode = this.txtUserCode.Text.Trim();
  781. // 此工号是否能生产工序
  782. CheckProcedureUserResult MsgCheckProcedureUser = (CheckProcedureUserResult)DoAsync(new BaseAsyncMethod(() =>
  783. {
  784. return PMModuleProxy.Service.CheckProcedureUser(this._procedureID, this.txtUserCode.Text.Trim());
  785. }));
  786. if (MsgCheckProcedureUser != null)
  787. {
  788. if (MsgCheckProcedureUser.ErrMsg != null)
  789. {
  790. MessageBox.Show(MsgCheckProcedureUser.ErrMsg,
  791. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  792. this.txtUserCode.SelectAll();
  793. e.Cancel = true;
  794. return;
  795. }
  796. if (UserID != -Constant.INT_IS_ONE)
  797. {
  798. if (MsgCheckProcedureUser.UserID != UserID)
  799. {
  800. btnSave_Click(sender, e);
  801. }
  802. }
  803. UserID = Convert.ToInt32(MsgCheckProcedureUser.UserID);
  804. UserCode = MsgCheckProcedureUser.UserCode;
  805. UserName = MsgCheckProcedureUser.UserName;
  806. this.txtUserCode.ReadOnly = true;
  807. }
  808. }
  809. }
  810. catch (Exception ex)
  811. {
  812. // 对异常进行共通处理
  813. ExceptionManager.HandleEventException(this.ToString(),
  814. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  815. }
  816. }
  817. /// <summary>
  818. /// 自动适应列宽
  819. /// </summary>
  820. /// <param name="sender"></param>
  821. /// <param name="e"></param>
  822. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  823. {
  824. this.dgvProduction.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  825. }
  826. /// <summary>
  827. /// 窗体关闭时事件
  828. /// </summary>
  829. /// <param name="sender"></param>
  830. /// <param name="e"></param>
  831. private void F_PM_0302_FormClosing(object sender, FormClosingEventArgs e)
  832. {
  833. if (this.btnSave.Visible)
  834. {
  835. try
  836. {
  837. this.DataSourceTable.AcceptChanges();
  838. this.DataSourceCollectTypeTable.Clear();
  839. if (this.DataSourceTable.Rows.Count > Constant.INT_IS_ZERO)
  840. {
  841. DialogResult result = MessageBox.Show(Messages.MSG_CMN_Q001, this.Text,
  842. MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
  843. if (result == DialogResult.Yes)
  844. {
  845. // 保存数据
  846. btnSave_Click(sender, e);
  847. }
  848. else if (result == DialogResult.Cancel)
  849. {
  850. e.Cancel = true;
  851. }
  852. }
  853. }
  854. catch (Exception ex)
  855. {
  856. // 对异常进行共通处理
  857. ExceptionManager.HandleEventException(this.ToString(),
  858. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  859. }
  860. }
  861. }
  862. /// <summary>
  863. /// 鼠标单击事件
  864. /// </summary>
  865. /// <param name="sender"></param>
  866. /// <param name="e"></param>
  867. private void txtUserCode_MouseClick(object sender, MouseEventArgs e)
  868. {
  869. if (this.txtUserCode.Text.Trim() != string.Empty)
  870. {
  871. this.txtUserCode.SelectAll();
  872. }
  873. }
  874. /// <summary>
  875. /// 生产工号回车事件
  876. /// </summary>
  877. /// <param name="sender"></param>
  878. /// <param name="e"></param>
  879. private void txtUserCode_KeyPress(object sender, KeyPressEventArgs e)
  880. {
  881. if ((int)e.KeyChar == 13) // 按了回车键
  882. {
  883. this.txtBarcode.Focus();
  884. }
  885. }
  886. #endregion
  887. #region 私有方法
  888. /// <summary>
  889. /// 设置控件禁用或启用
  890. /// </summary>
  891. private void SetControlEnable()
  892. {
  893. if (this._procedureDataEntity != null)
  894. {
  895. this.txtCollectType.Text = this._procedureDataEntity.CollectType == (int)Constant.ProcedureCollectType.SinglePoint ? "单点采集" : "集中采集";
  896. if (this._procedureDataEntity.CollectType == (int)Constant.ProcedureCollectType.Togather)
  897. {
  898. this.txtUserCode.Enabled = true;
  899. this.tsbtnDelete.Visible = true;
  900. this.tsbtnDelete.Enabled = true;
  901. this.btnSave.Visible = true;
  902. this.txtUserCode.Focus();
  903. }
  904. else
  905. {
  906. this.txtUserCode.Enabled = true;
  907. this.txtUserCode.ReadOnly = true;
  908. this.dgvProduction.ReadOnly = true;
  909. this.txtBarcode.Focus();
  910. // 此工号是否能生产工序
  911. CheckProcedureUserResult checkProcedureUser = (CheckProcedureUserResult)DoAsync(new BaseAsyncMethod(() =>
  912. {
  913. return PMModuleProxy.Service.CheckProcedureUser(this._procedureID,
  914. Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserCode);
  915. }));
  916. if (checkProcedureUser != null)
  917. {
  918. if (!string.IsNullOrEmpty(checkProcedureUser.ErrMsg))
  919. {
  920. // 此工号不允许生产工序
  921. MessageBox.Show(checkProcedureUser.ErrMsg,
  922. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  923. this.Close();
  924. return;
  925. }
  926. }
  927. UserID = checkProcedureUser.UserID;
  928. UserCode = checkProcedureUser.UserCode;
  929. UserName = checkProcedureUser.UserName;
  930. }
  931. this.txtUserCode.Text = UserCode;
  932. }
  933. }
  934. /// <summary>
  935. /// 单点采集模式
  936. /// </summary>
  937. /// <param name="procedureDataEntity"></param>
  938. private void CollectTypeTwo(ProductionDataEntity procedureDataEntity, DataSet dsGroutingProduct)
  939. {
  940. try
  941. {
  942. //// 由产品条码获取注浆信息
  943. //DataSet dsGroutingProduct = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  944. //{
  945. // return PMModuleProxy.Service.GetGroutingProducttByBarCode(procedureDataEntity.Barcode);
  946. //}));
  947. #region 单点采集
  948. // 添加行就可以 并保存
  949. // 保存到数据库
  950. DataSourceCollectTypeTable.Rows.Clear();
  951. DataRow drCollectType = DataSourceCollectTypeTable.NewRow();
  952. drCollectType["BarCode"] = procedureDataEntity.Barcode;
  953. drCollectType["IsPublicBody"] = dsGroutingProduct.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_ispublicbody.ToString()].ToString() != "1" ? 0 : 1;
  954. drCollectType["UserID"] = UserID;
  955. drCollectType["UserCode"] = UserCode;
  956. drCollectType["UserName"] = UserName;
  957. DataSourceCollectTypeTable.Rows.Add(drCollectType);
  958. DataTable returnString = (DataTable)DoAsync(new BaseAsyncMethod(() =>
  959. {
  960. return PMModuleProxy.Service.AddWorkPiece(this._procedureID, DataSourceCollectTypeTable);
  961. }
  962. ));
  963. if (returnString.Rows.Count <= Constant.INT_IS_ZERO)
  964. {
  965. // 提示信息
  966. MessageBox.Show(Messages.MSG_PM_W012,
  967. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  968. return;
  969. }
  970. else
  971. {
  972. if (string.IsNullOrEmpty(returnString.Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString()))//成功
  973. {
  974. // 单点采集成功后不需要提示
  975. // 提示信息
  976. //MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "新增" + this.Text, "保存"),
  977. // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  978. }
  979. else
  980. {
  981. // 提示信息
  982. MessageBox.Show(string.Format(returnString.Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString()),
  983. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  984. return;
  985. }
  986. }
  987. DataRow dr = this.DataSourceTable.NewRow();
  988. dr["BarCode"] = procedureDataEntity.Barcode;
  989. dr["GoodsCode"] = procedureDataEntity.GoodsCode;
  990. dr["GoodsName"] = procedureDataEntity.GoodsName;
  991. dr["ProductionLineCode"] = procedureDataEntity.ProductionLineCode;
  992. dr["ProcedureModel"] = procedureDataEntity.ProcedureModel == (int)Constant.ProcedureModel.Piece ? "计数模型" : "检验模型";
  993. dr["ModelType"] = procedureDataEntity.ModelType;
  994. dr["PieceType"] = procedureDataEntity.PieceType == (int)Constant.ProcedurePieceType.NoPiece ? "不计件"
  995. : "同工种策略";
  996. dr["IsReworked"] = procedureDataEntity.IsReworked == (int)Constant.SpecialReworkFlag.Yes ? "是" : "否";
  997. //dr["IsPublicBody"] = procedureDataEntity.IsPublicBody;
  998. dr["OrganizationName"] = string.Empty;
  999. dr["Remarks"] = procedureDataEntity.Remarks;
  1000. dr["UserCode"] = this.txtUserCode.Text.Trim();
  1001. dr["BarCodeUserCode"] = dsGroutingProduct.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()]; //Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserCode;
  1002. dr["MouldCode"] = dsGroutingProduct.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_mouldCode.ToString()];
  1003. dr["GroutingUserCode"] = dsGroutingProduct.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()];
  1004. dr["GroutingNum"] = dsGroutingProduct.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingNum.ToString()];
  1005. dr["IsPublicBody"] = dsGroutingProduct.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_ispublicbody.ToString()].ToString() != "1" ? 0 : 1;
  1006. dr["GroutingDate"] = Convert.ToDateTime(dsGroutingProduct.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingdate.ToString()]);
  1007. this.DataSourceTable.Rows.Add(dr);
  1008. this.dgvProduction.CurrentCell = null;
  1009. this.dgvProduction.Rows[dgvProduction.RowCount - 1].Selected = true;
  1010. this.dgvProduction.CurrentCell = this.dgvProduction.Rows[dgvProduction.RowCount - 1].Cells[0];
  1011. #endregion
  1012. }
  1013. catch (Exception ex)
  1014. {
  1015. throw ex;
  1016. }
  1017. }
  1018. /// <summary>
  1019. ///集中采集模式
  1020. /// </summary>
  1021. /// <param name="procedureDataEntity"></param>
  1022. private void CollectTypeOne(ProductionDataEntity procedureDataEntity, string barCodeUserCode, DataSet dsGroutingProduct)
  1023. {
  1024. try
  1025. {
  1026. #region 集中采集
  1027. DataRow[] drRows = this.DataSourceTable.Select("BarCode='" + procedureDataEntity.Barcode + "'");
  1028. if (drRows.Length > Constant.INT_IS_ZERO)
  1029. {
  1030. this.txtBarcode.Text = "";
  1031. return;
  1032. }
  1033. //// 由产品条码获取注浆信息
  1034. //DataSet dsGroutingProduct = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  1035. //{
  1036. // return PMModuleProxy.Service.GetGroutingProducttByBarCode(procedureDataEntity.Barcode);
  1037. //}));
  1038. DataRow dr = this.DataSourceTable.NewRow();
  1039. dr["BarCode"] = procedureDataEntity.Barcode;
  1040. dr["GoodsCode"] = procedureDataEntity.GoodsCode;
  1041. dr["GoodsName"] = procedureDataEntity.GoodsName;
  1042. dr["ProductionLineCode"] = procedureDataEntity.ProductionLineCode;
  1043. dr["ProcedureModel"] = procedureDataEntity.ProcedureModel == (int)Constant.ProcedureModel.Piece ? "计数模型" : "检验模型";
  1044. dr["ModelType"] = procedureDataEntity.ModelType;
  1045. dr["PieceType"] = procedureDataEntity.PieceType == (int)Constant.ProcedurePieceType.NoPiece ? "不计件"
  1046. : "同工种策略";
  1047. dr["IsReworked"] = procedureDataEntity.IsReworked == (int)Constant.SpecialReworkFlag.Yes ? "是" : "否";
  1048. //dr["IsPublicBody"] = procedureDataEntity.IsPublicBody;
  1049. dr["OrganizationName"] = string.Empty;
  1050. dr["Remarks"] = procedureDataEntity.Remarks;
  1051. dr["UserCode"] = this.txtUserCode.Text.Trim();
  1052. dr["UserID"] = procedureDataEntity.UserID;
  1053. dr["BarCodeUserCode"] = dsGroutingProduct.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()];// barCodeUserCode;
  1054. dr["MouldCode"] = dsGroutingProduct.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_mouldCode.ToString()];
  1055. dr["GroutingUserCode"] = dsGroutingProduct.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()];
  1056. dr["GroutingNum"] = dsGroutingProduct.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingNum.ToString()];
  1057. dr["IsPublicBody"] = dsGroutingProduct.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_ispublicbody.ToString()].ToString() != "1" ? 0 : 1;
  1058. dr["GroutingDate"] = Convert.ToDateTime(dsGroutingProduct.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingdate.ToString()]);
  1059. dr["LogoID"] = procedureDataEntity.LogoID;
  1060. dr["LogoCodeName"] = this._isLogoName + "[" + this._isLogoCode + "]";
  1061. this.DataSourceTable.Rows.Add(dr);
  1062. this.dgvProduction.CurrentCell = null;
  1063. this.dgvProduction.Rows[dgvProduction.RowCount - 1].Selected = true;
  1064. this.dgvProduction.CurrentCell = this.dgvProduction.Rows[dgvProduction.RowCount - 1].Cells[0];
  1065. #endregion
  1066. }
  1067. catch (Exception ex)
  1068. {
  1069. throw ex;
  1070. }
  1071. }
  1072. #endregion
  1073. }
  1074. }