F_PM_1107.cs 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144
  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. if ((int)e.KeyChar == 13 && (this.txtBarCode.Text != "" && this.txtBarCode.Text != string.Empty && this.txtBarCode.Text != null)) // 按了回车键
  522. {
  523. //var sss = SplitLong11(this.txtBarCode.Text);
  524. var sss = this.txtBarCode.Lines;
  525. //清除所有产品条码
  526. ReportingLosses.Clear();
  527. GroutingScrapProducts.Clear();
  528. var dt = new DataTable();
  529. //备注
  530. dt.Columns.Add("notes");
  531. //产品编码
  532. dt.Columns.Add("ProductCode");
  533. foreach (var item in sss)
  534. {
  535. if (string.IsNullOrWhiteSpace(item))
  536. {
  537. continue;
  538. }
  539. _barCodeRow = null;
  540. string pubg = GroutingScrapProduct(item);
  541. if ("NEXT" == pubg)
  542. {
  543. pubg = ReadAllDataByProductCode(item);
  544. if (pubg == "没有问题")
  545. {
  546. ReportingLosses.Add(item);
  547. }
  548. }
  549. else if (pubg == "没有问题")
  550. {
  551. GroutingScrapProducts.Add(item, _barCodeRow);
  552. }
  553. _barCodeRow = null;
  554. DataRow dr = dt.NewRow();
  555. dr["notes"] = pubg;
  556. dr["ProductCode"] = item;
  557. dt.Rows.Add(dr);
  558. }
  559. this.dgvResponsible.DataSource = dt;
  560. }
  561. }
  562. catch (Exception ex)
  563. {
  564. // 对异常进行共通处理
  565. ExceptionManager.HandleEventException(this.ToString(),
  566. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  567. }
  568. }
  569. /// <summary>
  570. /// 字符串按11位分割
  571. /// </summary>
  572. /// <param name="item"></param>
  573. /// <returns></returns>
  574. public List<string> SplitLong11(string item) {
  575. List<string> result = new List<string>();
  576. // 检查字符串长度是否大于或等于分组大小
  577. if (item.Length >= 11)
  578. {
  579. for (int i = 0; i < item.Length; i += 11)
  580. {
  581. // 截取当前分组,注意不要超出字符串长度
  582. int length = Math.Min(11, this.txtBarCode.Text.Length - i);
  583. string chunk = this.txtBarCode.Text.Substring(i, length);
  584. result.Add(chunk);
  585. }
  586. }
  587. return result;
  588. }
  589. #endregion
  590. /// <summary>
  591. /// 成型报损
  592. /// </summary>
  593. /// <param name="sender"></param>
  594. /// <param name="e"></param>
  595. private string GroutingScrapProduct(string item)
  596. {
  597. string notes = "没有问题";
  598. try
  599. {
  600. if (!string.IsNullOrWhiteSpace(item))
  601. {
  602. ClientRequestEntity cre = new ClientRequestEntity();
  603. cre.NameSpace = "GroutingScrapProduct";
  604. cre.Name = "GetGroutingDailyDetail";
  605. cre.Properties["BarCode"] = item;
  606. ServiceResultEntity result = (ServiceResultEntity)DoAsync(new BaseAsyncMethod(() =>
  607. {
  608. return PMModuleProxyNew.Service.HandleRequest(cre);
  609. }));
  610. if (result == null || result.Data == null || result.Data.Tables.Count == 0
  611. || result.Data.Tables[0].Rows.Count == 0)
  612. {
  613. return notes = "未查询到该产品信息,请确认该产品是否已经进行注浆!";
  614. }
  615. _barCodeRow = result.Data.Tables[0].Rows[0];
  616. // 判断是否进行了注浆
  617. if ("0".Equals(_barCodeRow["GroutingFlag"]))
  618. {
  619. return notes = "该产品还未进行注浆!";
  620. }
  621. // 判断是否已经报损
  622. if ("1".Equals(_barCodeRow["ScrapFlag"]))
  623. {
  624. return notes = "该产品已经报损!";
  625. }
  626. // 判断是否进行了交坯
  627. if ("1".Equals(_barCodeRow["DeliverFlag"]) || "1".Equals(_barCodeRow["beginningflag"]))
  628. {
  629. //return notes = "该产品已经交坯!";
  630. return notes = "NEXT";
  631. }
  632. return notes;
  633. }
  634. // 如果产品条码是空,那么就清空相关信息
  635. return notes = "无效条码";
  636. }
  637. catch (Exception ex)
  638. {
  639. // 对异常进行共通处理
  640. ExceptionManager.HandleEventException(this.ToString(),
  641. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  642. }
  643. return "条码成型报损验证异常";
  644. }
  645. /// <summary>
  646. /// 产品条码检验
  647. /// </summary>
  648. /// <param name="item"></param>
  649. /// <returns></returns>
  650. private string ReadAllDataByProductCode(string item)
  651. {
  652. string notes = "没有问题";
  653. try
  654. {
  655. string doRuselt = (string)DoAsync(new BaseAsyncMethod(() =>
  656. {
  657. return PMModuleProxy.Service.ScrapProductChack(item);
  658. }));
  659. string[] doRuselts = doRuselt.Split(':');
  660. int isHave = Convert.ToInt32(doRuselts[0]);
  661. if (isHave == 2)
  662. {
  663. return notes = "不是在产产品不能报损!";
  664. //MessageBox.Show("产品编码为" + item + " 不是在产产品不能报损!",
  665. // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  666. //this.txtBarCode.Text = "";
  667. //this.txtBarCode.Focus();
  668. //Product = false;
  669. }
  670. if (isHave == 3)
  671. {
  672. return notes = "当前工号没有此产品所在工序"+ doRuselts[1] + "的操作权限,不能报损!";
  673. //MessageBox.Show(string.Format("产品编码为" + item + " 当前工号没有此产品所在工序【{0}】的操作权限,不能报损!", doRuselts[1]),
  674. // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  675. //this.txtBarCode.Text = "";
  676. //this.txtBarCode.Focus();
  677. //Product = false;
  678. }
  679. if (isHave == 4)
  680. {
  681. return notes = doRuselts[1];
  682. // MessageBox.Show(doRuselts[1],
  683. // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  684. //this.txtBarCode.Text = "";
  685. //this.txtBarCode.Focus();
  686. //Product = false;
  687. }
  688. if (isHave == Constant.INT_IS_ZERO)
  689. {
  690. return notes = "已经存在报损记录!";
  691. // MessageBox.Show("产品编码为" + item + " 已经存在报损记录!",
  692. // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  693. //this.txtBarCode.Text = "";
  694. //this.txtBarCode.Focus();
  695. //Product = false;
  696. }
  697. DataSet dsReturn = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  698. {
  699. return PMModuleProxy.Service.GetInProductionAndProductionData(item);
  700. }));
  701. if (dsReturn != null)
  702. {
  703. if (dsReturn.Tables.Count == Constant.INT_IS_TWO)
  704. {
  705. if (dsReturn.Tables[0].Rows.Count == Constant.INT_IS_ZERO) //在产表中没有数据
  706. {
  707. //目前不在生产线上也只报损 2015/07/14 modify wangx
  708. DataSet dsDailyDetail = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  709. {
  710. return PMModuleProxy.Service.GetBarCodeInGroutingDailyDetail(item);
  711. }));
  712. if (dsDailyDetail != null && dsDailyDetail.Tables[0].Rows.Count == 0)
  713. {
  714. return notes = "条码无效,无法报损!";
  715. //MessageBox.Show("产品编码为" + item + " 条码无效,无法报损!",
  716. // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  717. //this.txtBarCode.Text = "";
  718. //this.txtBarCode.Focus();
  719. //Product = false;
  720. }
  721. return notes = "不是在产产品不能报损!";
  722. // 2015/07/14 modify wangx end
  723. ////产品不在生产线上
  724. //MessageBox.Show("产品编码为" + item + " 不是在产产品不能报损!",
  725. // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  726. //this.txtBarCode.Text = "";
  727. //this.txtBarCode.Focus();
  728. //////判断条码是否有效
  729. //Product = false;
  730. }
  731. //获取产品情况以及经过工序情况
  732. DataTable dtInProduction = dsReturn.Tables[0];
  733. //2015-05-26 begin modify by wangx
  734. if (dtInProduction != null && dtInProduction.Rows.Count > 0)
  735. {
  736. if (dtInProduction.Rows[0]["endmode"].ToString() == "2")//代表已经产成品
  737. {
  738. return notes = "已经生产完成,无法报损!";
  739. //MessageBox.Show("产品编码为" + item + " 已经生产完成,无法报损!",
  740. // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  741. //this.txtBarCode.Text = "";
  742. //this.txtBarCode.Focus();
  743. //Product = false;
  744. }
  745. if (dtInProduction.Rows[0]["IsReworkFlag"].ToString() == "1")//代表已经返工
  746. {
  747. return notes = "已经是返工状态,无法报损!";
  748. //MessageBox.Show("产品编码为" + item + " 已经是返工状态,无法报损!",
  749. // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  750. //this.txtBarCode.Text = "";
  751. //this.txtBarCode.Focus();
  752. //Product = false;
  753. }
  754. }
  755. //2015-05-26 end
  756. //获取节点类型
  757. //如果存在该类型的字段的话,判断一下
  758. // string a = dtInProduction.Columns[dtInProduction.Columns.Count - 1].ColumnName;
  759. foreach (DataColumn dcFor in dtInProduction.Columns)
  760. {
  761. if (dcFor.ColumnName.ToLower() == "proceduremodeltypeid")
  762. {
  763. int modelType = Convert.ToInt32(dtInProduction.Rows[0]["ProcedureModelTypeID"]);
  764. // 装车,入窑,出窑,窑车补件不能报损
  765. if (modelType == Constant.INT_IS_ONE || modelType == Constant.INT_IS_TWO || modelType == Constant.INT_IS_THREE || modelType == Constant.INT_IS_SIX)
  766. {
  767. return notes = "处于无法报损的特殊工序中!";
  768. //某些特殊工序不可报损
  769. //MessageBox.Show("产品编码为" + item + " 处于无法报损的特殊工序中!",
  770. // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  771. //this.txtBarCode.Text = "";
  772. //this.txtBarCode.Focus();
  773. //Product = false;
  774. }
  775. }
  776. }
  777. List<InProductionEntity> inProductionList = DataConvert.TableConvertToObject<InProductionEntity>(dtInProduction);
  778. if (inProductionList.Count != Constant.INT_IS_ZERO)
  779. {
  780. this._isScrapProductEntity = inProductionList[0];
  781. }
  782. else
  783. {
  784. if (this._updateEntity == null)
  785. {
  786. return null;
  787. }
  788. if (this._updateEntity.GoodsLevelTypeID != this._goodsLevelTypeID)
  789. {
  790. return null;
  791. }
  792. //失败,条码不存在数据或无法转换
  793. MessageBox.Show(Messages.MSG_PM_W007,
  794. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  795. return null;
  796. }
  797. }
  798. else
  799. {
  800. if (this._updateEntity == null)
  801. {
  802. return null;
  803. }
  804. if (this._updateEntity.GoodsLevelTypeID != this._goodsLevelTypeID)
  805. {
  806. return null;
  807. }
  808. //失败
  809. MessageBox.Show(Messages.MSG_PM_W007,
  810. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  811. }
  812. }
  813. }
  814. catch (Exception ex)
  815. {
  816. // 对异常进行共通处理
  817. ExceptionManager.HandleEventException(this.ToString(),
  818. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  819. }
  820. //return notes;
  821. return "条码产品报损验证异常";
  822. }
  823. #region 私有方法
  824. /// <summary>
  825. /// 加载数据
  826. /// </summary>
  827. private void BindEntity()
  828. {
  829. try
  830. {
  831. //条码控件不可用
  832. this.txtBarCode.Enabled = false;
  833. this._updateEntity = new ScrapProductEntity();
  834. this._updateEntity.BarCode = _barCode;
  835. this._updateEntity.ScrapProductID = _editSPId;
  836. //绑定生产工序集合
  837. DataSet dsReturn = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  838. {
  839. return PMModuleProxy.Service.GetInProductionAndProductionData(_barCode);
  840. }));
  841. if (dsReturn != null)
  842. {
  843. if (dsReturn.Tables.Count == Constant.INT_IS_TWO)
  844. {
  845. //获取产品情况以及经过工序情况
  846. DataTable dtInProduction = dsReturn.Tables[0];
  847. DataTable dtProductionData = dsReturn.Tables[1];
  848. //foreach (DataRow drFor in dtInProduction.Rows)
  849. //{
  850. // this.txtProductionLineName.Text = drFor["ProductionLineName"].ToString();
  851. // this.txtGoodsCode.Text = drFor["GoodsCode"].ToString();
  852. // this.txtGroutingLine.Text = drFor["GroutingLineCode"].ToString();
  853. // this.txtMouldCode.Text = drFor["GroutingMouldCode"].ToString();
  854. // this.txtGroutingUser.Text = drFor["GroutingUserCode"].ToString();
  855. //}
  856. //this.cbResponProcedure.DataSource = dtProductionData;
  857. //this.cbResponProcedure.DisplayMember = "ProcedureName";
  858. //this.cbResponProcedure.ValueMember = "ProcedureID";
  859. this._productionDataList = DataTableToListByProductionData(dtProductionData);
  860. if (this._productionDataList.Count != Constant.INT_IS_ZERO)
  861. {
  862. this._scrapProductResponProcedure = this._productionDataList[0];
  863. }
  864. }
  865. }
  866. //获取报废产品实体
  867. DataSet dsScrap = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  868. {
  869. return PMModuleProxy.Service.GetScrapProduct(this._updateEntity);
  870. }));
  871. if (dsScrap != null)
  872. {
  873. if (dsScrap.Tables.Count != Constant.INT_IS_ZERO)
  874. {
  875. DataRow drScrap = dsScrap.Tables[0].Rows[0];
  876. this._updateEntity.BarCode = drScrap["BarCode"].ToString();
  877. if (drScrap["ProductionLineID"].ToString() != "")
  878. {
  879. this._updateEntity.ProductionLineID = Convert.ToInt32(drScrap["ProductionLineID"]);
  880. this._updateEntity.ProductionLineCode = drScrap["ProductionLineCode"].ToString();
  881. this._updateEntity.ProductionLineName = drScrap["ProductionLineName"].ToString();
  882. //this.txtGoodsCode.Text = drScrap["GoodsCode"].ToString();
  883. //this.txtGroutingLine.Text = drScrap["GroutingLineCode"].ToString();
  884. //this.txtMouldCode.Text = drScrap["GroutingMouldCode"].ToString();
  885. //this.txtGroutingUser.Text = drScrap["GroutingUserCode"].ToString();
  886. this._CompleteProcdureID = Convert.ToInt32(drScrap["ProcedureID"]);
  887. this._CompleteProcdureCode = drScrap["ProcedureCode"].ToString();
  888. //this.txtCompleteProcdure.Text = drScrap["ProcedureName"].ToString();
  889. }
  890. //else //等于空时,取模具信息
  891. //{
  892. // this.txtGoodsCode.Text = drScrap["GoodsCode"].ToString();
  893. // this.txtGroutingLine.Text = drScrap["GroutingLineCode"].ToString();
  894. // this.txtMouldCode.Text = drScrap["GroutingMouldCode"].ToString();
  895. // this.txtGroutingUser.Text = drScrap["GroutingUserCode"].ToString();
  896. //}
  897. if (drScrap["logoid"].ToString() != "")
  898. {
  899. this._LogoID = Convert.ToInt32(drScrap["logoid"]);
  900. }
  901. this._updateEntity.GoodsID = Convert.ToInt32(drScrap["GoodsID"]);
  902. this._updateEntity.GoodsCode = drScrap["GoodsCode"].ToString();
  903. this._updateEntity.GoodsName = drScrap["GoodsName"].ToString();
  904. this._updateEntity.GroutingDailyID = Convert.ToInt32(drScrap["GroutingDailyID"]);
  905. this._updateEntity.GroutingDailyDetailID = Convert.ToInt32(drScrap["GroutingDailyDetailID"]);
  906. this._updateEntity.GroutingDate = Convert.ToDateTime(drScrap["GroutingDate"]);
  907. this._updateEntity.GroutingLineID = Convert.ToInt32(drScrap["GroutingLineID"]);
  908. this._updateEntity.GroutingLineCode = drScrap["GroutingLineCode"].ToString();
  909. this._updateEntity.GroutingLineName = drScrap["GroutingLineName"].ToString();
  910. this._updateEntity.GMouldTypeID = Convert.ToInt32(drScrap["GMouldTypeID"]);
  911. this._updateEntity.GroutingLineDetailID = Convert.ToInt32(drScrap["GroutingLineDetailID"]);
  912. this._updateEntity.GroutingMouldCode = drScrap["GroutingMouldCode"].ToString();
  913. this._updateEntity.MouldCode = drScrap["MouldCode"].ToString();
  914. this._updateEntity.GoodsLevelTypeID = Convert.ToInt32(drScrap["GoodsLevelTypeID"]);
  915. this._updateEntity.GoodsLevelID = Convert.ToInt32(drScrap["GoodsLevelID"]);
  916. this._updateEntity.ScrapDate = Convert.ToDateTime(drScrap["ScrapDate"]);
  917. this._updateEntity.Rreason = drScrap["Rreason"].ToString();
  918. this._updateEntity.Remarks = drScrap["Remarks"].ToString();
  919. this._updateEntity.AuditStatus = Convert.ToInt32(drScrap["AuditStatus"]);
  920. this._updateEntity.ResponType = Convert.ToInt32(drScrap["ResponType"]);
  921. this._updateEntity.SpecialRepairflag = Convert.ToInt32(drScrap["SpecialRepairflag"]);
  922. this.SpecialRepairFlag = Convert.ToInt32(drScrap["SpecialRepairflag"]);
  923. if (drScrap["Auditor"] != DBNull.Value)
  924. {
  925. this._updateEntity.Auditor = Convert.ToInt32(drScrap["Auditor"]);
  926. }
  927. if (drScrap["AuditDate"] != DBNull.Value)
  928. {
  929. this._updateEntity.AuditlDate = Convert.ToDateTime(drScrap["AuditDate"]);
  930. }
  931. this._updateEntity.SettlementFlag = Convert.ToInt32(drScrap["SettlementFlag"]);
  932. if (drScrap["ResponProcedureID"] != DBNull.Value) //ProcedureID--改到ResponProcedureID
  933. {
  934. this._updateEntity.ResponProcedureID = Convert.ToInt32(drScrap["ResponProcedureID"]);
  935. }
  936. if (drScrap["UserID"] != DBNull.Value)
  937. {
  938. this._updateEntity.ResponUserID = Convert.ToInt32(drScrap["UserID"]);
  939. }
  940. if (drScrap["UserCode"] != DBNull.Value)
  941. {
  942. this._updateEntity.ResponUserCode = drScrap["UserCode"].ToString();
  943. }
  944. if (drScrap["UserName"] != DBNull.Value)
  945. {
  946. this._updateEntity.ResponUserName = drScrap["UserName"].ToString();
  947. }
  948. if (drScrap["ScrapFine"] != DBNull.Value)
  949. {
  950. this._updateEntity.ScrapFine = Convert.ToDecimal(drScrap["ScrapFine"]);
  951. }
  952. this.cmbAuditStatus.SelectedValue = this._updateEntity.AuditStatus;
  953. if (this._updateEntity.GoodsLevelTypeID != this._goodsLevelTypeID ||
  954. (this._updateEntity.AuditStatus == Constant.INT_IS_ONE || this._updateEntity.AuditStatus == Constant.INT_IS_TWO)) //除关闭窗体外所有功能不可用
  955. {
  956. this.txtBarCode.Enabled = false;
  957. //this.txtGoodsCode.Enabled = false;
  958. //this.txtProductionLineName.Enabled = false;
  959. //this.cbResponProcedure.Enabled = false;
  960. // 报损日期不能修改
  961. //this.txtScrapDate.Enabled = false;
  962. this.cmbRreason.Enabled = false;
  963. this.txtRemarks.Enabled = false;
  964. //this.scbUser.Enabled = false;
  965. this.dgvResponsible.Enabled = false;
  966. this.btnSave.Enabled = false;
  967. //this.btnViewApprover.Visible = false;
  968. this.cmbAuditStatus.Enabled = false;
  969. }
  970. }
  971. }
  972. else
  973. {
  974. this.Close();
  975. return;
  976. }
  977. //获取报废责任工序实体
  978. if (Convert.ToInt32(_updateEntity.ResponType) == Constant.INT_IS_THREE)
  979. {
  980. DataSet dsResPro = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  981. {
  982. return PMModuleProxy.Service.GetResponProcedureBySPId(Convert.ToInt32(_updateEntity.ScrapProductID));
  983. }));
  984. this._updateProcedureEntity = new ResponProcedureEntity();
  985. if (dsResPro != null && dsResPro.Tables[0].Rows.Count > 0) //如果原来存在责任工序实体
  986. {
  987. DataRow drResPro = dsResPro.Tables[0].Rows[0];
  988. this._updateProcedureEntity.ResponProcedureID = Convert.ToInt32(drResPro["ResponProcedureID"]);
  989. //this.scbUser.Enabled = false;
  990. }
  991. this._updateProcedureEntity.BarCode = _updateEntity.BarCode;
  992. }
  993. //获取报废责任人实体集合
  994. if (Convert.ToInt32(_updateEntity.ResponType) != Constant.INT_IS_ONE)
  995. {
  996. this._updateScrapResponsibleList = new List<ScrapResponsibleEntity>();
  997. DataSet dsResponsible = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  998. {
  999. return PMModuleProxy.Service.GetScrapResponsibleBySPId(Convert.ToInt32(_updateEntity.ScrapProductID));
  1000. }));
  1001. DataTableToListByScrapResponsible(dsResponsible);
  1002. }
  1003. //控件赋值
  1004. this.txtBarCode.Text = _updateEntity.BarCode;
  1005. //this.txtGoodsCode.Text = _updateEntity.GoodsCode;
  1006. //this.txtProductionLineName.Text = _updateEntity.ProductionLineName;
  1007. //this.cbResponProcedure.SelectedValue = _updateEntity.ResponProcedureID;
  1008. try
  1009. {
  1010. this.cmbRreason.Text = _updateEntity.Rreason;
  1011. }
  1012. catch
  1013. {
  1014. this.cmbRreason.Text = "";
  1015. }
  1016. this.txtRemarks.Text = _updateEntity.Remarks;
  1017. //this.txtScrapFine.Text = _updateEntity.ScrapFine.ToString();
  1018. //this._updateEntity.ScrapFine
  1019. if (this._updateEntity.ResponUserID != null)
  1020. {
  1021. // scbUser.SearchedPKMember = Convert.ToInt32(_updateEntity.ResponUserID);
  1022. // scbUser.InitValue(_updateEntity.ResponUserName, _updateEntity.ResponUserCode);
  1023. //this.dkUser.UserID = _updateEntity.ResponUserID;
  1024. // this.dkUser.UserCode = _updateEntity.ResponUserCode;
  1025. // this.dkUser.UserName = _updateEntity.ResponUserName;
  1026. }
  1027. else if (this._scrapResponsibleList.Count != Constant.INT_IS_ZERO)
  1028. {
  1029. //scbUser.SearchedPKMember = Convert.ToInt32(_scrapResponsibleList[0].UserID);
  1030. //scbUser.InitValue(_scrapResponsibleList[0].UserName, _scrapResponsibleList[0].UserCode);
  1031. //this.dkUser.UserID = _scrapResponsibleList[0].UserID;
  1032. // this.dkUser.UserCode = _scrapResponsibleList[0].UserCode;
  1033. // this.dkUser.UserName = _scrapResponsibleList[0].UserName;
  1034. }
  1035. }
  1036. catch (Exception ex)
  1037. {
  1038. throw ex;
  1039. }
  1040. }
  1041. /// <summary>
  1042. /// 数据表到实体转换
  1043. /// </summary>
  1044. /// <param name="dsScrapResponsible"></param>
  1045. private void DataTableToListByScrapResponsible(DataSet dsScrapResponsible)
  1046. {
  1047. foreach (DataRow drFor in dsScrapResponsible.Tables[0].Rows)
  1048. {
  1049. ScrapResponsibleEntity srEntity = new ScrapResponsibleEntity();
  1050. srEntity.ResponsibleID = Convert.ToInt32(drFor["ResponsibleID"]);
  1051. srEntity.ScrapProductID = Convert.ToInt32(drFor["ScrapProductID"]);
  1052. srEntity.BarCode = drFor["BarCode"].ToString();
  1053. srEntity.ResponType = Convert.ToInt32(drFor["ResponType"]);
  1054. if (drFor["ResponProcedureID"] != DBNull.Value)
  1055. {
  1056. srEntity.ResponProcedureID = Convert.ToInt32(drFor["ResponProcedureID"]);
  1057. }
  1058. srEntity.StaffID = Convert.ToInt32(drFor["StaffID"]);
  1059. srEntity.UserID = Convert.ToInt32(drFor["UserID"]);
  1060. srEntity.UserCode = drFor["UserCode"].ToString();
  1061. srEntity.UJobsID = Convert.ToInt32(drFor["UJobsID"]);
  1062. srEntity.SJobsID = Convert.ToInt32(drFor["SJobsID"]);
  1063. srEntity.StaffStatus = Convert.ToInt32(drFor["StaffStatus"]);
  1064. srEntity.AccountID = Convert.ToInt32(drFor["AccountID"]);
  1065. srEntity.CreateTime = Convert.ToDateTime(drFor["CreateTime"]);
  1066. srEntity.CreateUserID = Convert.ToInt32(drFor["CreateUserID"]);
  1067. srEntity.UpdateTime = Convert.ToDateTime(drFor["UpdateTime"]);
  1068. srEntity.UpdateUserID = Convert.ToInt32(drFor["UpdateUserID"]);
  1069. srEntity.OPTimeStamp = Convert.ToDateTime(drFor["OPTimeStamp"]);
  1070. srEntity.UserName = drFor["userName"].ToString();
  1071. this._scrapResponsibleList.Add(srEntity);
  1072. }
  1073. }
  1074. /// <summary>
  1075. /// 数据表到实体转换
  1076. /// </summary>
  1077. /// <param name="dtProductionData"></param>
  1078. /// <returns></returns>
  1079. private List<ProductionDataEntity> DataTableToListByProductionData(DataTable dtProductionData)
  1080. {
  1081. List<ProductionDataEntity> pdList = new List<ProductionDataEntity>();
  1082. foreach (DataRow drFor in dtProductionData.Rows)
  1083. {
  1084. ProductionDataEntity pdEntity = new ProductionDataEntity();
  1085. pdEntity.ProductionDataID = Convert.ToInt32(drFor["ProductionDataID"]);
  1086. pdEntity.ProcedureID = Convert.ToInt32(drFor["ProcedureID"]);
  1087. pdEntity.ProcedureCode = drFor["ProcedureCode"].ToString();
  1088. pdEntity.ProcedureName = drFor["ProcedureName"].ToString();
  1089. pdList.Add(pdEntity);
  1090. }
  1091. return pdList;
  1092. }
  1093. #endregion
  1094. private void button1_Click(object sender, EventArgs e)
  1095. {
  1096. this.txtBarCode.Clear();
  1097. }
  1098. }
  1099. }