F_PM_1107.cs 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145
  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. return notes;
  782. }
  783. else
  784. {
  785. if (this._updateEntity == null)
  786. {
  787. return null;
  788. }
  789. if (this._updateEntity.GoodsLevelTypeID != this._goodsLevelTypeID)
  790. {
  791. return null;
  792. }
  793. //失败,条码不存在数据或无法转换
  794. MessageBox.Show(Messages.MSG_PM_W007,
  795. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  796. return null;
  797. }
  798. }
  799. else
  800. {
  801. if (this._updateEntity == null)
  802. {
  803. return null;
  804. }
  805. if (this._updateEntity.GoodsLevelTypeID != this._goodsLevelTypeID)
  806. {
  807. return null;
  808. }
  809. //失败
  810. MessageBox.Show(Messages.MSG_PM_W007,
  811. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  812. }
  813. }
  814. }
  815. catch (Exception ex)
  816. {
  817. // 对异常进行共通处理
  818. ExceptionManager.HandleEventException(this.ToString(),
  819. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  820. }
  821. //return notes;
  822. return "条码产品报损验证异常";
  823. }
  824. #region 私有方法
  825. /// <summary>
  826. /// 加载数据
  827. /// </summary>
  828. private void BindEntity()
  829. {
  830. try
  831. {
  832. //条码控件不可用
  833. this.txtBarCode.Enabled = false;
  834. this._updateEntity = new ScrapProductEntity();
  835. this._updateEntity.BarCode = _barCode;
  836. this._updateEntity.ScrapProductID = _editSPId;
  837. //绑定生产工序集合
  838. DataSet dsReturn = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  839. {
  840. return PMModuleProxy.Service.GetInProductionAndProductionData(_barCode);
  841. }));
  842. if (dsReturn != null)
  843. {
  844. if (dsReturn.Tables.Count == Constant.INT_IS_TWO)
  845. {
  846. //获取产品情况以及经过工序情况
  847. DataTable dtInProduction = dsReturn.Tables[0];
  848. DataTable dtProductionData = dsReturn.Tables[1];
  849. //foreach (DataRow drFor in dtInProduction.Rows)
  850. //{
  851. // this.txtProductionLineName.Text = drFor["ProductionLineName"].ToString();
  852. // this.txtGoodsCode.Text = drFor["GoodsCode"].ToString();
  853. // this.txtGroutingLine.Text = drFor["GroutingLineCode"].ToString();
  854. // this.txtMouldCode.Text = drFor["GroutingMouldCode"].ToString();
  855. // this.txtGroutingUser.Text = drFor["GroutingUserCode"].ToString();
  856. //}
  857. //this.cbResponProcedure.DataSource = dtProductionData;
  858. //this.cbResponProcedure.DisplayMember = "ProcedureName";
  859. //this.cbResponProcedure.ValueMember = "ProcedureID";
  860. this._productionDataList = DataTableToListByProductionData(dtProductionData);
  861. if (this._productionDataList.Count != Constant.INT_IS_ZERO)
  862. {
  863. this._scrapProductResponProcedure = this._productionDataList[0];
  864. }
  865. }
  866. }
  867. //获取报废产品实体
  868. DataSet dsScrap = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  869. {
  870. return PMModuleProxy.Service.GetScrapProduct(this._updateEntity);
  871. }));
  872. if (dsScrap != null)
  873. {
  874. if (dsScrap.Tables.Count != Constant.INT_IS_ZERO)
  875. {
  876. DataRow drScrap = dsScrap.Tables[0].Rows[0];
  877. this._updateEntity.BarCode = drScrap["BarCode"].ToString();
  878. if (drScrap["ProductionLineID"].ToString() != "")
  879. {
  880. this._updateEntity.ProductionLineID = Convert.ToInt32(drScrap["ProductionLineID"]);
  881. this._updateEntity.ProductionLineCode = drScrap["ProductionLineCode"].ToString();
  882. this._updateEntity.ProductionLineName = drScrap["ProductionLineName"].ToString();
  883. //this.txtGoodsCode.Text = drScrap["GoodsCode"].ToString();
  884. //this.txtGroutingLine.Text = drScrap["GroutingLineCode"].ToString();
  885. //this.txtMouldCode.Text = drScrap["GroutingMouldCode"].ToString();
  886. //this.txtGroutingUser.Text = drScrap["GroutingUserCode"].ToString();
  887. this._CompleteProcdureID = Convert.ToInt32(drScrap["ProcedureID"]);
  888. this._CompleteProcdureCode = drScrap["ProcedureCode"].ToString();
  889. //this.txtCompleteProcdure.Text = drScrap["ProcedureName"].ToString();
  890. }
  891. //else //等于空时,取模具信息
  892. //{
  893. // this.txtGoodsCode.Text = drScrap["GoodsCode"].ToString();
  894. // this.txtGroutingLine.Text = drScrap["GroutingLineCode"].ToString();
  895. // this.txtMouldCode.Text = drScrap["GroutingMouldCode"].ToString();
  896. // this.txtGroutingUser.Text = drScrap["GroutingUserCode"].ToString();
  897. //}
  898. if (drScrap["logoid"].ToString() != "")
  899. {
  900. this._LogoID = Convert.ToInt32(drScrap["logoid"]);
  901. }
  902. this._updateEntity.GoodsID = Convert.ToInt32(drScrap["GoodsID"]);
  903. this._updateEntity.GoodsCode = drScrap["GoodsCode"].ToString();
  904. this._updateEntity.GoodsName = drScrap["GoodsName"].ToString();
  905. this._updateEntity.GroutingDailyID = Convert.ToInt32(drScrap["GroutingDailyID"]);
  906. this._updateEntity.GroutingDailyDetailID = Convert.ToInt32(drScrap["GroutingDailyDetailID"]);
  907. this._updateEntity.GroutingDate = Convert.ToDateTime(drScrap["GroutingDate"]);
  908. this._updateEntity.GroutingLineID = Convert.ToInt32(drScrap["GroutingLineID"]);
  909. this._updateEntity.GroutingLineCode = drScrap["GroutingLineCode"].ToString();
  910. this._updateEntity.GroutingLineName = drScrap["GroutingLineName"].ToString();
  911. this._updateEntity.GMouldTypeID = Convert.ToInt32(drScrap["GMouldTypeID"]);
  912. this._updateEntity.GroutingLineDetailID = Convert.ToInt32(drScrap["GroutingLineDetailID"]);
  913. this._updateEntity.GroutingMouldCode = drScrap["GroutingMouldCode"].ToString();
  914. this._updateEntity.MouldCode = drScrap["MouldCode"].ToString();
  915. this._updateEntity.GoodsLevelTypeID = Convert.ToInt32(drScrap["GoodsLevelTypeID"]);
  916. this._updateEntity.GoodsLevelID = Convert.ToInt32(drScrap["GoodsLevelID"]);
  917. this._updateEntity.ScrapDate = Convert.ToDateTime(drScrap["ScrapDate"]);
  918. this._updateEntity.Rreason = drScrap["Rreason"].ToString();
  919. this._updateEntity.Remarks = drScrap["Remarks"].ToString();
  920. this._updateEntity.AuditStatus = Convert.ToInt32(drScrap["AuditStatus"]);
  921. this._updateEntity.ResponType = Convert.ToInt32(drScrap["ResponType"]);
  922. this._updateEntity.SpecialRepairflag = Convert.ToInt32(drScrap["SpecialRepairflag"]);
  923. this.SpecialRepairFlag = Convert.ToInt32(drScrap["SpecialRepairflag"]);
  924. if (drScrap["Auditor"] != DBNull.Value)
  925. {
  926. this._updateEntity.Auditor = Convert.ToInt32(drScrap["Auditor"]);
  927. }
  928. if (drScrap["AuditDate"] != DBNull.Value)
  929. {
  930. this._updateEntity.AuditlDate = Convert.ToDateTime(drScrap["AuditDate"]);
  931. }
  932. this._updateEntity.SettlementFlag = Convert.ToInt32(drScrap["SettlementFlag"]);
  933. if (drScrap["ResponProcedureID"] != DBNull.Value) //ProcedureID--改到ResponProcedureID
  934. {
  935. this._updateEntity.ResponProcedureID = Convert.ToInt32(drScrap["ResponProcedureID"]);
  936. }
  937. if (drScrap["UserID"] != DBNull.Value)
  938. {
  939. this._updateEntity.ResponUserID = Convert.ToInt32(drScrap["UserID"]);
  940. }
  941. if (drScrap["UserCode"] != DBNull.Value)
  942. {
  943. this._updateEntity.ResponUserCode = drScrap["UserCode"].ToString();
  944. }
  945. if (drScrap["UserName"] != DBNull.Value)
  946. {
  947. this._updateEntity.ResponUserName = drScrap["UserName"].ToString();
  948. }
  949. if (drScrap["ScrapFine"] != DBNull.Value)
  950. {
  951. this._updateEntity.ScrapFine = Convert.ToDecimal(drScrap["ScrapFine"]);
  952. }
  953. this.cmbAuditStatus.SelectedValue = this._updateEntity.AuditStatus;
  954. if (this._updateEntity.GoodsLevelTypeID != this._goodsLevelTypeID ||
  955. (this._updateEntity.AuditStatus == Constant.INT_IS_ONE || this._updateEntity.AuditStatus == Constant.INT_IS_TWO)) //除关闭窗体外所有功能不可用
  956. {
  957. this.txtBarCode.Enabled = false;
  958. //this.txtGoodsCode.Enabled = false;
  959. //this.txtProductionLineName.Enabled = false;
  960. //this.cbResponProcedure.Enabled = false;
  961. // 报损日期不能修改
  962. //this.txtScrapDate.Enabled = false;
  963. this.cmbRreason.Enabled = false;
  964. this.txtRemarks.Enabled = false;
  965. //this.scbUser.Enabled = false;
  966. this.dgvResponsible.Enabled = false;
  967. this.btnSave.Enabled = false;
  968. //this.btnViewApprover.Visible = false;
  969. this.cmbAuditStatus.Enabled = false;
  970. }
  971. }
  972. }
  973. else
  974. {
  975. this.Close();
  976. return;
  977. }
  978. //获取报废责任工序实体
  979. if (Convert.ToInt32(_updateEntity.ResponType) == Constant.INT_IS_THREE)
  980. {
  981. DataSet dsResPro = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  982. {
  983. return PMModuleProxy.Service.GetResponProcedureBySPId(Convert.ToInt32(_updateEntity.ScrapProductID));
  984. }));
  985. this._updateProcedureEntity = new ResponProcedureEntity();
  986. if (dsResPro != null && dsResPro.Tables[0].Rows.Count > 0) //如果原来存在责任工序实体
  987. {
  988. DataRow drResPro = dsResPro.Tables[0].Rows[0];
  989. this._updateProcedureEntity.ResponProcedureID = Convert.ToInt32(drResPro["ResponProcedureID"]);
  990. //this.scbUser.Enabled = false;
  991. }
  992. this._updateProcedureEntity.BarCode = _updateEntity.BarCode;
  993. }
  994. //获取报废责任人实体集合
  995. if (Convert.ToInt32(_updateEntity.ResponType) != Constant.INT_IS_ONE)
  996. {
  997. this._updateScrapResponsibleList = new List<ScrapResponsibleEntity>();
  998. DataSet dsResponsible = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  999. {
  1000. return PMModuleProxy.Service.GetScrapResponsibleBySPId(Convert.ToInt32(_updateEntity.ScrapProductID));
  1001. }));
  1002. DataTableToListByScrapResponsible(dsResponsible);
  1003. }
  1004. //控件赋值
  1005. this.txtBarCode.Text = _updateEntity.BarCode;
  1006. //this.txtGoodsCode.Text = _updateEntity.GoodsCode;
  1007. //this.txtProductionLineName.Text = _updateEntity.ProductionLineName;
  1008. //this.cbResponProcedure.SelectedValue = _updateEntity.ResponProcedureID;
  1009. try
  1010. {
  1011. this.cmbRreason.Text = _updateEntity.Rreason;
  1012. }
  1013. catch
  1014. {
  1015. this.cmbRreason.Text = "";
  1016. }
  1017. this.txtRemarks.Text = _updateEntity.Remarks;
  1018. //this.txtScrapFine.Text = _updateEntity.ScrapFine.ToString();
  1019. //this._updateEntity.ScrapFine
  1020. if (this._updateEntity.ResponUserID != null)
  1021. {
  1022. // scbUser.SearchedPKMember = Convert.ToInt32(_updateEntity.ResponUserID);
  1023. // scbUser.InitValue(_updateEntity.ResponUserName, _updateEntity.ResponUserCode);
  1024. //this.dkUser.UserID = _updateEntity.ResponUserID;
  1025. // this.dkUser.UserCode = _updateEntity.ResponUserCode;
  1026. // this.dkUser.UserName = _updateEntity.ResponUserName;
  1027. }
  1028. else if (this._scrapResponsibleList.Count != Constant.INT_IS_ZERO)
  1029. {
  1030. //scbUser.SearchedPKMember = Convert.ToInt32(_scrapResponsibleList[0].UserID);
  1031. //scbUser.InitValue(_scrapResponsibleList[0].UserName, _scrapResponsibleList[0].UserCode);
  1032. //this.dkUser.UserID = _scrapResponsibleList[0].UserID;
  1033. // this.dkUser.UserCode = _scrapResponsibleList[0].UserCode;
  1034. // this.dkUser.UserName = _scrapResponsibleList[0].UserName;
  1035. }
  1036. }
  1037. catch (Exception ex)
  1038. {
  1039. throw ex;
  1040. }
  1041. }
  1042. /// <summary>
  1043. /// 数据表到实体转换
  1044. /// </summary>
  1045. /// <param name="dsScrapResponsible"></param>
  1046. private void DataTableToListByScrapResponsible(DataSet dsScrapResponsible)
  1047. {
  1048. foreach (DataRow drFor in dsScrapResponsible.Tables[0].Rows)
  1049. {
  1050. ScrapResponsibleEntity srEntity = new ScrapResponsibleEntity();
  1051. srEntity.ResponsibleID = Convert.ToInt32(drFor["ResponsibleID"]);
  1052. srEntity.ScrapProductID = Convert.ToInt32(drFor["ScrapProductID"]);
  1053. srEntity.BarCode = drFor["BarCode"].ToString();
  1054. srEntity.ResponType = Convert.ToInt32(drFor["ResponType"]);
  1055. if (drFor["ResponProcedureID"] != DBNull.Value)
  1056. {
  1057. srEntity.ResponProcedureID = Convert.ToInt32(drFor["ResponProcedureID"]);
  1058. }
  1059. srEntity.StaffID = Convert.ToInt32(drFor["StaffID"]);
  1060. srEntity.UserID = Convert.ToInt32(drFor["UserID"]);
  1061. srEntity.UserCode = drFor["UserCode"].ToString();
  1062. srEntity.UJobsID = Convert.ToInt32(drFor["UJobsID"]);
  1063. srEntity.SJobsID = Convert.ToInt32(drFor["SJobsID"]);
  1064. srEntity.StaffStatus = Convert.ToInt32(drFor["StaffStatus"]);
  1065. srEntity.AccountID = Convert.ToInt32(drFor["AccountID"]);
  1066. srEntity.CreateTime = Convert.ToDateTime(drFor["CreateTime"]);
  1067. srEntity.CreateUserID = Convert.ToInt32(drFor["CreateUserID"]);
  1068. srEntity.UpdateTime = Convert.ToDateTime(drFor["UpdateTime"]);
  1069. srEntity.UpdateUserID = Convert.ToInt32(drFor["UpdateUserID"]);
  1070. srEntity.OPTimeStamp = Convert.ToDateTime(drFor["OPTimeStamp"]);
  1071. srEntity.UserName = drFor["userName"].ToString();
  1072. this._scrapResponsibleList.Add(srEntity);
  1073. }
  1074. }
  1075. /// <summary>
  1076. /// 数据表到实体转换
  1077. /// </summary>
  1078. /// <param name="dtProductionData"></param>
  1079. /// <returns></returns>
  1080. private List<ProductionDataEntity> DataTableToListByProductionData(DataTable dtProductionData)
  1081. {
  1082. List<ProductionDataEntity> pdList = new List<ProductionDataEntity>();
  1083. foreach (DataRow drFor in dtProductionData.Rows)
  1084. {
  1085. ProductionDataEntity pdEntity = new ProductionDataEntity();
  1086. pdEntity.ProductionDataID = Convert.ToInt32(drFor["ProductionDataID"]);
  1087. pdEntity.ProcedureID = Convert.ToInt32(drFor["ProcedureID"]);
  1088. pdEntity.ProcedureCode = drFor["ProcedureCode"].ToString();
  1089. pdEntity.ProcedureName = drFor["ProcedureName"].ToString();
  1090. pdList.Add(pdEntity);
  1091. }
  1092. return pdList;
  1093. }
  1094. #endregion
  1095. private void button1_Click(object sender, EventArgs e)
  1096. {
  1097. this.txtBarCode.Clear();
  1098. }
  1099. }
  1100. }