F_PM_1107.cs 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134
  1. /*******************************************************************************
  2. * 类的信息:
  3. * 1.程序名称:F_PM_1107.cs
  4. * 2.功能描述:批量报废信息窗体
  5. * 编辑履历:
  6. * 作者 日期
  7. * 李士越 2024/05/29
  8. *******************************************************************************/
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Data;
  12. using System.Windows.Forms;
  13. using Dongke.IBOSS.PRD.Basics.BaseResources;
  14. using Dongke.IBOSS.PRD.WCF.Proxys;
  15. using Dongke.IBOSS.PRD.WCF.Proxys.PMModuleService;
  16. using Dongke.IBOSS.PRD.Client.CommonModule;
  17. using Dongke.IBOSS.PRD.Basics.BaseControls;
  18. using Dongke.IBOSS.PRD.Basics.Library;
  19. using Dongke.IBOSS.PRD.WCF.DataModels;
  20. using Dongke.IBOSS.PRD.Client.Controls;
  21. namespace Dongke.IBOSS.PRD.Client.PMModule
  22. {
  23. /// <summary>
  24. /// 批量报废信息窗体
  25. /// </summary>
  26. public partial class F_PM_1107 : DKFormBase
  27. {
  28. #region 成员变量
  29. //窗体模式ID
  30. private Constant.FormMode _formType;
  31. //修改产品报损信息ID
  32. private string _barCode;
  33. //页面报损工序的数据源
  34. private List<ProductionDataEntity> _productionDataList = new List<ProductionDataEntity>();
  35. //该产品在产信息实体
  36. private InProductionEntity _isScrapProductEntity;
  37. //用户选择报损工序实体
  38. private ProductionDataEntity _scrapProductResponProcedure;
  39. //当前责任人集合
  40. private List<ScrapResponsibleEntity> _scrapResponsibleList = new List<ScrapResponsibleEntity>();
  41. //修改用废弃产品实体
  42. private ScrapProductEntity _updateEntity;
  43. //修改用废弃责任工序实体
  44. private ResponProcedureEntity _updateProcedureEntity;
  45. //修改用责任人集合
  46. private List<ScrapResponsibleEntity> _updateScrapResponsibleList;
  47. //有效条码标示
  48. private bool _yxBarCode = false;
  49. //产品分级类别ID
  50. private int _goodsLevelTypeID = Convert.ToInt32(Constant.GoodsLevelType.Damage);
  51. //产品分级ID
  52. private int _goodsLevelId;
  53. //报损信息ID
  54. private int _editSPId;
  55. //是否允许审批
  56. private bool _isScrap = false;
  57. //未干补
  58. int SpecialRepairFlag = 0;
  59. //完成工序
  60. int? _CompleteProcdureID = null;
  61. //完成工序编码
  62. string _CompleteProcdureCode = "";
  63. //完成工序名称
  64. string _CompleteProcdureName = "";
  65. // 商标ID
  66. int? _LogoID = null;
  67. //可以报损的产品条码集合
  68. List<string> ReportingLosses = new List<string>();
  69. // 可成型报损产品条码
  70. Dictionary<string, DataRow> GroutingScrapProducts = new Dictionary<string, DataRow>();
  71. DataRow _barCodeRow = null;
  72. #endregion
  73. #region 构造函数
  74. /// <summary>
  75. /// 窗体构造
  76. /// </summary>
  77. public F_PM_1107(Constant.FormMode formType, string BarCode, int EditSPId, bool isScrap)
  78. {
  79. InitializeComponent();
  80. this._formType = formType;
  81. this._barCode = BarCode;
  82. this._editSPId = EditSPId;
  83. this._isScrap = isScrap;
  84. //if (formType == Constant.FormMode.Add)
  85. //{
  86. this.Text = "批量报损";
  87. //}
  88. //else
  89. //{
  90. // this.Text = FormTitles.F_PM_1107_EDIT;
  91. //}
  92. //this.btnViewApprover.Text = ButtonText.BTN_VIEWAPPROVER;
  93. this.btnSave.Text = ButtonText.BTN_SAVE;
  94. this.btnCancel.Text = ButtonText.BTN_CLOSE;
  95. }
  96. #endregion
  97. #region 事件
  98. /// <summary>
  99. /// 窗体加载
  100. /// </summary>
  101. /// <param name="sender"></param>
  102. /// <param name="e"></param>
  103. private void F_PM_1107_Load(object sender, EventArgs e)
  104. {
  105. try
  106. {
  107. //获取当前产品分级ID
  108. this._goodsLevelId = Convert.ToInt32(SystemModuleProxy.Service.GetGoodsLevelDataById(_goodsLevelTypeID, null)
  109. .Tables[0].Rows[0]["GoodsLevelID"]);
  110. DataTable dt = new DataTable();
  111. dt.Columns.Add("DictionaryID", typeof(int));
  112. dt.Columns.Add("DictionaryValue", typeof(string));
  113. DataRow drbydt = dt.NewRow();
  114. drbydt["DictionaryID"] = 119;
  115. drbydt["DictionaryValue"] = "盘点报损";
  116. dt.Rows.Add(drbydt);
  117. this.cmbRreason.DisplayMember = "DictionaryValue";
  118. this.cmbRreason.ValueMember = "DictionaryID";
  119. this.cmbRreason.DataSource = dt;
  120. //绑定损坯状态
  121. DataTable dtAuditStatus = new DataTable();
  122. dtAuditStatus.Columns.Add("AuditStatusID");
  123. dtAuditStatus.Columns.Add("AuditStatusValue");
  124. DataRow dr = dtAuditStatus.NewRow();
  125. dr = dtAuditStatus.NewRow();
  126. dr["AuditStatusID"] = 1;
  127. dr["AuditStatusValue"] = "损坯通过";
  128. dtAuditStatus.Rows.Add(dr);
  129. this.cmbAuditStatus.DisplayMember = "AuditStatusValue";
  130. this.cmbAuditStatus.ValueMember = "AuditStatusID";
  131. this.cmbAuditStatus.DataSource = dtAuditStatus;
  132. if (this._formType == Constant.FormMode.Edit)
  133. {
  134. BindEntity();
  135. }
  136. }
  137. catch (Exception ex)
  138. {
  139. // 对异常进行共通处理
  140. ExceptionManager.HandleEventException(this.ToString(),
  141. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  142. }
  143. }
  144. /// <summary>
  145. /// 提交操作
  146. /// </summary>
  147. /// <param name="sender"></param>
  148. /// <param name="e"></param>
  149. private void btnSave_Click(object sender, EventArgs e)
  150. {
  151. try
  152. {
  153. if (this.txtBarCode.Text == string.Empty)
  154. {
  155. this.txtBarCode.Focus();
  156. return;
  157. }
  158. //模拟回车
  159. KeyPressEventArgs args = new KeyPressEventArgs('\r');
  160. //条码校验防止重复报损
  161. txtBarCode_KeyPress(sender, args);
  162. this.txtRemarks.Focus();//把光标移开,由于删除工号后,值未变
  163. //if (ReportingLosses.Count == 0)
  164. //{
  165. // MessageBox.Show("未有可报损条码",
  166. // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  167. //}
  168. //this.txtRemarks.Focus();//把光标移开,由于删除工号后,值未变
  169. DataTable dt = new DataTable();
  170. //备注
  171. dt.Columns.Add("notes");
  172. //产品编码
  173. dt.Columns.Add("ProductCode");
  174. // 成型报损
  175. foreach (var item in GroutingScrapProducts.Keys)
  176. {
  177. DataRow dr = dt.NewRow();
  178. dr["notes"] = saveGroutingScrapProducts(item);
  179. dr["ProductCode"] = item;
  180. dt.Rows.Add(dr);
  181. }
  182. // 产品报损
  183. foreach (var item in ReportingLosses) {
  184. DataRow dr = dt.NewRow();
  185. dr["notes"] = save(item);
  186. dr["ProductCode"] = item;
  187. dt.Rows.Add(dr);
  188. }
  189. this.detailsView.DataSource = dt;
  190. }
  191. catch (Exception ex)
  192. {
  193. // 对异常进行共通处理
  194. ExceptionManager.HandleEventException(this.ToString(),
  195. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  196. }
  197. }
  198. private string saveGroutingScrapProducts(string barcode)
  199. {
  200. try
  201. {
  202. _barCodeRow = GroutingScrapProducts[barcode];
  203. int ResponUserID = Convert.ToInt32(_barCodeRow["GroutingUserID"]);
  204. string ResponUserCode = _barCodeRow["GroutingUserCode"] + "";
  205. // 校验数据
  206. DataSet dsUser = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  207. {
  208. return HRModuleProxy.Service.SearchHrStaffInfo(ResponUserID);
  209. }));
  210. if (dsUser != null && dsUser.Tables.Count > 0)
  211. {
  212. //DataTable returnTable = dsUser.Tables[0];
  213. //if (!returnTable.Columns.Contains("UserSelected"))
  214. //{
  215. // returnTable.Columns.Add("UserSelected", typeof(int));
  216. //}
  217. //foreach (DataRow row in returnTable.Rows)
  218. //{
  219. // row["UserSelected"] = 1;
  220. //}
  221. }
  222. else
  223. {
  224. return string.Format(Messages.W_CMN_C_003, "责任员工");
  225. }
  226. // 给实体赋值
  227. ClientRequestEntity cre = new ClientRequestEntity();
  228. cre.NameSpace = "GroutingScrapProduct";
  229. cre.Name = "SaveGroutingScrapProduct";
  230. // 产品条码
  231. cre.Properties["BarCode"] = _barCodeRow["BarCode"];
  232. // 产品ID
  233. cre.Properties["GoodsID"] = _barCodeRow["GoodsID"];
  234. // 产品编码
  235. cre.Properties["GoodsCode"] = _barCodeRow["GoodsCode"];
  236. // 产品名称
  237. cre.Properties["GoodsName"] = _barCodeRow["GoodsName"];
  238. // 注浆日报ID
  239. cre.Properties["GroutingDailyID"] = _barCodeRow["GroutingDailyID"];
  240. // 注浆日报明细ID
  241. cre.Properties["GroutingDailyDetailID"] = _barCodeRow["GroutingDailyDetailID"];
  242. // 注浆日期
  243. cre.Properties["GroutingDate"] = _barCodeRow["GroutingDate"];
  244. // 成型生产线ID
  245. cre.Properties["GroutingLineID"] = _barCodeRow["GroutingLineID"];
  246. // 成型生产线编码
  247. cre.Properties["GroutingLineCode"] = _barCodeRow["GroutingLineCode"];
  248. // 成型生产线名称
  249. cre.Properties["GroutingLineName"] = _barCodeRow["GroutingLineName"];
  250. // 成型线类型ID
  251. cre.Properties["GMouldTypeID"] = _barCodeRow["GMouldTypeID"];
  252. // 成型生产线明细ID
  253. cre.Properties["GroutingLineDetailID"] = _barCodeRow["GroutingLineDetailID"];
  254. // 注浆模具编号
  255. cre.Properties["GroutingMouldCode"] = _barCodeRow["GroutingMouldCode"];
  256. // 模具编号
  257. cre.Properties["MouldCode"] = _barCodeRow["MouldCode"];
  258. // 注浆工号ID
  259. cre.Properties["GroutingUserID"] = _barCodeRow["GroutingUserID"];
  260. // 注浆工号编码
  261. cre.Properties["GroutingUserCode"] = _barCodeRow["GroutingUserCode"];
  262. // 注浆次数
  263. cre.Properties["GroutingNum"] = _barCodeRow["GroutingNum"];
  264. // 报损类型
  265. cre.Properties["ScrapType"] = "1";
  266. // 损坯日期
  267. cre.Properties["ScrapDate"] = DateTime.Now.ToString("yyyy-MM-dd");
  268. // 报损原因
  269. cre.Properties["ScrapRreasonID"] = 3;
  270. // 责任工号ID
  271. cre.Properties["ResponUserID"] = ResponUserID;
  272. // 责任工号编码
  273. cre.Properties["ResponUserCode"] = ResponUserCode;
  274. // 备注
  275. cre.Properties["Remarks"] = this.txtRemarks.Text.Trim();
  276. // 审核状态
  277. cre.Properties["AuditStatus"] = this.cmbAuditStatus.SelectedValue;
  278. // 责任员工
  279. //DataTable returnTable = this.dgvResponsible.DataSource as DataTable;
  280. //returnTable.AcceptChanges();
  281. //returnTable = returnTable.Copy();
  282. //returnTable.DefaultView.RowFilter = "UserSelected = 1";
  283. //returnTable = returnTable.DefaultView.ToTable();
  284. //cre.Data = new DataSet();
  285. //cre.Data.Tables.Add(returnTable);
  286. cre.Data = dsUser;
  287. ServiceResultEntity result = (ServiceResultEntity)DoAsync(new BaseAsyncMethod(() =>
  288. {
  289. return PMModuleProxyNew.Service.HandleRequest(cre);
  290. }));
  291. int resultRow = (int)result.Result;
  292. if (resultRow > Constant.INT_IS_ZERO)
  293. {
  294. //成功
  295. return string.Format(Messages.MSG_CMN_I001, "成型报损", "保存");
  296. }
  297. else if (resultRow == -99)
  298. {
  299. return string.Format(Messages.W_CMN_C_006, "未查询到该产品信息,请确认该产品是否已经进行注浆");
  300. }
  301. else if (resultRow == -100)
  302. {
  303. return string.Format(Messages.W_CMN_C_006, "该产品还未进行注浆");
  304. }
  305. else if (resultRow == -101)
  306. {
  307. return string.Format(Messages.W_CMN_C_006, "该产品已经交坯");
  308. }
  309. else if (resultRow == -102)
  310. {
  311. return string.Format(Messages.W_CMN_C_006, "该产品已经报损");
  312. }
  313. else
  314. {
  315. //失败
  316. return string.Format(Messages.MSG_CMN_W001, "成型报损", "保存");
  317. }
  318. }
  319. catch (Exception ex)
  320. {
  321. // 对异常进行共通处理
  322. ExceptionManager.HandleEventException(this.ToString(),
  323. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  324. }
  325. return string.Format(Messages.MSG_CMN_W001, "成型报损", "保存");
  326. }
  327. /// <summary>
  328. /// 保存方法
  329. /// </summary>
  330. /// <param name="barcode"></param>
  331. /// <returns></returns>
  332. public string save(string barcode) {
  333. string result = "";
  334. try
  335. {
  336. if (this.txtBarCode.Text == string.Empty)
  337. {
  338. this.txtBarCode.Focus();
  339. return "";
  340. }
  341. ServiceResultEntity sreByid = DoAsync<ServiceResultEntity>(() =>
  342. {
  343. ClientRequestEntity cre = new ClientRequestEntity();
  344. cre.NameSpace = "F_PM_1107";
  345. cre.Name = "ReadAllDataByProductCode";
  346. cre.Properties["BARCODE"] = barcode;
  347. return SystemModuleProxy.Service.DoRequest(cre);
  348. });
  349. if (sreByid.Data.Tables[0].Rows[0]["USERID"].ToString()==string.Empty || sreByid.Data.Tables[0].Rows[0]["USERID"].ToString()=="" || sreByid.Data.Tables[0].Rows[0]["USERID"].ToString()==null) {
  350. return "信息不全,此产品不做任何处理";
  351. }
  352. ServiceResultEntity sreByuserid = DoAsync<ServiceResultEntity>(() =>
  353. {
  354. ClientRequestEntity cre = new ClientRequestEntity();
  355. cre.NameSpace = "F_PM_1107";
  356. cre.Name = "ReadStaffInformation";
  357. cre.Properties["USERID"] = sreByid.Data.Tables[0].Rows[0]["USERID"].ToString();
  358. return SystemModuleProxy.Service.DoRequest(cre);
  359. });
  360. this.txtRemarks.Focus();//把光标移开,由于删除工号后,值未变
  361. if (this._formType == Constant.FormMode.Add)
  362. {
  363. //获取责任人集合
  364. List<ScrapResponsibleEntity> addResponsibleList = new List<ScrapResponsibleEntity>()
  365. {
  366. new ScrapResponsibleEntity() {
  367. BarCode = sreByid.Data.Tables[0].Rows[0]["BarCode"].ToString(),
  368. StaffID = Convert.ToInt32(sreByuserid.Data.Tables[0].Rows[0]["STAFFID"].ToString()),
  369. StaffStatus = Convert.ToInt32(sreByuserid.Data.Tables[0].Rows[0]["Staffstatus"].ToString()),
  370. UserID = Convert.ToInt32(sreByuserid.Data.Tables[0].Rows[0]["USERID"].ToString()),
  371. UserCode = sreByuserid.Data.Tables[0].Rows[0]["USERCODE"].ToString() + "",
  372. UJobsID = Convert.ToInt32(sreByuserid.Data.Tables[0].Rows[0]["UJobsId"].ToString()),
  373. SJobsID = Convert.ToInt32(sreByuserid.Data.Tables[0].Rows[0]["JOBS"].ToString()),
  374. }
  375. };
  376. //如果选择了责任工序就一定要选择责任人
  377. //if (cbResponProcedure.Text != string.Empty && addResponsibleList.Count == Constant.INT_IS_ZERO)
  378. if (addResponsibleList.Count == Constant.INT_IS_ZERO)
  379. {
  380. //MessageBox.Show("请选择责任人!",
  381. // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  382. return "请选择责任人!";
  383. }
  384. //首先判断责任类型
  385. int thisResponType = 0;
  386. if (sreByid.Data.Tables[0].Rows.Count == 0 && addResponsibleList.Count == Constant.INT_IS_ZERO)
  387. {
  388. thisResponType = 1;
  389. }
  390. else if (sreByid.Data.Tables[0].Rows.Count > 0 && addResponsibleList.Count != Constant.INT_IS_ZERO)
  391. {
  392. thisResponType = 3;
  393. }
  394. else if (sreByid.Data.Tables[0].Rows.Count == 0 && addResponsibleList.Count != Constant.INT_IS_ZERO)
  395. {
  396. thisResponType = 2;
  397. }
  398. if (thisResponType == Constant.INT_IS_ZERO)
  399. {
  400. //MessageBox.Show("责任类别不正确!",
  401. // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  402. return "责任类别不正确!";
  403. }
  404. //新建报损产品实体
  405. ScrapProductEntity addScrapProduct = new ScrapProductEntity();
  406. addScrapProduct.BarCode = sreByid.Data.Tables[0].Rows[0]["BarCode"].ToString();
  407. addScrapProduct.ProductionLineID = int.Parse(sreByid.Data.Tables[0].Rows[0]["PRODUCTIONLINEID"].ToString());
  408. addScrapProduct.ProductionLineCode = sreByid.Data.Tables[0].Rows[0]["PRODUCTIONLINECODE"].ToString();
  409. addScrapProduct.ProductionLineName = sreByid.Data.Tables[0].Rows[0]["PRODUCTIONLINENAME"].ToString();
  410. addScrapProduct.GoodsID = int.Parse(sreByid.Data.Tables[0].Rows[0]["GOODSID"].ToString());
  411. addScrapProduct.GoodsCode = sreByid.Data.Tables[0].Rows[0]["GOODSCODE"].ToString();
  412. addScrapProduct.GoodsName = sreByid.Data.Tables[0].Rows[0]["GOODSNAME"].ToString();
  413. addScrapProduct.GroutingDailyID = int.Parse(sreByid.Data.Tables[0].Rows[0]["GROUTINGDAILYID"].ToString());
  414. addScrapProduct.GroutingDailyDetailID = int.Parse(sreByid.Data.Tables[0].Rows[0]["GROUTINGDAILYDETAILID"].ToString());
  415. addScrapProduct.GroutingDate = Convert.ToDateTime(sreByid.Data.Tables[0].Rows[0]["GROUTINGDATE"].ToString());
  416. addScrapProduct.GroutingLineID = int.Parse(sreByid.Data.Tables[0].Rows[0]["GROUTINGLINEID"].ToString());
  417. addScrapProduct.GroutingLineCode = sreByid.Data.Tables[0].Rows[0]["GROUTINGLINECODE"].ToString();
  418. addScrapProduct.GroutingLineName = sreByid.Data.Tables[0].Rows[0]["GROUTINGLINENAME"].ToString();
  419. addScrapProduct.GMouldTypeID = int.Parse(sreByid.Data.Tables[0].Rows[0]["GMOULDTYPEID"].ToString());
  420. addScrapProduct.GroutingLineDetailID = int.Parse(sreByid.Data.Tables[0].Rows[0]["GROUTINGLINEDETAILID"].ToString());
  421. addScrapProduct.GroutingMouldCode = sreByid.Data.Tables[0].Rows[0]["GROUTINGMOULDCODE"].ToString();
  422. addScrapProduct.MouldCode = sreByid.Data.Tables[0].Rows[0]["MOULDCODE"].ToString();
  423. addScrapProduct.GoodsLevelTypeID = _goodsLevelTypeID;
  424. addScrapProduct.GoodsLevelID = _goodsLevelId;
  425. addScrapProduct.ScrapDate = DateTime.Now;
  426. addScrapProduct.Rreason = "盘点报损";
  427. addScrapProduct.ResponUserID = Convert.ToInt32(sreByuserid.Data.Tables[0].Rows[0]["USERID"].ToString());
  428. addScrapProduct.ResponUserCode = sreByuserid.Data.Tables[0].Rows[0]["USERCODE"].ToString() + "";
  429. addScrapProduct.ResponUserName = sreByuserid.Data.Tables[0].Rows[0]["USERNAME"].ToString();
  430. addScrapProduct.Remarks = this.txtRemarks.Text;
  431. addScrapProduct.AuditStatus = 0;
  432. addScrapProduct.SettlementFlag = 0;
  433. addScrapProduct.ResponType = thisResponType;
  434. addScrapProduct.GroutingUserID = Convert.ToInt32(sreByid.Data.Tables[0].Rows[0]["GROUTINGUSERID"].ToString());
  435. addScrapProduct.GroutingUserCode = sreByid.Data.Tables[0].Rows[0]["GROUTINGUSERCODE"].ToString();
  436. addScrapProduct.GroutingNum = decimal.Parse(sreByid.Data.Tables[0].Rows[0]["GROUTINGNUM"].ToString());
  437. addScrapProduct.IsPublicBody = Convert.ToInt32(sreByid.Data.Tables[0].Rows[0]["ISPUBLICBODY"].ToString());
  438. addScrapProduct.IsReFire = Convert.ToInt32(sreByid.Data.Tables[0].Rows[0]["ISREFIRE"].ToString());
  439. addScrapProduct.AuditStatus = Convert.ToInt32(cmbAuditStatus.SelectedValue);
  440. addScrapProduct.SpecialRepairflag = int.Parse(sreByid.Data.Tables[0].Rows[0]["SPECIALREPAIRFLAG"].ToString());
  441. addScrapProduct.LogoID = int.Parse(sreByid.Data.Tables[0].Rows[0]["LogoID"].ToString());
  442. if (sreByid.Data.Tables[0].Rows[0]["PROCEDUREID"].ToString() != null)
  443. {
  444. addScrapProduct.ProcedureID = int.Parse(sreByid.Data.Tables[0].Rows[0]["PROCEDUREID"].ToString());
  445. //addScrapProduct.ProcedureName = this.txtCompleteProcdure.Text;
  446. addScrapProduct.ProcedureName = sreByid.Data.Tables[0].Rows[0]["ProcedureName"].ToString();
  447. addScrapProduct.ProcedureCode = sreByid.Data.Tables[0].Rows[0]["ProcedureCode"].ToString();
  448. }
  449. ResponProcedureEntity addRProcedure = new ResponProcedureEntity();
  450. //如果存在责任工序的话,也要添加责任工序
  451. if (thisResponType == Constant.INT_IS_THREE)
  452. {
  453. addRProcedure.BarCode = sreByid.Data.Tables[0].Rows[0]["BarCode"].ToString();
  454. addRProcedure.ProductionDataID = int.Parse(sreByid.Data.Tables[0].Rows[0]["PRODUCTIONDATAID"].ToString());
  455. addRProcedure.ProductionLineID = int.Parse(sreByid.Data.Tables[0].Rows[0]["PRODUCTIONLINEID"].ToString());
  456. addRProcedure.ProductionLineCode = sreByid.Data.Tables[0].Rows[0]["PRODUCTIONLINECODE"].ToString();
  457. addRProcedure.ProductionLineName = sreByid.Data.Tables[0].Rows[0]["PRODUCTIONLINENAME"].ToString();
  458. addRProcedure.ProcedureID = int.Parse(sreByid.Data.Tables[0].Rows[0]["PROCEDUREID"].ToString());
  459. addRProcedure.ProcedureCode = sreByid.Data.Tables[0].Rows[0]["ProcedureCode"].ToString();
  460. addRProcedure.ProcedureName = sreByid.Data.Tables[0].Rows[0]["ProcedureName"].ToString();
  461. addRProcedure.UserID = Convert.ToInt32(sreByuserid.Data.Tables[0].Rows[0]["USERID"].ToString());
  462. addRProcedure.UserCode = sreByuserid.Data.Tables[0].Rows[0]["USERCODE"].ToString() + "";
  463. addRProcedure.UserName = sreByuserid.Data.Tables[0].Rows[0]["USERNAME"].ToString();
  464. addRProcedure.Remarks = "";
  465. }
  466. int addReturn = (int)DoAsync(new BaseAsyncMethod(() =>
  467. {
  468. return PMModuleProxy.Service.AddScrapProduct(addScrapProduct, addRProcedure, addResponsibleList);
  469. }));
  470. if (addReturn > Constant.INT_IS_ZERO)
  471. {
  472. //成功
  473. //MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "废弃产品", "保存"),
  474. // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  475. //this.DialogResult = DialogResult.OK;
  476. return string.Format(Messages.MSG_CMN_I001, "废弃产品", "保存");
  477. }
  478. else if (addReturn == Constant.RETURN_IS_DATACHANGED)
  479. {
  480. //成功
  481. //MessageBox.Show(string.Format(Messages.MSG_CMN_W007, "操作的数据已经发生了变化"),
  482. // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  483. //this.DialogResult = DialogResult.OK;
  484. return string.Format(Messages.MSG_CMN_W007, "操作的数据已经发生了变化");
  485. }
  486. else
  487. {
  488. //失败
  489. //MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "废弃产品", "保存"),
  490. // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  491. return string.Format(Messages.MSG_CMN_W001, "废弃产品", "保存");
  492. }
  493. }
  494. }
  495. catch (Exception ex)
  496. {
  497. // 对异常进行共通处理
  498. ExceptionManager.HandleEventException(this.ToString(),
  499. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  500. }
  501. return result;
  502. }
  503. /// <summary>
  504. /// 窗体关闭
  505. /// </summary>
  506. /// <param name="sender"></param>
  507. /// <param name="e"></param>
  508. private void btnCancel_Click(object sender, EventArgs e)
  509. {
  510. this.Close();
  511. }
  512. /// <summary>
  513. /// 按下回车后调用产品条码检验
  514. /// </summary>
  515. /// <param name="sender"></param>
  516. /// <param name="e"></param>
  517. private void txtBarCode_KeyPress(object sender, KeyPressEventArgs e)
  518. {
  519. try
  520. {
  521. //清除所有产品条码
  522. ReportingLosses.Clear();
  523. GroutingScrapProducts.Clear();
  524. if ((int)e.KeyChar == 13 && (this.txtBarCode.Text != "" && this.txtBarCode.Text != string.Empty && this.txtBarCode.Text != null)) // 按了回车键
  525. {
  526. var dt = new DataTable();
  527. //备注
  528. dt.Columns.Add("notes");
  529. //产品编码
  530. dt.Columns.Add("ProductCode");
  531. var sss = SplitLong11(this.txtBarCode.Text);
  532. foreach (var item in sss)
  533. {
  534. _barCodeRow = null;
  535. string pubg = GroutingScrapProduct(item);
  536. if ("NEXT" == pubg)
  537. {
  538. pubg = ReadAllDataByProductCode(item);
  539. if (pubg == "没有问题")
  540. {
  541. ReportingLosses.Add(item);
  542. }
  543. }
  544. else if (pubg == "没有问题")
  545. {
  546. GroutingScrapProducts.Add(item, _barCodeRow);
  547. }
  548. _barCodeRow = null;
  549. DataRow dr = dt.NewRow();
  550. dr["notes"] = pubg;
  551. dr["ProductCode"] = item;
  552. dt.Rows.Add(dr);
  553. }
  554. this.dgvResponsible.DataSource = dt;
  555. }
  556. }
  557. catch (Exception ex)
  558. {
  559. // 对异常进行共通处理
  560. ExceptionManager.HandleEventException(this.ToString(),
  561. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  562. }
  563. }
  564. /// <summary>
  565. /// 字符串按11位分割
  566. /// </summary>
  567. /// <param name="item"></param>
  568. /// <returns></returns>
  569. public List<string> SplitLong11(string item) {
  570. List<string> result = new List<string>();
  571. // 检查字符串长度是否大于或等于分组大小
  572. if (item.Length >= 11)
  573. {
  574. for (int i = 0; i < item.Length; i += 11)
  575. {
  576. // 截取当前分组,注意不要超出字符串长度
  577. int length = Math.Min(11, this.txtBarCode.Text.Length - i);
  578. string chunk = this.txtBarCode.Text.Substring(i, length);
  579. result.Add(chunk);
  580. }
  581. }
  582. return result;
  583. }
  584. #endregion
  585. /// <summary>
  586. /// 成型报损
  587. /// </summary>
  588. /// <param name="sender"></param>
  589. /// <param name="e"></param>
  590. private string GroutingScrapProduct(string item)
  591. {
  592. string notes = "没有问题";
  593. try
  594. {
  595. if (!string.IsNullOrWhiteSpace(item))
  596. {
  597. ClientRequestEntity cre = new ClientRequestEntity();
  598. cre.NameSpace = "GroutingScrapProduct";
  599. cre.Name = "GetGroutingDailyDetail";
  600. cre.Properties["BarCode"] = item;
  601. ServiceResultEntity result = (ServiceResultEntity)DoAsync(new BaseAsyncMethod(() =>
  602. {
  603. return PMModuleProxyNew.Service.HandleRequest(cre);
  604. }));
  605. if (result == null || result.Data == null || result.Data.Tables.Count == 0
  606. || result.Data.Tables[0].Rows.Count == 0)
  607. {
  608. return notes = "未查询到该产品信息,请确认该产品是否已经进行注浆!";
  609. }
  610. _barCodeRow = result.Data.Tables[0].Rows[0];
  611. // 判断是否进行了注浆
  612. if ("0".Equals(_barCodeRow["GroutingFlag"]))
  613. {
  614. return notes = "该产品还未进行注浆!";
  615. }
  616. // 判断是否已经报损
  617. if ("1".Equals(_barCodeRow["ScrapFlag"]))
  618. {
  619. return notes = "该产品已经报损!";
  620. }
  621. // 判断是否进行了交坯
  622. if ("1".Equals(_barCodeRow["DeliverFlag"]) || "1".Equals(_barCodeRow["beginningflag"]))
  623. {
  624. //return notes = "该产品已经交坯!";
  625. return notes = "NEXT";
  626. }
  627. return notes;
  628. }
  629. // 如果产品条码是空,那么就清空相关信息
  630. return notes = "无效条码";
  631. }
  632. catch (Exception ex)
  633. {
  634. // 对异常进行共通处理
  635. ExceptionManager.HandleEventException(this.ToString(),
  636. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  637. }
  638. return "条码成型报损验证异常";
  639. }
  640. /// <summary>
  641. /// 产品条码检验
  642. /// </summary>
  643. /// <param name="item"></param>
  644. /// <returns></returns>
  645. private string ReadAllDataByProductCode(string item)
  646. {
  647. string notes = "没有问题";
  648. try
  649. {
  650. string doRuselt = (string)DoAsync(new BaseAsyncMethod(() =>
  651. {
  652. return PMModuleProxy.Service.ScrapProductChack(item);
  653. }));
  654. string[] doRuselts = doRuselt.Split(':');
  655. int isHave = Convert.ToInt32(doRuselts[0]);
  656. if (isHave == 2)
  657. {
  658. return notes = "不是在产产品不能报损!";
  659. //MessageBox.Show("产品编码为" + item + " 不是在产产品不能报损!",
  660. // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  661. //this.txtBarCode.Text = "";
  662. //this.txtBarCode.Focus();
  663. //Product = false;
  664. }
  665. if (isHave == 3)
  666. {
  667. return notes = "当前工号没有此产品所在工序"+ doRuselts[1] + "的操作权限,不能报损!";
  668. //MessageBox.Show(string.Format("产品编码为" + item + " 当前工号没有此产品所在工序【{0}】的操作权限,不能报损!", doRuselts[1]),
  669. // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  670. //this.txtBarCode.Text = "";
  671. //this.txtBarCode.Focus();
  672. //Product = false;
  673. }
  674. if (isHave == 4)
  675. {
  676. return notes = doRuselts[1];
  677. // MessageBox.Show(doRuselts[1],
  678. // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  679. //this.txtBarCode.Text = "";
  680. //this.txtBarCode.Focus();
  681. //Product = false;
  682. }
  683. if (isHave == Constant.INT_IS_ZERO)
  684. {
  685. return notes = "已经存在报损记录!";
  686. // MessageBox.Show("产品编码为" + item + " 已经存在报损记录!",
  687. // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  688. //this.txtBarCode.Text = "";
  689. //this.txtBarCode.Focus();
  690. //Product = false;
  691. }
  692. DataSet dsReturn = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  693. {
  694. return PMModuleProxy.Service.GetInProductionAndProductionData(item);
  695. }));
  696. if (dsReturn != null)
  697. {
  698. if (dsReturn.Tables.Count == Constant.INT_IS_TWO)
  699. {
  700. if (dsReturn.Tables[0].Rows.Count == Constant.INT_IS_ZERO) //在产表中没有数据
  701. {
  702. //目前不在生产线上也只报损 2015/07/14 modify wangx
  703. DataSet dsDailyDetail = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  704. {
  705. return PMModuleProxy.Service.GetBarCodeInGroutingDailyDetail(item);
  706. }));
  707. if (dsDailyDetail != null && dsDailyDetail.Tables[0].Rows.Count == 0)
  708. {
  709. return notes = "条码无效,无法报损!";
  710. //MessageBox.Show("产品编码为" + item + " 条码无效,无法报损!",
  711. // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  712. //this.txtBarCode.Text = "";
  713. //this.txtBarCode.Focus();
  714. //Product = false;
  715. }
  716. return notes = "不是在产产品不能报损!";
  717. // 2015/07/14 modify wangx end
  718. ////产品不在生产线上
  719. //MessageBox.Show("产品编码为" + item + " 不是在产产品不能报损!",
  720. // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  721. //this.txtBarCode.Text = "";
  722. //this.txtBarCode.Focus();
  723. //////判断条码是否有效
  724. //Product = false;
  725. }
  726. //获取产品情况以及经过工序情况
  727. DataTable dtInProduction = dsReturn.Tables[0];
  728. //2015-05-26 begin modify by wangx
  729. if (dtInProduction != null && dtInProduction.Rows.Count > 0)
  730. {
  731. if (dtInProduction.Rows[0]["endmode"].ToString() == "2")//代表已经产成品
  732. {
  733. return notes = "已经生产完成,无法报损!";
  734. //MessageBox.Show("产品编码为" + item + " 已经生产完成,无法报损!",
  735. // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  736. //this.txtBarCode.Text = "";
  737. //this.txtBarCode.Focus();
  738. //Product = false;
  739. }
  740. if (dtInProduction.Rows[0]["IsReworkFlag"].ToString() == "1")//代表已经返工
  741. {
  742. return notes = "已经是返工状态,无法报损!";
  743. //MessageBox.Show("产品编码为" + item + " 已经是返工状态,无法报损!",
  744. // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  745. //this.txtBarCode.Text = "";
  746. //this.txtBarCode.Focus();
  747. //Product = false;
  748. }
  749. }
  750. //2015-05-26 end
  751. //获取节点类型
  752. //如果存在该类型的字段的话,判断一下
  753. // string a = dtInProduction.Columns[dtInProduction.Columns.Count - 1].ColumnName;
  754. foreach (DataColumn dcFor in dtInProduction.Columns)
  755. {
  756. if (dcFor.ColumnName.ToLower() == "proceduremodeltypeid")
  757. {
  758. int modelType = Convert.ToInt32(dtInProduction.Rows[0]["ProcedureModelTypeID"]);
  759. // 装车,入窑,出窑,窑车补件不能报损
  760. if (modelType == Constant.INT_IS_ONE || modelType == Constant.INT_IS_TWO || modelType == Constant.INT_IS_THREE || modelType == Constant.INT_IS_SIX)
  761. {
  762. return notes = "处于无法报损的特殊工序中!";
  763. //某些特殊工序不可报损
  764. //MessageBox.Show("产品编码为" + item + " 处于无法报损的特殊工序中!",
  765. // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  766. //this.txtBarCode.Text = "";
  767. //this.txtBarCode.Focus();
  768. //Product = false;
  769. }
  770. }
  771. }
  772. List<InProductionEntity> inProductionList = DataConvert.TableConvertToObject<InProductionEntity>(dtInProduction);
  773. if (inProductionList.Count != Constant.INT_IS_ZERO)
  774. {
  775. this._isScrapProductEntity = inProductionList[0];
  776. }
  777. else
  778. {
  779. if (this._updateEntity == null)
  780. {
  781. return null;
  782. }
  783. if (this._updateEntity.GoodsLevelTypeID != this._goodsLevelTypeID)
  784. {
  785. return null;
  786. }
  787. //失败,条码不存在数据或无法转换
  788. MessageBox.Show(Messages.MSG_PM_W007,
  789. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  790. return null;
  791. }
  792. }
  793. else
  794. {
  795. if (this._updateEntity == null)
  796. {
  797. return null;
  798. }
  799. if (this._updateEntity.GoodsLevelTypeID != this._goodsLevelTypeID)
  800. {
  801. return null;
  802. }
  803. //失败
  804. MessageBox.Show(Messages.MSG_PM_W007,
  805. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  806. }
  807. }
  808. }
  809. catch (Exception ex)
  810. {
  811. // 对异常进行共通处理
  812. ExceptionManager.HandleEventException(this.ToString(),
  813. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  814. }
  815. //return notes;
  816. return "条码产品报损验证异常";
  817. }
  818. #region 私有方法
  819. /// <summary>
  820. /// 加载数据
  821. /// </summary>
  822. private void BindEntity()
  823. {
  824. try
  825. {
  826. //条码控件不可用
  827. this.txtBarCode.Enabled = false;
  828. this._updateEntity = new ScrapProductEntity();
  829. this._updateEntity.BarCode = _barCode;
  830. this._updateEntity.ScrapProductID = _editSPId;
  831. //绑定生产工序集合
  832. DataSet dsReturn = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  833. {
  834. return PMModuleProxy.Service.GetInProductionAndProductionData(_barCode);
  835. }));
  836. if (dsReturn != null)
  837. {
  838. if (dsReturn.Tables.Count == Constant.INT_IS_TWO)
  839. {
  840. //获取产品情况以及经过工序情况
  841. DataTable dtInProduction = dsReturn.Tables[0];
  842. DataTable dtProductionData = dsReturn.Tables[1];
  843. //foreach (DataRow drFor in dtInProduction.Rows)
  844. //{
  845. // this.txtProductionLineName.Text = drFor["ProductionLineName"].ToString();
  846. // this.txtGoodsCode.Text = drFor["GoodsCode"].ToString();
  847. // this.txtGroutingLine.Text = drFor["GroutingLineCode"].ToString();
  848. // this.txtMouldCode.Text = drFor["GroutingMouldCode"].ToString();
  849. // this.txtGroutingUser.Text = drFor["GroutingUserCode"].ToString();
  850. //}
  851. //this.cbResponProcedure.DataSource = dtProductionData;
  852. //this.cbResponProcedure.DisplayMember = "ProcedureName";
  853. //this.cbResponProcedure.ValueMember = "ProcedureID";
  854. this._productionDataList = DataTableToListByProductionData(dtProductionData);
  855. if (this._productionDataList.Count != Constant.INT_IS_ZERO)
  856. {
  857. this._scrapProductResponProcedure = this._productionDataList[0];
  858. }
  859. }
  860. }
  861. //获取报废产品实体
  862. DataSet dsScrap = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  863. {
  864. return PMModuleProxy.Service.GetScrapProduct(this._updateEntity);
  865. }));
  866. if (dsScrap != null)
  867. {
  868. if (dsScrap.Tables.Count != Constant.INT_IS_ZERO)
  869. {
  870. DataRow drScrap = dsScrap.Tables[0].Rows[0];
  871. this._updateEntity.BarCode = drScrap["BarCode"].ToString();
  872. if (drScrap["ProductionLineID"].ToString() != "")
  873. {
  874. this._updateEntity.ProductionLineID = Convert.ToInt32(drScrap["ProductionLineID"]);
  875. this._updateEntity.ProductionLineCode = drScrap["ProductionLineCode"].ToString();
  876. this._updateEntity.ProductionLineName = drScrap["ProductionLineName"].ToString();
  877. //this.txtGoodsCode.Text = drScrap["GoodsCode"].ToString();
  878. //this.txtGroutingLine.Text = drScrap["GroutingLineCode"].ToString();
  879. //this.txtMouldCode.Text = drScrap["GroutingMouldCode"].ToString();
  880. //this.txtGroutingUser.Text = drScrap["GroutingUserCode"].ToString();
  881. this._CompleteProcdureID = Convert.ToInt32(drScrap["ProcedureID"]);
  882. this._CompleteProcdureCode = drScrap["ProcedureCode"].ToString();
  883. //this.txtCompleteProcdure.Text = drScrap["ProcedureName"].ToString();
  884. }
  885. //else //等于空时,取模具信息
  886. //{
  887. // this.txtGoodsCode.Text = drScrap["GoodsCode"].ToString();
  888. // this.txtGroutingLine.Text = drScrap["GroutingLineCode"].ToString();
  889. // this.txtMouldCode.Text = drScrap["GroutingMouldCode"].ToString();
  890. // this.txtGroutingUser.Text = drScrap["GroutingUserCode"].ToString();
  891. //}
  892. if (drScrap["logoid"].ToString() != "")
  893. {
  894. this._LogoID = Convert.ToInt32(drScrap["logoid"]);
  895. }
  896. this._updateEntity.GoodsID = Convert.ToInt32(drScrap["GoodsID"]);
  897. this._updateEntity.GoodsCode = drScrap["GoodsCode"].ToString();
  898. this._updateEntity.GoodsName = drScrap["GoodsName"].ToString();
  899. this._updateEntity.GroutingDailyID = Convert.ToInt32(drScrap["GroutingDailyID"]);
  900. this._updateEntity.GroutingDailyDetailID = Convert.ToInt32(drScrap["GroutingDailyDetailID"]);
  901. this._updateEntity.GroutingDate = Convert.ToDateTime(drScrap["GroutingDate"]);
  902. this._updateEntity.GroutingLineID = Convert.ToInt32(drScrap["GroutingLineID"]);
  903. this._updateEntity.GroutingLineCode = drScrap["GroutingLineCode"].ToString();
  904. this._updateEntity.GroutingLineName = drScrap["GroutingLineName"].ToString();
  905. this._updateEntity.GMouldTypeID = Convert.ToInt32(drScrap["GMouldTypeID"]);
  906. this._updateEntity.GroutingLineDetailID = Convert.ToInt32(drScrap["GroutingLineDetailID"]);
  907. this._updateEntity.GroutingMouldCode = drScrap["GroutingMouldCode"].ToString();
  908. this._updateEntity.MouldCode = drScrap["MouldCode"].ToString();
  909. this._updateEntity.GoodsLevelTypeID = Convert.ToInt32(drScrap["GoodsLevelTypeID"]);
  910. this._updateEntity.GoodsLevelID = Convert.ToInt32(drScrap["GoodsLevelID"]);
  911. this._updateEntity.ScrapDate = Convert.ToDateTime(drScrap["ScrapDate"]);
  912. this._updateEntity.Rreason = drScrap["Rreason"].ToString();
  913. this._updateEntity.Remarks = drScrap["Remarks"].ToString();
  914. this._updateEntity.AuditStatus = Convert.ToInt32(drScrap["AuditStatus"]);
  915. this._updateEntity.ResponType = Convert.ToInt32(drScrap["ResponType"]);
  916. this._updateEntity.SpecialRepairflag = Convert.ToInt32(drScrap["SpecialRepairflag"]);
  917. this.SpecialRepairFlag = Convert.ToInt32(drScrap["SpecialRepairflag"]);
  918. if (drScrap["Auditor"] != DBNull.Value)
  919. {
  920. this._updateEntity.Auditor = Convert.ToInt32(drScrap["Auditor"]);
  921. }
  922. if (drScrap["AuditDate"] != DBNull.Value)
  923. {
  924. this._updateEntity.AuditlDate = Convert.ToDateTime(drScrap["AuditDate"]);
  925. }
  926. this._updateEntity.SettlementFlag = Convert.ToInt32(drScrap["SettlementFlag"]);
  927. if (drScrap["ResponProcedureID"] != DBNull.Value) //ProcedureID--改到ResponProcedureID
  928. {
  929. this._updateEntity.ResponProcedureID = Convert.ToInt32(drScrap["ResponProcedureID"]);
  930. }
  931. if (drScrap["UserID"] != DBNull.Value)
  932. {
  933. this._updateEntity.ResponUserID = Convert.ToInt32(drScrap["UserID"]);
  934. }
  935. if (drScrap["UserCode"] != DBNull.Value)
  936. {
  937. this._updateEntity.ResponUserCode = drScrap["UserCode"].ToString();
  938. }
  939. if (drScrap["UserName"] != DBNull.Value)
  940. {
  941. this._updateEntity.ResponUserName = drScrap["UserName"].ToString();
  942. }
  943. if (drScrap["ScrapFine"] != DBNull.Value)
  944. {
  945. this._updateEntity.ScrapFine = Convert.ToDecimal(drScrap["ScrapFine"]);
  946. }
  947. this.cmbAuditStatus.SelectedValue = this._updateEntity.AuditStatus;
  948. if (this._updateEntity.GoodsLevelTypeID != this._goodsLevelTypeID ||
  949. (this._updateEntity.AuditStatus == Constant.INT_IS_ONE || this._updateEntity.AuditStatus == Constant.INT_IS_TWO)) //除关闭窗体外所有功能不可用
  950. {
  951. this.txtBarCode.Enabled = false;
  952. //this.txtGoodsCode.Enabled = false;
  953. //this.txtProductionLineName.Enabled = false;
  954. //this.cbResponProcedure.Enabled = false;
  955. // 报损日期不能修改
  956. //this.txtScrapDate.Enabled = false;
  957. this.cmbRreason.Enabled = false;
  958. this.txtRemarks.Enabled = false;
  959. //this.scbUser.Enabled = false;
  960. this.dgvResponsible.Enabled = false;
  961. this.btnSave.Enabled = false;
  962. //this.btnViewApprover.Visible = false;
  963. this.cmbAuditStatus.Enabled = false;
  964. }
  965. }
  966. }
  967. else
  968. {
  969. this.Close();
  970. return;
  971. }
  972. //获取报废责任工序实体
  973. if (Convert.ToInt32(_updateEntity.ResponType) == Constant.INT_IS_THREE)
  974. {
  975. DataSet dsResPro = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  976. {
  977. return PMModuleProxy.Service.GetResponProcedureBySPId(Convert.ToInt32(_updateEntity.ScrapProductID));
  978. }));
  979. this._updateProcedureEntity = new ResponProcedureEntity();
  980. if (dsResPro != null && dsResPro.Tables[0].Rows.Count > 0) //如果原来存在责任工序实体
  981. {
  982. DataRow drResPro = dsResPro.Tables[0].Rows[0];
  983. this._updateProcedureEntity.ResponProcedureID = Convert.ToInt32(drResPro["ResponProcedureID"]);
  984. //this.scbUser.Enabled = false;
  985. }
  986. this._updateProcedureEntity.BarCode = _updateEntity.BarCode;
  987. }
  988. //获取报废责任人实体集合
  989. if (Convert.ToInt32(_updateEntity.ResponType) != Constant.INT_IS_ONE)
  990. {
  991. this._updateScrapResponsibleList = new List<ScrapResponsibleEntity>();
  992. DataSet dsResponsible = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  993. {
  994. return PMModuleProxy.Service.GetScrapResponsibleBySPId(Convert.ToInt32(_updateEntity.ScrapProductID));
  995. }));
  996. DataTableToListByScrapResponsible(dsResponsible);
  997. }
  998. //控件赋值
  999. this.txtBarCode.Text = _updateEntity.BarCode;
  1000. //this.txtGoodsCode.Text = _updateEntity.GoodsCode;
  1001. //this.txtProductionLineName.Text = _updateEntity.ProductionLineName;
  1002. //this.cbResponProcedure.SelectedValue = _updateEntity.ResponProcedureID;
  1003. try
  1004. {
  1005. this.cmbRreason.Text = _updateEntity.Rreason;
  1006. }
  1007. catch
  1008. {
  1009. this.cmbRreason.Text = "";
  1010. }
  1011. this.txtRemarks.Text = _updateEntity.Remarks;
  1012. //this.txtScrapFine.Text = _updateEntity.ScrapFine.ToString();
  1013. //this._updateEntity.ScrapFine
  1014. if (this._updateEntity.ResponUserID != null)
  1015. {
  1016. // scbUser.SearchedPKMember = Convert.ToInt32(_updateEntity.ResponUserID);
  1017. // scbUser.InitValue(_updateEntity.ResponUserName, _updateEntity.ResponUserCode);
  1018. //this.dkUser.UserID = _updateEntity.ResponUserID;
  1019. // this.dkUser.UserCode = _updateEntity.ResponUserCode;
  1020. // this.dkUser.UserName = _updateEntity.ResponUserName;
  1021. }
  1022. else if (this._scrapResponsibleList.Count != Constant.INT_IS_ZERO)
  1023. {
  1024. //scbUser.SearchedPKMember = Convert.ToInt32(_scrapResponsibleList[0].UserID);
  1025. //scbUser.InitValue(_scrapResponsibleList[0].UserName, _scrapResponsibleList[0].UserCode);
  1026. //this.dkUser.UserID = _scrapResponsibleList[0].UserID;
  1027. // this.dkUser.UserCode = _scrapResponsibleList[0].UserCode;
  1028. // this.dkUser.UserName = _scrapResponsibleList[0].UserName;
  1029. }
  1030. }
  1031. catch (Exception ex)
  1032. {
  1033. throw ex;
  1034. }
  1035. }
  1036. /// <summary>
  1037. /// 数据表到实体转换
  1038. /// </summary>
  1039. /// <param name="dsScrapResponsible"></param>
  1040. private void DataTableToListByScrapResponsible(DataSet dsScrapResponsible)
  1041. {
  1042. foreach (DataRow drFor in dsScrapResponsible.Tables[0].Rows)
  1043. {
  1044. ScrapResponsibleEntity srEntity = new ScrapResponsibleEntity();
  1045. srEntity.ResponsibleID = Convert.ToInt32(drFor["ResponsibleID"]);
  1046. srEntity.ScrapProductID = Convert.ToInt32(drFor["ScrapProductID"]);
  1047. srEntity.BarCode = drFor["BarCode"].ToString();
  1048. srEntity.ResponType = Convert.ToInt32(drFor["ResponType"]);
  1049. if (drFor["ResponProcedureID"] != DBNull.Value)
  1050. {
  1051. srEntity.ResponProcedureID = Convert.ToInt32(drFor["ResponProcedureID"]);
  1052. }
  1053. srEntity.StaffID = Convert.ToInt32(drFor["StaffID"]);
  1054. srEntity.UserID = Convert.ToInt32(drFor["UserID"]);
  1055. srEntity.UserCode = drFor["UserCode"].ToString();
  1056. srEntity.UJobsID = Convert.ToInt32(drFor["UJobsID"]);
  1057. srEntity.SJobsID = Convert.ToInt32(drFor["SJobsID"]);
  1058. srEntity.StaffStatus = Convert.ToInt32(drFor["StaffStatus"]);
  1059. srEntity.AccountID = Convert.ToInt32(drFor["AccountID"]);
  1060. srEntity.CreateTime = Convert.ToDateTime(drFor["CreateTime"]);
  1061. srEntity.CreateUserID = Convert.ToInt32(drFor["CreateUserID"]);
  1062. srEntity.UpdateTime = Convert.ToDateTime(drFor["UpdateTime"]);
  1063. srEntity.UpdateUserID = Convert.ToInt32(drFor["UpdateUserID"]);
  1064. srEntity.OPTimeStamp = Convert.ToDateTime(drFor["OPTimeStamp"]);
  1065. srEntity.UserName = drFor["userName"].ToString();
  1066. this._scrapResponsibleList.Add(srEntity);
  1067. }
  1068. }
  1069. /// <summary>
  1070. /// 数据表到实体转换
  1071. /// </summary>
  1072. /// <param name="dtProductionData"></param>
  1073. /// <returns></returns>
  1074. private List<ProductionDataEntity> DataTableToListByProductionData(DataTable dtProductionData)
  1075. {
  1076. List<ProductionDataEntity> pdList = new List<ProductionDataEntity>();
  1077. foreach (DataRow drFor in dtProductionData.Rows)
  1078. {
  1079. ProductionDataEntity pdEntity = new ProductionDataEntity();
  1080. pdEntity.ProductionDataID = Convert.ToInt32(drFor["ProductionDataID"]);
  1081. pdEntity.ProcedureID = Convert.ToInt32(drFor["ProcedureID"]);
  1082. pdEntity.ProcedureCode = drFor["ProcedureCode"].ToString();
  1083. pdEntity.ProcedureName = drFor["ProcedureName"].ToString();
  1084. pdList.Add(pdEntity);
  1085. }
  1086. return pdList;
  1087. }
  1088. #endregion
  1089. }
  1090. }