F_PM_0402.cs 56 KB

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