F_PM_1302.cs 87 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PM_1302.cs
  5. * 2.功能描述:新建入窑前检验-新建、编辑
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 王鑫 2014/10/11 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Data;
  13. using System.Drawing;
  14. using System.Drawing.Drawing2D;
  15. using System.Drawing.Imaging;
  16. using System.IO;
  17. using System.Windows.Forms;
  18. using Dongke.IBOSS.PRD.Basics.BaseControls;
  19. using Dongke.IBOSS.PRD.Basics.BaseResources;
  20. using Dongke.IBOSS.PRD.Client.CommonModule;
  21. using Dongke.IBOSS.PRD.Client.Controls.FormCommon;
  22. using Dongke.IBOSS.PRD.WCF.DataModels;
  23. using Dongke.IBOSS.PRD.WCF.Proxys;
  24. using Dongke.IBOSS.PRD.WCF.Proxys.PMModuleService;
  25. using Dongke.IBOSS.PRD.WCF.Proxys.SystemModuleService;
  26. namespace Dongke.IBOSS.PRD.Client.PMModule
  27. {
  28. /// <summary>
  29. /// 新建入窑前检验-新建、编辑
  30. /// </summary>
  31. public partial class F_PM_1302 : FormBase
  32. {
  33. #region 成员变量
  34. // 工序ID
  35. private int _procedureID;
  36. // 生产工号
  37. private int _userID = -1;
  38. // 生产编号
  39. private string _userCode;
  40. // 生产名称
  41. private string _userName;
  42. // 工序实体类
  43. ProcedureEntity _procedureDataEntity;
  44. // 产品数据表
  45. DataTable _dtProductionData = null;
  46. // 产品缺陷数据表
  47. DataTable _dtProductionDefectData = null;
  48. // 当前选择的行
  49. private int _selectedRowIndex;
  50. // ComBoxEditingControl
  51. private DataGridViewComboBoxEditingControl _dataGridViewComboBox = null;
  52. // 当前产品条码的产品ID,用来查询缺陷位置
  53. private int _currentGoodsID = 0;
  54. // 当前产品条码,用来切换筛选列表数据
  55. private string _currentBarCode = "";
  56. // 当前产品缺陷
  57. private int _currentDefectFlag = 0;
  58. // 返工工序搜索列表对象
  59. C_DGV_Cell_ListBoxComboBox _C_DGV_Cell_ListBoxComboBox = null;
  60. // 过滤结果集
  61. private DataSet _ds = null;
  62. // 过滤员工结果集
  63. private DataSet _dsStaff = null;
  64. // 过滤缺陷图片
  65. private DataSet _dsImage = null;
  66. // 临时数,用来过滤责任员工数据源标识
  67. private int _tempCount = 0;
  68. // 当前临时标记
  69. private string _currentTempSign = "";
  70. // 图片字节集
  71. private List<byte[]> _PicByte = new List<byte[]>();
  72. // 缩略图片字节集
  73. private List<byte[]> _smallByte = new List<byte[]>();
  74. // 当前产品缺陷
  75. private int _currentDefaultDefectFlag = 0;
  76. // 当前默认产品分级ID
  77. private int _currentGoodsLevelTypeID = 0;
  78. // 返工工序数据源
  79. private DataSet _dsRework = null;
  80. // 产品等级数据源
  81. private DataSet _dsGoodsLevel = null;
  82. // 生产数据ID
  83. private int? _productionDataID = null;
  84. // 过滤漏检员工结果集
  85. private DataSet _dsMissdeStaff = null;
  86. #endregion
  87. #region 属性
  88. /// <summary>
  89. /// 条码返工工序数据源
  90. /// </summary>
  91. public DataSet DSREWORK
  92. {
  93. set
  94. {
  95. _dsRework = value;
  96. }
  97. get
  98. {
  99. if (_dsRework == null)
  100. {
  101. return _dsRework = new DataSet();
  102. }
  103. return _dsRework;
  104. }
  105. }
  106. /// <summary>
  107. /// 生产工号
  108. /// </summary>
  109. public int UserID
  110. {
  111. set
  112. {
  113. _userID = value;
  114. }
  115. get
  116. {
  117. return _userID;
  118. }
  119. }
  120. /// <summary>
  121. /// 生产编号
  122. /// </summary>
  123. public string UserCode
  124. {
  125. set
  126. {
  127. _userCode = value;
  128. }
  129. get
  130. {
  131. return _userCode;
  132. }
  133. }
  134. /// <summary>
  135. /// 用户名称
  136. /// </summary>
  137. public string UserName
  138. {
  139. set
  140. {
  141. _userName = value;
  142. }
  143. get
  144. {
  145. return _userName;
  146. }
  147. }
  148. /// <summary>
  149. /// 产品数据表
  150. /// </summary>
  151. public DataTable TableProductionData
  152. {
  153. set
  154. {
  155. _dtProductionData = value;
  156. }
  157. get
  158. {
  159. if (_dtProductionData == null)
  160. {
  161. _dtProductionData = new DataTable("ProductionData");
  162. _dtProductionData.Columns.Add("ProductionDataID");
  163. _dtProductionData.Columns.Add("BarCode");
  164. _dtProductionData.Columns.Add("GoodsID");
  165. _dtProductionData.Columns.Add("GoodsCode");
  166. _dtProductionData.Columns.Add("GoodsName");
  167. _dtProductionData.Columns.Add("DefectFlagID", typeof(decimal));
  168. _dtProductionData.Columns.Add("ReworkProcedureID", typeof(decimal));
  169. _dtProductionData.Columns.Add("Remarks");
  170. _dtProductionData.Columns.Add("UserID");
  171. _dtProductionData.Columns.Add("KilnCarCode");
  172. _dtProductionData.Columns.Add("KilnCode");
  173. _dtProductionData.Columns.Add("Dictionaryvalue");
  174. _dtProductionData.Columns.Add("GoodsLevelTypeID");
  175. _dtProductionData.Columns.Add("ReFine");//重烧标识
  176. _dtProductionData.Columns.Add("SpecialRepairflag");//干补标识
  177. _dtProductionData.Columns.Add("SpecialRepairflagValue");//干补标识
  178. _dtProductionData.Columns.Add("UserCode");//生产工号
  179. _dtProductionData.Columns.Add("MouldCode");//模具编号
  180. _dtProductionData.Columns.Add("GroutingDate", typeof(DateTime));//注浆日期
  181. _dtProductionData.Columns.Add("GroutingUserCode");//成型工号
  182. _dtProductionData.Columns.Add("IsPublicBody");//公坯标识
  183. _dtProductionData.Columns.Add("GroutingNum");//注浆次数
  184. _dtProductionData.Columns.Add("LogoID");//
  185. _dtProductionData.Columns.Add("LogoCodeName");//
  186. return _dtProductionData;
  187. }
  188. else
  189. {
  190. return _dtProductionData;
  191. }
  192. }
  193. }
  194. /// <summary>
  195. /// 产品缺陷表
  196. /// </summary>
  197. public DataTable TableProductionDefectData
  198. {
  199. set
  200. {
  201. _dtProductionDefectData = value;
  202. }
  203. get
  204. {
  205. if (_dtProductionDefectData == null)
  206. {
  207. _dtProductionDefectData = new DataTable("ProductionDefectData");
  208. _dtProductionDefectData.Columns.Add("ProductionBarCode");
  209. _dtProductionDefectData.Columns.Add("DefectFlag", typeof(decimal));
  210. _dtProductionDefectData.Columns.Add("DefectLocation", typeof(decimal));
  211. _dtProductionDefectData.Columns.Add("DutyProcedureUserID", typeof(decimal));
  212. _dtProductionDefectData.Columns.Add("DutyUserCode");
  213. _dtProductionDefectData.Columns.Add("DefectRemarks");
  214. return _dtProductionDefectData;
  215. }
  216. else
  217. {
  218. return _dtProductionDefectData;
  219. }
  220. }
  221. }
  222. /// <summary>
  223. /// 缺陷数据集
  224. /// </summary>
  225. public DataSet DSTable
  226. {
  227. set
  228. {
  229. _ds = value;
  230. }
  231. get
  232. {
  233. if (_ds == null)
  234. {
  235. _ds = new DataSet();
  236. return _ds;
  237. }
  238. else
  239. {
  240. return _ds;
  241. }
  242. }
  243. }
  244. /// <summary>
  245. /// 员工数据集
  246. /// </summary>
  247. public DataSet DSTableStaff
  248. {
  249. set
  250. {
  251. _dsStaff = value;
  252. }
  253. get
  254. {
  255. if (_dsStaff == null)
  256. {
  257. _dsStaff = new DataSet();
  258. return _dsStaff;
  259. }
  260. else
  261. {
  262. return _dsStaff;
  263. }
  264. }
  265. }
  266. /// <summary>
  267. /// 漏检员工数据集
  268. /// </summary>
  269. public DataSet DSTableMissedStaff
  270. {
  271. set
  272. {
  273. _dsMissdeStaff = value;
  274. }
  275. get
  276. {
  277. if (_dsMissdeStaff == null)
  278. {
  279. _dsMissdeStaff = new DataSet();
  280. return _dsMissdeStaff;
  281. }
  282. else
  283. {
  284. return _dsMissdeStaff;
  285. }
  286. }
  287. }
  288. /// <summary>
  289. /// 缺陷图片
  290. /// </summary>
  291. public DataSet DSTableImage
  292. {
  293. set
  294. {
  295. _dsImage = value;
  296. }
  297. get
  298. {
  299. if (_dsImage == null)
  300. {
  301. _dsImage = new DataSet();
  302. return _dsImage;
  303. }
  304. else
  305. {
  306. return _dsImage;
  307. }
  308. }
  309. }
  310. #endregion
  311. #region 构造函数
  312. public F_PM_1302()
  313. {
  314. InitializeComponent();
  315. }
  316. public F_PM_1302(int procedureID, string fromTitle)
  317. {
  318. InitializeComponent();
  319. this._procedureID = procedureID;
  320. this.Text = fromTitle;
  321. this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
  322. this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
  323. this.btnSave.Text = ButtonText.BTN_SAVE;
  324. this.btnCancel.Text = ButtonText.BTN_CLOSE;
  325. this.tsbtnClose.Text = ButtonText.TSBTN_TOOL_CLOSE;
  326. this.btnUpload.Text = ButtonText.BTN_UPLOAD;
  327. this.btnDelete.Text = ButtonText.BTN_DELETE;
  328. }
  329. public F_PM_1302(int procedureID, string fromTitle, int ProductionDataID)
  330. {
  331. InitializeComponent();
  332. this._procedureID = procedureID;
  333. this._productionDataID = ProductionDataID;
  334. this.Text = fromTitle;
  335. this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
  336. this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
  337. this.btnSave.Text = ButtonText.BTN_SAVE;
  338. this.btnCancel.Text = ButtonText.BTN_CLOSE;
  339. this.tsbtnClose.Text = ButtonText.TSBTN_TOOL_CLOSE;
  340. this.btnUpload.Text = ButtonText.BTN_UPLOAD;
  341. this.btnDelete.Text = ButtonText.BTN_DELETE;
  342. }
  343. #endregion
  344. #region 事件
  345. /// <summary>
  346. /// 窗体加载事件
  347. /// </summary>
  348. /// <param name="sender"></param>
  349. /// <param name="e"></param>
  350. private void F_PM_1302_Load(object sender, System.EventArgs e)
  351. {
  352. try
  353. {
  354. this.dgvProductionData.AutoGenerateColumns = false;
  355. this.dgvProductionData.DataSource = TableProductionData;
  356. this.dgvDefect.AutoGenerateColumns = false;
  357. this.dgvDefectStaff.AutoGenerateColumns = false;
  358. // 加载权限
  359. FormPermissionManager.FormPermissionControl(this.Name, this,
  360. Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
  361. Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  362. // 获取工序明细数据
  363. ProcedureEntity procedureDataEntity = (ProcedureEntity)DoAsync(new BaseAsyncMethod(() =>
  364. {
  365. return PMModuleProxy.Service.GetProcedureDataEntityByID(this._procedureID);
  366. }));
  367. this._procedureDataEntity = procedureDataEntity;
  368. // 缺陷数据源
  369. DataSet dsGoodsLevel = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  370. {
  371. return SystemModuleProxy.Service.GetGoodsLevel(1);//半成品检验
  372. }));
  373. if (dsGoodsLevel != null && dsGoodsLevel.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  374. {
  375. this._dsGoodsLevel = dsGoodsLevel;
  376. }
  377. // 设置控件禁用或启用
  378. SetControlEnable();
  379. #region wangx 2012-12-28 add
  380. if (this._productionDataID != null)
  381. {
  382. //加载数据源
  383. this.txtUserCode.Enabled = false;
  384. this.txtBarCode.Enabled = false;
  385. this.tsbtnAdd.Enabled = true;
  386. // 此工号是否能生产工序
  387. CheckProcedureUserResult checkProcedureUser = (CheckProcedureUserResult)DoAsync(new BaseAsyncMethod(() =>
  388. {
  389. return PMModuleProxy.Service.CheckProcedureUser(this._procedureID,
  390. Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserCode);
  391. }));
  392. if (checkProcedureUser != null)
  393. {
  394. if (!string.IsNullOrEmpty(checkProcedureUser.ErrMsg))
  395. {
  396. // 此工号不允许生产工序
  397. MessageBox.Show(checkProcedureUser.ErrMsg,
  398. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  399. this.Close();
  400. return;
  401. }
  402. }
  403. UserID = checkProcedureUser.UserID;
  404. UserCode = checkProcedureUser.UserCode;
  405. UserName = checkProcedureUser.UserName;
  406. this.txtUserCode.Text = UserCode;
  407. DataSet dsProductionDataByID = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  408. {
  409. return PMModuleProxy.Service.GetProductionDataByID(Convert.ToInt32(this._productionDataID));
  410. }));
  411. if (dsProductionDataByID != null && dsProductionDataByID.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  412. {
  413. // 干补标识
  414. int SpecialRepairflag = (int)DoAsync(new BaseAsyncMethod(() =>
  415. {
  416. return PMModuleProxy.Service.GetSpecialRepairflagByBarcode(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString());
  417. }));
  418. // 产品数据
  419. DataRow drNew = TableProductionData.NewRow();
  420. drNew["ProductionDataID"] = this._productionDataID;
  421. drNew["BarCode"] = dsProductionDataByID.Tables[0].Rows[0]["BarCode"];
  422. drNew["GoodsID"] = dsProductionDataByID.Tables[0].Rows[0]["GoodsID"];
  423. drNew["GoodsCode"] = dsProductionDataByID.Tables[0].Rows[0]["GoodsCode"];
  424. drNew["GoodsName"] = dsProductionDataByID.Tables[0].Rows[0]["GoodsName"];
  425. drNew["DefectFlagID"] = dsProductionDataByID.Tables[0].Rows[0]["DefectFlagID"];
  426. drNew["ReworkProcedureID"] = dsProductionDataByID.Tables[0].Rows[0]["ReworkProcedureID"];
  427. drNew["Remarks"] = dsProductionDataByID.Tables[0].Rows[0]["Remarks"];
  428. drNew["UserID"] = dsProductionDataByID.Tables[0].Rows[0]["UserID"];
  429. drNew["KilnCarCode"] = dsProductionDataByID.Tables[0].Rows[0]["KilnCarCode"];
  430. drNew["KilnCode"] = dsProductionDataByID.Tables[0].Rows[0]["KilnCode"];
  431. drNew["Dictionaryvalue"] = dsProductionDataByID.Tables[0].Rows[0]["Dictionaryvalue"];
  432. drNew["GoodsLevelTypeID"] = dsProductionDataByID.Tables[0].Rows[0]["GoodsLevelTypeID"];
  433. drNew["ReFine"] = 0;
  434. drNew["SpecialRepairflag"] = SpecialRepairflag.ToString() == "1" ? 1 : 0;
  435. drNew["UserCode"] = dsProductionDataByID.Tables[0].Rows[0]["UserCode"];
  436. drNew["MouldCode"] = dsProductionDataByID.Tables[0].Rows[0]["MouldCode"];
  437. drNew["GroutingDate"] = Convert.ToDateTime(dsProductionDataByID.Tables[0].Rows[0]["GroutingDate"]);
  438. drNew["GroutingUserCode"] = dsProductionDataByID.Tables[0].Rows[0]["GroutingUserCode"];
  439. drNew["IsPublicBody"] = dsProductionDataByID.Tables[0].Rows[0]["IsPublicBody"].ToString() != "1" ? 0 : 1;
  440. drNew["GroutingNum"] = dsProductionDataByID.Tables[0].Rows[0]["GroutingNum"];
  441. drNew["LogoCodeName"] = dsProductionDataByID.Tables[0].Rows[0]["LogoName"] + "[" + dsProductionDataByID.Tables[0].Rows[0]["LogoCode"] + "]";
  442. drNew["LogoId"] = dsProductionDataByID.Tables[0].Rows[0]["LogoId"];
  443. TableProductionData.Rows.Add(drNew);
  444. this.dgvProductionData.Rows[TableProductionData.Rows.Count - 1].Selected = true;
  445. this._selectedRowIndex = TableProductionData.Rows.Count - 1;
  446. this._currentBarCode = dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString();
  447. this._currentGoodsID = Convert.ToInt32(dsProductionDataByID.Tables[0].Rows[0]["GoodsID"]);
  448. if (DSTable.Tables.IndexOf(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString()) == -Constant.INT_IS_ONE)
  449. {
  450. DataTable dtProductionDefectData = new DataTable(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString());
  451. dtProductionDefectData.Columns.Add("BarCode");
  452. dtProductionDefectData.Columns.Add("discarde");
  453. dtProductionDefectData.Columns.Add("DefectID", typeof(decimal));
  454. dtProductionDefectData.Columns.Add("DefectName");
  455. dtProductionDefectData.Columns.Add("DefectCode");
  456. dtProductionDefectData.Columns.Add("DefectPositionID", typeof(decimal));
  457. dtProductionDefectData.Columns.Add("DefectPositionName");
  458. dtProductionDefectData.Columns.Add("DefectPositionCode");
  459. dtProductionDefectData.Columns.Add("DefectProcedureID", typeof(decimal));
  460. dtProductionDefectData.Columns.Add("DefectProcedureName");
  461. dtProductionDefectData.Columns.Add("DefectProcedureCode");
  462. dtProductionDefectData.Columns.Add("DefectUserID", typeof(decimal));//责任员工
  463. dtProductionDefectData.Columns.Add("DefectUserName");//责任员工
  464. dtProductionDefectData.Columns.Add("DefectUserCode");//
  465. dtProductionDefectData.Columns.Add("Jobs", typeof(decimal));//工种
  466. dtProductionDefectData.Columns.Add("JobsText");//工种
  467. dtProductionDefectData.Columns.Add("DefectRemarks");
  468. dtProductionDefectData.Columns.Add("TempCount");
  469. dtProductionDefectData.Columns.Add("ProductionDataID"); //生产数据ID
  470. dtProductionDefectData.Columns.Add("DefectFineID"); //缺陷扣罚ID
  471. dtProductionDefectData.Columns.Add("DefectFineValue"); //缺陷扣罚
  472. dtProductionDefectData.Columns.Add("MissedUserID"); //漏检工号ID
  473. dtProductionDefectData.Columns.Add("MissedUserCode"); //漏检工号编码
  474. dtProductionDefectData.Columns.Add("MissedUserName"); //漏检工号名称
  475. dtProductionDefectData.Columns.Add("IsAllowEdit"); //是否允许编辑 0 不允许,1允许
  476. dtProductionDefectData.Columns.Add("CheckTime"); //缺陷检验时间
  477. DSTable.Tables.Add(dtProductionDefectData);
  478. }
  479. for (int i = 0; i < dsProductionDataByID.Tables[1].Rows.Count; i++)
  480. {
  481. DataRow dr = DSTable.Tables[dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString()].NewRow();
  482. dr["BarCode"] = dsProductionDataByID.Tables[1].Rows[i]["BarCode"];
  483. dr["DefectID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectID"];
  484. dr["DefectName"] = dsProductionDataByID.Tables[1].Rows[i]["DefectName"];
  485. dr["DefectCode"] = dsProductionDataByID.Tables[1].Rows[i]["DefectCode"];
  486. dr["DefectPositionID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectPositionID"];
  487. dr["DefectPositionName"] = dsProductionDataByID.Tables[1].Rows[i]["DefectPositionName"];
  488. dr["DefectPositionCode"] = dsProductionDataByID.Tables[1].Rows[i]["DefectPositionCode"];
  489. dr["DefectProcedureID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectProcedureID"];
  490. dr["DefectProcedureName"] = dsProductionDataByID.Tables[1].Rows[i]["DefectProcedureName"];
  491. dr["DefectProcedureCode"] = dsProductionDataByID.Tables[1].Rows[i]["DefectProcedureCode"];
  492. dr["DefectUserID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectUserID"];
  493. dr["DefectUserName"] = dsProductionDataByID.Tables[1].Rows[i]["DefectUserName"];
  494. dr["DefectUserCode"] = dsProductionDataByID.Tables[1].Rows[i]["DefectUserCode"];
  495. dr["Jobs"] = dsProductionDataByID.Tables[1].Rows[i]["Jobs"];
  496. dr["JobsText"] = dsProductionDataByID.Tables[1].Rows[i]["JobsText"];
  497. dr["DefectRemarks"] = dsProductionDataByID.Tables[1].Rows[i]["DefectRemarks"];
  498. dr["TempCount"] = this._tempCount;
  499. dr["ProductionDataID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectProductionDataID"];// dsProductionDataByID.Tables[1].Rows[i]["ProductionDataID"];
  500. dr["DefectFineID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectFineID"];
  501. dr["DefectFineValue"] = dsProductionDataByID.Tables[1].Rows[i]["DefectFineValue"];
  502. dr["MissedUserID"] = dsProductionDataByID.Tables[1].Rows[i]["MissedUserID"];
  503. dr["MissedUserCode"] = dsProductionDataByID.Tables[1].Rows[i]["MissedUserCode"];
  504. dr["MissedUserName"] = dsProductionDataByID.Tables[1].Rows[i]["MissedUserName"];
  505. dr["IsAllowEdit"] = 1;
  506. dr["CheckTime"] = Convert.ToDateTime(dsProductionDataByID.Tables[1].Rows[i]["CheckTime"]);
  507. DSTable.Tables[dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString()].Rows.Add(dr);
  508. // 防止工种不选择的话,直接New一个
  509. if (!this.DSTableStaff.Tables.Contains(string.Format("TempTable{0}", this._tempCount)))
  510. {
  511. DataTable dtStaff = new DataTable(string.Format("TempTable{0}", this._tempCount));
  512. dtStaff.Columns.Add("IsSelected");
  513. dtStaff.Columns.Add("StaffID");
  514. dtStaff.Columns.Add("StaffCode");
  515. dtStaff.Columns.Add("StaffName");
  516. dtStaff.Columns.Add("StaffTempCount");
  517. dtStaff.Columns.Add("StaffStatus");
  518. this.DSTableStaff.Tables.Add(dtStaff);
  519. }
  520. // 责任员工
  521. DataRow[] drRow = dsProductionDataByID.Tables[2].Select("ProductionDefectID=" + dsProductionDataByID.Tables[1].Rows[i]["ProductionDefectID"]);
  522. if (drRow.Length > Constant.INT_IS_ZERO)
  523. {
  524. foreach (DataRow r in drRow)
  525. {
  526. DataRow drStaff = this.DSTableStaff.Tables[string.Format("TempTable{0}", this._tempCount)].NewRow();
  527. drStaff["IsSelected"] = 1;
  528. drStaff["StaffID"] = r["StaffID"];
  529. drStaff["StaffCode"] = r["StaffCode"];
  530. drStaff["StaffName"] = r["StaffName"];
  531. drStaff["StaffTempCount"] = this._tempCount;
  532. drStaff["StaffStatus"] = r["StaffStatus"];
  533. this.DSTableStaff.Tables[string.Format("TempTable{0}", this._tempCount)].Rows.Add(drStaff);
  534. }
  535. }
  536. // 漏检员工临时表
  537. if (!this.DSTableMissedStaff.Tables.Contains(string.Format("TempTable{0}", this._tempCount)))
  538. {
  539. DataTable dtMissedStaff = new DataTable(string.Format("TempTable{0}", this._tempCount));
  540. dtMissedStaff.Columns.Add("IsSelected");
  541. dtMissedStaff.Columns.Add("StaffID");
  542. dtMissedStaff.Columns.Add("StaffCode");
  543. dtMissedStaff.Columns.Add("StaffName");
  544. dtMissedStaff.Columns.Add("StaffTempCount");
  545. dtMissedStaff.Columns.Add("StaffStatus");
  546. dtMissedStaff.Columns.Add("UJobsID");
  547. dtMissedStaff.Columns.Add("SJobsID");
  548. this.DSTableMissedStaff.Tables.Add(dtMissedStaff);
  549. }
  550. //漏检员工临时表数据
  551. DataRow[] drMissedRow = dsProductionDataByID.Tables[4].Select("ProductionDefectID=" + dsProductionDataByID.Tables[1].Rows[i]["ProductionDefectID"]);
  552. if (drMissedRow.Length > Constant.INT_IS_ZERO)
  553. {
  554. foreach (DataRow r in drMissedRow)
  555. {
  556. DataRow drMissedStaff = this.DSTableMissedStaff.Tables[string.Format("TempTable{0}", this._tempCount)].NewRow();
  557. drMissedStaff["IsSelected"] = 1;
  558. drMissedStaff["StaffID"] = r["StaffID"];
  559. drMissedStaff["StaffCode"] = r["StaffCode"];
  560. drMissedStaff["StaffName"] = r["StaffName"];
  561. drMissedStaff["StaffTempCount"] = this._tempCount;
  562. drMissedStaff["StaffStatus"] = r["StaffStatus"];
  563. drMissedStaff["UJobsID"] = r["UJobsID"];
  564. drMissedStaff["SJobsID"] = r["SJobsID"];
  565. this.DSTableMissedStaff.Tables[string.Format("TempTable{0}", this._tempCount)].Rows.Add(drMissedStaff);
  566. }
  567. }
  568. if (!this.DSTableImage.Tables.Contains(string.Format("TempTable{0}", this._tempCount.ToString())))
  569. {
  570. DataTable dtImage = new DataTable(string.Format("TempTable{0}", this._tempCount.ToString()));
  571. dtImage.Columns.Add("StaffTempCount");
  572. dtImage.Columns.Add("ImageByte", typeof(byte[]));
  573. dtImage.Columns.Add("OrgImageByte", typeof(byte[]));
  574. this.DSTableImage.Tables.Add(dtImage);
  575. }
  576. this._currentTempSign = i.ToString();
  577. // 缺陷图片
  578. DataRow[] drImageRow = dsProductionDataByID.Tables[3].Select("ProductionDefectID=" + dsProductionDataByID.Tables[1].Rows[i]["ProductionDefectID"]);
  579. if (drImageRow.Length > Constant.INT_IS_ZERO)
  580. {
  581. foreach (DataRow r in drImageRow)
  582. {
  583. if (r["SourcePathByte"] != DBNull.Value)
  584. {
  585. byte[] orgImageByte = (byte[])r["SourcePathByte"];
  586. this._PicByte.Add(orgImageByte);
  587. //this._smallByte.Add(orgImageByte);
  588. if (!this.DSTableImage.Tables.Contains(string.Format("TempTable{0}", this._currentTempSign.ToString())))
  589. {
  590. DataTable dtImage = new DataTable(string.Format("TempTable{0}", this._currentTempSign.ToString()));
  591. dtImage.Columns.Add("StaffTempCount");
  592. dtImage.Columns.Add("ImageByte", typeof(byte[]));
  593. dtImage.Columns.Add("OrgImageByte", typeof(byte[]));
  594. this.DSTableImage.Tables.Add(dtImage);
  595. }
  596. DataRow drrow = DSTableImage.Tables[string.Format("TempTable{0}", this._currentTempSign)].NewRow();
  597. drrow["StaffTempCount"] = this._currentTempSign;
  598. drrow["ImageByte"] = orgImageByte;
  599. drrow["OrgImageByte"] = orgImageByte;
  600. DSTableImage.Tables[string.Format("TempTable{0}", this._currentTempSign)].Rows.Add(drrow);
  601. BindImg();
  602. }
  603. }
  604. }
  605. this._tempCount = this._tempCount + 1;
  606. }
  607. this.dgvDefect.DataSource = DSTable.Tables[dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString()];//根据条码产生不同数据源
  608. }
  609. }
  610. #endregion wangx 2012-12-28 add end
  611. }
  612. catch (Exception ex)
  613. {
  614. // 对异常进行共通处理
  615. ExceptionManager.HandleEventException(this.ToString(),
  616. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  617. }
  618. }
  619. /// <summary>
  620. /// 设置控件禁用或启用
  621. /// </summary>
  622. private void SetControlEnable()
  623. {
  624. if (this._procedureDataEntity != null)
  625. {
  626. if (this._procedureDataEntity.CollectType == (int)Constant.ProcedureCollectType.Togather)
  627. {
  628. this.txtUserCode.Enabled = true;
  629. this.btnSave.Visible = true;
  630. }
  631. else
  632. {
  633. this.txtUserCode.Enabled = true;
  634. this.txtUserCode.ReadOnly = true;
  635. // 此工号是否能生产工序
  636. CheckProcedureUserResult checkProcedureUser = (CheckProcedureUserResult)DoAsync(new BaseAsyncMethod(() =>
  637. {
  638. return PMModuleProxy.Service.CheckProcedureUser(this._procedureID,
  639. Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserCode);
  640. }));
  641. if (checkProcedureUser != null)
  642. {
  643. if (!string.IsNullOrEmpty(checkProcedureUser.ErrMsg))
  644. {
  645. // 此工号不允许生产工序
  646. MessageBox.Show(checkProcedureUser.ErrMsg,
  647. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  648. this.Close();
  649. return;
  650. }
  651. }
  652. UserID = checkProcedureUser.UserID;
  653. UserCode = checkProcedureUser.UserCode;
  654. UserName = checkProcedureUser.UserName;
  655. }
  656. this.txtUserCode.Text = UserCode;
  657. }
  658. }
  659. /// <summary>
  660. /// 条形码按键事件
  661. /// </summary>
  662. /// <param name="sender"></param>
  663. /// <param name="e"></param>
  664. private void txtBarCode_KeyPress(object sender, KeyPressEventArgs e)
  665. {
  666. try
  667. {
  668. if (this.txtBarCode.ReadOnly)
  669. {
  670. return;
  671. }
  672. if ((int)e.KeyChar == 13) // 按了回车键
  673. {
  674. if (this.txtUserCode.Text.Trim() == string.Empty)
  675. {
  676. this.txtUserCode.Focus();
  677. this.txtBarCode.Text = string.Empty;
  678. return;
  679. }
  680. if (this.txtBarCode.Text.Trim() == string.Empty)
  681. {
  682. this.txtBarCode.Focus();
  683. return;
  684. }
  685. // 校验条码 获取校验条码信
  686. DataSet dsCheckBarcode = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  687. {
  688. return PMModuleProxy.Service.CheckBarcode(this._procedureID, this.txtBarCode.Text.Trim());
  689. }));
  690. if (dsCheckBarcode != null && dsCheckBarcode.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  691. {
  692. if (dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString() != string.Empty)
  693. {
  694. // 表示有错误
  695. //MessageBox.Show(string.Format(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString(), this.txtBarCode.Text.Trim(), "产品条码"),
  696. // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  697. //this.txtBarCode.Focus();
  698. //return;
  699. if (dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_missFlag.ToString()].ToString() == "0")
  700. {
  701. // 表示有错误
  702. MessageBox.Show(string.Format(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString(), this.txtBarCode.Text.Trim(), "产品条码"),
  703. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  704. }
  705. else
  706. {
  707. S_CMN_020 frmscmn020 = new S_CMN_020(Convert.ToInt32(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_missFlag.ToString()])
  708. , dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString());
  709. frmscmn020.ShowDialog();
  710. }
  711. this.txtBarCode.Focus();
  712. this.txtBarCode.SelectAll();
  713. return;
  714. }
  715. else
  716. {
  717. BindProductionData(dsCheckBarcode);
  718. this._currentBarCode = txtBarCode.Text.Trim();
  719. this.txtBarCode.Text = string.Empty;
  720. }
  721. }
  722. }
  723. }
  724. catch (Exception ex)
  725. {
  726. // 对异常进行共通处理
  727. ExceptionManager.HandleEventException(this.ToString(),
  728. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  729. }
  730. }
  731. /// <summary>
  732. /// 生产数据下拉列表改变事件
  733. /// </summary>
  734. /// <param name="sender"></param>
  735. /// <param name="e"></param>
  736. private void dataGridViewComboBox_SelectionChangeCommitted(object sender, EventArgs e)
  737. {
  738. this._currentDefectFlag = Convert.ToInt32(((ComboBox)sender).SelectedValue.ToString());//当前缺陷类型
  739. SetGridView(Convert.ToInt32(((ComboBox)sender).SelectedValue.ToString()));
  740. }
  741. /// <summary>
  742. /// 产品数据单元格进入事件
  743. /// </summary>
  744. /// <param name="sender"></param>
  745. /// <param name="e"></param>
  746. private void dgvProductionData_CellEnter(object sender, DataGridViewCellEventArgs e)
  747. {
  748. try
  749. {
  750. if (this.dgvProductionData.CurrentCell != null)
  751. {
  752. // 记录最后选择行
  753. this._selectedRowIndex = this.dgvProductionData.CurrentCell.RowIndex;
  754. this._currentBarCode = this.dgvProductionData.Rows[_selectedRowIndex].Cells["BarCode"].Value.ToString();
  755. this._C_DGV_Cell_ListBoxComboBox = dgvProductionData.Rows[_selectedRowIndex].Cells[4] as C_DGV_Cell_ListBoxComboBox;
  756. DataSet ds = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  757. {
  758. return PMModuleProxy.Service.GetReworkProcedureByBarcode(this._procedureID, this.dgvProductionData.Rows[_selectedRowIndex].Cells["BarCode"].Value.ToString());
  759. }));
  760. this._currentGoodsID = Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["GoodsID"].Value);
  761. this._currentBarCode = this.dgvProductionData.Rows[_selectedRowIndex].Cells["BarCode"].Value.ToString();
  762. this._C_DGV_Cell_ListBoxComboBox.DisplayMember = "ReworkProcedureName";
  763. this._C_DGV_Cell_ListBoxComboBox.ValueMember = "ReworkProcedureID";
  764. this._C_DGV_Cell_ListBoxComboBox.DataSource = ds.Tables[0];
  765. }
  766. }
  767. catch (Exception ex)
  768. {
  769. // 对异常进行共通处理
  770. ExceptionManager.HandleEventException(this.ToString(),
  771. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  772. }
  773. }
  774. /// <summary>
  775. /// 产品数据选定项改变事件
  776. /// </summary>
  777. /// <param name="sender"></param>
  778. /// <param name="e"></param>
  779. private void dgvProductionData_SelectionChanged(object sender, EventArgs e)
  780. {
  781. try
  782. {
  783. if (this.dgvProductionData.CurrentCell != null)
  784. {
  785. this._selectedRowIndex = this.dgvProductionData.CurrentCell.RowIndex;
  786. // 有无缺陷 0无缺陷 1有缺陷
  787. this._currentDefectFlag = Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["DefectFlag"].Value.ToString());
  788. this._currentGoodsID = Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["GoodsID"].Value);
  789. this._currentBarCode = this.dgvProductionData.Rows[_selectedRowIndex].Cells["BarCode"].Value.ToString();
  790. this.dgvDefect.DataSource = DSTable.Tables[this._currentBarCode];
  791. this.dgvDefectStaff.CurrentCell = null;
  792. this.dgvDefectStaff.DataSource = null;
  793. this._smallByte.Clear();//防止重复绑定图片
  794. this.lvPic.Clear();//
  795. }
  796. }
  797. catch (Exception ex)
  798. {
  799. // 对异常进行共通处理
  800. ExceptionManager.HandleEventException(this.ToString(),
  801. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  802. }
  803. }
  804. /// <summary>
  805. /// 缺陷数据源选定项改变事件
  806. /// </summary>
  807. /// <param name="sender"></param>
  808. /// <param name="e"></param>
  809. private void dgvDefect_SelectionChanged(object sender, EventArgs e)
  810. {
  811. try
  812. {
  813. if (this.dgvDefect.CurrentCell != null)
  814. {
  815. this.tsbtnEdit.Enabled = true;
  816. if (this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["TempCount"].Value.ToString() != string.Empty)
  817. {
  818. int staffTempCount = Convert.ToInt32(this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["TempCount"].Value.ToString());
  819. this.dgvDefectStaff.DataSource = DSTableStaff.Tables[string.Format("TempTable{0}", staffTempCount.ToString())];
  820. this._currentTempSign = this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["TempCount"].Value.ToString(); //当前临时标记
  821. this._smallByte.Clear();//防止重复绑定图片
  822. BindByteImage(DSTableImage.Tables[string.Format("TempTable{0}", staffTempCount.ToString())]);
  823. }
  824. else
  825. {
  826. this.dgvDefectStaff.DataSource = null;
  827. this._smallByte.Clear();//防止重复绑定图片
  828. this.lvPic.Clear();//
  829. }
  830. }
  831. }
  832. catch (Exception ex)
  833. {
  834. // 对异常进行共通处理
  835. ExceptionManager.HandleEventException(this.ToString(),
  836. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  837. }
  838. }
  839. /// <summary>
  840. /// 单元格CheckBox事件
  841. /// </summary>
  842. /// <param name="sender"></param>
  843. /// <param name="e"></param>
  844. private void dgvDefect_CellContentClick(object sender, DataGridViewCellEventArgs e)
  845. {
  846. if (e.ColumnIndex == Constant.INT_IS_ZERO && e.RowIndex != -Constant.INT_IS_ONE)
  847. {
  848. int checkValue = Convert.ToInt32(this.dgvDefect.Rows[e.RowIndex].Cells[0].EditedFormattedValue);
  849. if (checkValue == Constant.INT_IS_ZERO)
  850. {
  851. SetCheckBoxSelected(checkValue, e.RowIndex);
  852. }
  853. else
  854. {
  855. this.dgvDefect.Rows[e.RowIndex].Cells[0].Value = 0;
  856. }
  857. }
  858. }
  859. /// <summary>
  860. /// 上传图片按钮事件
  861. /// </summary>
  862. /// <param name="sender"></param>
  863. /// <param name="e"></param>
  864. private void btnUpload_Click(object sender, EventArgs e)
  865. {
  866. try
  867. {
  868. this.odlgFile.Filter = Constant.FILTER_PIC;
  869. this.odlgFile.FilterIndex = Constant.INT_IS_ZERO;
  870. this.odlgFile.RestoreDirectory = true;
  871. this.odlgFile.Title = "选择缺陷图片";
  872. this.odlgFile.FileName = null;
  873. this.odlgFile.RestoreDirectory = true;
  874. if (this.odlgFile.ShowDialog() == DialogResult.OK)
  875. {
  876. FileInfo file = new FileInfo(odlgFile.FileName);
  877. if (Constant.UPLOAD_PIC_MAX_SIZE < file.Length)
  878. {
  879. MessageBox.Show(string.Format(Messages.MSG_CMN_W013, "缺陷图片", "大小", "1M"),
  880. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  881. }
  882. else
  883. {
  884. Image PicImage = Image.FromStream(file.OpenRead());
  885. byte[] orgImageByte = ImageToByte(PicImage);
  886. this._PicByte.Add(orgImageByte);
  887. GetThumbnail(file, orgImageByte);
  888. BindImg();
  889. }
  890. }
  891. }
  892. catch (Exception ex)
  893. {
  894. // 对异常进行共通处理
  895. ExceptionManager.HandleEventException(this.ToString(),
  896. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  897. }
  898. }
  899. /// <summary>
  900. /// 删除图片按钮事件
  901. /// </summary>
  902. /// <param name="sender"></param>
  903. /// <param name="e"></param>
  904. private void btnDelete_Click(object sender, EventArgs e)
  905. {
  906. foreach (ListViewItem lvSelect in lvPic.SelectedItems)
  907. {
  908. int index = lvSelect.Index;
  909. if (index < Constant.INT_IS_ZERO)
  910. {
  911. index = Constant.INT_IS_ZERO;
  912. }
  913. if (this._currentTempSign != string.Empty)
  914. {
  915. DSTableImage.Tables[string.Format("TempTable{0}", this._currentTempSign)].Rows.RemoveAt(lvSelect.Index);
  916. DSTableImage.Tables[string.Format("TempTable{0}", this._currentTempSign)].AcceptChanges();
  917. }
  918. BindByteImage(DSTableImage.Tables[string.Format("TempTable{0}", this._currentTempSign)]);
  919. }
  920. }
  921. /// <summary>
  922. /// 关闭按钮事件
  923. /// </summary>
  924. /// <param name="sender"></param>
  925. /// <param name="e"></param>
  926. private void tsbtnClose_Click(object sender, EventArgs e)
  927. {
  928. this.Close();
  929. }
  930. /// <summary>
  931. /// 产品条码列表删除事件
  932. /// </summary>
  933. /// <param name="sender"></param>
  934. /// <param name="e"></param>
  935. private void dgvProductionData_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
  936. {
  937. try
  938. {
  939. string BarCode = this.dgvProductionData.Rows[e.Row.Index].Cells["BarCode"].Value.ToString();
  940. DSTable.Tables[BarCode].Rows.Clear();//清空行
  941. this.dgvDefectStaff.DataSource = null;
  942. this.lvPic.Clear();
  943. }
  944. catch (Exception ex)
  945. {
  946. throw ex;
  947. }
  948. }
  949. /// <summary>
  950. /// 产品缺陷删除行事件
  951. /// </summary>
  952. /// <param name="sender"></param>
  953. /// <param name="e"></param>
  954. private void dgvDefect_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
  955. {
  956. try
  957. {
  958. string TempCount = this.dgvDefect.Rows[e.Row.Index].Cells["TempCount"].Value.ToString();
  959. DSTableStaff.Tables[string.Format("TempTable{0}", TempCount.ToString())].Rows.Clear();//清空行
  960. this.dgvDefectStaff.DataSource = null;
  961. this.lvPic.Clear();
  962. }
  963. catch (Exception ex)
  964. {
  965. throw ex;
  966. }
  967. }
  968. /// <summary>
  969. /// 新建按钮事件
  970. /// </summary>
  971. /// <param name="sender"></param>
  972. /// <param name="e"></param>
  973. private void tsbtnAdd_Click(object sender, EventArgs e)
  974. {
  975. if (this.TableProductionData.Rows.Count > 0)
  976. {
  977. F_PM_1303 frm1303 = new F_PM_1303(
  978. DSTable.Tables[this._currentBarCode], this._currentBarCode,
  979. this._currentGoodsID, this._tempCount, this._procedureID, this.Text, false, this, this.DSTableStaff, this.DSTableImage, this._PicByte, this._smallByte, -1);
  980. frm1303.ShowDialog();
  981. }
  982. }
  983. /// <summary>
  984. /// 编辑按钮事件
  985. /// </summary>
  986. /// <param name="sender"></param>
  987. /// <param name="e"></param>
  988. private void tsbtnEdit_Click(object sender, EventArgs e)
  989. {
  990. if (this.dgvDefect.CurrentCell != null)
  991. {
  992. string barcode = this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["ProductionBarCode"].Value.ToString();
  993. int tempcount = Convert.ToInt32(this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["TempCount"].Value.ToString());
  994. int goodsID = 0;
  995. DataRow[] dr = this.TableProductionData.Select("BarCode='" + barcode + "'");
  996. if (dr.Length > Constant.INT_IS_ZERO)
  997. {
  998. goodsID = Convert.ToInt32(dr[0]["GoodsID"]);
  999. }
  1000. F_PM_1303 frm1303 = new F_PM_1303(
  1001. DSTable.Tables[barcode], barcode,
  1002. goodsID, tempcount, this._procedureID, this.Text, true, this, this.DSTableStaff, this.DSTableImage, this._PicByte, this._smallByte, this.dgvDefect.CurrentCell.RowIndex);
  1003. frm1303.ShowDialog();
  1004. }
  1005. }
  1006. /// <summary>
  1007. /// 保存按钮事件
  1008. /// </summary>
  1009. /// <param name="sender"></param>
  1010. /// <param name="e"></param>
  1011. private void btnSave_Click(object sender, EventArgs e)
  1012. {
  1013. try
  1014. {
  1015. ProductionDataEntity[] productionDataEntitys = new ProductionDataEntity[this.TableProductionData.Rows.Count];
  1016. bool isError = false; // 是否存在缺陷员工
  1017. int ErrorNumber = -1;//错误编码
  1018. for (int i = 0; i < this.TableProductionData.Rows.Count; i++)
  1019. {
  1020. ProductionDataEntity productionDataEntity = new ProductionDataEntity();
  1021. productionDataEntity.ProductionDataID = this._productionDataID==null?0:Convert.ToInt32(this._productionDataID);
  1022. productionDataEntity.Barcode = this.TableProductionData.Rows[i]["BarCode"].ToString();
  1023. productionDataEntity.UserID = UserID;
  1024. productionDataEntity.UserCode = UserCode;
  1025. productionDataEntity.UserName = UserName;
  1026. productionDataEntity.DefectFlag = Constant.GoodsLevelType.Defect.GetHashCode();
  1027. DataRow[] drSelected = this.DSTable.Tables[productionDataEntity.Barcode].Select("discarde=1");
  1028. if (drSelected.Length == 0)
  1029. {
  1030. productionDataEntity.GoodsLevelTypeID = Constant.GoodsLevelType.Defect.GetHashCode();
  1031. }
  1032. else
  1033. {
  1034. productionDataEntity.GoodsLevelTypeID = Constant.GoodsLevelType.Waste.GetHashCode();//废品
  1035. }
  1036. if (this._dsGoodsLevel != null)
  1037. {
  1038. DataRow[] dr = this._dsGoodsLevel.Tables[0].Select("GoodsLevelTypeID=" + productionDataEntity.GoodsLevelTypeID);
  1039. if (dr.Length > 0)
  1040. {
  1041. productionDataEntity.GoodsLevelID = Convert.ToInt32(dr[0]["DefectFlagID"]);
  1042. }
  1043. }
  1044. productionDataEntity.Remarks = this.TableProductionData.Rows[i]["Remarks"].ToString();
  1045. if (this.TableProductionData.Rows[i]["LogoID"].ToString() != "")
  1046. {
  1047. productionDataEntity.LogoID = Convert.ToInt32(this.TableProductionData.Rows[i]["LogoID"]);
  1048. }
  1049. productionDataEntitys[i] = productionDataEntity;
  1050. if (this.DSTable.Tables[productionDataEntity.Barcode].Rows.Count == 0)//但是没有缺陷数据
  1051. {
  1052. isError = true;
  1053. ErrorNumber = -2;
  1054. this.dgvProductionData.Rows[i].Selected = true;
  1055. break;
  1056. }
  1057. List<ProductionDefectEntity> productionDefectEntitys = new List<ProductionDefectEntity>();
  1058. ProductionDefectEntity productionDefectEntity = null;
  1059. for (int j = 0; j < this.DSTable.Tables[productionDataEntity.Barcode].Rows.Count; j++) //缺陷列表
  1060. {
  1061. productionDefectEntity = new ProductionDefectEntity();
  1062. productionDefectEntity.ScrapFlag = Convert.ToBoolean(
  1063. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["discarde"].ToString() == "" ? 0 : this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["discarde"]));
  1064. productionDefectEntity.ScrapResponFlag =
  1065. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["discarde"].ToString();
  1066. productionDefectEntity.DefectID =
  1067. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectID"]);
  1068. productionDefectEntity.DefectCode =
  1069. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectCode"].ToString();
  1070. //productionDefectEntity.DefectName =
  1071. // this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectName"].ToString();
  1072. productionDefectEntity.DefectName =
  1073. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectName"].ToString().Replace(productionDefectEntity.DefectCode + "->", "");
  1074. productionDefectEntity.DefectPositionID =
  1075. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectPositionID"]);
  1076. productionDefectEntity.DefectPositionCode =
  1077. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectPositionCode"].ToString();
  1078. productionDefectEntity.DefectPositionName =
  1079. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectPositionName"].ToString().Replace(productionDefectEntity.DefectPositionCode + "->", "");
  1080. productionDefectEntity.DefectProductionDataID =
  1081. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["ProductionDataID"].ToString());
  1082. productionDefectEntity.DefectProcedureID =
  1083. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectProcedureID"]);
  1084. productionDefectEntity.DefectProcedureCode =
  1085. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectProcedureCode"].ToString();
  1086. productionDefectEntity.DefectProcedureName =
  1087. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectProcedureName"].ToString();
  1088. productionDefectEntity.DefectUserID =
  1089. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectUserID"]);
  1090. productionDefectEntity.DefectUserCode =
  1091. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectUserCode"].ToString();
  1092. productionDefectEntity.DefectUserName =
  1093. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectUserName"].ToString();
  1094. productionDefectEntity.DefectJobs =
  1095. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["Jobs"].ToString());
  1096. productionDefectEntity.Remarks =
  1097. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectRemarks"].ToString();
  1098. if (this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectFineID"].ToString() != "-1"
  1099. && this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectFineID"].ToString() != string.Empty)
  1100. {
  1101. productionDefectEntity.DefectFine = Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectFineID"]);
  1102. }
  1103. if (this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["CheckTime"].ToString() != string.Empty)
  1104. {
  1105. productionDefectEntity.CheckTime = Convert.ToDateTime(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["CheckTime"]);
  1106. }
  1107. // 遍历责任员工
  1108. List<DefectResponsibleEntity> DefectResponsibles = new List<DefectResponsibleEntity>();
  1109. if (this.DSTableStaff.Tables.Contains(string.Format("TempTable{0}",
  1110. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["TempCount"].ToString())))
  1111. {
  1112. DefectResponsibleEntity defectResponsibleEntity = null;
  1113. DataTable dtTemp = this.DSTableStaff.Tables[string.Format("TempTable{0}",
  1114. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["TempCount"].ToString())];
  1115. foreach (DataRow drStaff in dtTemp.Rows)
  1116. {
  1117. if (Convert.ToInt32(drStaff["IsSelected"]) == Constant.INT_IS_ONE)
  1118. {
  1119. defectResponsibleEntity = new DefectResponsibleEntity();
  1120. defectResponsibleEntity.StaffID = Convert.ToInt32(drStaff["StaffID"]);
  1121. defectResponsibleEntity.UserID = Convert.ToInt32(productionDefectEntity.DefectUserID);
  1122. defectResponsibleEntity.UserCode = productionDefectEntity.DefectUserCode;
  1123. defectResponsibleEntity.UJobsID =
  1124. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["Jobs"].ToString());
  1125. defectResponsibleEntity.SJobsID =
  1126. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["Jobs"].ToString());
  1127. defectResponsibleEntity.StaffStatus = Convert.ToInt32(drStaff["StaffStatus"]);
  1128. DefectResponsibles.Add(defectResponsibleEntity);
  1129. }
  1130. }
  1131. //productionDefectEntity.DefectResponsibles = DefectResponsibles.ToArray();//每个缺陷对应的责任员工
  1132. productionDefectEntity.DefectResponsibles = DefectResponsibles;//每个缺陷对应的责任员工
  1133. }
  1134. if (DefectResponsibles.Count == Constant.INT_IS_ZERO) // 并没有责任员工
  1135. {
  1136. isError = true;
  1137. this.dgvDefect.DataSource = this.DSTable.Tables[productionDataEntity.Barcode];
  1138. this.dgvDefect.CurrentCell = null;
  1139. this.dgvDefect.Rows[j].Selected = true;
  1140. if (this.DSTableStaff.Tables.Contains(string.Format("TempTable{0}",
  1141. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["TempCount"].ToString())))
  1142. {
  1143. this.dgvDefectStaff.DataSource = this.DSTableStaff.Tables[string.Format("TempTable{0}",
  1144. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["TempCount"].ToString())];
  1145. }
  1146. else
  1147. {
  1148. this.dgvDefectStaff.DataSource = null;
  1149. }
  1150. break;
  1151. }
  1152. // 遍历缺陷图片
  1153. if (this.DSTableImage.Tables.Contains(string.Format("TempTable{0}",
  1154. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["TempCount"].ToString())))
  1155. {
  1156. List<DefectImageEntity> defectImageEntitys = new List<DefectImageEntity>();
  1157. DefectImageEntity defectImageEntity = null;
  1158. DataTable dtTemp = this.DSTableImage.Tables[string.Format("TempTable{0}",
  1159. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["TempCount"].ToString())];
  1160. foreach (DataRow drImage in dtTemp.Rows)
  1161. {
  1162. defectImageEntity = new DefectImageEntity();
  1163. defectImageEntity.Thumbnail = (byte[])drImage["ImageByte"];
  1164. defectImageEntity.Image = (byte[])drImage["orgImageByte"];
  1165. defectImageEntitys.Add(defectImageEntity);
  1166. }
  1167. //productionDefectEntity.DefectImages = defectImageEntitys.ToArray();
  1168. productionDefectEntity.DefectImages = defectImageEntitys;
  1169. }
  1170. productionDefectEntitys.Add(productionDefectEntity);
  1171. }
  1172. if (isError)
  1173. {
  1174. break;
  1175. }
  1176. //productionDataEntitys[i].ProductionDefects = productionDefectEntitys.ToArray();
  1177. productionDataEntitys[i].ProductionDefects = productionDefectEntitys;
  1178. }
  1179. if (isError && ErrorNumber == -Constant.INT_IS_ONE)
  1180. {
  1181. // 提示信息
  1182. MessageBox.Show(Messages.MSG_PM_W002,
  1183. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1184. return;
  1185. }
  1186. else if (isError && ErrorNumber == -Constant.INT_IS_TWO)
  1187. {
  1188. // 提示信息
  1189. MessageBox.Show(Messages.MSG_PM_W013,
  1190. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1191. return;
  1192. }
  1193. if (productionDataEntitys.Length > Constant.INT_IS_ZERO)
  1194. {
  1195. // 最外层For循环结束
  1196. string returnValue = (string)DoAsync(new BaseAsyncMethod(() =>
  1197. {
  1198. return PMModuleProxy.Service.AddCheckBarcode(this._procedureID, productionDataEntitys);
  1199. }));
  1200. if (string.IsNullOrEmpty(returnValue))//成功
  1201. {
  1202. // 提示信息
  1203. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "新建" + this.Text, "保存"),
  1204. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  1205. this.TableProductionData.Rows.Clear();
  1206. this.dgvProductionData.DataSource = TableProductionData;
  1207. this.DSTable.Tables.Clear();
  1208. this.dgvDefect.DataSource = null;
  1209. this.DSTableStaff.Tables.Clear();
  1210. this.dgvDefectStaff.DataSource = null;
  1211. this.DSTableImage.Tables.Clear();
  1212. this.lvPic.Clear();
  1213. this._PicByte.Clear();
  1214. this._smallByte.Clear();
  1215. if (this._procedureDataEntity.CollectType == (int)Constant.ProcedureCollectType.Togather)
  1216. {
  1217. this.txtUserCode.Text = string.Empty;
  1218. this.txtUserCode.ReadOnly = false;
  1219. }
  1220. this.DSREWORK.Tables.Clear();
  1221. }
  1222. else
  1223. {
  1224. // 提示信息
  1225. MessageBox.Show(returnValue,
  1226. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1227. }
  1228. }
  1229. }
  1230. catch (Exception ex)
  1231. {
  1232. // 对异常进行共通处理
  1233. ExceptionManager.HandleEventException(this.ToString(),
  1234. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  1235. }
  1236. }
  1237. /// <summary>
  1238. /// 关闭按钮事件
  1239. /// </summary>
  1240. /// <param name="sender"></param>
  1241. /// <param name="e"></param>
  1242. private void tsbCloseTop_Click(object sender, EventArgs e)
  1243. {
  1244. this.Close();
  1245. }
  1246. /// <summary>
  1247. /// 单元格开始编辑时事件
  1248. /// </summary>
  1249. /// <param name="sender"></param>
  1250. /// <param name="e"></param>
  1251. private void dgvProductionData_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
  1252. {
  1253. if (e.ColumnIndex == Constant.INT_IS_FOUR && e.RowIndex != -Constant.INT_IS_ONE)
  1254. {
  1255. DataGridView dgv = (DataGridView)sender;
  1256. string value = this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["GoodsLevelTypeID"].Value.ToString();
  1257. if (value != Convert.ToString((int)Constant.GoodsLevelType.Defect))
  1258. {
  1259. e.Cancel = true;
  1260. }
  1261. }
  1262. }
  1263. /// <summary>
  1264. /// 生产工号验证事件
  1265. /// </summary>
  1266. /// <param name="sender"></param>
  1267. /// <param name="e"></param>
  1268. private void txtUserCode_Validating(object sender, System.ComponentModel.CancelEventArgs e)
  1269. {
  1270. try
  1271. {
  1272. if (txtUserCode.Text.Trim() == string.Empty) // 如果未添加数据,则此项获取焦点
  1273. {
  1274. this.txtUserCode.IsMustInput = true;
  1275. this.txtUserCode.SelectAll();
  1276. e.Cancel = true;
  1277. return;
  1278. }
  1279. else if (!this.txtUserCode.ReadOnly)
  1280. {
  1281. SUserEntity userEntity = new SUserEntity();
  1282. userEntity.UserCode = this.txtUserCode.Text.Trim();
  1283. // 此工号是否能生产工序
  1284. CheckProcedureUserResult MsgCheckProcedureUser = (CheckProcedureUserResult)DoAsync(new BaseAsyncMethod(() =>
  1285. {
  1286. return PMModuleProxy.Service.CheckProcedureUser(this._procedureID, this.txtUserCode.Text.Trim());
  1287. }));
  1288. if (MsgCheckProcedureUser != null)
  1289. {
  1290. if (MsgCheckProcedureUser.ErrMsg != null)
  1291. {
  1292. MessageBox.Show(MsgCheckProcedureUser.ErrMsg,
  1293. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1294. this.txtUserCode.SelectAll();
  1295. e.Cancel = true;
  1296. return;
  1297. }
  1298. UserID = Convert.ToInt32(MsgCheckProcedureUser.UserID);
  1299. UserCode = MsgCheckProcedureUser.UserCode;
  1300. UserName = MsgCheckProcedureUser.UserName;
  1301. this.txtUserCode.ReadOnly = true;
  1302. }
  1303. }
  1304. }
  1305. catch (Exception ex)
  1306. {
  1307. // 对异常进行共通处理
  1308. ExceptionManager.HandleEventException(this.ToString(),
  1309. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  1310. }
  1311. }
  1312. /// <summary>
  1313. /// 鼠标单击事件
  1314. /// </summary>
  1315. /// <param name="sender"></param>
  1316. /// <param name="e"></param>
  1317. private void txtUserCode_MouseClick(object sender, MouseEventArgs e)
  1318. {
  1319. if (this.txtUserCode.Text.Trim() != string.Empty)
  1320. {
  1321. this.txtUserCode.SelectAll();
  1322. }
  1323. }
  1324. #endregion
  1325. #region 私有方法
  1326. /// <summary>
  1327. /// 设置数据源
  1328. /// </summary>
  1329. /// <param name="tempCount"></param>
  1330. public void SetDataSource(int tempCount)
  1331. {
  1332. this.dgvDefect.DataSource = DSTable.Tables[this._currentBarCode];
  1333. this.dgvDefectStaff.DataSource = DSTableStaff.Tables[string.Format("TempTable{0}", this._tempCount.ToString())];
  1334. this._tempCount = tempCount;
  1335. }
  1336. /// <summary>
  1337. /// 绑定到第一个DataGriwView数据源
  1338. /// </summary>
  1339. private void BindProductionData(DataSet dsCheckBarcode)
  1340. {
  1341. try
  1342. {
  1343. DataRow[] dr = TableProductionData.Select("BarCode='" + this.txtBarCode.Text.Trim() + "'");
  1344. if (dr.Length > Constant.INT_IS_ZERO)
  1345. {
  1346. // 不允许重复添加
  1347. return;
  1348. }
  1349. string KilnCarCode = string.Empty;
  1350. string KilnCode = string.Empty;
  1351. string Dictionaryvalue = string.Empty;
  1352. DataSet dsKilnCar = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  1353. {
  1354. return PMModuleProxy.Service.GetKilnCarByBarCode(txtBarCode.Text.Trim());
  1355. }));
  1356. if (dsKilnCar != null && dsKilnCar.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  1357. {
  1358. KilnCarCode = dsKilnCar.Tables[0].Rows[0]["KilnCarCode"].ToString();
  1359. KilnCode = dsKilnCar.Tables[0].Rows[0]["KilnCode"].ToString();
  1360. Dictionaryvalue = dsKilnCar.Tables[0].Rows[0]["Dictionaryvalue"].ToString();
  1361. }
  1362. DataRow drNew = TableProductionData.NewRow();
  1363. drNew["BarCode"] = this.txtBarCode.Text.Trim();
  1364. drNew["GoodsID"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsID.ToString()];
  1365. drNew["GoodsCode"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsCode.ToString()];
  1366. drNew["GoodsName"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsName.ToString()];
  1367. drNew["DefectFlagID"] = Constant.GoodsLevelType.Defect;
  1368. drNew["ReworkProcedureID"] = DBNull.Value;
  1369. drNew["Remarks"] = "";
  1370. drNew["UserID"] = UserID;
  1371. drNew["KilnCarCode"] = KilnCarCode;
  1372. drNew["KilnCode"] = KilnCode;
  1373. drNew["Dictionaryvalue"] = Dictionaryvalue;
  1374. drNew["GoodsLevelTypeID"] = DBNull.Value;
  1375. // 查重烧及干补标识
  1376. DataSet dsInProductionDataList = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  1377. {
  1378. return PMModuleProxy.Service.GetInProductionDataList(this.txtBarCode.Text.Trim());
  1379. }));
  1380. if (dsInProductionDataList != null && dsInProductionDataList.Tables[0].Rows.Count > 0)
  1381. {
  1382. drNew["ReFine"] = dsInProductionDataList.Tables[0].Rows[0]["IsReFire"].ToString() == "1" ? 1 : 0;
  1383. drNew["SpecialRepairflag"] = dsInProductionDataList.Tables[0].Rows[0]["SpecialRepairflag"].ToString() == "1" ? 1 : 0;
  1384. drNew["SpecialRepairflagValue"] = dsInProductionDataList.Tables[0].Rows[0]["SpecialRepairflag"].ToString();//过滤干补标识
  1385. }
  1386. else
  1387. {
  1388. drNew["ReFine"] = 0;
  1389. drNew["SpecialRepairflag"] = 0;
  1390. drNew["SpecialRepairflagValue"] = 0;
  1391. }
  1392. drNew["UserCode"] = this.txtUserCode.Text.Trim();
  1393. // 由产品条码获取注浆信息
  1394. //DataSet dsGroutingProduct = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  1395. //{
  1396. // return PMModuleProxy.Service.GetGroutingProducttByBarCode(txtBarCode.Text.Trim());
  1397. //}));
  1398. drNew["MouldCode"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_mouldCode.ToString()];
  1399. drNew["GroutingUserCode"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()];
  1400. drNew["GroutingNum"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingNum.ToString()];
  1401. drNew["IsPublicBody"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_ispublicbody.ToString()].ToString() != "1" ? 0 : 1;
  1402. drNew["GroutingDate"] = Convert.ToDateTime(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingdate.ToString()]);
  1403. drNew["LogoCodeName"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoName.ToString()]
  1404. + "[" + dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoCode.ToString()] + "]";
  1405. drNew["LogoId"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoID.ToString()];
  1406. TableProductionData.Rows.Add(drNew);
  1407. if (DSTable.Tables.IndexOf(this.txtBarCode.Text.Trim()) == -Constant.INT_IS_ONE)
  1408. {
  1409. DataTable dtProductionDefectData = new DataTable(this.txtBarCode.Text.Trim());
  1410. dtProductionDefectData.Columns.Add("BarCode");
  1411. dtProductionDefectData.Columns.Add("discarde");
  1412. dtProductionDefectData.Columns.Add("DefectID", typeof(decimal));
  1413. dtProductionDefectData.Columns.Add("DefectName");
  1414. dtProductionDefectData.Columns.Add("DefectCode");
  1415. dtProductionDefectData.Columns.Add("DefectPositionID", typeof(decimal));
  1416. dtProductionDefectData.Columns.Add("DefectPositionName");
  1417. dtProductionDefectData.Columns.Add("DefectPositionCode");
  1418. dtProductionDefectData.Columns.Add("DefectProcedureID", typeof(decimal));
  1419. dtProductionDefectData.Columns.Add("DefectProcedureName");
  1420. dtProductionDefectData.Columns.Add("DefectProcedureCode");
  1421. dtProductionDefectData.Columns.Add("DefectUserID", typeof(decimal));//责任员工
  1422. dtProductionDefectData.Columns.Add("DefectUserName");//责任员工
  1423. dtProductionDefectData.Columns.Add("DefectUserCode");//
  1424. dtProductionDefectData.Columns.Add("Jobs", typeof(decimal));//工种
  1425. dtProductionDefectData.Columns.Add("JobsText");//工种
  1426. dtProductionDefectData.Columns.Add("DefectRemarks");
  1427. dtProductionDefectData.Columns.Add("TempCount");
  1428. dtProductionDefectData.Columns.Add("ProductionDataID"); //生产数据ID
  1429. dtProductionDefectData.Columns.Add("DefectFineID"); //缺席扣罚ID
  1430. dtProductionDefectData.Columns.Add("DefectFineValue"); //缺席扣罚
  1431. dtProductionDefectData.Columns.Add("CheckTime"); //缺陷检验时间
  1432. DSTable.Tables.Add(dtProductionDefectData);
  1433. }
  1434. this.dgvDefect.DataSource = DSTable.Tables[this.txtBarCode.Text.Trim()];//根据条码产生不同数据源
  1435. this.dgvProductionData.Rows[TableProductionData.Rows.Count - 1].Selected = true;
  1436. this.dgvDefect.DataSource = null;
  1437. this.dgvDefectStaff.DataSource = null;
  1438. this.lvPic.Clear();
  1439. // 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
  1440. this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
  1441. // 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
  1442. this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
  1443. this._selectedRowIndex = TableProductionData.Rows.Count - 1;
  1444. //DataSet ds = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  1445. //{
  1446. // return PMModuleProxy.Service.GetReworkProcedureByBarcode(this._procedureID, this.dgvProductionData.Rows[_selectedRowIndex].Cells["BarCode"].Value.ToString());
  1447. //}));
  1448. //ds.Tables[0].TableName = this.txtBarCode.Text.Trim();
  1449. //if (this.DSREWORK == null)
  1450. //{
  1451. // this.DSREWORK = new DataSet();
  1452. //}
  1453. //this.DSREWORK.Tables.Add(ds.Tables[0].Copy());
  1454. //C_DGV_Cell_ListBoxComboBox C_DGV_Cell_ListBoxComboBox = dgvProductionData.Rows[_selectedRowIndex].Cells[4] as C_DGV_Cell_ListBoxComboBox;
  1455. //C_DGV_Cell_ListBoxComboBox.DataSource = ds.Tables[0];
  1456. //C_DGV_Cell_ListBoxComboBox.DisplayMember = "ReworkProcedureName";
  1457. //C_DGV_Cell_ListBoxComboBox.ValueMember = "ReworkProcedureID";
  1458. }
  1459. catch (Exception ex)
  1460. {
  1461. throw ex;
  1462. }
  1463. }
  1464. /// <summary>
  1465. /// 通过是否有缺陷来启用或禁用
  1466. /// </summary>
  1467. /// <param name="DefectFlag"></param>
  1468. private void SetGridView(int GoodsLevelID)
  1469. {
  1470. DataTable dtDefectFlag = this.DefectFlag.DataSource as DataTable;//获取缺陷数据源
  1471. int GoodsLevelTypeID = -1;
  1472. DataRow[] dr = dtDefectFlag.Select("DefectFlagID=" + GoodsLevelID);
  1473. if (dr.Length > 0)
  1474. {
  1475. GoodsLevelTypeID = Convert.ToInt32(dr[0]["GoodsLevelTypeID"]);
  1476. this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["GoodsLevelTypeID"].Value = GoodsLevelTypeID;
  1477. }
  1478. if (GoodsLevelTypeID != -1)
  1479. {
  1480. if (GoodsLevelTypeID == (int)Constant.GoodsLevelType.NoDefects) //没有缺陷
  1481. {
  1482. try
  1483. {
  1484. this.dgvDefect.ReadOnly = true;
  1485. this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureID"].Value = null;
  1486. this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureCode"].Value = string.Empty;
  1487. this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureName"].Value = string.Empty;
  1488. this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureID"].ReadOnly = true;
  1489. string BarCode = this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["BarCode"].Value.ToString();
  1490. if (DSTable.Tables.Contains(BarCode))
  1491. {
  1492. DSTable.Tables[BarCode].Rows.Clear();//清空行
  1493. }
  1494. this.dgvDefectStaff.DataSource = null;
  1495. this.lvPic.Clear();
  1496. }
  1497. catch (Exception ex)
  1498. {
  1499. throw ex;
  1500. }
  1501. }
  1502. else if (GoodsLevelTypeID == (int)Constant.GoodsLevelType.Defect) //有缺陷
  1503. {
  1504. this.dgvDefect.ReadOnly = true;
  1505. this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureID"].ReadOnly = false;
  1506. }
  1507. else if (GoodsLevelTypeID == (int)Constant.GoodsLevelType.Waste) //废品
  1508. {
  1509. this.dgvDefect.ReadOnly = false;
  1510. }
  1511. }
  1512. }
  1513. /// <summary>
  1514. /// 清空以前所选中的缺陷
  1515. /// </summary>
  1516. /// <param name="checkValue"></param>
  1517. private void SetCheckBoxSelected(int checkValue, int rowIndex)
  1518. {
  1519. DataTable dtOrgDataSource = this.dgvDefect.DataSource as DataTable;
  1520. for (int i = 0; i < DSTable.Tables[dtOrgDataSource.TableName].Rows.Count; i++)
  1521. {
  1522. if (i == rowIndex)
  1523. {
  1524. dtOrgDataSource.Rows[i]["discarde"] = 1;
  1525. }
  1526. else
  1527. {
  1528. dtOrgDataSource.Rows[i]["discarde"] = 0;
  1529. }
  1530. }
  1531. }
  1532. /// <summary>
  1533. /// 绑定并显示图片
  1534. /// </summary>
  1535. /// <param name="ImageData"></param>
  1536. public void BindByteImage(DataTable ImageData)
  1537. {
  1538. this._smallByte.Clear();
  1539. foreach (DataRow dr in ImageData.Rows)
  1540. {
  1541. //将数据库中的缩略图取出
  1542. this._smallByte.Add((byte[])dr[1]);
  1543. }
  1544. //绑定缩略图
  1545. BindImg();
  1546. }
  1547. /// <summary>
  1548. /// 将图片文件转换成二进制
  1549. /// </summary>
  1550. /// <param name="img"></param>
  1551. /// <returns></returns>
  1552. public static byte[] ImageToByte(Image img)
  1553. {
  1554. byte[] smallbuffer = null;
  1555. using (MemoryStream ms = new MemoryStream())
  1556. {
  1557. img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
  1558. ms.Position = Constant.INT_IS_ZERO;
  1559. smallbuffer = new byte[ms.Length];
  1560. ms.Read(smallbuffer, Constant.INT_IS_ZERO, Convert.ToInt32(ms.Length));
  1561. ms.Flush();
  1562. }
  1563. return smallbuffer;
  1564. }
  1565. /// <SUMMARY>
  1566. /// 重绘缩略图并把缩略图转为二进制储存
  1567. /// </SUMMARY>
  1568. /// <PARAM name="sourceFile">图片源路径</PARAM>
  1569. /// <PARAM name="destHeight">缩放后图片高度</PARAM>
  1570. /// <PARAM name="destWidth">缩放后图片宽度</PARAM>
  1571. /// <RETURNS></RETURNS>
  1572. public void GetThumbnail(FileInfo sourceFile, byte[] orgImageByte)
  1573. {
  1574. Image imgSource = Image.FromStream(sourceFile.OpenRead());
  1575. ImageFormat thisFormat = imgSource.RawFormat;
  1576. int sW = 0, sH = 0;
  1577. // 按比例缩放
  1578. int sWidth = imgSource.Width;
  1579. int sHeight = imgSource.Height;
  1580. int destWidth = 100;
  1581. int destHeight = getSmallImageHeight(sWidth, sHeight, destWidth);
  1582. if (sHeight > destHeight || sWidth > destWidth)
  1583. {
  1584. if ((sWidth * destHeight) > (sHeight * destWidth))
  1585. {
  1586. sW = destWidth;
  1587. sH = (destWidth * sHeight) / sWidth;
  1588. }
  1589. else
  1590. {
  1591. sH = destHeight;
  1592. sW = (sWidth * destHeight) / sHeight;
  1593. }
  1594. }
  1595. else
  1596. {
  1597. sW = sWidth;
  1598. sH = sHeight;
  1599. }
  1600. Bitmap outBmp = new Bitmap(destWidth, destHeight);
  1601. Graphics g = Graphics.FromImage(outBmp);
  1602. g.Clear(Color.Black);
  1603. // 设置画布的描绘质量
  1604. g.CompositingQuality = CompositingQuality.HighQuality;
  1605. g.SmoothingMode = SmoothingMode.HighQuality;
  1606. g.InterpolationMode = InterpolationMode.HighQualityBicubic;
  1607. g.DrawImage(imgSource, new Rectangle((destWidth - sW) / 2, (destHeight - sH) / 2, sW, sH), 0, 0, imgSource.Width, imgSource.Height, GraphicsUnit.Pixel);
  1608. g.Dispose();
  1609. //将重绘的图片转为二进制并保存
  1610. Image image = (Image)outBmp;
  1611. byte[] smallbuffer = ImageToByte(image);
  1612. if (this._currentTempSign != "")
  1613. {
  1614. if (!this.DSTableImage.Tables.Contains(string.Format("TempTable{0}", this._currentTempSign.ToString())))
  1615. {
  1616. DataTable dtImage = new DataTable(string.Format("TempTable{0}", this._currentTempSign.ToString()));
  1617. dtImage.Columns.Add("StaffTempCount");
  1618. dtImage.Columns.Add("ImageByte", typeof(byte[]));
  1619. dtImage.Columns.Add("OrgImageByte", typeof(byte[]));
  1620. this.DSTableImage.Tables.Add(dtImage);
  1621. }
  1622. DataRow dr = DSTableImage.Tables[string.Format("TempTable{0}", this._currentTempSign)].NewRow();
  1623. dr["StaffTempCount"] = this._currentTempSign;
  1624. dr["ImageByte"] = smallbuffer;
  1625. dr["OrgImageByte"] = orgImageByte;
  1626. DSTableImage.Tables[string.Format("TempTable{0}", this._currentTempSign)].Rows.Add(dr);
  1627. }
  1628. this._smallByte.Add(smallbuffer);
  1629. imgSource.Dispose();
  1630. outBmp.Dispose();
  1631. }
  1632. /// <summary>
  1633. /// 根据原图片宽高比获取缩略图的高(根据宽)
  1634. /// </summary>
  1635. /// <param name="BigWidth"></param>
  1636. /// <param name="BigHeight"></param>
  1637. /// <param name="SmallWidth"></param>
  1638. /// <returns></returns>
  1639. protected int getSmallImageHeight(int BigWidth, int BigHeight, int SmallWidth)
  1640. {
  1641. decimal scale = Convert.ToDecimal(BigWidth) / Convert.ToDecimal(BigHeight);
  1642. return Convert.ToInt32(SmallWidth / scale);
  1643. }
  1644. /// <summary>
  1645. /// 绑定缩略图到控件中
  1646. /// </summary>
  1647. protected void BindImg()
  1648. {
  1649. ImageList ilPic = new ImageList();
  1650. //每次绑定要清空数据源
  1651. ilPic.Images.Clear();
  1652. //将缩略图二进制集合中的数据转换成图片文件
  1653. List<Image> LSImageList = new List<Image>();
  1654. foreach (byte[] smallby in _smallByte)
  1655. {
  1656. LSImageList.Add(byteArrayToImage(smallby));
  1657. }
  1658. //添加数据源
  1659. foreach (Image img in LSImageList)
  1660. {
  1661. ilPic.Images.Add(img);
  1662. }
  1663. ilPic.ImageSize = new Size(100, 100);
  1664. this.lvPic.LargeImageList = ilPic;
  1665. this.lvPic.BeginUpdate();
  1666. //清空列表的数据源
  1667. lvPic.Items.Clear();
  1668. //添加列表的数据源
  1669. for (int i = 0; i < ilPic.Images.Count; i++)
  1670. {
  1671. ListViewItem lvi = new ListViewItem();
  1672. lvi.ImageIndex = i;
  1673. this.lvPic.Items.Add(lvi);
  1674. }
  1675. this.lvPic.EndUpdate();
  1676. }
  1677. /// <summary>
  1678. /// 将数据库中的二进制转换成图片
  1679. /// </summary>
  1680. /// <param name="data"></param>
  1681. /// <returns></returns>
  1682. public static Image byteArrayToImage(object data)
  1683. {
  1684. System.IO.MemoryStream ms = new System.IO.MemoryStream((byte[])data);
  1685. System.Drawing.Image returnImage = System.Drawing.Image.FromStream(ms);
  1686. return returnImage;
  1687. }
  1688. #endregion
  1689. }
  1690. }