F_PM_3202.cs 166 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075
  1. /*******************************************************************************
  2. * Copyright(c) 2019 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PM_3202.cs
  5. * 2.功能描述:半检
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * xuwei 2019/12/12 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.DataModels.PMModule;
  24. using Dongke.IBOSS.PRD.WCF.Proxys;
  25. using Dongke.IBOSS.PRD.WCF.Proxys.PMModuleService;
  26. using Dongke.IBOSS.PRD.WCF.Proxys.SystemModuleService;
  27. namespace Dongke.IBOSS.PRD.Client.PMModule
  28. {
  29. /// <summary>
  30. /// 成品检验
  31. /// </summary>
  32. public partial class F_PM_3202 : FormBase
  33. {
  34. #region 成员变量
  35. // 工序ID
  36. private int _procedureID;
  37. // 生产工号
  38. private int _userID = -1;
  39. // 生产编号
  40. private string _userCode;
  41. // 生产名称
  42. private string _userName;
  43. // 工序实体类
  44. ProcedureEntity _procedureDataEntity;
  45. // 产品数据表
  46. DataTable _dtProductionData = null;
  47. // 产品缺陷数据表
  48. DataTable _dtProductionDefectData = null;
  49. // 当前选择的行
  50. private int _selectedRowIndex;
  51. // ComBoxEditingControl
  52. private DataGridViewComboBoxEditingControl _dataGridViewComboBox = null;
  53. // 当前产品条码的产品ID,用来查询缺陷位置
  54. private int _currentGoodsID = 0;
  55. // 当前产品条码,用来切换筛选列表数据
  56. private string _currentBarCode = "";
  57. // 当前产品缺陷
  58. private int _currentDefectFlag = 0;
  59. // 返工工序搜索列表对象
  60. C_DGV_Cell_ListBoxComboBox _C_DGV_Cell_ListBoxComboBox = null;
  61. // 过滤结果集
  62. private DataSet _ds = null;
  63. // 过滤员工结果集
  64. private DataSet _dsStaff = null;
  65. // 过滤缺陷图片
  66. private DataSet _dsImage = null;
  67. // 过滤漏检员工结果集
  68. private DataSet _dsMissdeStaff = null;
  69. // 临时数,用来过滤责任员工数据源标识
  70. private int _tempCount = 0;
  71. // 当前临时标记
  72. private string _currentTempSign = "";
  73. // 图片字节集
  74. private List<byte[]> _PicByte = new List<byte[]>();
  75. // 缩略图片字节集
  76. private List<byte[]> _smallByte = new List<byte[]>();
  77. // 当前产品缺陷
  78. private int _currentDefaultDefectFlag = 0;
  79. // 当前默认产品分级ID
  80. private int _currentGoodsLevelTypeID = 0;
  81. // 返工工序数据源
  82. private DataSet _dsRework = null;
  83. // 产品等级数据源
  84. private DataSet _dsGoodsLevel = null;
  85. //编辑生产数据ID
  86. private int _productiondataid = 0;
  87. // 是否查看
  88. private bool _isView = false;
  89. // 允许编辑
  90. private int _AllowEdit = 0;
  91. // 是否只读
  92. private int _ReadOnly = 0;// 1为只读
  93. // 时间戳
  94. private DateTime _optimestamp;
  95. // 成检登记改判限制天数
  96. private int _settingvaluedays = 0;
  97. #endregion
  98. #region 属性
  99. /// <summary>
  100. /// 条码返工工序数据源
  101. /// </summary>
  102. public DataSet DSREWORK
  103. {
  104. set
  105. {
  106. _dsRework = value;
  107. }
  108. get
  109. {
  110. if (_dsRework == null)
  111. {
  112. return _dsRework = new DataSet();
  113. }
  114. return _dsRework;
  115. }
  116. }
  117. /// <summary>
  118. /// 生产工号
  119. /// </summary>
  120. public int UserID
  121. {
  122. set
  123. {
  124. _userID = value;
  125. }
  126. get
  127. {
  128. return _userID;
  129. }
  130. }
  131. /// <summary>
  132. /// 生产编号
  133. /// </summary>
  134. public string UserCode
  135. {
  136. set
  137. {
  138. _userCode = value;
  139. }
  140. get
  141. {
  142. return _userCode;
  143. }
  144. }
  145. /// <summary>
  146. /// 用户名称
  147. /// </summary>
  148. public string UserName
  149. {
  150. set
  151. {
  152. _userName = value;
  153. }
  154. get
  155. {
  156. return _userName;
  157. }
  158. }
  159. /// <summary>
  160. /// 时间戳
  161. /// </summary>
  162. public DateTime PTimeStamp
  163. {
  164. get
  165. {
  166. return _optimestamp;
  167. }
  168. set
  169. {
  170. _optimestamp = value;
  171. }
  172. }
  173. /// <summary>
  174. /// 产品数据表
  175. /// </summary>
  176. public DataTable TableProductionData
  177. {
  178. set
  179. {
  180. _dtProductionData = value;
  181. }
  182. get
  183. {
  184. if (_dtProductionData == null)
  185. {
  186. _dtProductionData = new DataTable("ProductionData");
  187. _dtProductionData.Columns.Add("ProductionDataID");
  188. _dtProductionData.Columns.Add("BarCode");
  189. _dtProductionData.Columns.Add("GoodsID");
  190. _dtProductionData.Columns.Add("GoodsCode");
  191. _dtProductionData.Columns.Add("GoodsName");
  192. _dtProductionData.Columns.Add("DefectFlagID", typeof(decimal));
  193. _dtProductionData.Columns.Add("ReworkProcedureID", typeof(decimal));
  194. _dtProductionData.Columns.Add("Remarks");
  195. _dtProductionData.Columns.Add("UserID");
  196. _dtProductionData.Columns.Add("UserCode");
  197. _dtProductionData.Columns.Add("UserName");
  198. _dtProductionData.Columns.Add("GoodsLevelTypeID");
  199. _dtProductionData.Columns.Add("OrgGoodsLevelTypeID");//原产品分级ID
  200. _dtProductionData.Columns.Add("ReFine");//重烧标识
  201. _dtProductionData.Columns.Add("SpecialRepairflag");//干补标识
  202. _dtProductionData.Columns.Add("ReadOnly");//1 为 只读
  203. _dtProductionData.Columns.Add("KilnCarCode");
  204. _dtProductionData.Columns.Add("KilnCode");
  205. _dtProductionData.Columns.Add("Dictionaryvalue");
  206. _dtProductionData.Columns.Add("MouldCode");//模具编号
  207. _dtProductionData.Columns.Add("GroutingDate", typeof(DateTime));//注浆日期
  208. _dtProductionData.Columns.Add("GroutingUserCode");//成型工号
  209. _dtProductionData.Columns.Add("IsPublicBody");//公坯标识
  210. _dtProductionData.Columns.Add("GroutingNum");//注浆次数
  211. _dtProductionData.Columns.Add("OPTimeStamp", typeof(DateTime));//时间戳 记录在产记录的时间戳
  212. _dtProductionData.Columns.Add("LogoCodeName");//
  213. _dtProductionData.Columns.Add("LogoID");//
  214. _dtProductionData.Columns.Add("CheckTime");//
  215. return _dtProductionData;
  216. }
  217. else
  218. {
  219. return _dtProductionData;
  220. }
  221. }
  222. }
  223. /// <summary>
  224. /// 缺陷数据集
  225. /// </summary>
  226. public DataSet DSTable
  227. {
  228. set
  229. {
  230. _ds = value;
  231. }
  232. get
  233. {
  234. if (_ds == null)
  235. {
  236. _ds = new DataSet();
  237. return _ds;
  238. }
  239. else
  240. {
  241. return _ds;
  242. }
  243. }
  244. }
  245. /// <summary>
  246. /// 员工数据集
  247. /// </summary>
  248. public DataSet DSTableStaff
  249. {
  250. set
  251. {
  252. _dsStaff = value;
  253. }
  254. get
  255. {
  256. if (_dsStaff == null)
  257. {
  258. _dsStaff = new DataSet();
  259. return _dsStaff;
  260. }
  261. else
  262. {
  263. return _dsStaff;
  264. }
  265. }
  266. }
  267. /// <summary>
  268. /// 漏检员工数据集
  269. /// </summary>
  270. public DataSet DSTableMissedStaff
  271. {
  272. set
  273. {
  274. _dsMissdeStaff = value;
  275. }
  276. get
  277. {
  278. if (_dsMissdeStaff == null)
  279. {
  280. _dsMissdeStaff = new DataSet();
  281. return _dsMissdeStaff;
  282. }
  283. else
  284. {
  285. return _dsMissdeStaff;
  286. }
  287. }
  288. }
  289. /// <summary>
  290. /// 缺陷图片
  291. /// </summary>
  292. public DataSet DSTableImage
  293. {
  294. set
  295. {
  296. _dsImage = value;
  297. }
  298. get
  299. {
  300. if (_dsImage == null)
  301. {
  302. _dsImage = new DataSet();
  303. return _dsImage;
  304. }
  305. else
  306. {
  307. return _dsImage;
  308. }
  309. }
  310. }
  311. #endregion
  312. #region 构造函数
  313. public F_PM_3202()
  314. {
  315. InitializeComponent();
  316. }
  317. public F_PM_3202(int procedureID, string fromTitle)
  318. {
  319. InitializeComponent();
  320. this._procedureID = procedureID;
  321. this.Text = fromTitle;
  322. this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
  323. this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
  324. this.btnSave.Text = ButtonText.BTN_SAVE;
  325. this.btnCancel.Text = ButtonText.BTN_CLOSE;
  326. this.tsbtnClose.Text = ButtonText.TSBTN_TOOL_CLOSE;
  327. this.btnUpload.Text = ButtonText.BTN_UPLOAD;
  328. this.btnDelete.Text = ButtonText.BTN_DELETE;
  329. }
  330. public F_PM_3202(int procedureID, string fromTitle, int productiondataID, bool isView)
  331. {
  332. InitializeComponent();
  333. this._AllowEdit = 1;//允许编辑
  334. this._productiondataid = productiondataID;
  335. this._procedureID = procedureID;
  336. this.Text = fromTitle;
  337. this._isView = isView;
  338. this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
  339. this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
  340. this.btnSave.Text = ButtonText.BTN_SAVE;
  341. this.btnCancel.Text = ButtonText.BTN_CLOSE;
  342. this.tsbtnClose.Text = ButtonText.TSBTN_TOOL_CLOSE;
  343. this.btnUpload.Text = ButtonText.BTN_UPLOAD;
  344. this.btnDelete.Text = ButtonText.BTN_DELETE;
  345. }
  346. #endregion
  347. #region 事件
  348. /// <summary>
  349. /// 窗体加载事件
  350. /// </summary>
  351. /// <param name="sender"></param>
  352. /// <param name="e"></param>
  353. private void F_PM_3202_Load(object sender, System.EventArgs e)
  354. {
  355. try
  356. {
  357. this.dgvProductionData.AutoGenerateColumns = false;
  358. this.dgvProductionData.DataSource = null;
  359. this.dgvProductionData.DataSource = TableProductionData;
  360. this.dgvDefect.AutoGenerateColumns = false;
  361. this.dgvDefectStaff.AutoGenerateColumns = false;
  362. // 加载权限
  363. FormPermissionManager.FormPermissionControl(this.Name, this,
  364. Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
  365. Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  366. // 获取工序明细数据
  367. ProcedureEntity procedureDataEntity = (ProcedureEntity)DoAsync(new BaseAsyncMethod(() =>
  368. {
  369. return PMModuleProxy.Service.GetProcedureDataEntityByID(this._procedureID);
  370. }));
  371. this._procedureDataEntity = procedureDataEntity;
  372. // 产品分级数据源
  373. DataSet dsGoodsLevel = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  374. {
  375. //xuwei modify 2019-12-12
  376. //return SystemModuleProxy.Service.GetGoodsLevel(2);//半成品检验
  377. ClientRequestEntity cre = new ClientRequestEntity();
  378. cre.NameSpace = "ProcedureSemi";
  379. cre.Name = "GetGoodsGradeDataSemi";
  380. cre.Properties["procedureId"] = procedureDataEntity.ProcedureID;
  381. return PMModuleProxyNew.Service.HandleRequest(cre).Data;
  382. }));
  383. if (dsGoodsLevel != null && dsGoodsLevel.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  384. {
  385. //xuwei modify 2019-12-12
  386. //this.DefectFlag.DisplayMember = "DefectFlagName";
  387. //this.DefectFlag.ValueMember = "DefectFlagID";
  388. //this.DefectFlag.DataSource = dsGoodsLevel.Tables[0];
  389. //this._currentDefaultDefectFlag = Convert.ToInt32(dsGoodsLevel.Tables[0].Rows[0]["DefectFlagID"]);
  390. //this._currentGoodsLevelTypeID = Convert.ToInt32(dsGoodsLevel.Tables[0].Rows[0]["GoodsLevelTypeID"]);
  391. this.DefectFlag.DisplayMember = "GOODSLEVELNAME";
  392. this.DefectFlag.ValueMember = "GOODSLEVELID";
  393. this.DefectFlag.DataSource = dsGoodsLevel.Tables[0];
  394. this._currentDefaultDefectFlag = Convert.ToInt32(dsGoodsLevel.Tables[0].Rows[0]["GOODSLEVELID"]);
  395. this._currentGoodsLevelTypeID = Convert.ToInt32(dsGoodsLevel.Tables[0].Rows[0]["GOODSLEVELTYPEID"]);
  396. this._dsGoodsLevel = dsGoodsLevel;
  397. }
  398. DataSet ds = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  399. {
  400. return PMModuleProxy.Service.GetReworkProcedureByProcedureID(this._procedureID);
  401. }));
  402. //ds.Tables[0].TableName = this.txtBarCode.Text.Trim();
  403. if (this.DSREWORK == null)
  404. {
  405. this.DSREWORK = new DataSet();
  406. }
  407. this.DSREWORK.Tables.Add(ds.Tables[0].Copy());
  408. // 返工工序数据源
  409. //C_DGV_Cell_ListBoxComboBox C_DGV_Cell_ListBoxComboBox = dgvProductionData.Rows[_selectedRowIndex].Cells[4] as C_DGV_Cell_ListBoxComboBox;
  410. //C_DGV_Cell_ListBoxComboBox.DataSource = ds.Tables[0];
  411. //C_DGV_Cell_ListBoxComboBox.DisplayMember = "ReworkProcedureName";
  412. //C_DGV_Cell_ListBoxComboBox.ValueMember = "ReworkProcedureID";
  413. this.ReworkProcedureID.DataSource = ds.Tables[0];
  414. this.ReworkProcedureID.DisplayMember = "ReworkProcedureName";
  415. this.ReworkProcedureID.ValueMember = "ReworkProcedureID";
  416. // 2016-10-10 是否启用成检登记改判限制天数 wangx
  417. DataSet dsSetting = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  418. {
  419. return SystemModuleProxy.Service.GetSystemSettingDataByCode(Constant.SettingType.S_PM_009.ToString());
  420. }));
  421. if (dsSetting != null && dsSetting.Tables[0].Rows.Count > 0)
  422. {
  423. _settingvaluedays = Convert.ToInt32(dsSetting.Tables[0].Rows[0]["SettingValue"]);
  424. }
  425. // end
  426. // 设置控件禁用或启用
  427. SetControlEnable(); //判断此生产工号是否能成检
  428. if (this._productiondataid > Constant.INT_IS_ZERO)
  429. {
  430. SetEditDataSource();
  431. if (this._isView)
  432. {
  433. SetSubstandard();
  434. }
  435. }
  436. }
  437. catch (Exception ex)
  438. {
  439. // 对异常进行共通处理
  440. ExceptionManager.HandleEventException(this.ToString(),
  441. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  442. }
  443. }
  444. /// <summary>
  445. /// 设置控件禁用或启用
  446. /// </summary>
  447. private void SetControlEnable()
  448. {
  449. if (this._procedureDataEntity != null)
  450. {
  451. if (this._procedureDataEntity.CollectType == (int)Constant.ProcedureCollectType.Togather)
  452. {
  453. this.txtUserCode.Enabled = true;
  454. this.btnSave.Visible = true;
  455. }
  456. else
  457. {
  458. this.txtUserCode.Enabled = true;
  459. this.txtUserCode.ReadOnly = true;
  460. // 此工号是否能生产工序
  461. CheckProcedureUserResult checkProcedureUser = (CheckProcedureUserResult)DoAsync(new BaseAsyncMethod(() =>
  462. {
  463. return PMModuleProxy.Service.CheckProcedureUser(this._procedureID,
  464. Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserCode);
  465. }));
  466. if (checkProcedureUser != null)
  467. {
  468. if (!string.IsNullOrEmpty(checkProcedureUser.ErrMsg))
  469. {
  470. // 此工号不允许生产工序
  471. MessageBox.Show(checkProcedureUser.ErrMsg,
  472. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  473. this.Close();
  474. return;
  475. }
  476. }
  477. UserID = checkProcedureUser.UserID;
  478. UserCode = checkProcedureUser.UserCode;
  479. UserName = checkProcedureUser.UserName;
  480. }
  481. this.txtUserCode.Text = UserCode;
  482. }
  483. }
  484. /// <summary>
  485. /// 条形码按键事件
  486. /// </summary>
  487. /// <param name="sender"></param>
  488. /// <param name="e"></param>
  489. private void txtBarCode_KeyPress(object sender, KeyPressEventArgs e)
  490. {
  491. try
  492. {
  493. this._ReadOnly = 0;//防止输入前一个条码为只读时,在输入另一个条码永远是只读
  494. if (this.txtBarCode.ReadOnly)
  495. {
  496. return;
  497. }
  498. if ((int)e.KeyChar == 13) // 按了回车键
  499. {
  500. if (this.txtUserCode.Text.Trim() == string.Empty)
  501. {
  502. this.txtUserCode.Focus();
  503. this.txtBarCode.Text = string.Empty;
  504. return;
  505. }
  506. if (this.txtBarCode.Text.Trim() == string.Empty)
  507. {
  508. this.txtBarCode.Focus();
  509. return;
  510. }
  511. //检验之前查是否编辑还是新增
  512. SearchProductionDataEntity searchProductionDataEntity = new SearchProductionDataEntity();
  513. searchProductionDataEntity.ProcedureID = this._procedureID;
  514. searchProductionDataEntity.BarCode = this.txtBarCode.Text.Trim();
  515. DataTable ProductionData = (DataTable)DoAsync(new BaseAsyncMethod(() =>
  516. {
  517. return PMModuleProxy.Service.GetProductionDataPDA(searchProductionDataEntity);
  518. }));
  519. if (ProductionData != null && ProductionData.Rows.Count > 0) //走过当前的工序,从大到小排序,取行一永远是最后一条数据,获取生产数据ID
  520. {
  521. // 尽管等于当前工序,但是如果该条码又插入了一条生产数据,在编辑此数据时,也应该为只读,即重烧后添加的生产数据,编辑上一次生产数据ID
  522. int CompleteProductionDataID = (int)DoAsync(new BaseAsyncMethod(() =>
  523. {
  524. return PMModuleProxy.Service.GetCompleteProductionDataID(this.txtBarCode.Text.Trim());
  525. }));
  526. // 走过的当前工序与在产工序相同,即在此工序上,未走到其它工序上,应该直接编辑,
  527. // 走过的当前工序与在产工序不相同时,首先校验条码,如果条码通过,还需判断是否重烧,及干补
  528. if (Convert.ToInt32(ProductionData.Rows[0]["ProductionDataID"]) == CompleteProductionDataID)
  529. {
  530. this._productiondataid = Convert.ToInt32(ProductionData.Rows[0]["productiondataid"]);
  531. ////是否己报损,如果已经报损也是查看记录
  532. //DataSet dsReturn = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  533. //{
  534. // return PMModuleProxy.Service.GetSubstandardInfo(this.txtBarCode.Text.Trim());
  535. //}));
  536. //if (dsReturn != null && dsReturn.Tables[0].Rows.Count > 0) //有报损记录
  537. //{
  538. // this._ReadOnly = 1;
  539. //}
  540. //if (dsReturn != null && dsReturn.Tables[0].Rows.Count == 0)
  541. //{
  542. int auditstatus = (int)DoAsync(new BaseAsyncMethod(() =>
  543. {
  544. return PMModuleProxy.Service.CheckScrapProduct(this.txtBarCode.Text.Trim());
  545. }));
  546. if (auditstatus != -100)
  547. {
  548. //this._ReadOnly = 1;
  549. if (auditstatus == 0)
  550. {
  551. MessageBox.Show("该条码:" + this.txtBarCode.Text.Trim() + "存在报损记录(待审批)", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  552. }
  553. else
  554. {
  555. MessageBox.Show("该条码:" + this.txtBarCode.Text.Trim() + "存在报损记录(审批通过)", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  556. }
  557. this.txtBarCode.SelectAll();
  558. this.txtBarCode.Focus();
  559. return;
  560. }
  561. //}
  562. DataRow[] dr = TableProductionData.Select("BarCode='" + this.txtBarCode.Text.Trim() + "'");
  563. if (dr.Length > Constant.INT_IS_ZERO)
  564. {
  565. // 不允许重复添加
  566. this.txtBarCode.Text = "";
  567. return;
  568. }
  569. SetEditDataSource();
  570. this._currentBarCode = txtBarCode.Text.Trim();
  571. this.txtBarCode.Text = string.Empty;
  572. if (this._procedureDataEntity.CollectType == (int)Constant.ProcedureCollectType.Togather)//集中
  573. {
  574. this.txtUserCode.Enabled = true;
  575. this.txtBarCode.Enabled = true;
  576. }
  577. else
  578. {
  579. this.txtBarCode.Enabled = true;
  580. }
  581. }
  582. else
  583. {
  584. DataSet dsProductionDataByID = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  585. {
  586. return PMModuleProxy.Service.GetProductionDataByID(this._productiondataid);
  587. }));
  588. if (dsProductionDataByID != null && dsProductionDataByID.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  589. {
  590. #region 如果是次品,回收后不允许编辑
  591. if (Convert.ToInt32(dsProductionDataByID.Tables[0].Rows[0]["GoodsLevelTypeID"]) == 7)//次品
  592. {
  593. int recyclingflag = (int)DoAsync(new BaseAsyncMethod(() =>
  594. {
  595. return PMModuleProxy.Service.GetRecyclingflagByBarcode(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString());
  596. }));
  597. if (recyclingflag > 0)
  598. {
  599. MessageBox.Show("此产品已经回收,不能改判", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  600. this.txtBarCode.Enabled = true;
  601. this.txtBarCode.Focus();
  602. return;
  603. }
  604. }
  605. #endregion
  606. }
  607. //int recyclingflag = (int)DoAsync(new BaseAsyncMethod(() =>
  608. //{
  609. // return PMModuleProxy.Service.GetRecyclingflagByBarcode(this.txtBarCode.Text.Trim());
  610. //}));
  611. //if (recyclingflag > 0)
  612. //{
  613. // MessageBox.Show("【此产品已经回收,不能改判】", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  614. // this.txtBarCode.Enabled = true;
  615. // this.txtBarCode.Focus();
  616. // return;
  617. //}
  618. DataSet dsInProductionDataList = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  619. {
  620. return PMModuleProxy.Service.GetInProductionDataList(this.txtBarCode.Text.Trim());
  621. }));
  622. //当生产数据ID与当前工序生产数据ID不等时,还有一种况就是正品报废干补回来
  623. if (dsInProductionDataList.Tables[0].Rows.Count > 0 && dsInProductionDataList.Tables[0].Rows[0]["FlowProcedureID"].ToString() == this._procedureID.ToString())
  624. {
  625. //新增
  626. this._productiondataid = Convert.ToInt32(ProductionData.Rows[0]["ProductionDataID"]);
  627. BindProductionDataEdit(null);
  628. this._currentBarCode = txtBarCode.Text.Trim();
  629. this.txtBarCode.Text = string.Empty;
  630. }
  631. else
  632. {
  633. //如果不相等的应该提示不允许编辑,因为尽管条码有效,但是并不在此工序流程中,只能列表搜索后进行编辑(只读查看)
  634. //但是还需要判断当前产品,是否重烧及干补,如果这两个都不是从而进行提示
  635. //1.校验条码是否有效
  636. // 校验条码 获取校验条码
  637. DataSet dsCheckBarcode = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  638. {
  639. return PMModuleProxy.Service.CheckBarcode(this._procedureID, this.txtBarCode.Text.Trim());
  640. }));
  641. if (dsCheckBarcode != null && dsCheckBarcode.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  642. {
  643. if (dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString() != string.Empty)
  644. {
  645. //MessageBox.Show(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString(), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  646. //this.txtBarCode.SelectAll();
  647. //this.txtBarCode.Focus();
  648. //return;
  649. if (dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_missFlag.ToString()].ToString() == "0")
  650. {
  651. // 表示有错误
  652. MessageBox.Show(string.Format(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString(), this.txtBarCode.Text.Trim(), "产品条码"),
  653. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  654. }
  655. else
  656. {
  657. S_CMN_020 frmscmn020 = new S_CMN_020(Convert.ToInt32(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_missFlag.ToString()])
  658. , dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString());
  659. frmscmn020.ShowDialog();
  660. }
  661. this.txtBarCode.Focus();
  662. this.txtBarCode.SelectAll();
  663. return;
  664. }
  665. else
  666. {
  667. #region 校验条码无错误 无论干补或者重烧只查在产表就可以
  668. //DataSet dsInProductionDataList = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  669. //{
  670. // return PMModuleProxy.Service.GetInProductionDataList(this.txtBarCode.Text.Trim());
  671. //}));
  672. // 只有干补才会出现这种情况
  673. if (dsInProductionDataList.Tables[0].Rows[0]["FlowProcedureID"].ToString() != dsInProductionDataList.Tables[0].Rows[0]["ProcedureID"].ToString())
  674. {
  675. //新增
  676. BindProductionData(dsCheckBarcode);
  677. this._currentBarCode = txtBarCode.Text.Trim();
  678. this.txtBarCode.Text = string.Empty;
  679. }
  680. else if (dsInProductionDataList.Tables[0].Rows[0]["FlowProcedureID"].ToString() == dsInProductionDataList.Tables[0].Rows[0]["ProcedureID"].ToString()
  681. && dsInProductionDataList.Tables[0].Rows[0]["IsReFire"].ToString() == "6") //重烧
  682. {
  683. //新增
  684. this._productiondataid = Convert.ToInt32(ProductionData.Rows[0]["productiondataid"]);
  685. BindProductionDataReFine(dsCheckBarcode);//说明重烧后回来成检
  686. this._currentBarCode = txtBarCode.Text.Trim();
  687. this.txtBarCode.Text = string.Empty;
  688. }
  689. else
  690. {
  691. // 要不不显示,要不显示,应该过滤掉
  692. this._productiondataid = Convert.ToInt32(ProductionData.Rows[0]["productiondataid"]);
  693. this._ReadOnly = 1;
  694. SetEditDataSource();
  695. this._currentBarCode = txtBarCode.Text.Trim();
  696. this.txtBarCode.Text = string.Empty;//////////但是只是显示,这个应该不能编辑,及提交的时候不应该保存
  697. }
  698. #endregion
  699. }
  700. }//--------------------------校验条码结束括号---------------------------------------------------------------
  701. }//--------------------------else结束括号---------------------------------------------------------------
  702. }
  703. }
  704. else //未走过当前工序
  705. {
  706. // 校验条码 获取校验条码信
  707. DataSet dsCheckBarcode = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  708. {
  709. return PMModuleProxy.Service.CheckBarcode(this._procedureID, this.txtBarCode.Text.Trim());
  710. }));
  711. if (dsCheckBarcode != null && dsCheckBarcode.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  712. {
  713. if (dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString() != string.Empty)
  714. {
  715. // 表示有错误
  716. //MessageBox.Show(string.Format(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString(), this.txtBarCode.Text.Trim(), "产品条码"),
  717. // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  718. //this.txtBarCode.Focus();
  719. //return;
  720. if (dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_missFlag.ToString()].ToString() == "0")
  721. {
  722. // 表示有错误
  723. MessageBox.Show(string.Format(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString(), this.txtBarCode.Text.Trim(), "产品条码"),
  724. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  725. }
  726. else
  727. {
  728. S_CMN_020 frmscmn020 = new S_CMN_020(Convert.ToInt32(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_missFlag.ToString()])
  729. , dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString());
  730. frmscmn020.ShowDialog();
  731. }
  732. this.txtBarCode.Focus();
  733. this.txtBarCode.SelectAll();
  734. return;
  735. }
  736. else
  737. {
  738. BindProductionData(dsCheckBarcode);//从来未走过此工序
  739. this._currentBarCode = txtBarCode.Text.Trim();
  740. this.txtBarCode.Text = string.Empty;
  741. }
  742. }
  743. }
  744. //if (ProductionData != null && ProductionData.Rows.Count > 0) //走过当前的工序,从大到小排序,取行一永远是最后一条数据,获取生产数据ID
  745. //{
  746. // DataSet dsReFine = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  747. // {
  748. // return PMModuleProxy.Service.GetReFine(this.txtBarCode.Text.Trim()); //生产数据取重烧标识
  749. // }));
  750. // // 重烧标识
  751. // if (dsReFine != null && dsReFine.Tables[0].Rows.Count > 0 && dsReFine.Tables[0].Rows[0]["IsReFire"].ToString() == "6")
  752. // {
  753. // int GetCompleteProcedureID = (int)DoAsync(new BaseAsyncMethod(() =>
  754. // {
  755. // return PMModuleProxy.Service.GetCompleteProcedureID(this.txtBarCode.Text.Trim());
  756. // }));
  757. // if (GetCompleteProcedureID != this._procedureID)//流程工序不等于当前工序
  758. // {
  759. // // 校验条码 获取校验条码
  760. // DataSet dsCheckBarcode = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  761. // {
  762. // return PMModuleProxy.Service.CheckBarcode(this._procedureID, this.txtBarCode.Text.Trim());
  763. // }));
  764. // if (dsCheckBarcode != null && dsCheckBarcode.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  765. // {
  766. // if (dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString() != string.Empty)
  767. // // 表示有错误
  768. // {
  769. // MessageBox.Show(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString(), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  770. // this.txtBarCode.SelectAll();
  771. // this.txtBarCode.Focus();
  772. // return;
  773. // }
  774. // else
  775. // {
  776. // //生产数据ID
  777. // this._productiondataid = Convert.ToInt32(ProductionData.Rows[0]["productiondataid"]);
  778. // BindProductionDataReFine(dsCheckBarcode);//说明重烧后回来成检
  779. // this._currentBarCode = txtBarCode.Text.Trim();
  780. // this.txtBarCode.Text = string.Empty;
  781. // }
  782. // }
  783. // } // GetCompleteProcedureID != this._procedureID
  784. // else //流程工序与当前工序相,代码进行编辑
  785. // {
  786. // this._productiondataid = Convert.ToInt32(ProductionData.Rows[0]["productiondataid"]);
  787. // SetEditDataSource();
  788. // this._currentBarCode = txtBarCode.Text.Trim();
  789. // this.txtBarCode.Text = string.Empty;
  790. // }
  791. // }
  792. // else // 不是重烧
  793. // {
  794. // int GetCompleteProcedureID = (int)DoAsync(new BaseAsyncMethod(() =>
  795. // {
  796. // return PMModuleProxy.Service.GetCompleteProcedureID(this.txtBarCode.Text.Trim());
  797. // }));
  798. // if (GetCompleteProcedureID != this._procedureID)
  799. // {
  800. // // 表示有错误
  801. // MessageBox.Show("当前条码己不在此工序不允许编辑", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  802. // this.txtBarCode.SelectAll();
  803. // this.txtBarCode.Focus();
  804. // return;
  805. // }
  806. // else
  807. // {
  808. // this._productiondataid = Convert.ToInt32(ProductionData.Rows[0]["productiondataid"]);
  809. // SetEditDataSource();
  810. // this.txtUserCode.Enabled = true;
  811. // this.txtBarCode.Enabled = true;
  812. // this.txtBarCode.Text = string.Empty;
  813. // }
  814. // }
  815. //}
  816. //else
  817. //{
  818. // // 校验条码 获取校验条码信
  819. // DataSet dsCheckBarcode = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  820. // {
  821. // return PMModuleProxy.Service.CheckBarcode(this._procedureID, this.txtBarCode.Text.Trim());
  822. // }));
  823. // if (dsCheckBarcode != null && dsCheckBarcode.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  824. // {
  825. // if (dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString() != string.Empty)
  826. // {
  827. // // 表示有错误
  828. // MessageBox.Show(string.Format(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString(), this.txtBarCode.Text.Trim(), "产品条码"),
  829. // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  830. // this.txtBarCode.Focus();
  831. // return;
  832. // }
  833. // else
  834. // {
  835. // BindProductionData(dsCheckBarcode);//从来未走过此工序
  836. // this._currentBarCode = txtBarCode.Text.Trim();
  837. // this.txtBarCode.Text = string.Empty;
  838. // }
  839. // }
  840. //}
  841. }
  842. }
  843. catch (Exception ex)
  844. {
  845. // 对异常进行共通处理
  846. ExceptionManager.HandleEventException(this.ToString(),
  847. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  848. }
  849. }
  850. /// <summary>
  851. /// 生产数据编辑控件显示事件
  852. /// </summary>
  853. /// <param name="sender"></param>
  854. /// <param name="e"></param>
  855. private void dgvProductionData_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
  856. {
  857. if (e.Control is DataGridViewComboBoxEditingControl
  858. && this.dgvProductionData.CurrentCell.ColumnIndex == Constant.INT_IS_THREE
  859. && this.dgvProductionData.CurrentCell.RowIndex != -Constant.INT_IS_ONE)
  860. {
  861. this._dataGridViewComboBox = (DataGridViewComboBoxEditingControl)e.Control;
  862. //增加委托处理
  863. this._dataGridViewComboBox.SelectionChangeCommitted += new EventHandler(this.dataGridViewComboBox_SelectionChangeCommitted);
  864. }
  865. if (e.Control is DKListBoxComboBox
  866. && this.dgvProductionData.CurrentCell.ColumnIndex == Constant.INT_IS_FOUR
  867. && this.dgvProductionData.CurrentCell.RowIndex != -Constant.INT_IS_ONE)
  868. {
  869. //_selectedRowIndex = TableProductionData.Rows.Count - 1;
  870. _selectedRowIndex = this.dgvProductionData.CurrentCell.RowIndex;
  871. DKListBoxComboBox dkListBoxComboBox = (DKListBoxComboBox)e.Control;
  872. _currentGoodsID = Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["GoodsID"].Value);
  873. _currentBarCode = this.dgvProductionData.Rows[_selectedRowIndex].Cells["BarCode"].Value.ToString();
  874. dkListBoxComboBox.DisplayMember = "ReworkProcedureName";
  875. dkListBoxComboBox.ValueMember = "ReworkProcedureID";
  876. dkListBoxComboBox.DataSource = DSREWORK.Tables[0];// DSREWORK.Tables[_currentBarCode];
  877. }
  878. }
  879. /// <summary>
  880. /// 生产数据下拉列表改变事件
  881. /// </summary>
  882. /// <param name="sender"></param>
  883. /// <param name="e"></param>
  884. private void dataGridViewComboBox_SelectionChangeCommitted(object sender, EventArgs e)
  885. {
  886. this._currentDefectFlag = Convert.ToInt32(((ComboBox)sender).SelectedValue.ToString());//当前缺陷类型
  887. SetGridView(this._currentDefectFlag);
  888. }
  889. /// <summary>
  890. /// 产品数据单元格进入事件
  891. /// </summary>
  892. /// <param name="sender"></param>
  893. /// <param name="e"></param>
  894. private void dgvProductionData_CellEnter(object sender, DataGridViewCellEventArgs e)
  895. {
  896. try
  897. {
  898. if (this.dgvProductionData.CurrentCell != null)
  899. {
  900. // 记录最后选择行
  901. if (e.ColumnIndex == Constant.INT_IS_FOUR && e.RowIndex != -Constant.INT_IS_ONE)
  902. {
  903. this._selectedRowIndex = this.dgvProductionData.CurrentCell.RowIndex;
  904. this._currentBarCode = this.dgvProductionData.Rows[_selectedRowIndex].Cells["BarCode"].Value.ToString();
  905. this._C_DGV_Cell_ListBoxComboBox = dgvProductionData.Rows[_selectedRowIndex].Cells[4] as C_DGV_Cell_ListBoxComboBox;
  906. DataSet ds = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  907. {
  908. return PMModuleProxy.Service.GetReworkProcedureByProcedureID(this._procedureID);
  909. }));
  910. this._currentGoodsID = Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["GoodsID"].Value);
  911. this._currentBarCode = this.dgvProductionData.Rows[_selectedRowIndex].Cells["BarCode"].Value.ToString();
  912. this._C_DGV_Cell_ListBoxComboBox.DisplayMember = "ReworkProcedureName";
  913. this._C_DGV_Cell_ListBoxComboBox.ValueMember = "ReworkProcedureID";
  914. this._C_DGV_Cell_ListBoxComboBox.DataSource = ds.Tables[0];
  915. }
  916. }
  917. }
  918. catch (Exception ex)
  919. {
  920. // 对异常进行共通处理
  921. ExceptionManager.HandleEventException(this.ToString(),
  922. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  923. }
  924. }
  925. /// <summary>
  926. /// 产品数据选定项改变事件
  927. /// </summary>
  928. /// <param name="sender"></param>
  929. /// <param name="e"></param>
  930. private void dgvProductionData_SelectionChanged(object sender, EventArgs e)
  931. {
  932. try
  933. {
  934. if (this.dgvProductionData.CurrentCell != null)
  935. {
  936. this._selectedRowIndex = this.dgvProductionData.CurrentCell.RowIndex;
  937. // 有无缺陷 0无缺陷 1有缺陷
  938. this._currentDefectFlag = Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["GoodsLevelTypeID"].Value.ToString());
  939. this._currentGoodsID = Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["GoodsID"].Value);
  940. this._currentBarCode = this.dgvProductionData.Rows[_selectedRowIndex].Cells["BarCode"].Value.ToString();
  941. this.dgvDefect.DataSource = DSTable.Tables[this._currentBarCode];
  942. this.dgvDefectStaff.CurrentCell = null;
  943. this.dgvDefectStaff.DataSource = null;
  944. this._smallByte.Clear();//防止重复绑定图片
  945. this.lvPic.Clear();//
  946. //设置只读数据,交不显示数据
  947. string readonlyFlag = this.dgvProductionData.Rows[_selectedRowIndex].Cells["ReadOnly"].Value.ToString();
  948. if (readonlyFlag == "1")
  949. {
  950. tsbtnAdd.Enabled = false;
  951. tsbtnEdit.Enabled = false;
  952. }
  953. else
  954. {
  955. tsbtnAdd.Enabled = true;
  956. tsbtnEdit.Enabled = true;
  957. }
  958. }
  959. }
  960. catch (Exception ex)
  961. {
  962. // 对异常进行共通处理
  963. ExceptionManager.HandleEventException(this.ToString(),
  964. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  965. }
  966. }
  967. /// <summary>
  968. /// 缺陷数据源选定项改变事件
  969. /// </summary>
  970. /// <param name="sender"></param>
  971. /// <param name="e"></param>
  972. private void dgvDefect_SelectionChanged(object sender, EventArgs e)
  973. {
  974. try
  975. {
  976. if (this.dgvDefect.CurrentCell != null)
  977. {
  978. DataRow[] dr = this.TableProductionData.Select("barcode='" + this._currentBarCode + "'");
  979. if (dr.Length > 0)
  980. {
  981. if (dr[0]["ReadOnly"].ToString() == "1")
  982. {
  983. this.tsbtnEdit.Enabled = false;
  984. this.tsbtnAdd.Enabled = false;
  985. this.btnDelete.Enabled = false;
  986. this.btnUpload.Enabled = false;
  987. }
  988. else
  989. {
  990. this.tsbtnEdit.Enabled = true;
  991. this.tsbtnAdd.Enabled = true;
  992. this.btnDelete.Enabled = true;
  993. this.btnUpload.Enabled = true;
  994. }
  995. }
  996. else
  997. {
  998. //if (this._productiondataid > Constant.INT_IS_ZERO)
  999. //{
  1000. if (this.btnSave.Enabled)
  1001. {
  1002. this.tsbtnEdit.Enabled = true;
  1003. this.tsbtnAdd.Enabled = true;
  1004. this.btnDelete.Enabled = true;
  1005. this.btnUpload.Enabled = true;
  1006. }
  1007. }
  1008. // }
  1009. if (this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["TempCount"].Value.ToString() != string.Empty)
  1010. {
  1011. int staffTempCount = Convert.ToInt32(this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["TempCount"].Value.ToString());
  1012. this.dgvDefectStaff.DataSource = DSTableStaff.Tables[string.Format("TempTable{0}", staffTempCount.ToString())];
  1013. this.dgvMissStaff.DataSource = DSTableMissedStaff.Tables[string.Format("TempTable{0}", staffTempCount.ToString())];
  1014. this._currentTempSign = this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["TempCount"].Value.ToString(); //当前临时标记
  1015. this._smallByte.Clear();//防止重复绑定图片
  1016. BindByteImage(DSTableImage.Tables[string.Format("TempTable{0}", staffTempCount.ToString())]);
  1017. }
  1018. else
  1019. {
  1020. this.dgvDefectStaff.DataSource = null;
  1021. this.dgvMissStaff.DataSource = null;
  1022. this._smallByte.Clear();//防止重复绑定图片
  1023. this.lvPic.Clear();//
  1024. }
  1025. }
  1026. }
  1027. catch (Exception ex)
  1028. {
  1029. // 对异常进行共通处理
  1030. ExceptionManager.HandleEventException(this.ToString(),
  1031. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  1032. }
  1033. }
  1034. /// <summary>
  1035. /// 单元格CheckBox事件
  1036. /// </summary>
  1037. /// <param name="sender"></param>
  1038. /// <param name="e"></param>
  1039. private void dgvDefect_CellContentClick(object sender, DataGridViewCellEventArgs e)
  1040. {
  1041. if (e.ColumnIndex == Constant.INT_IS_ZERO && e.RowIndex != -Constant.INT_IS_ONE)
  1042. {
  1043. int checkValue = Convert.ToInt32(this.dgvDefect.Rows[e.RowIndex].Cells[0].EditedFormattedValue);
  1044. if (checkValue == Constant.INT_IS_ZERO)
  1045. {
  1046. SetCheckBoxSelected(checkValue, e.RowIndex);
  1047. }
  1048. else
  1049. {
  1050. this.dgvDefect.Rows[e.RowIndex].Cells[0].Value = 0;
  1051. }
  1052. }
  1053. }
  1054. /// <summary>
  1055. /// 上传图片按钮事件
  1056. /// </summary>
  1057. /// <param name="sender"></param>
  1058. /// <param name="e"></param>
  1059. private void btnUpload_Click(object sender, EventArgs e)
  1060. {
  1061. try
  1062. {
  1063. this.odlgFile.Filter = Constant.FILTER_PIC;
  1064. this.odlgFile.FilterIndex = Constant.INT_IS_ZERO;
  1065. this.odlgFile.RestoreDirectory = true;
  1066. this.odlgFile.Title = "选择缺陷图片";
  1067. this.odlgFile.FileName = null;
  1068. this.odlgFile.RestoreDirectory = true;
  1069. if (this.odlgFile.ShowDialog() == DialogResult.OK)
  1070. {
  1071. FileInfo file = new FileInfo(odlgFile.FileName);
  1072. if (Constant.UPLOAD_PIC_MAX_SIZE < file.Length)
  1073. {
  1074. MessageBox.Show(string.Format(Messages.MSG_CMN_W013, "缺陷图片", "大小", "1M"),
  1075. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  1076. }
  1077. else
  1078. {
  1079. Image PicImage = Image.FromStream(file.OpenRead());
  1080. byte[] orgImageByte = ImageToByte(PicImage);
  1081. this._PicByte.Add(orgImageByte);
  1082. GetThumbnail(file, orgImageByte);
  1083. BindImg();
  1084. }
  1085. }
  1086. }
  1087. catch (Exception ex)
  1088. {
  1089. // 对异常进行共通处理
  1090. ExceptionManager.HandleEventException(this.ToString(),
  1091. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  1092. }
  1093. }
  1094. /// <summary>
  1095. /// 删除图片按钮事件
  1096. /// </summary>
  1097. /// <param name="sender"></param>
  1098. /// <param name="e"></param>
  1099. private void btnDelete_Click(object sender, EventArgs e)
  1100. {
  1101. foreach (ListViewItem lvSelect in lvPic.SelectedItems)
  1102. {
  1103. int index = lvSelect.Index;
  1104. if (index < Constant.INT_IS_ZERO)
  1105. {
  1106. index = Constant.INT_IS_ZERO;
  1107. }
  1108. if (this._currentTempSign != string.Empty)
  1109. {
  1110. DSTableImage.Tables[string.Format("TempTable{0}", this._currentTempSign)].Rows.RemoveAt(lvSelect.Index);
  1111. DSTableImage.Tables[string.Format("TempTable{0}", this._currentTempSign)].AcceptChanges();
  1112. }
  1113. BindByteImage(DSTableImage.Tables[string.Format("TempTable{0}", this._currentTempSign)]);
  1114. }
  1115. }
  1116. /// <summary>
  1117. /// 关闭按钮事件
  1118. /// </summary>
  1119. /// <param name="sender"></param>
  1120. /// <param name="e"></param>
  1121. private void tsbtnClose_Click(object sender, EventArgs e)
  1122. {
  1123. this.Close();
  1124. }
  1125. /// <summary>
  1126. /// 产品条码列表删除事件
  1127. /// </summary>
  1128. /// <param name="sender"></param>
  1129. /// <param name="e"></param>
  1130. private void dgvProductionData_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
  1131. {
  1132. try
  1133. {
  1134. string BarCode = this.dgvProductionData.Rows[e.Row.Index].Cells["BarCode"].Value.ToString();
  1135. DSTable.Tables[BarCode].Rows.Clear();//清空行
  1136. this.dgvDefectStaff.DataSource = null;//责任员工数据源
  1137. this.dgvMissStaff.DataSource = null; //漏检员工数据源
  1138. this.lvPic.Clear();
  1139. }
  1140. catch (Exception ex)
  1141. {
  1142. throw ex;
  1143. }
  1144. }
  1145. /// <summary>
  1146. /// 产品缺陷删除行事件
  1147. /// </summary>
  1148. /// <param name="sender"></param>
  1149. /// <param name="e"></param>
  1150. private void dgvDefect_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
  1151. {
  1152. try
  1153. {
  1154. if (e.Row.Index != -1)
  1155. {
  1156. //ProductionDataID
  1157. if (this.dgvDefect.CurrentCell != null)
  1158. {
  1159. //是新增进来,加载条码是不允许删除的,只是编辑权限才能可以删除
  1160. if (this.dgvDefect.Rows[e.Row.Index].Cells["ProductionDataID"].Value.ToString() != "" && Convert.ToInt32(this.dgvDefect.Rows[e.Row.Index].Cells["ProductionDataID"].Value) > 0 && this.dgvDefect.Rows[e.Row.Index].Cells["IsAllowEdit"].Value.ToString() == "0")
  1161. {
  1162. e.Cancel = true;
  1163. return;
  1164. }
  1165. string TempCount = this.dgvDefect.Rows[e.Row.Index].Cells["TempCount"].Value.ToString();
  1166. DSTableStaff.Tables[string.Format("TempTable{0}", TempCount.ToString())].Rows.Clear();//清空行
  1167. this.dgvDefectStaff.DataSource = null;
  1168. DSTableMissedStaff.Tables[string.Format("TempTable{0}", TempCount.ToString())].Rows.Clear();//清空行
  1169. this.dgvMissStaff.DataSource = null;
  1170. this.lvPic.Clear();
  1171. if (Convert.ToInt32(TempCount) > 0)
  1172. {
  1173. if (this.dgvDefect.CurrentCell != null)
  1174. {
  1175. DataRow[] dr = this.TableProductionData.Select("barcode='" + this._currentBarCode + "'");
  1176. if (dr.Length > 0)
  1177. {
  1178. if (dr[0]["ReadOnly"].ToString() == "1")
  1179. {
  1180. this.tsbtnEdit.Enabled = false;
  1181. this.tsbtnAdd.Enabled = false;
  1182. this.btnDelete.Enabled = false;
  1183. this.btnUpload.Enabled = false;
  1184. }
  1185. else
  1186. {
  1187. this.tsbtnEdit.Enabled = true;
  1188. this.tsbtnAdd.Enabled = true;
  1189. this.btnDelete.Enabled = true;
  1190. this.btnUpload.Enabled = true;
  1191. }
  1192. }
  1193. else
  1194. {
  1195. //if (this._productiondataid > Constant.INT_IS_ZERO)
  1196. //{
  1197. if (this.btnSave.Enabled)
  1198. {
  1199. this.tsbtnEdit.Enabled = true;
  1200. this.tsbtnAdd.Enabled = true;
  1201. this.btnDelete.Enabled = true;
  1202. this.btnUpload.Enabled = true;
  1203. }
  1204. }
  1205. // }
  1206. if (this.dgvDefect.Rows[0].Cells["TempCount"].Value.ToString() != string.Empty)
  1207. {
  1208. int staffTempCount = Convert.ToInt32(this.dgvDefect.Rows[0].Cells["TempCount"].Value.ToString());
  1209. this.dgvDefectStaff.DataSource = DSTableStaff.Tables[string.Format("TempTable{0}", staffTempCount.ToString())];
  1210. this.dgvMissStaff.DataSource = DSTableMissedStaff.Tables[string.Format("TempTable{0}", staffTempCount.ToString())];
  1211. this._currentTempSign = this.dgvDefect.Rows[0].Cells["TempCount"].Value.ToString(); //当前临时标记
  1212. this._smallByte.Clear();//防止重复绑定图片
  1213. BindByteImage(DSTableImage.Tables[string.Format("TempTable{0}", staffTempCount.ToString())]);
  1214. }
  1215. else
  1216. {
  1217. this.dgvDefectStaff.DataSource = null;
  1218. this.dgvMissStaff.DataSource = null;
  1219. this._smallByte.Clear();//防止重复绑定图片
  1220. this.lvPic.Clear();//
  1221. }
  1222. }
  1223. }
  1224. }
  1225. }
  1226. }
  1227. catch (Exception ex)
  1228. {
  1229. throw ex;
  1230. }
  1231. }
  1232. /// <summary>
  1233. /// 新建按钮事件
  1234. /// </summary>
  1235. /// <param name="sender"></param>
  1236. /// <param name="e"></param>
  1237. private void tsbtnAdd_Click(object sender, EventArgs e)
  1238. {
  1239. if (this.dgvProductionData.CurrentCell != null)
  1240. {
  1241. int allow = Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["GoodsLevelTypeID"].Value.ToString());
  1242. if (allow != Constant.INT_IS_FOUR) // 有缺陷才能新建
  1243. {
  1244. F_PM_3203 frm3203 = new F_PM_3203(
  1245. DSTable.Tables[this._currentBarCode], this._currentBarCode,
  1246. this._currentGoodsID, this._tempCount, this._procedureID, this.Text, false, this, this.DSTableStaff, this.DSTableMissedStaff, this.DSTableImage, this._PicByte, this._smallByte, -1);
  1247. frm3203.ShowDialog();
  1248. }
  1249. }
  1250. }
  1251. /// <summary>
  1252. /// 编辑按钮事件
  1253. /// </summary>
  1254. /// <param name="sender"></param>
  1255. /// <param name="e"></param>
  1256. private void tsbtnEdit_Click(object sender, EventArgs e)
  1257. {
  1258. if (this.dgvDefect.CurrentCell != null)
  1259. {
  1260. //int isallowedit = Convert.ToInt32(this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["IsAllowEdit"].Value.ToString());
  1261. if (Convert.ToInt32(this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["IsAllowEdit"].Value.ToString()) == 1) //如果_AllowEdit=1,则是编辑状态,肯定允许编辑,因为分权限的时候就定义了
  1262. {
  1263. string barcode = this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["ProductionBarCode"].Value.ToString();
  1264. int tempcount = Convert.ToInt32(this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["TempCount"].Value.ToString());
  1265. int goodsID = 0;
  1266. DataRow[] dr = this.TableProductionData.Select("BarCode='" + barcode + "'");
  1267. if (dr.Length > Constant.INT_IS_ZERO)
  1268. {
  1269. goodsID = Convert.ToInt32(dr[0]["GoodsID"]);
  1270. }
  1271. F_PM_3203 frm3203 = new F_PM_3203(
  1272. DSTable.Tables[barcode], barcode,
  1273. goodsID, tempcount, this._procedureID, this.Text, true, this, this.DSTableStaff, this.DSTableMissedStaff, this.DSTableImage, this._PicByte, this._smallByte, this.dgvDefect.CurrentCell.RowIndex);
  1274. frm3203.ShowDialog();
  1275. }
  1276. }
  1277. }
  1278. /// <summary>
  1279. /// 产品数据源值改变后
  1280. /// </summary>
  1281. /// <param name="sender"></param>
  1282. /// <param name="e"></param>
  1283. private void dgvProductionData_CellValueChanged(object sender, DataGridViewCellEventArgs e)
  1284. {
  1285. if (e.ColumnIndex == Constant.INT_IS_FOUR && e.RowIndex != -Constant.INT_IS_ONE)
  1286. {
  1287. //if (this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureID"].Value.ToString() != string.Empty)
  1288. //{
  1289. // string barcode = dgvProductionData.Rows[e.RowIndex].Cells["BarCode"].Value.ToString();
  1290. // DataTable dt = this.DSREWORK.Tables[barcode];
  1291. // if (dt != null && dt.Rows.Count > Constant.INT_IS_ZERO)
  1292. // {
  1293. // DataRow[] dr = dt.Select("ReworkProcedureID=" + this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureID"].Value);
  1294. // if (dr.Length > Constant.INT_IS_ZERO)
  1295. // {
  1296. // this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureName"].Value = dr[0]["ReworkProcedureName"];
  1297. // }
  1298. // }
  1299. //}
  1300. }
  1301. }
  1302. /// <summary>
  1303. /// 保存按钮事件
  1304. /// </summary>
  1305. /// <param name="sender"></param>
  1306. /// <param name="e"></param>
  1307. private void btnSave_Click(object sender, EventArgs e)
  1308. {
  1309. try
  1310. {
  1311. //ProductionDataEntity[] productionDataEntitys = new ProductionDataEntity[this.TableProductionData.Rows.Count];
  1312. if (this.TableProductionData.Select("ReadOnly<>1").Length > 0)
  1313. {
  1314. this.TableProductionData = this.TableProductionData.Select("ReadOnly<>1").CopyToDataTable();
  1315. }
  1316. ProductionDataEntity[] productionDataEntitys = new ProductionDataEntity[this.TableProductionData.Rows.Count];
  1317. bool isError = false; // 是否存在缺陷员工
  1318. int ErrorCount = -1;
  1319. int CurrentRowIndex = -1;
  1320. for (int i = 0; i < this.TableProductionData.Rows.Count; i++)
  1321. {
  1322. if (this.TableProductionData.Rows[i]["ReadOnly"].ToString() == "1") //只读数据不进行保存
  1323. {
  1324. continue;
  1325. }
  1326. ProductionDataEntity productionDataEntity = new ProductionDataEntity();
  1327. //if (this._productiondataid > 0)
  1328. //{
  1329. // productionDataEntity.ProductionDataID = this._productiondataid;
  1330. //}
  1331. if (this.TableProductionData.Rows[i]["ProductionDataID"].ToString() != "")
  1332. {
  1333. productionDataEntity.ProductionDataID = Convert.ToInt32(this.TableProductionData.Rows[i]["ProductionDataID"]);
  1334. }
  1335. productionDataEntity.Barcode = this.TableProductionData.Rows[i]["BarCode"].ToString();
  1336. productionDataEntity.UserID = UserID;// Convert.ToInt32(this.TableProductionData.Rows[i]["UserID"]);
  1337. productionDataEntity.UserCode = UserCode;// this.TableProductionData.Rows[i]["UserCode"].ToString();
  1338. productionDataEntity.UserName = UserName;// this.TableProductionData.Rows[i]["UserName"].ToString(); ;
  1339. //1没缺陷 2有缺陷
  1340. productionDataEntity.DefectFlag = Convert.ToInt32(this.TableProductionData.Rows[i]["GoodsLevelTypeID"]) == 1 ? 1 : 2;
  1341. //xuwei modify 2019-12-12
  1342. productionDataEntity.GoodsLevelID = Convert.ToInt32(this.TableProductionData.Rows[i]["DefectFlagID"]);
  1343. productionDataEntity.GoodsLevelTypeID = Convert.ToInt32(this.TableProductionData.Rows[i]["GoodsLevelTypeID"]);
  1344. productionDataEntity.Remarks = this.TableProductionData.Rows[i]["Remarks"].ToString();
  1345. if (this.TableProductionData.Rows[i]["LogoID"].ToString() != "")
  1346. {
  1347. productionDataEntity.LogoID = Convert.ToInt32(this.TableProductionData.Rows[i]["LogoID"]);
  1348. }
  1349. if (this.TableProductionData.Rows[i]["OPTimeStamp"].ToString() != "")
  1350. {
  1351. productionDataEntity.OPTimeStamp = Convert.ToDateTime(this.TableProductionData.Rows[i]["OPTimeStamp"]);
  1352. }
  1353. if (this.TableProductionData.Rows[i]["CheckTime"].ToString() != "")
  1354. {
  1355. productionDataEntity.CheckTime = Convert.ToDateTime(this.TableProductionData.Rows[i]["CheckTime"]);
  1356. }
  1357. if (this.TableProductionData.Rows[i]["OrgGoodsLevelTypeID"].ToString() != "-1")
  1358. {
  1359. productionDataEntity.OrgGoodsLevelTypeID = Convert.ToInt32(this.TableProductionData.Rows[i]["OrgGoodsLevelTypeID"]);
  1360. }
  1361. if (!string.IsNullOrEmpty(this.TableProductionData.Rows[i]["ReworkProcedureID"].ToString()))
  1362. {
  1363. productionDataEntity.ReworkProcedureID = int.Parse(this.TableProductionData.Rows[i]["ReworkProcedureID"].ToString());
  1364. productionDataEntity.IsReworked = 1;
  1365. }
  1366. productionDataEntitys[i] = productionDataEntity;
  1367. if (Convert.ToInt32(this.TableProductionData.Rows[i]["GoodsLevelTypeID"]) == (int)Constant.GoodsLevelType.ReFire) //重烧
  1368. {
  1369. if (this.TableProductionData.Rows[i]["ReworkProcedureID"].ToString() == "" ||
  1370. Convert.ToInt32(this.TableProductionData.Rows[i]["ReworkProcedureID"].ToString()) == -Constant.INT_IS_ONE)
  1371. {
  1372. isError = true;
  1373. ErrorCount = 1;
  1374. CurrentRowIndex = i;
  1375. this.dgvProductionData.Rows[i].Selected = true;
  1376. break;
  1377. }
  1378. }
  1379. if (Convert.ToInt32(this.TableProductionData.Rows[i]["GoodsLevelTypeID"]) != (int)Constant.GoodsLevelType.Quality) //正品
  1380. {
  1381. // 不是正品
  1382. if (this.DSTable.Tables[productionDataEntity.Barcode].Rows.Count == Constant.INT_IS_ZERO)
  1383. {
  1384. isError = true;
  1385. ErrorCount = -2;
  1386. CurrentRowIndex = i;
  1387. this.dgvProductionData.Rows[i].Selected = true;
  1388. break;
  1389. }
  1390. }
  1391. List<ProductionDefectEntity> productionDefectEntitys = new List<ProductionDefectEntity>();
  1392. ProductionDefectEntity productionDefectEntity = null;
  1393. for (int j = 0; j < this.DSTable.Tables[productionDataEntity.Barcode].Rows.Count; j++) //缺陷列表
  1394. {
  1395. productionDefectEntity = new ProductionDefectEntity();
  1396. productionDefectEntity.SpecialDefect = this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["IsOtherDefect"].ToString();
  1397. //if (this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectDeductionID"].ToString() != "-1"
  1398. // && this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectDeductionID"].ToString() != string.Empty)
  1399. //{
  1400. // productionDefectEntity.DefectDeductionNum = Convert.ToDecimal(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectDeductionNum"]);
  1401. //}
  1402. if (!string.IsNullOrEmpty(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectDeductionNum"] + ""))
  1403. {
  1404. productionDefectEntity.DefectDeductionNum = Convert.ToDecimal(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectDeductionNum"]);
  1405. }
  1406. productionDefectEntity.ScrapResponFlag = "0";
  1407. productionDefectEntity.DefectID =
  1408. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectID"]);
  1409. productionDefectEntity.DefectCode =
  1410. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectCode"].ToString();
  1411. productionDefectEntity.DefectName =
  1412. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectName"].ToString().Replace(productionDefectEntity.DefectCode + "->", "");
  1413. productionDefectEntity.DefectPositionID =
  1414. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectPositionID"]);
  1415. productionDefectEntity.DefectPositionCode =
  1416. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectPositionCode"].ToString();
  1417. productionDefectEntity.DefectPositionName =
  1418. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectPositionName"].ToString().Replace(productionDefectEntity.DefectPositionCode + "->", "");
  1419. productionDefectEntity.DefectProductionDataID =
  1420. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["ProductionDataID"].ToString());
  1421. if (productionDefectEntity.DefectProductionDataID == 0)
  1422. {
  1423. productionDefectEntity.DefectProductionDataID = null;
  1424. }
  1425. if (this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectProcedureID"].ToString() != string.Empty &&
  1426. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectProcedureID"]) > Constant.INT_IS_ZERO)
  1427. {
  1428. productionDefectEntity.DefectProcedureID =
  1429. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectProcedureID"]);
  1430. }
  1431. productionDefectEntity.DefectProcedureCode =
  1432. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectProcedureCode"].ToString();
  1433. productionDefectEntity.DefectProcedureName =
  1434. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectProcedureName"].ToString();
  1435. productionDefectEntity.DefectUserID =
  1436. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectUserID"]);
  1437. productionDefectEntity.DefectUserCode =
  1438. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectUserCode"].ToString();
  1439. productionDefectEntity.DefectUserName =
  1440. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectUserName"].ToString();
  1441. productionDefectEntity.DefectJobs =
  1442. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["Jobs"].ToString());
  1443. productionDefectEntity.Remarks =
  1444. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectRemarks"].ToString();
  1445. productionDefectEntity.Remarks =
  1446. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectRemarks"].ToString();
  1447. if (this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectFineID"].ToString() != "-1"
  1448. && this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectFineID"].ToString() != string.Empty)
  1449. {
  1450. productionDefectEntity.DefectFine = Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectFineID"]);
  1451. }
  1452. if (this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["CheckTime"].ToString() != string.Empty)
  1453. {
  1454. //if (Convert.ToInt32(this.TableProductionData.Rows[i]["OrgGoodsLevelTypeID"]) == Convert.ToInt32(this.TableProductionData.Rows[i]["GoodsLevelTypeID"]))
  1455. //{
  1456. productionDefectEntity.CheckTime = Convert.ToDateTime(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["CheckTime"]);
  1457. //}
  1458. }
  1459. if (this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["MissedUserID"].ToString() != "-1"
  1460. && this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["MissedUserID"].ToString() != string.Empty)
  1461. {
  1462. productionDefectEntity.MissedUserID = Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["MissedUserID"]);
  1463. productionDefectEntity.MissedUserCode = this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["MissedUserCode"].ToString();
  1464. productionDefectEntity.MissedUserName = this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["MissedUserName"].ToString();
  1465. }
  1466. // 遍历责任员工
  1467. List<DefectResponsibleEntity> DefectResponsibles = new List<DefectResponsibleEntity>();
  1468. if (this.DSTableStaff.Tables.Contains(string.Format("TempTable{0}",
  1469. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["TempCount"].ToString())))
  1470. {
  1471. DefectResponsibleEntity defectResponsibleEntity = null;
  1472. DataTable dtTemp = this.DSTableStaff.Tables[string.Format("TempTable{0}",
  1473. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["TempCount"].ToString())];
  1474. foreach (DataRow drStaff in dtTemp.Rows)
  1475. {
  1476. if (Convert.ToInt32(drStaff["IsSelected"]) == Constant.INT_IS_ONE)
  1477. {
  1478. defectResponsibleEntity = new DefectResponsibleEntity();
  1479. defectResponsibleEntity.StaffID = Convert.ToInt32(drStaff["StaffID"]);
  1480. defectResponsibleEntity.UserID = Convert.ToInt32(productionDefectEntity.DefectUserID);
  1481. defectResponsibleEntity.UserCode = productionDefectEntity.DefectUserCode;
  1482. defectResponsibleEntity.UJobsID =
  1483. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["Jobs"].ToString());
  1484. defectResponsibleEntity.SJobsID =
  1485. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["Jobs"].ToString());
  1486. defectResponsibleEntity.StaffStatus = Convert.ToInt32(drStaff["StaffStatus"]);
  1487. DefectResponsibles.Add(defectResponsibleEntity);
  1488. }
  1489. }
  1490. //productionDefectEntity.DefectResponsibles = DefectResponsibles.ToArray();//每个缺陷对应的责任员工
  1491. productionDefectEntity.DefectResponsibles = DefectResponsibles;//每个缺陷对应的责任员工
  1492. }
  1493. if (DefectResponsibles.Count == Constant.INT_IS_ZERO) // 并没有责任员工
  1494. {
  1495. isError = true;
  1496. this.dgvDefect.DataSource = this.DSTable.Tables[productionDataEntity.Barcode];
  1497. this.dgvDefect.CurrentCell = null;
  1498. this.dgvDefect.Rows[j].Selected = true;
  1499. if (this.DSTableStaff.Tables.Contains(string.Format("TempTable{0}",
  1500. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["TempCount"].ToString())))
  1501. {
  1502. this.dgvDefectStaff.DataSource = this.DSTableStaff.Tables[string.Format("TempTable{0}",
  1503. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["TempCount"].ToString())];
  1504. }
  1505. else
  1506. {
  1507. this.dgvDefectStaff.DataSource = null;
  1508. }
  1509. break;
  1510. }
  1511. // 遍历漏检责任员工
  1512. List<DefectMissedResponsibleEntity> DefectMissedResponsibles = new List<DefectMissedResponsibleEntity>();
  1513. if (this.DSTableMissedStaff.Tables.Contains(string.Format("TempTable{0}",
  1514. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["TempCount"].ToString())))
  1515. {
  1516. DefectMissedResponsibleEntity defectMissedResponsibleEntity = null;
  1517. DataTable dtTemp = this.DSTableMissedStaff.Tables[string.Format("TempTable{0}",
  1518. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["TempCount"].ToString())];
  1519. foreach (DataRow drStaff in dtTemp.Rows)
  1520. {
  1521. if (Convert.ToInt32(drStaff["IsSelected"]) == Constant.INT_IS_ONE)
  1522. {
  1523. defectMissedResponsibleEntity = new DefectMissedResponsibleEntity();
  1524. defectMissedResponsibleEntity.StaffID = Convert.ToInt32(drStaff["StaffID"]);
  1525. defectMissedResponsibleEntity.UserID = Convert.ToInt32(productionDefectEntity.DefectUserID);
  1526. defectMissedResponsibleEntity.UserCode = productionDefectEntity.DefectUserCode;
  1527. defectMissedResponsibleEntity.UJobsID = Convert.ToInt32(drStaff["UJobsID"]);
  1528. defectMissedResponsibleEntity.SJobsID = Convert.ToInt32(drStaff["SJobsID"]);
  1529. defectMissedResponsibleEntity.StaffStatus = Convert.ToInt32(drStaff["StaffStatus"]);
  1530. DefectMissedResponsibles.Add(defectMissedResponsibleEntity);
  1531. }
  1532. }
  1533. //productionDefectEntity.DefectMissedResponsibles = DefectMissedResponsibles.ToArray();
  1534. productionDefectEntity.DefectMissedResponsibles = DefectMissedResponsibles;
  1535. }
  1536. // 遍历缺陷图片
  1537. if (this.DSTableImage.Tables.Contains(string.Format("TempTable{0}",
  1538. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["TempCount"].ToString())))
  1539. {
  1540. List<DefectImageEntity> defectImageEntitys = new List<DefectImageEntity>();
  1541. DefectImageEntity defectImageEntity = null;
  1542. DataTable dtTemp = this.DSTableImage.Tables[string.Format("TempTable{0}",
  1543. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["TempCount"].ToString())];
  1544. foreach (DataRow drImage in dtTemp.Rows)
  1545. {
  1546. defectImageEntity = new DefectImageEntity();
  1547. defectImageEntity.Thumbnail = (byte[])drImage["ImageByte"];
  1548. defectImageEntity.Image = (byte[])drImage["orgImageByte"];
  1549. defectImageEntitys.Add(defectImageEntity);
  1550. }
  1551. //productionDefectEntity.DefectImages = defectImageEntitys.ToArray();
  1552. productionDefectEntity.DefectImages = defectImageEntitys;
  1553. }
  1554. productionDefectEntitys.Add(productionDefectEntity);
  1555. }
  1556. if (isError)
  1557. {
  1558. break;
  1559. }
  1560. //productionDataEntitys[i].ProductionDefects = productionDefectEntitys.ToArray();
  1561. productionDataEntitys[i].ProductionDefects = productionDefectEntitys;
  1562. }
  1563. // 有错误
  1564. if (isError)
  1565. {
  1566. if (CurrentRowIndex != -Constant.INT_IS_ONE)
  1567. {
  1568. this._currentDefectFlag = Convert.ToInt32(this.TableProductionData.Rows[CurrentRowIndex]["DefectFlagID"].ToString());
  1569. }
  1570. if (ErrorCount == -Constant.INT_IS_ONE)
  1571. {
  1572. // 提示信息
  1573. MessageBox.Show(Messages.MSG_PM_W002,
  1574. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1575. return;
  1576. }
  1577. else if (ErrorCount == -Constant.INT_IS_TWO)
  1578. {
  1579. // 提示信息
  1580. MessageBox.Show(Messages.MSG_PM_W004,
  1581. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1582. return;
  1583. }
  1584. else
  1585. {
  1586. this.dgvProductionData.DataSource = TableProductionData;
  1587. //this.TableProductionData.Columns["ReworkProcedureID"].DataType=typeof(decimal);// data typeof(decimal));
  1588. //this.ReworkProcedureID.DataSource = this.DSREWORK.Tables[0];
  1589. //this.ReworkProcedureID.DisplayMember = "ReworkProcedureName";
  1590. //this.ReworkProcedureID.ValueMember = "ReworkProcedureID";
  1591. // 提示信息
  1592. MessageBox.Show(Messages.MSG_PM_W003,
  1593. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1594. //this.ReworkProcedureID.DataSource = this.DSREWORK.Tables[0];
  1595. //this.ReworkProcedureID.DisplayMember = "ReworkProcedureName";
  1596. //this.ReworkProcedureID.ValueMember = "ReworkProcedureID";
  1597. return;
  1598. }
  1599. }
  1600. // 最外层For循环结束
  1601. if (productionDataEntitys.Length > Constant.INT_IS_ZERO)
  1602. {
  1603. string returnValue = (string)DoAsync(new BaseAsyncMethod(() =>
  1604. {
  1605. return PMModuleProxy.Service.AddCheckBarcode(this._procedureID, productionDataEntitys);
  1606. }));
  1607. if (string.IsNullOrEmpty(returnValue))//成功
  1608. {
  1609. // 提示信息
  1610. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "新建" + this.Text, "保存"),
  1611. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  1612. ////保存成功后,并且为编辑时候,把上次编辑的数据禁用
  1613. //if (this._productiondataid > Constant.INT_IS_ZERO)
  1614. //{
  1615. // int deleteRow = (int)DoAsync(new BaseAsyncMethod(() =>
  1616. // {
  1617. // return PMModuleProxy.Service.DeleteProductionDataByID(this._productiondataid);
  1618. // }));
  1619. //}
  1620. // 保存成功后,清空相应数据源
  1621. this.TableProductionData.Rows.Clear();
  1622. this.dgvProductionData.DataSource = TableProductionData;
  1623. this.DSTable.Tables.Clear();
  1624. this.dgvDefect.DataSource = null;
  1625. this.DSTableStaff.Tables.Clear();
  1626. this.dgvDefectStaff.DataSource = null;
  1627. this.DSTableMissedStaff.Tables.Clear();
  1628. this.dgvMissStaff.DataSource = null;
  1629. this.DSTableImage.Tables.Clear();
  1630. this.lvPic.Clear();
  1631. this._PicByte.Clear();
  1632. this._smallByte.Clear();
  1633. this.txtBarCode.Text = string.Empty;
  1634. if (this._procedureDataEntity.CollectType == (int)Constant.ProcedureCollectType.Togather)
  1635. {
  1636. this.txtUserCode.Text = string.Empty;
  1637. this.txtUserCode.ReadOnly = false;
  1638. }
  1639. //this.DSREWORK.Tables.Clear();
  1640. }
  1641. else
  1642. {
  1643. // 提示信息
  1644. MessageBox.Show(returnValue,
  1645. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1646. }
  1647. }
  1648. }
  1649. catch (Exception ex)
  1650. {
  1651. // 对异常进行共通处理
  1652. ExceptionManager.HandleEventException(this.ToString(),
  1653. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  1654. }
  1655. }
  1656. /// <summary>
  1657. /// 关闭按钮事件
  1658. /// </summary>
  1659. /// <param name="sender"></param>
  1660. /// <param name="e"></param>
  1661. private void tsbCloseTop_Click(object sender, EventArgs e)
  1662. {
  1663. this.Close();
  1664. }
  1665. /// <summary>
  1666. /// 单元格编辑开始时事件
  1667. /// </summary>
  1668. /// <param name="sender"></param>
  1669. /// <param name="e"></param>
  1670. private void dgvProductionData_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
  1671. {
  1672. //if (e.ColumnIndex == Constant.INT_IS_FOUR && e.RowIndex != -Constant.INT_IS_ONE)
  1673. //{
  1674. // DataGridView dgv = (DataGridView)sender;
  1675. // string value = this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["GoodsLevelTypeID"].Value.ToString();
  1676. // if (value != Constant.GoodsLevelType.ReFire.GetHashCode().ToString())
  1677. // {
  1678. // e.Cancel = true;
  1679. // }
  1680. //}
  1681. //if (e.ColumnIndex == Constant.INT_IS_THREE && e.RowIndex != -Constant.INT_IS_ONE)
  1682. //{
  1683. // if (this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReadOnly"].Value.ToString() == "1")
  1684. // {
  1685. // e.Cancel = true;
  1686. // }
  1687. //}
  1688. if (e.ColumnIndex == Constant.INT_IS_FOUR && e.RowIndex != -Constant.INT_IS_ONE)
  1689. {
  1690. DataGridView dgv = (DataGridView)sender;
  1691. string value = this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["GoodsLevelTypeID"].Value.ToString();
  1692. if (value != Constant.GoodsLevelType.ReFire.GetHashCode().ToString())
  1693. {
  1694. e.Cancel = true;
  1695. }
  1696. }
  1697. if (e.ColumnIndex == Constant.INT_IS_THREE && e.RowIndex != -Constant.INT_IS_ONE)
  1698. {
  1699. if (this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReadOnly"].Value.ToString() == "1")
  1700. {
  1701. e.Cancel = true;
  1702. }
  1703. }
  1704. }
  1705. /// <summary>
  1706. /// 用户编码验证事件
  1707. /// </summary>
  1708. /// <param name="sender"></param>
  1709. /// <param name="e"></param>
  1710. private void txtUserCode_Validating(object sender, System.ComponentModel.CancelEventArgs e)
  1711. {
  1712. try
  1713. {
  1714. if (txtUserCode.Text.Trim() == string.Empty) // 如果未添加数据,则此项获取焦点
  1715. {
  1716. this.txtUserCode.IsMustInput = true;
  1717. this.txtUserCode.SelectAll();
  1718. e.Cancel = true;
  1719. return;
  1720. }
  1721. else if (!this.txtUserCode.ReadOnly)
  1722. {
  1723. SUserEntity userEntity = new SUserEntity();
  1724. userEntity.UserCode = this.txtUserCode.Text.Trim();
  1725. // 此工号是否能生产工序
  1726. CheckProcedureUserResult MsgCheckProcedureUser = (CheckProcedureUserResult)DoAsync(new BaseAsyncMethod(() =>
  1727. {
  1728. return PMModuleProxy.Service.CheckProcedureUser(this._procedureID, this.txtUserCode.Text.Trim());
  1729. }));
  1730. if (MsgCheckProcedureUser != null)
  1731. {
  1732. if (MsgCheckProcedureUser.ErrMsg != null)
  1733. {
  1734. MessageBox.Show(MsgCheckProcedureUser.ErrMsg,
  1735. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1736. this.txtUserCode.SelectAll();
  1737. e.Cancel = true;
  1738. return;
  1739. }
  1740. UserID = Convert.ToInt32(MsgCheckProcedureUser.UserID);
  1741. UserCode = MsgCheckProcedureUser.UserCode;
  1742. UserName = MsgCheckProcedureUser.UserName;
  1743. this.txtUserCode.ReadOnly = true;
  1744. }
  1745. }
  1746. }
  1747. catch (Exception ex)
  1748. {
  1749. // 对异常进行共通处理
  1750. ExceptionManager.HandleEventException(this.ToString(),
  1751. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  1752. }
  1753. }
  1754. /// <summary>
  1755. /// 鼠标单击事件
  1756. /// </summary>
  1757. /// <param name="sender"></param>
  1758. /// <param name="e"></param>
  1759. private void txtUserCode_MouseClick(object sender, MouseEventArgs e)
  1760. {
  1761. if (this.txtUserCode.Text.Trim() != string.Empty)
  1762. {
  1763. this.txtUserCode.SelectAll();
  1764. }
  1765. }
  1766. #endregion
  1767. #region 私有方法
  1768. /// <summary>
  1769. /// 设置数据源
  1770. /// </summary>
  1771. /// <param name="tempCount"></param>
  1772. public void SetDataSource(int tempCount)
  1773. {
  1774. this.dgvDefect.DataSource = DSTable.Tables[this._currentBarCode];
  1775. this.dgvDefectStaff.DataSource = DSTableStaff.Tables[string.Format("TempTable{0}", this._tempCount.ToString())];
  1776. this.dgvMissStaff.DataSource = DSTableMissedStaff.Tables[string.Format("TempTable{0}", this._tempCount.ToString())];
  1777. this._tempCount = tempCount;
  1778. }
  1779. /// <summary>
  1780. /// 设置编辑产品为时设置只读
  1781. /// </summary>
  1782. private void SetSubstandard()
  1783. {
  1784. this.btnSave.Enabled = false;
  1785. this.dgvProductionData.ReadOnly = true;
  1786. this.tsbtnAdd.Enabled = false;
  1787. this.tsbtnEdit.Enabled = false;
  1788. this.dgvDefect.ReadOnly = true;
  1789. this.dgvDefectStaff.ReadOnly = true;
  1790. this.dgvMissStaff.ReadOnly = true;
  1791. this.btnDelete.Enabled = false;
  1792. this.btnUpload.Enabled = false;
  1793. }
  1794. /// <summary>
  1795. /// 编辑后设置数据源
  1796. /// </summary>
  1797. private void SetEditDataSource()
  1798. {
  1799. try
  1800. {
  1801. this.txtUserCode.Enabled = false;
  1802. this.txtBarCode.Enabled = false;
  1803. DataSet dsProductionDataByID = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  1804. {
  1805. return PMModuleProxy.Service.GetProductionDataByID(this._productiondataid);
  1806. }));
  1807. if (dsProductionDataByID != null && dsProductionDataByID.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  1808. {
  1809. #region wangx 2016-10-10 校验是否可以成检登记改判
  1810. if (_settingvaluedays > 0)
  1811. {
  1812. ServiceResultEntity resultEntity = (ServiceResultEntity)DoAsync(new BaseAsyncMethod(() =>
  1813. {
  1814. return PMModuleProxy.Service.BarcodeAllowCancel(
  1815. Convert.ToDateTime(dsProductionDataByID.Tables[0].Rows[0]["createtime"]),
  1816. _settingvaluedays, Constant.SettingType.S_PM_009.ToString());
  1817. }));
  1818. if (Convert.ToInt32(resultEntity.Result) < 0)
  1819. {
  1820. MessageBox.Show(resultEntity.Message,
  1821. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1822. this.txtBarCode.Text = "";
  1823. this.btnSave.Visible = false;
  1824. }
  1825. }
  1826. #endregion wangx 2016-10-10 end
  1827. #region 如果是次品,回收后不允许编辑
  1828. if (Convert.ToInt32(dsProductionDataByID.Tables[0].Rows[0]["GoodsLevelTypeID"]) == 7)//次品
  1829. {
  1830. int recyclingflag = (int)DoAsync(new BaseAsyncMethod(() =>
  1831. {
  1832. return PMModuleProxy.Service.GetRecyclingflagByBarcode(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString());
  1833. }));
  1834. if (recyclingflag > 0)
  1835. {
  1836. MessageBox.Show("条码【" + dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString() + "】已经回收,不允许改判", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1837. this.txtBarCode.Enabled = true;
  1838. this.txtBarCode.Focus();
  1839. return;
  1840. }
  1841. }
  1842. #endregion
  1843. int SpecialRepairflag = (int)DoAsync(new BaseAsyncMethod(() =>
  1844. {
  1845. return PMModuleProxy.Service.GetSpecialRepairflagByBarcode(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString());
  1846. }));
  1847. // 产品数据
  1848. DataRow drNew = TableProductionData.NewRow();
  1849. drNew["ProductionDataID"] = this._productiondataid;
  1850. drNew["BarCode"] = dsProductionDataByID.Tables[0].Rows[0]["BarCode"];
  1851. drNew["GoodsID"] = dsProductionDataByID.Tables[0].Rows[0]["GoodsID"];
  1852. drNew["GoodsCode"] = dsProductionDataByID.Tables[0].Rows[0]["GoodsCode"];
  1853. drNew["GoodsName"] = dsProductionDataByID.Tables[0].Rows[0]["GoodsName"];
  1854. drNew["DefectFlagID"] = dsProductionDataByID.Tables[0].Rows[0]["DefectFlagID"];
  1855. drNew["ReworkProcedureID"] = dsProductionDataByID.Tables[0].Rows[0]["ReworkProcedureID"];
  1856. drNew["Remarks"] = dsProductionDataByID.Tables[0].Rows[0]["Remarks"];
  1857. drNew["UserID"] = dsProductionDataByID.Tables[0].Rows[0]["UserID"];
  1858. drNew["GoodsLevelTypeID"] = dsProductionDataByID.Tables[0].Rows[0]["GoodsLevelTypeID"];
  1859. drNew["UserCode"] = dsProductionDataByID.Tables[0].Rows[0]["UserCode"];
  1860. drNew["UserName"] = dsProductionDataByID.Tables[0].Rows[0]["UserName"];
  1861. UserID = Convert.ToInt32(dsProductionDataByID.Tables[0].Rows[0]["UserID"]);
  1862. UserCode = dsProductionDataByID.Tables[0].Rows[0]["UserCode"].ToString();
  1863. UserName = dsProductionDataByID.Tables[0].Rows[0]["UserName"].ToString();
  1864. drNew["OrgGoodsLevelTypeID"] = dsProductionDataByID.Tables[0].Rows[0]["GoodsLevelTypeID"];
  1865. drNew["ReadOnly"] = this._ReadOnly;
  1866. drNew["KilnCarCode"] = dsProductionDataByID.Tables[0].Rows[0]["KilnCarCode"];
  1867. drNew["KilnCode"] = dsProductionDataByID.Tables[0].Rows[0]["KilnCode"];
  1868. drNew["Dictionaryvalue"] = dsProductionDataByID.Tables[0].Rows[0]["Dictionaryvalue"];
  1869. drNew["UserCode"] = dsProductionDataByID.Tables[0].Rows[0]["UserCode"];
  1870. drNew["MouldCode"] = dsProductionDataByID.Tables[0].Rows[0]["MouldCode"];
  1871. drNew["GroutingUserCode"] = dsProductionDataByID.Tables[0].Rows[0]["GroutingUserCode"];
  1872. drNew["GroutingNum"] = dsProductionDataByID.Tables[0].Rows[0]["GroutingNum"];
  1873. drNew["IsPublicBody"] = dsProductionDataByID.Tables[0].Rows[0]["IsPublicBody"].ToString() != "1" ? 0 : 1;
  1874. drNew["GroutingDate"] = Convert.ToDateTime(dsProductionDataByID.Tables[0].Rows[0]["GroutingDate"]);
  1875. drNew["LogoCodeName"] = dsProductionDataByID.Tables[0].Rows[0]["LogoName"] + "[" + dsProductionDataByID.Tables[0].Rows[0]["LogoCode"] + "]";
  1876. drNew["LogoId"] = dsProductionDataByID.Tables[0].Rows[0]["LogoId"];
  1877. drNew["CheckTime"] = dsProductionDataByID.Tables[0].Rows[0]["CheckTime"];
  1878. DataSet dsOPTimeStamp = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  1879. {
  1880. return PMModuleProxy.Service.GetCompleteProcedureIDPDA(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString());
  1881. }));
  1882. if (dsOPTimeStamp != null && dsOPTimeStamp.Tables[0].Rows.Count > 0)
  1883. {
  1884. drNew["OPTimeStamp"] = Convert.ToDateTime(dsOPTimeStamp.Tables[0].Rows[0]["OPTimeStamp"]);
  1885. }
  1886. //drNew["OPTimeStamp"]
  1887. // 校验条码是否重烧过,这个地方必须重新读取,因为防止编辑重烧以前的成检数据,如果直接取表里的就不准了
  1888. DataSet dsReFine = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  1889. {
  1890. return PMModuleProxy.Service.GetReFine(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString());
  1891. }));
  1892. if (dsReFine != null && dsReFine.Tables[0].Rows.Count > 0 && dsReFine.Tables[0].Rows[0]["IsReFire"].ToString() == "6")
  1893. {
  1894. drNew["ReFine"] = 1;
  1895. }
  1896. else
  1897. {
  1898. drNew["ReFine"] = 0;
  1899. }
  1900. drNew["SpecialRepairflag"] = SpecialRepairflag.ToString() == "1" ? 1 : 0;
  1901. //原产品类别
  1902. //UserID = Convert.ToInt32(dsProductionDataByID.Tables[0].Rows[0]["UserID"]);
  1903. //UserCode = dsProductionDataByID.Tables[0].Rows[0]["UserCode"].ToString();
  1904. //UserName = dsProductionDataByID.Tables[0].Rows[0]["UserName"].ToString();
  1905. TableProductionData.Rows.Add(drNew);
  1906. this.dgvProductionData.Rows[TableProductionData.Rows.Count - 1].Selected = true;
  1907. this._selectedRowIndex = TableProductionData.Rows.Count - 1;
  1908. this._currentBarCode = dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString();
  1909. this._currentGoodsID = Convert.ToInt32(dsProductionDataByID.Tables[0].Rows[0]["GoodsID"]);
  1910. if (dsProductionDataByID.Tables[0].Rows[0]["GoodsLevelTypeID"].ToString() == Constant.INT_IS_SEVEN.ToString())
  1911. {
  1912. //次品设置只读的时候,原来默认不允许修改,目前注释掉
  1913. //SetSubstandard();
  1914. DataSet dsReturn = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  1915. {
  1916. return PMModuleProxy.Service.GetSubstandardInfo(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString());
  1917. }));
  1918. if (dsReturn != null && dsReturn.Tables[0].Rows.Count == 0) //防止回收站里没有此条码
  1919. {
  1920. // 提示信息
  1921. MessageBox.Show("次品条码:" + dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString() + "不允许修改",
  1922. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1923. return;
  1924. }
  1925. this.tsbtnAdd.Enabled = true;
  1926. }
  1927. else
  1928. {
  1929. this.tsbtnAdd.Enabled = true;
  1930. if (dsProductionDataByID != null && dsProductionDataByID.Tables[1].Rows.Count > Constant.INT_IS_ZERO)
  1931. {
  1932. this.tsbtnEdit.Enabled = true;
  1933. }
  1934. }
  1935. }
  1936. if (DSTable.Tables.IndexOf(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString()) == -Constant.INT_IS_ONE)
  1937. {
  1938. DataTable dtProductionDefectData = new DataTable(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString());
  1939. dtProductionDefectData.Columns.Add("BarCode");
  1940. dtProductionDefectData.Columns.Add("DefectID", typeof(decimal));
  1941. dtProductionDefectData.Columns.Add("DefectName");
  1942. dtProductionDefectData.Columns.Add("DefectCode");
  1943. dtProductionDefectData.Columns.Add("DefectPositionID", typeof(decimal));
  1944. dtProductionDefectData.Columns.Add("DefectPositionName");
  1945. dtProductionDefectData.Columns.Add("DefectPositionCode");
  1946. dtProductionDefectData.Columns.Add("DefectProcedureID", typeof(decimal));
  1947. dtProductionDefectData.Columns.Add("DefectProcedureName");
  1948. dtProductionDefectData.Columns.Add("DefectProcedureCode");
  1949. dtProductionDefectData.Columns.Add("DefectUserID", typeof(decimal));//责任员工
  1950. dtProductionDefectData.Columns.Add("DefectUserName");//责任员工
  1951. dtProductionDefectData.Columns.Add("DefectUserCode");//
  1952. dtProductionDefectData.Columns.Add("Jobs", typeof(decimal));//工种
  1953. dtProductionDefectData.Columns.Add("JobsText");//工种
  1954. dtProductionDefectData.Columns.Add("DefectRemarks");
  1955. dtProductionDefectData.Columns.Add("TempCount");
  1956. dtProductionDefectData.Columns.Add("ProductionDataID"); //生产数据ID
  1957. dtProductionDefectData.Columns.Add("DefectFineID"); //缺陷扣罚ID
  1958. dtProductionDefectData.Columns.Add("DefectFineValue"); //缺陷扣罚
  1959. dtProductionDefectData.Columns.Add("MissedUserID"); //漏检工号ID
  1960. dtProductionDefectData.Columns.Add("MissedUserCode"); //漏检工号编码
  1961. dtProductionDefectData.Columns.Add("MissedUserName"); //漏检工号名称
  1962. dtProductionDefectData.Columns.Add("IsAllowEdit"); //是否允许编辑 0 不允许,1允许
  1963. //新添加的 wangx 2016/1/6
  1964. dtProductionDefectData.Columns.Add("DefectDeductionID"); //缺陷扣除数ID
  1965. dtProductionDefectData.Columns.Add("DefectDeductionNum"); //缺陷扣除数
  1966. dtProductionDefectData.Columns.Add("IsOtherDefect"); //特殊缺陷
  1967. dtProductionDefectData.Columns.Add("CheckTime"); //缺陷检验时间
  1968. //新添加的 wangx 2016/1/6 end
  1969. DSTable.Tables.Add(dtProductionDefectData);
  1970. }
  1971. if (dsProductionDataByID != null && dsProductionDataByID.Tables[1].Rows.Count > Constant.INT_IS_ZERO)
  1972. {
  1973. // 产品缺陷
  1974. if (DSTable.Tables.IndexOf(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString()) == -Constant.INT_IS_ONE)
  1975. {
  1976. DataTable dtProductionDefectData = new DataTable(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString());
  1977. dtProductionDefectData.Columns.Add("BarCode");
  1978. dtProductionDefectData.Columns.Add("DefectID", typeof(decimal));
  1979. dtProductionDefectData.Columns.Add("DefectName");
  1980. dtProductionDefectData.Columns.Add("DefectCode");
  1981. dtProductionDefectData.Columns.Add("DefectPositionID", typeof(decimal));
  1982. dtProductionDefectData.Columns.Add("DefectPositionName");
  1983. dtProductionDefectData.Columns.Add("DefectPositionCode");
  1984. dtProductionDefectData.Columns.Add("DefectProcedureID", typeof(decimal));
  1985. dtProductionDefectData.Columns.Add("DefectProcedureName");
  1986. dtProductionDefectData.Columns.Add("DefectProcedureCode");
  1987. dtProductionDefectData.Columns.Add("DefectUserID", typeof(decimal));//责任员工
  1988. dtProductionDefectData.Columns.Add("DefectUserName");//责任员工
  1989. dtProductionDefectData.Columns.Add("DefectUserCode");//
  1990. dtProductionDefectData.Columns.Add("Jobs", typeof(decimal));//工种
  1991. dtProductionDefectData.Columns.Add("JobsText");//工种
  1992. dtProductionDefectData.Columns.Add("DefectRemarks");
  1993. dtProductionDefectData.Columns.Add("TempCount");
  1994. dtProductionDefectData.Columns.Add("ProductionDataID"); //生产数据ID
  1995. dtProductionDefectData.Columns.Add("DefectFineID"); //缺席扣罚ID
  1996. dtProductionDefectData.Columns.Add("DefectFineValue"); //缺席扣罚
  1997. dtProductionDefectData.Columns.Add("MissedUserID"); //漏检工号ID
  1998. dtProductionDefectData.Columns.Add("MissedUserCode"); //漏检工号编码
  1999. dtProductionDefectData.Columns.Add("MissedUserName"); //漏检工号名称
  2000. dtProductionDefectData.Columns.Add("IsAllowEdit"); //是否允许编辑 0 不允许,1允许
  2001. //新添加的 wangx 2016/1/6
  2002. dtProductionDefectData.Columns.Add("DefectDeductionID"); //缺陷扣除数ID
  2003. dtProductionDefectData.Columns.Add("DefectDeductionNum"); //缺陷扣除数
  2004. dtProductionDefectData.Columns.Add("IsOtherDefect"); //特殊缺陷
  2005. dtProductionDefectData.Columns.Add("CheckTime"); //缺陷检验时间
  2006. //新添加的 wangx 2016/1/6 end
  2007. DSTable.Tables.Add(dtProductionDefectData);
  2008. }
  2009. this.dgvProductionData.Rows[TableProductionData.Rows.Count - 1].Selected = true;
  2010. this._selectedRowIndex = TableProductionData.Rows.Count - 1;
  2011. this._currentDefectFlag = Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["GoodsLevelTypeID"].Value.ToString());
  2012. this._currentGoodsID = Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["GoodsID"].Value);
  2013. this._currentBarCode = this.dgvProductionData.Rows[_selectedRowIndex].Cells["BarCode"].Value.ToString();
  2014. //-----------------------
  2015. //DataSet ds = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2016. //{
  2017. // return PMModuleProxy.Service.GetReworkProcedureByProcedureID(this._procedureID);
  2018. //}));
  2019. //ds.Tables[0].TableName = dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString();
  2020. //if (this.DSREWORK == null)
  2021. //{
  2022. // this.DSREWORK = new DataSet();
  2023. //}
  2024. //this.DSREWORK.Tables.Add(ds.Tables[0].Copy());
  2025. //C_DGV_Cell_ListBoxComboBox C_DGV_Cell_ListBoxComboBox = dgvProductionData.Rows[_selectedRowIndex].Cells[4] as C_DGV_Cell_ListBoxComboBox;
  2026. //C_DGV_Cell_ListBoxComboBox.DataSource = ds.Tables[0];
  2027. //C_DGV_Cell_ListBoxComboBox.DisplayMember = "ReworkProcedureName";
  2028. //C_DGV_Cell_ListBoxComboBox.ValueMember = "ReworkProcedureID";
  2029. for (int i = 0; i < dsProductionDataByID.Tables[1].Rows.Count; i++)
  2030. {
  2031. DataRow dr = DSTable.Tables[dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString()].NewRow();
  2032. dr["BarCode"] = dsProductionDataByID.Tables[1].Rows[i]["BarCode"];
  2033. dr["DefectID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectID"];
  2034. dr["DefectName"] = dsProductionDataByID.Tables[1].Rows[i]["DefectName"];
  2035. dr["DefectCode"] = dsProductionDataByID.Tables[1].Rows[i]["DefectCode"];
  2036. dr["DefectPositionID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectPositionID"];
  2037. dr["DefectPositionName"] = dsProductionDataByID.Tables[1].Rows[i]["DefectPositionName"];
  2038. dr["DefectPositionCode"] = dsProductionDataByID.Tables[1].Rows[i]["DefectPositionCode"];
  2039. dr["DefectProcedureID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectProcedureID"];
  2040. dr["DefectProcedureName"] = dsProductionDataByID.Tables[1].Rows[i]["DefectProcedureName"];
  2041. dr["DefectProcedureCode"] = dsProductionDataByID.Tables[1].Rows[i]["DefectProcedureCode"];
  2042. dr["DefectUserID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectUserID"];
  2043. dr["DefectUserName"] = dsProductionDataByID.Tables[1].Rows[i]["DefectUserName"];
  2044. dr["DefectUserCode"] = dsProductionDataByID.Tables[1].Rows[i]["DefectUserCode"];
  2045. dr["Jobs"] = dsProductionDataByID.Tables[1].Rows[i]["Jobs"];
  2046. dr["JobsText"] = dsProductionDataByID.Tables[1].Rows[i]["JobsText"];
  2047. dr["DefectRemarks"] = dsProductionDataByID.Tables[1].Rows[i]["DefectRemarks"];
  2048. dr["TempCount"] = this._tempCount;
  2049. dr["ProductionDataID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectProductionDataID"];// dsProductionDataByID.Tables[1].Rows[i]["ProductionDataID"];
  2050. dr["DefectFineID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectFineID"];
  2051. dr["DefectFineValue"] = dsProductionDataByID.Tables[1].Rows[i]["DefectFineValue"];
  2052. dr["MissedUserID"] = dsProductionDataByID.Tables[1].Rows[i]["MissedUserID"];
  2053. dr["MissedUserCode"] = dsProductionDataByID.Tables[1].Rows[i]["MissedUserCode"];
  2054. dr["MissedUserName"] = dsProductionDataByID.Tables[1].Rows[i]["MissedUserName"];
  2055. dr["IsAllowEdit"] = this._AllowEdit;
  2056. //dr["DefectDeductionID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectDeductionID"];
  2057. dr["DefectDeductionNum"] = dsProductionDataByID.Tables[1].Rows[i]["DefectDeductionNum"];
  2058. dr["IsOtherDefect"] = dsProductionDataByID.Tables[1].Rows[i]["SpecialDefect"];
  2059. dr["CheckTime"] = dsProductionDataByID.Tables[1].Rows[i]["CheckTime"];
  2060. DSTable.Tables[dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString()].Rows.Add(dr);
  2061. // 防止工种不选择的话,直接New一个
  2062. if (!this.DSTableStaff.Tables.Contains(string.Format("TempTable{0}", this._tempCount)))
  2063. {
  2064. DataTable dtStaff = new DataTable(string.Format("TempTable{0}", this._tempCount));
  2065. dtStaff.Columns.Add("IsSelected");
  2066. dtStaff.Columns.Add("StaffID");
  2067. dtStaff.Columns.Add("StaffCode");
  2068. dtStaff.Columns.Add("StaffName");
  2069. dtStaff.Columns.Add("StaffTempCount");
  2070. dtStaff.Columns.Add("StaffStatus");
  2071. this.DSTableStaff.Tables.Add(dtStaff);
  2072. }
  2073. // 责任员工
  2074. DataRow[] drRow = dsProductionDataByID.Tables[2].Select("ProductionDefectID=" + dsProductionDataByID.Tables[1].Rows[i]["ProductionDefectID"]);
  2075. if (drRow.Length > Constant.INT_IS_ZERO)
  2076. {
  2077. foreach (DataRow r in drRow)
  2078. {
  2079. DataRow drStaff = this.DSTableStaff.Tables[string.Format("TempTable{0}", this._tempCount)].NewRow();
  2080. drStaff["IsSelected"] = 1;
  2081. drStaff["StaffID"] = r["StaffID"];
  2082. drStaff["StaffCode"] = r["StaffCode"];
  2083. drStaff["StaffName"] = r["StaffName"];
  2084. drStaff["StaffTempCount"] = this._tempCount;
  2085. drStaff["StaffStatus"] = r["StaffStatus"];
  2086. this.DSTableStaff.Tables[string.Format("TempTable{0}", this._tempCount)].Rows.Add(drStaff);
  2087. }
  2088. }
  2089. // 漏检员工临时表
  2090. if (!this.DSTableMissedStaff.Tables.Contains(string.Format("TempTable{0}", this._tempCount)))
  2091. {
  2092. DataTable dtMissedStaff = new DataTable(string.Format("TempTable{0}", this._tempCount));
  2093. dtMissedStaff.Columns.Add("IsSelected");
  2094. dtMissedStaff.Columns.Add("StaffID");
  2095. dtMissedStaff.Columns.Add("StaffCode");
  2096. dtMissedStaff.Columns.Add("StaffName");
  2097. dtMissedStaff.Columns.Add("StaffTempCount");
  2098. dtMissedStaff.Columns.Add("StaffStatus");
  2099. dtMissedStaff.Columns.Add("UJobsID");
  2100. dtMissedStaff.Columns.Add("SJobsID");
  2101. this.DSTableMissedStaff.Tables.Add(dtMissedStaff);
  2102. }
  2103. //漏检员工临时表数据
  2104. DataRow[] drMissedRow = dsProductionDataByID.Tables[4].Select("ProductionDefectID=" + dsProductionDataByID.Tables[1].Rows[i]["ProductionDefectID"]);
  2105. if (drMissedRow.Length > Constant.INT_IS_ZERO)
  2106. {
  2107. foreach (DataRow r in drMissedRow)
  2108. {
  2109. DataRow drMissedStaff = this.DSTableMissedStaff.Tables[string.Format("TempTable{0}", this._tempCount)].NewRow();
  2110. drMissedStaff["IsSelected"] = 1;
  2111. drMissedStaff["StaffID"] = r["StaffID"];
  2112. drMissedStaff["StaffCode"] = r["StaffCode"];
  2113. drMissedStaff["StaffName"] = r["StaffName"];
  2114. drMissedStaff["StaffTempCount"] = this._tempCount;
  2115. drMissedStaff["StaffStatus"] = r["StaffStatus"];
  2116. drMissedStaff["UJobsID"] = r["UJobsID"];
  2117. drMissedStaff["SJobsID"] = r["SJobsID"];
  2118. this.DSTableMissedStaff.Tables[string.Format("TempTable{0}", this._tempCount)].Rows.Add(drMissedStaff);
  2119. }
  2120. }
  2121. if (!this.DSTableImage.Tables.Contains(string.Format("TempTable{0}", this._tempCount.ToString())))
  2122. {
  2123. DataTable dtImage = new DataTable(string.Format("TempTable{0}", this._tempCount.ToString()));
  2124. dtImage.Columns.Add("StaffTempCount");
  2125. dtImage.Columns.Add("ImageByte", typeof(byte[]));
  2126. dtImage.Columns.Add("OrgImageByte", typeof(byte[]));
  2127. this.DSTableImage.Tables.Add(dtImage);
  2128. }
  2129. this._currentTempSign = i.ToString();
  2130. // 缺陷图片
  2131. DataRow[] drImageRow = dsProductionDataByID.Tables[3].Select("ProductionDefectID=" + dsProductionDataByID.Tables[1].Rows[i]["ProductionDefectID"]);
  2132. if (drImageRow.Length > Constant.INT_IS_ZERO)
  2133. {
  2134. foreach (DataRow r in drImageRow)
  2135. {
  2136. if (r["SourcePathByte"] != DBNull.Value)
  2137. {
  2138. byte[] orgImageByte = (byte[])r["SourcePathByte"];
  2139. this._PicByte.Add(orgImageByte);
  2140. //this._smallByte.Add(orgImageByte);
  2141. if (!this.DSTableImage.Tables.Contains(string.Format("TempTable{0}", this._currentTempSign.ToString())))
  2142. {
  2143. DataTable dtImage = new DataTable(string.Format("TempTable{0}", this._currentTempSign.ToString()));
  2144. dtImage.Columns.Add("StaffTempCount");
  2145. dtImage.Columns.Add("ImageByte", typeof(byte[]));
  2146. dtImage.Columns.Add("OrgImageByte", typeof(byte[]));
  2147. this.DSTableImage.Tables.Add(dtImage);
  2148. }
  2149. DataRow drrow = DSTableImage.Tables[string.Format("TempTable{0}", this._currentTempSign)].NewRow();
  2150. drrow["StaffTempCount"] = this._currentTempSign;
  2151. drrow["ImageByte"] = orgImageByte;
  2152. drrow["OrgImageByte"] = orgImageByte;
  2153. DSTableImage.Tables[string.Format("TempTable{0}", this._currentTempSign)].Rows.Add(drrow);
  2154. BindImg();
  2155. }
  2156. }
  2157. }
  2158. this._tempCount = this._tempCount + 1;
  2159. }
  2160. this.dgvDefect.DataSource = DSTable.Tables[dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString()];//根据条码产生不同数据源
  2161. //控制产品等级,只有编辑权限的人才能随便改
  2162. if (this._AllowEdit == 0) //
  2163. {
  2164. for (int i = 0; i < this.dgvProductionData.Rows.Count; i++)
  2165. {
  2166. int goodsLevelTypeID = Convert.ToInt32(this.TableProductionData.Rows[i]["GoodsLevelTypeID"]);
  2167. if (this._dsGoodsLevel != null)
  2168. {
  2169. DataTable dt = this._dsGoodsLevel.Tables[0].Copy();
  2170. DataView dv = dt.DefaultView;
  2171. dv.RowFilter = "GoodsLevelTypeID>=" + goodsLevelTypeID;
  2172. DataGridViewComboBoxCell dgcbc = (DataGridViewComboBoxCell)dgvProductionData.Rows[i].Cells[3];
  2173. //xuwei modify 2019-12-12
  2174. //dgcbc.DisplayMember = "DefectFlagName";
  2175. //dgcbc.ValueMember = "DefectFlagID";
  2176. dgcbc.DisplayMember = "GOODSLEVELNAME";
  2177. dgcbc.ValueMember = "GOODSLEVELID";
  2178. dgcbc.DataSource = dv.ToTable();
  2179. }
  2180. }
  2181. }
  2182. }
  2183. if (!this.btnSave.Visible)
  2184. {
  2185. this.tsbtnAdd.Enabled = false;
  2186. this.tsbtnEdit.Enabled = false;
  2187. }
  2188. }
  2189. catch (Exception ex)
  2190. {
  2191. throw ex;
  2192. }
  2193. }
  2194. /// <summary>
  2195. /// 绑定到第一个DataGriwView数据源
  2196. /// </summary>
  2197. private void BindProductionDataReFine(DataSet dsCheckBarcode)
  2198. {
  2199. try
  2200. {
  2201. DataRow[] dr = TableProductionData.Select("BarCode='" + this.txtBarCode.Text.Trim() + "'");
  2202. if (dr.Length > Constant.INT_IS_ZERO)
  2203. {
  2204. // 不允许重复添加
  2205. return;
  2206. }
  2207. int SpecialRepairflag = (int)DoAsync(new BaseAsyncMethod(() =>
  2208. {
  2209. return PMModuleProxy.Service.GetSpecialRepairflagByBarcode(this.txtBarCode.Text.Trim());
  2210. }));
  2211. string KilnCarCode = string.Empty;
  2212. string KilnCode = string.Empty;
  2213. string Dictionaryvalue = string.Empty;
  2214. DataSet dsKilnCar = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2215. {
  2216. return PMModuleProxy.Service.GetKilnCarByBarCode(txtBarCode.Text.Trim());
  2217. }));
  2218. if (dsKilnCar != null && dsKilnCar.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  2219. {
  2220. KilnCarCode = dsKilnCar.Tables[0].Rows[0]["KilnCarCode"].ToString();
  2221. KilnCode = dsKilnCar.Tables[0].Rows[0]["KilnCode"].ToString();
  2222. Dictionaryvalue = dsKilnCar.Tables[0].Rows[0]["Dictionaryvalue"].ToString();
  2223. }
  2224. DataRow drNew = TableProductionData.NewRow();
  2225. drNew["BarCode"] = this.txtBarCode.Text.Trim();
  2226. drNew["ProductionDataID"] = this._productiondataid;
  2227. drNew["GoodsID"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsID.ToString()];
  2228. drNew["GoodsCode"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsCode.ToString()];
  2229. drNew["GoodsName"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsName.ToString()];
  2230. drNew["DefectFlagID"] = _dsGoodsLevel.Tables[0].Rows[0]["DefectFlagID"];
  2231. drNew["ReworkProcedureID"] = DBNull.Value;
  2232. drNew["Remarks"] = "";
  2233. drNew["UserID"] = UserID;
  2234. drNew["UserCode"] = UserCode;
  2235. drNew["UserName"] = UserName;
  2236. drNew["GoodsLevelTypeID"] = _dsGoodsLevel.Tables[0].Rows[0]["GoodsLevelTypeID"];
  2237. drNew["OrgGoodsLevelTypeID"] = -1;
  2238. drNew["SpecialRepairflag"] = SpecialRepairflag == 1 ? 1 : 0;
  2239. drNew["KilnCarCode"] = KilnCarCode;
  2240. drNew["KilnCode"] = KilnCode;
  2241. drNew["Dictionaryvalue"] = Dictionaryvalue;
  2242. // 校验条码是否重烧过
  2243. DataSet dsReFine = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2244. {
  2245. return PMModuleProxy.Service.GetReFine(this.txtBarCode.Text.Trim());
  2246. }));
  2247. if (dsReFine != null && dsReFine.Tables[0].Rows.Count > 0 && dsReFine.Tables[0].Rows[0]["IsReFire"].ToString() == "6")
  2248. {
  2249. drNew["ReFine"] = 1;
  2250. }
  2251. else
  2252. {
  2253. drNew["ReFine"] = 0;
  2254. }
  2255. drNew["UserCode"] = this.txtUserCode.Text.Trim();
  2256. // 由产品条码获取注浆信息
  2257. DataSet dsGroutingProduct = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2258. {
  2259. return PMModuleProxy.Service.GetGroutingProducttByBarCode(txtBarCode.Text.Trim());
  2260. }));
  2261. drNew["MouldCode"] = dsGroutingProduct.Tables[0].Rows[0]["MouldCode"];
  2262. drNew["GroutingUserCode"] = dsGroutingProduct.Tables[0].Rows[0]["GroutingUserCode"];
  2263. drNew["GroutingNum"] = dsGroutingProduct.Tables[0].Rows[0]["GroutingNum"];
  2264. drNew["IsPublicBody"] = dsGroutingProduct.Tables[0].Rows[0]["IsPublicBody"].ToString() != "1" ? 0 : 1;
  2265. drNew["GroutingDate"] = Convert.ToDateTime(dsGroutingProduct.Tables[0].Rows[0]["GroutingDate"]);
  2266. drNew["LogoCodeName"] = dsGroutingProduct.Tables[0].Rows[0]["LogoName"] + "[" + dsGroutingProduct.Tables[0].Rows[0]["LogoCode"] + "]";
  2267. drNew["LogoID"] = dsGroutingProduct.Tables[0].Rows[0]["LogoID"];
  2268. TableProductionData.Rows.Add(drNew);
  2269. if (DSTable.Tables.IndexOf(this.txtBarCode.Text.Trim()) == -Constant.INT_IS_ONE)
  2270. {
  2271. DataTable dtProductionDefectData = new DataTable(this.txtBarCode.Text.Trim());
  2272. dtProductionDefectData.Columns.Add("BarCode");
  2273. dtProductionDefectData.Columns.Add("DefectID", typeof(decimal));
  2274. dtProductionDefectData.Columns.Add("DefectName");
  2275. dtProductionDefectData.Columns.Add("DefectCode");
  2276. dtProductionDefectData.Columns.Add("DefectPositionID", typeof(decimal));
  2277. dtProductionDefectData.Columns.Add("DefectPositionName");
  2278. dtProductionDefectData.Columns.Add("DefectPositionCode");
  2279. dtProductionDefectData.Columns.Add("DefectProcedureID", typeof(decimal));
  2280. dtProductionDefectData.Columns.Add("DefectProcedureName");
  2281. dtProductionDefectData.Columns.Add("DefectProcedureCode");
  2282. dtProductionDefectData.Columns.Add("DefectUserID", typeof(decimal));//责任员工
  2283. dtProductionDefectData.Columns.Add("DefectUserName");//责任员工
  2284. dtProductionDefectData.Columns.Add("DefectUserCode");//
  2285. dtProductionDefectData.Columns.Add("Jobs", typeof(decimal));//工种
  2286. dtProductionDefectData.Columns.Add("JobsText");//工种
  2287. dtProductionDefectData.Columns.Add("DefectRemarks");
  2288. dtProductionDefectData.Columns.Add("TempCount");
  2289. dtProductionDefectData.Columns.Add("ProductionDataID"); //生产数据ID
  2290. dtProductionDefectData.Columns.Add("DefectFineID"); //缺席扣罚ID
  2291. dtProductionDefectData.Columns.Add("DefectFineValue"); //缺席扣罚
  2292. dtProductionDefectData.Columns.Add("MissedUserID"); //漏检工号ID
  2293. dtProductionDefectData.Columns.Add("MissedUserCode"); //漏检工号编码
  2294. dtProductionDefectData.Columns.Add("MissedUserName"); //漏检工号名称
  2295. dtProductionDefectData.Columns.Add("IsAllowEdit"); //漏检工号名称
  2296. //新添加的 wangx 2016/1/6
  2297. dtProductionDefectData.Columns.Add("DefectDeductionID"); //缺陷扣除数ID
  2298. dtProductionDefectData.Columns.Add("DefectDeductionNum"); //缺陷扣除数
  2299. dtProductionDefectData.Columns.Add("IsOtherDefect"); //特殊缺陷
  2300. dtProductionDefectData.Columns.Add("CheckTime"); //缺陷检验时间
  2301. DSTable.Tables.Add(dtProductionDefectData);
  2302. }
  2303. this.dgvDefect.DataSource = DSTable.Tables[this.txtBarCode.Text.Trim()];//根据条码产生不同数据源
  2304. this.dgvProductionData.Rows[TableProductionData.Rows.Count - 1].Selected = true;
  2305. this.dgvDefect.DataSource = null;
  2306. this.dgvDefectStaff.DataSource = null;
  2307. this.lvPic.Clear();
  2308. // 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
  2309. this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
  2310. // 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
  2311. this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
  2312. // 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
  2313. this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
  2314. this._selectedRowIndex = TableProductionData.Rows.Count - 1;
  2315. //DataSet ds = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2316. //{
  2317. // return PMModuleProxy.Service.GetReworkProcedureByProcedureID(this._procedureID);
  2318. //}));
  2319. //ds.Tables[0].TableName = this.txtBarCode.Text.Trim();
  2320. //if (this.DSREWORK == null)
  2321. //{
  2322. // this.DSREWORK = new DataSet();
  2323. //}
  2324. //this.DSREWORK.Tables.Add(ds.Tables[0].Copy());
  2325. //// 返工工序数据源
  2326. //C_DGV_Cell_ListBoxComboBox C_DGV_Cell_ListBoxComboBox = dgvProductionData.Rows[_selectedRowIndex].Cells[4] as C_DGV_Cell_ListBoxComboBox;
  2327. //C_DGV_Cell_ListBoxComboBox.DataSource = ds.Tables[0];
  2328. //C_DGV_Cell_ListBoxComboBox.DisplayMember = "ReworkProcedureName";
  2329. //C_DGV_Cell_ListBoxComboBox.ValueMember = "ReworkProcedureID";
  2330. }
  2331. catch (Exception ex)
  2332. {
  2333. throw ex;
  2334. }
  2335. }
  2336. /// <summary>
  2337. /// 绑定到第一个DataGriwView数据源
  2338. /// </summary>
  2339. private void BindProductionDataEdit(DataSet dsCheckBarcode)
  2340. {
  2341. try
  2342. {
  2343. DataRow[] dr = TableProductionData.Select("BarCode='" + this.txtBarCode.Text.Trim() + "'");
  2344. if (dr.Length > Constant.INT_IS_ZERO)
  2345. {
  2346. // 不允许重复添加
  2347. return;
  2348. }
  2349. int SpecialRepairflag = (int)DoAsync(new BaseAsyncMethod(() =>
  2350. {
  2351. return PMModuleProxy.Service.GetSpecialRepairflagByBarcode(this.txtBarCode.Text.Trim());
  2352. }));
  2353. string KilnCarCode = string.Empty;
  2354. string KilnCode = string.Empty;
  2355. string Dictionaryvalue = string.Empty;
  2356. DataSet dsKilnCar = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2357. {
  2358. return PMModuleProxy.Service.GetKilnCarByBarCode(txtBarCode.Text.Trim());
  2359. }));
  2360. if (dsKilnCar != null && dsKilnCar.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  2361. {
  2362. KilnCarCode = dsKilnCar.Tables[0].Rows[0]["KilnCarCode"].ToString();
  2363. KilnCode = dsKilnCar.Tables[0].Rows[0]["KilnCode"].ToString();
  2364. Dictionaryvalue = dsKilnCar.Tables[0].Rows[0]["Dictionaryvalue"].ToString();
  2365. }
  2366. DataRow drNew = TableProductionData.NewRow();
  2367. drNew["ProductionDataID"] = this._productiondataid;
  2368. drNew["BarCode"] = this.txtBarCode.Text.Trim();
  2369. DataSet ds = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2370. {
  2371. return PMModuleProxy.Service.GetGoodsInfoBybarcode(this.txtBarCode.Text.Trim());
  2372. }));
  2373. if (ds != null && ds.Tables[0].Rows.Count > 0)
  2374. {
  2375. drNew["GoodsID"] = ds.Tables[0].Rows[0]["GoodsID"];
  2376. drNew["GoodsCode"] = ds.Tables[0].Rows[0]["GoodsCode"];
  2377. drNew["GoodsName"] = ds.Tables[0].Rows[0]["GoodsName"];
  2378. }
  2379. drNew["DefectFlagID"] = _dsGoodsLevel.Tables[0].Rows[0]["DefectFlagID"];
  2380. drNew["ReworkProcedureID"] = DBNull.Value;
  2381. drNew["Remarks"] = "";
  2382. drNew["UserID"] = UserID;
  2383. drNew["UserCode"] = UserCode;
  2384. drNew["UserName"] = UserName;
  2385. drNew["GoodsLevelTypeID"] = _dsGoodsLevel.Tables[0].Rows[0]["GoodsLevelTypeID"];
  2386. drNew["OrgGoodsLevelTypeID"] = -1;
  2387. drNew["SpecialRepairflag"] = SpecialRepairflag == 1 ? 1 : 0;
  2388. drNew["KilnCarCode"] = KilnCarCode;
  2389. drNew["KilnCode"] = KilnCode;
  2390. drNew["Dictionaryvalue"] = Dictionaryvalue;
  2391. // 校验条码是否重烧过
  2392. DataSet dsReFine = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2393. {
  2394. return PMModuleProxy.Service.GetReFine(this.txtBarCode.Text.Trim());
  2395. }));
  2396. if (dsReFine != null && dsReFine.Tables[0].Rows.Count > 0 && dsReFine.Tables[0].Rows[0]["IsReFire"].ToString() == "6")
  2397. {
  2398. drNew["ReFine"] = 1;
  2399. }
  2400. else
  2401. {
  2402. drNew["ReFine"] = 0;
  2403. }
  2404. drNew["UserCode"] = this.txtUserCode.Text.Trim();
  2405. // 由产品条码获取注浆信息
  2406. DataSet dsGroutingProduct = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2407. {
  2408. return PMModuleProxy.Service.GetGroutingProducttByBarCode(txtBarCode.Text.Trim());
  2409. }));
  2410. drNew["MouldCode"] = dsGroutingProduct.Tables[0].Rows[0]["MouldCode"];
  2411. drNew["GroutingUserCode"] = dsGroutingProduct.Tables[0].Rows[0]["GroutingUserCode"];
  2412. drNew["GroutingNum"] = dsGroutingProduct.Tables[0].Rows[0]["GroutingNum"];
  2413. drNew["IsPublicBody"] = dsGroutingProduct.Tables[0].Rows[0]["IsPublicBody"].ToString() != "1" ? 0 : 1;
  2414. drNew["GroutingDate"] = Convert.ToDateTime(dsGroutingProduct.Tables[0].Rows[0]["GroutingDate"]);
  2415. drNew["LogoCodeName"] = dsGroutingProduct.Tables[0].Rows[0]["LogoName"] + "[" + dsGroutingProduct.Tables[0].Rows[0]["LogoCode"] + "]";
  2416. drNew["LogoId"] = dsGroutingProduct.Tables[0].Rows[0]["LogoId"];
  2417. TableProductionData.Rows.Add(drNew);
  2418. if (DSTable.Tables.IndexOf(this.txtBarCode.Text.Trim()) == -Constant.INT_IS_ONE)
  2419. {
  2420. DataTable dtProductionDefectData = new DataTable(this.txtBarCode.Text.Trim());
  2421. dtProductionDefectData.Columns.Add("BarCode");
  2422. dtProductionDefectData.Columns.Add("DefectID", typeof(decimal));
  2423. dtProductionDefectData.Columns.Add("DefectName");
  2424. dtProductionDefectData.Columns.Add("DefectCode");
  2425. dtProductionDefectData.Columns.Add("DefectPositionID", typeof(decimal));
  2426. dtProductionDefectData.Columns.Add("DefectPositionName");
  2427. dtProductionDefectData.Columns.Add("DefectPositionCode");
  2428. dtProductionDefectData.Columns.Add("DefectProcedureID", typeof(decimal));
  2429. dtProductionDefectData.Columns.Add("DefectProcedureName");
  2430. dtProductionDefectData.Columns.Add("DefectProcedureCode");
  2431. dtProductionDefectData.Columns.Add("DefectUserID", typeof(decimal));//责任员工
  2432. dtProductionDefectData.Columns.Add("DefectUserName");//责任员工
  2433. dtProductionDefectData.Columns.Add("DefectUserCode");//
  2434. dtProductionDefectData.Columns.Add("Jobs", typeof(decimal));//工种
  2435. dtProductionDefectData.Columns.Add("JobsText");//工种
  2436. dtProductionDefectData.Columns.Add("DefectRemarks");
  2437. dtProductionDefectData.Columns.Add("TempCount");
  2438. dtProductionDefectData.Columns.Add("ProductionDataID"); //生产数据ID
  2439. dtProductionDefectData.Columns.Add("DefectFineID"); //缺席扣罚ID
  2440. dtProductionDefectData.Columns.Add("DefectFineValue"); //缺席扣罚
  2441. dtProductionDefectData.Columns.Add("MissedUserID"); //漏检工号ID
  2442. dtProductionDefectData.Columns.Add("MissedUserCode"); //漏检工号编码
  2443. dtProductionDefectData.Columns.Add("MissedUserName"); //漏检工号名称
  2444. dtProductionDefectData.Columns.Add("IsAllowEdit"); //允许编辑
  2445. //新添加的 wangx 2016/1/6
  2446. dtProductionDefectData.Columns.Add("DefectDeductionID"); //缺陷扣除数ID
  2447. dtProductionDefectData.Columns.Add("DefectDeductionNum"); //缺陷扣除数
  2448. dtProductionDefectData.Columns.Add("IsOtherDefect"); //特殊缺陷
  2449. dtProductionDefectData.Columns.Add("CheckTime"); //缺陷检验时间
  2450. DSTable.Tables.Add(dtProductionDefectData);
  2451. }
  2452. this.dgvDefect.DataSource = DSTable.Tables[this.txtBarCode.Text.Trim()];//根据条码产生不同数据源
  2453. this.dgvProductionData.Rows[TableProductionData.Rows.Count - 1].Selected = true;
  2454. this.dgvDefect.DataSource = null;
  2455. this.dgvDefectStaff.DataSource = null;
  2456. this.lvPic.Clear();
  2457. // 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
  2458. this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
  2459. // 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
  2460. this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
  2461. // 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
  2462. this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
  2463. this._selectedRowIndex = TableProductionData.Rows.Count - 1;
  2464. }
  2465. catch (Exception ex)
  2466. {
  2467. throw ex;
  2468. }
  2469. }
  2470. /// <summary>
  2471. /// 绑定到第一个DataGriwView数据源
  2472. /// </summary>
  2473. private void BindProductionData(DataSet dsCheckBarcode)
  2474. {
  2475. try
  2476. {
  2477. DataRow[] dr = TableProductionData.Select("BarCode='" + this.txtBarCode.Text.Trim() + "'");
  2478. if (dr.Length > Constant.INT_IS_ZERO)
  2479. {
  2480. // 不允许重复添加
  2481. return;
  2482. }
  2483. int SpecialRepairflag = 0;
  2484. if (dsCheckBarcode == null || dsCheckBarcode.Tables[0].Rows.Count == 0)
  2485. {
  2486. SpecialRepairflag = (int)DoAsync(new BaseAsyncMethod(() =>
  2487. {
  2488. return PMModuleProxy.Service.GetSpecialRepairflagByBarcode(this.txtBarCode.Text.Trim());
  2489. }));
  2490. }
  2491. else
  2492. {
  2493. SpecialRepairflag = Convert.ToInt32(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_specialRepairFlag.ToString()]);
  2494. }
  2495. string KilnCarCode = string.Empty;
  2496. string KilnCode = string.Empty;
  2497. string Dictionaryvalue = string.Empty;
  2498. DataSet dsKilnCar = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2499. {
  2500. return PMModuleProxy.Service.GetKilnCarByBarCode(txtBarCode.Text.Trim());
  2501. }));
  2502. if (dsKilnCar != null && dsKilnCar.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  2503. {
  2504. KilnCarCode = dsKilnCar.Tables[0].Rows[0]["KilnCarCode"].ToString();
  2505. KilnCode = dsKilnCar.Tables[0].Rows[0]["KilnCode"].ToString();
  2506. Dictionaryvalue = dsKilnCar.Tables[0].Rows[0]["Dictionaryvalue"].ToString();
  2507. }
  2508. DataRow drNew = TableProductionData.NewRow();
  2509. drNew["BarCode"] = this.txtBarCode.Text.Trim();
  2510. if (dsCheckBarcode != null)
  2511. {
  2512. drNew["GoodsID"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsID.ToString()];
  2513. drNew["GoodsCode"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsCode.ToString()];
  2514. drNew["GoodsName"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsName.ToString()];
  2515. }
  2516. else
  2517. {
  2518. DataSet ds = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2519. {
  2520. return PMModuleProxy.Service.GetGoodsInfoBybarcode(this.txtBarCode.Text.Trim());
  2521. }));
  2522. if (ds != null && ds.Tables[0].Rows.Count > 0)
  2523. {
  2524. drNew["GoodsID"] = ds.Tables[0].Rows[0]["GoodsID"];
  2525. drNew["GoodsCode"] = ds.Tables[0].Rows[0]["GoodsCode"];
  2526. drNew["GoodsName"] = ds.Tables[0].Rows[0]["GoodsName"];
  2527. }
  2528. }
  2529. drNew["UserID"] = UserID;
  2530. drNew["KilnCarCode"] = KilnCarCode;
  2531. drNew["KilnCode"] = KilnCode;
  2532. drNew["Dictionaryvalue"] = Dictionaryvalue;
  2533. //xuwei modify 2019-12-12
  2534. //drNew["DefectFlagID"] = _dsGoodsLevel.Tables[0].Rows[0]["DefectFlagID"];
  2535. drNew["DefectFlagID"] = _dsGoodsLevel.Tables[0].Rows[0]["GOODSLEVELID"];
  2536. drNew["ReworkProcedureID"] = DBNull.Value;
  2537. drNew["Remarks"] = "";
  2538. drNew["UserID"] = UserID;
  2539. drNew["UserCode"] = UserCode;
  2540. drNew["UserName"] = UserName;
  2541. drNew["GoodsLevelTypeID"] = _dsGoodsLevel.Tables[0].Rows[0]["GoodsLevelTypeID"];
  2542. drNew["OrgGoodsLevelTypeID"] = -1;
  2543. drNew["SpecialRepairflag"] = SpecialRepairflag == 1 ? 1 : 0;
  2544. drNew["LogoCodeName"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoName.ToString()]
  2545. + "[" + dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoCode.ToString()] + "]";
  2546. drNew["LogoID"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoID.ToString()];
  2547. // 校验条码是否重烧过
  2548. DataSet dsReFine = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2549. {
  2550. return PMModuleProxy.Service.GetReFine(this.txtBarCode.Text.Trim());
  2551. }));
  2552. if (dsReFine != null && dsReFine.Tables[0].Rows.Count > 0 && dsReFine.Tables[0].Rows[0]["IsReFire"].ToString() == "6")
  2553. {
  2554. drNew["ReFine"] = 1;
  2555. }
  2556. else
  2557. {
  2558. drNew["ReFine"] = 0;
  2559. }
  2560. if (dsCheckBarcode == null || dsCheckBarcode.Tables[0].Rows.Count == 0)
  2561. {
  2562. // 由产品条码获取注浆信息
  2563. DataSet dsGroutingProduct = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2564. {
  2565. return PMModuleProxy.Service.GetGroutingProducttByBarCode(txtBarCode.Text.Trim());
  2566. }));
  2567. drNew["UserCode"] = this.txtUserCode.Text.Trim();
  2568. drNew["MouldCode"] = dsGroutingProduct.Tables[0].Rows[0]["MouldCode"];
  2569. drNew["GroutingUserCode"] = dsGroutingProduct.Tables[0].Rows[0]["GroutingUserCode"];
  2570. drNew["GroutingNum"] = dsGroutingProduct.Tables[0].Rows[0]["GroutingNum"];
  2571. drNew["IsPublicBody"] = dsGroutingProduct.Tables[0].Rows[0]["IsPublicBody"].ToString() != "1" ? 0 : 1;
  2572. drNew["GroutingDate"] = Convert.ToDateTime(dsGroutingProduct.Tables[0].Rows[0]["GroutingDate"]);
  2573. }
  2574. else
  2575. {
  2576. drNew["UserCode"] = this.txtUserCode.Text.Trim();
  2577. drNew["MouldCode"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_mouldCode.ToString()];
  2578. drNew["GroutingUserCode"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()];
  2579. drNew["GroutingNum"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingNum.ToString()];
  2580. drNew["IsPublicBody"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_ispublicbody.ToString()].ToString() != "1" ? 0 : 1;
  2581. drNew["GroutingDate"] = Convert.ToDateTime(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingdate.ToString()]);
  2582. }
  2583. TableProductionData.Rows.Add(drNew);
  2584. if (DSTable.Tables.IndexOf(this.txtBarCode.Text.Trim()) == -Constant.INT_IS_ONE)
  2585. {
  2586. DataTable dtProductionDefectData = new DataTable(this.txtBarCode.Text.Trim());
  2587. dtProductionDefectData.Columns.Add("BarCode");
  2588. dtProductionDefectData.Columns.Add("DefectID", typeof(decimal));
  2589. dtProductionDefectData.Columns.Add("DefectName");
  2590. dtProductionDefectData.Columns.Add("DefectCode");
  2591. dtProductionDefectData.Columns.Add("DefectPositionID", typeof(decimal));
  2592. dtProductionDefectData.Columns.Add("DefectPositionName");
  2593. dtProductionDefectData.Columns.Add("DefectPositionCode");
  2594. dtProductionDefectData.Columns.Add("DefectProcedureID", typeof(decimal));
  2595. dtProductionDefectData.Columns.Add("DefectProcedureName");
  2596. dtProductionDefectData.Columns.Add("DefectProcedureCode");
  2597. dtProductionDefectData.Columns.Add("DefectUserID", typeof(decimal));//责任员工
  2598. dtProductionDefectData.Columns.Add("DefectUserName");//责任员工
  2599. dtProductionDefectData.Columns.Add("DefectUserCode");//
  2600. dtProductionDefectData.Columns.Add("Jobs", typeof(decimal));//工种
  2601. dtProductionDefectData.Columns.Add("JobsText");//工种
  2602. dtProductionDefectData.Columns.Add("DefectRemarks");
  2603. dtProductionDefectData.Columns.Add("TempCount");
  2604. dtProductionDefectData.Columns.Add("ProductionDataID"); //生产数据ID
  2605. dtProductionDefectData.Columns.Add("DefectFineID"); //缺席扣罚ID
  2606. dtProductionDefectData.Columns.Add("DefectFineValue"); //缺席扣罚
  2607. dtProductionDefectData.Columns.Add("MissedUserID"); //漏检工号ID
  2608. dtProductionDefectData.Columns.Add("MissedUserCode"); //漏检工号编码
  2609. dtProductionDefectData.Columns.Add("MissedUserName"); //漏检工号名称
  2610. dtProductionDefectData.Columns.Add("IsAllowEdit"); //允许编辑
  2611. //新添加的 wangx 2016/1/6
  2612. dtProductionDefectData.Columns.Add("DefectDeductionID"); //缺陷扣除数ID
  2613. dtProductionDefectData.Columns.Add("DefectDeductionNum"); //缺陷扣除数
  2614. dtProductionDefectData.Columns.Add("IsOtherDefect"); //特殊缺陷
  2615. dtProductionDefectData.Columns.Add("CheckTime"); //缺陷检验时间
  2616. DSTable.Tables.Add(dtProductionDefectData);
  2617. }
  2618. this.dgvDefect.DataSource = DSTable.Tables[this.txtBarCode.Text.Trim()];//根据条码产生不同数据源
  2619. this.dgvProductionData.Rows[TableProductionData.Rows.Count - 1].Selected = true;
  2620. this.dgvDefect.DataSource = null;
  2621. this.dgvDefectStaff.DataSource = null;
  2622. this.lvPic.Clear();
  2623. // 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
  2624. this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
  2625. // 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
  2626. this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
  2627. // 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
  2628. this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
  2629. this._selectedRowIndex = TableProductionData.Rows.Count - 1;
  2630. //DataTable dt = this._dsGoodsLevel.Tables[0];
  2631. //DataView dv = dt.DefaultView;
  2632. //dv.RowFilter = "GoodsLevelTypeID>=" + goodsLevelTypeID;
  2633. //DataSet ds = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2634. //{
  2635. // return PMModuleProxy.Service.GetReworkProcedureByProcedureID(this._procedureID);
  2636. //}));
  2637. //ds.Tables[0].TableName = this.txtBarCode.Text.Trim();
  2638. //if (this.DSREWORK == null)
  2639. //{
  2640. // this.DSREWORK = new DataSet();
  2641. //}
  2642. //this.DSREWORK.Tables.Add(ds.Tables[0].Copy());
  2643. //// 返工工序数据源
  2644. //C_DGV_Cell_ListBoxComboBox C_DGV_Cell_ListBoxComboBox = dgvProductionData.Rows[_selectedRowIndex].Cells[4] as C_DGV_Cell_ListBoxComboBox;
  2645. //C_DGV_Cell_ListBoxComboBox.DataSource = ds.Tables[0];
  2646. //C_DGV_Cell_ListBoxComboBox.DisplayMember = "ReworkProcedureName";
  2647. //C_DGV_Cell_ListBoxComboBox.ValueMember = "ReworkProcedureID";
  2648. }
  2649. catch (Exception ex)
  2650. {
  2651. throw ex;
  2652. }
  2653. }
  2654. /// <summary>
  2655. /// 通过是否有缺陷来启用或禁用
  2656. /// </summary>
  2657. /// <param name="DefectFlag"></param>
  2658. private void SetGridView(int GoodsLevelID)
  2659. {
  2660. DataTable dtDefectFlag = this.DefectFlag.DataSource as DataTable;//获取缺陷数据源
  2661. int GoodsLevelTypeID = -1;
  2662. //xuwei modify 2019-12-12
  2663. //DataRow[] dr = dtDefectFlag.Select("DefectFlagID=" + GoodsLevelID);
  2664. DataRow[] dr = dtDefectFlag.Select("GoodsLevelID=" + GoodsLevelID);
  2665. if (dr.Length > Constant.INT_IS_ZERO)
  2666. {
  2667. GoodsLevelTypeID = Convert.ToInt32(dr[0]["GoodsLevelTypeID"]);
  2668. this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["GoodsLevelTypeID"].Value = GoodsLevelTypeID;
  2669. }
  2670. if (GoodsLevelTypeID != -Constant.INT_IS_ONE)
  2671. {
  2672. this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureID"].Value = DBNull.Value;
  2673. this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureCode"].Value = string.Empty;
  2674. this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureName"].Value = string.Empty;
  2675. if (GoodsLevelTypeID == (int)Constant.GoodsLevelType.Quality) //正品
  2676. {
  2677. this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureID"].ReadOnly = true;
  2678. try
  2679. {
  2680. string BarCode = this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["BarCode"].Value.ToString();
  2681. if (DSTable.Tables.Contains(BarCode))
  2682. {
  2683. DSTable.Tables[BarCode].Rows.Clear();//清空行
  2684. }
  2685. this.dgvDefectStaff.DataSource = null;
  2686. this.lvPic.Clear();
  2687. }
  2688. catch (Exception ex)
  2689. {
  2690. throw ex;
  2691. }
  2692. }
  2693. else if (GoodsLevelTypeID == (int)Constant.GoodsLevelType.Quality) //次品 或者正品
  2694. {
  2695. this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureID"].ReadOnly = true;
  2696. }
  2697. else if (GoodsLevelTypeID == (int)Constant.GoodsLevelType.ReFire)//重烧
  2698. {
  2699. this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureID"].ReadOnly = false;
  2700. }
  2701. else if (GoodsLevelTypeID == (int)Constant.GoodsLevelType.Substandard)//重烧
  2702. {
  2703. // this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["GoodsLevelTypeID"].Value = GoodsLevelTypeID;
  2704. this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureID"].ReadOnly = false;
  2705. }
  2706. }
  2707. }
  2708. /// <summary>
  2709. /// 清空以前所选中的缺陷
  2710. /// </summary>
  2711. /// <param name="checkValue"></param>
  2712. private void SetCheckBoxSelected(int checkValue, int rowIndex)
  2713. {
  2714. DataTable dtOrgDataSource = this.dgvDefect.DataSource as DataTable;
  2715. for (int i = 0; i < DSTable.Tables[dtOrgDataSource.TableName].Rows.Count; i++)
  2716. {
  2717. if (i == rowIndex)
  2718. {
  2719. dtOrgDataSource.Rows[i]["discarde"] = 1;
  2720. }
  2721. else
  2722. {
  2723. dtOrgDataSource.Rows[i]["discarde"] = 0;
  2724. }
  2725. }
  2726. }
  2727. /// <summary>
  2728. /// 绑定并显示图片
  2729. /// </summary>
  2730. /// <param name="ImageData"></param>
  2731. public void BindByteImage(DataTable ImageData)
  2732. {
  2733. this._smallByte.Clear();
  2734. foreach (DataRow dr in ImageData.Rows)
  2735. {
  2736. //将数据库中的缩略图取出
  2737. this._smallByte.Add((byte[])dr[1]);
  2738. }
  2739. //绑定缩略图
  2740. BindImg();
  2741. }
  2742. /// <summary>
  2743. /// 将图片文件转换成二进制
  2744. /// </summary>
  2745. /// <param name="img"></param>
  2746. /// <returns></returns>
  2747. public static byte[] ImageToByte(Image img)
  2748. {
  2749. byte[] smallbuffer = null;
  2750. using (MemoryStream ms = new MemoryStream())
  2751. {
  2752. img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
  2753. ms.Position = Constant.INT_IS_ZERO;
  2754. smallbuffer = new byte[ms.Length];
  2755. ms.Read(smallbuffer, Constant.INT_IS_ZERO, Convert.ToInt32(ms.Length));
  2756. ms.Flush();
  2757. }
  2758. return smallbuffer;
  2759. }
  2760. /// <SUMMARY>
  2761. /// 重绘缩略图并把缩略图转为二进制储存
  2762. /// </SUMMARY>
  2763. /// <PARAM name="sourceFile">图片源路径</PARAM>
  2764. /// <PARAM name="destHeight">缩放后图片高度</PARAM>
  2765. /// <PARAM name="destWidth">缩放后图片宽度</PARAM>
  2766. /// <RETURNS></RETURNS>
  2767. public void GetThumbnail(FileInfo sourceFile, byte[] orgImageByte)
  2768. {
  2769. Image imgSource = Image.FromStream(sourceFile.OpenRead());
  2770. ImageFormat thisFormat = imgSource.RawFormat;
  2771. int sW = 0, sH = 0;
  2772. // 按比例缩放
  2773. int sWidth = imgSource.Width;
  2774. int sHeight = imgSource.Height;
  2775. int destWidth = 100;
  2776. int destHeight = getSmallImageHeight(sWidth, sHeight, destWidth);
  2777. if (sHeight > destHeight || sWidth > destWidth)
  2778. {
  2779. if ((sWidth * destHeight) > (sHeight * destWidth))
  2780. {
  2781. sW = destWidth;
  2782. sH = (destWidth * sHeight) / sWidth;
  2783. }
  2784. else
  2785. {
  2786. sH = destHeight;
  2787. sW = (sWidth * destHeight) / sHeight;
  2788. }
  2789. }
  2790. else
  2791. {
  2792. sW = sWidth;
  2793. sH = sHeight;
  2794. }
  2795. Bitmap outBmp = new Bitmap(destWidth, destHeight);
  2796. Graphics g = Graphics.FromImage(outBmp);
  2797. g.Clear(Color.Black);
  2798. // 设置画布的描绘质量
  2799. g.CompositingQuality = CompositingQuality.HighQuality;
  2800. g.SmoothingMode = SmoothingMode.HighQuality;
  2801. g.InterpolationMode = InterpolationMode.HighQualityBicubic;
  2802. g.DrawImage(imgSource, new Rectangle((destWidth - sW) / 2, (destHeight - sH) / 2, sW, sH), 0, 0, imgSource.Width, imgSource.Height, GraphicsUnit.Pixel);
  2803. g.Dispose();
  2804. //将重绘的图片转为二进制并保存
  2805. Image image = (Image)outBmp;
  2806. byte[] smallbuffer = ImageToByte(image);
  2807. if (this._currentTempSign != string.Empty)
  2808. {
  2809. if (!this.DSTableImage.Tables.Contains(string.Format("TempTable{0}", this._currentTempSign.ToString())))
  2810. {
  2811. DataTable dtImage = new DataTable(string.Format("TempTable{0}", this._currentTempSign.ToString()));
  2812. dtImage.Columns.Add("StaffTempCount");
  2813. dtImage.Columns.Add("ImageByte", typeof(byte[]));
  2814. dtImage.Columns.Add("OrgImageByte", typeof(byte[]));
  2815. this.DSTableImage.Tables.Add(dtImage);
  2816. }
  2817. DataRow dr = DSTableImage.Tables[string.Format("TempTable{0}", this._currentTempSign)].NewRow();
  2818. dr["StaffTempCount"] = this._currentTempSign;
  2819. dr["ImageByte"] = smallbuffer;
  2820. dr["OrgImageByte"] = orgImageByte;
  2821. DSTableImage.Tables[string.Format("TempTable{0}", this._currentTempSign)].Rows.Add(dr);
  2822. }
  2823. this._smallByte.Add(smallbuffer);
  2824. imgSource.Dispose();
  2825. outBmp.Dispose();
  2826. }
  2827. /// <summary>
  2828. /// 根据原图片宽高比获取缩略图的高(根据宽)
  2829. /// </summary>
  2830. /// <param name="BigWidth"></param>
  2831. /// <param name="BigHeight"></param>
  2832. /// <param name="SmallWidth"></param>
  2833. /// <returns></returns>
  2834. protected int getSmallImageHeight(int BigWidth, int BigHeight, int SmallWidth)
  2835. {
  2836. decimal scale = Convert.ToDecimal(BigWidth) / Convert.ToDecimal(BigHeight);
  2837. return Convert.ToInt32(SmallWidth / scale);
  2838. }
  2839. /// <summary>
  2840. /// 绑定缩略图到控件中
  2841. /// </summary>
  2842. protected void BindImg()
  2843. {
  2844. ImageList ilPic = new ImageList();
  2845. //每次绑定要清空数据源
  2846. ilPic.Images.Clear();
  2847. //将缩略图二进制集合中的数据转换成图片文件
  2848. List<Image> LSImageList = new List<Image>();
  2849. foreach (byte[] smallby in _smallByte)
  2850. {
  2851. LSImageList.Add(byteArrayToImage(smallby));
  2852. }
  2853. //添加数据源
  2854. foreach (Image img in LSImageList)
  2855. {
  2856. ilPic.Images.Add(img);
  2857. }
  2858. ilPic.ImageSize = new Size(100, 100);
  2859. this.lvPic.LargeImageList = ilPic;
  2860. this.lvPic.BeginUpdate();
  2861. //清空列表的数据源
  2862. lvPic.Items.Clear();
  2863. //添加列表的数据源
  2864. for (int i = 0; i < ilPic.Images.Count; i++)
  2865. {
  2866. ListViewItem lvi = new ListViewItem();
  2867. lvi.ImageIndex = i;
  2868. this.lvPic.Items.Add(lvi);
  2869. }
  2870. this.lvPic.EndUpdate();
  2871. }
  2872. /// <summary>
  2873. /// 将数据库中的二进制转换成图片
  2874. /// </summary>
  2875. /// <param name="data"></param>
  2876. /// <returns></returns>
  2877. public static Image byteArrayToImage(object data)
  2878. {
  2879. System.IO.MemoryStream ms = new System.IO.MemoryStream((byte[])data);
  2880. System.Drawing.Image returnImage = System.Drawing.Image.FromStream(ms);
  2881. return returnImage;
  2882. }
  2883. #endregion
  2884. /// <summary>
  2885. /// 责任员工
  2886. /// </summary>
  2887. /// <param name="sender"></param>
  2888. /// <param name="e"></param>
  2889. private void dgvDefectStaff_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
  2890. {
  2891. try
  2892. {
  2893. if (e.Row.Index != -1)
  2894. {
  2895. if (this.dgvDefect.CurrentCell != null)
  2896. {
  2897. //是新增进来,加载条码是不允许删除的,只是编辑权限才能可以删除
  2898. if (this.dgvDefect.Rows[e.Row.Index].Cells["ProductionDataID"].Value.ToString() != "" && Convert.ToInt32(this.dgvDefect.Rows[e.Row.Index].Cells["ProductionDataID"].Value) > 0 && this.dgvDefect.Rows[e.Row.Index].Cells["IsAllowEdit"].Value.ToString() == "0")
  2899. {
  2900. e.Cancel = true;
  2901. return;
  2902. }
  2903. }
  2904. }
  2905. }
  2906. catch (Exception ex)
  2907. {
  2908. throw ex;
  2909. }
  2910. }
  2911. /// <summary>
  2912. /// 漏扫责任员工
  2913. /// </summary>
  2914. /// <param name="sender"></param>
  2915. /// <param name="e"></param>
  2916. private void dgvMissStaff_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
  2917. {
  2918. try
  2919. {
  2920. if (e.Row.Index != -1)
  2921. {
  2922. if (this.dgvDefect.CurrentCell != null)
  2923. {
  2924. //是新增进来,加载条码是不允许删除的,只是编辑权限才能可以删除
  2925. if (this.dgvDefect.Rows[e.Row.Index].Cells["ProductionDataID"].Value.ToString() != "" && Convert.ToInt32(this.dgvDefect.Rows[e.Row.Index].Cells["ProductionDataID"].Value) > 0 && this.dgvDefect.Rows[e.Row.Index].Cells["IsAllowEdit"].Value.ToString() == "0")
  2926. {
  2927. e.Cancel = true;
  2928. return;
  2929. }
  2930. }
  2931. }
  2932. }
  2933. catch (Exception ex)
  2934. {
  2935. throw ex;
  2936. }
  2937. }
  2938. }
  2939. }