F_PM_3202.cs 166 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079
  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.NoDefects
  1380. &&
  1381. Convert.ToInt32(this.TableProductionData.Rows[i]["GoodsLevelTypeID"]) != 15
  1382. ) //良品 或 复检 xuwei modify 2019-12-13
  1383. {
  1384. // 不是 良品 和 复检
  1385. if (this.DSTable.Tables[productionDataEntity.Barcode].Rows.Count == Constant.INT_IS_ZERO)
  1386. {
  1387. isError = true;
  1388. ErrorCount = -2;
  1389. CurrentRowIndex = i;
  1390. this.dgvProductionData.Rows[i].Selected = true;
  1391. break;
  1392. }
  1393. }
  1394. List<ProductionDefectEntity> productionDefectEntitys = new List<ProductionDefectEntity>();
  1395. ProductionDefectEntity productionDefectEntity = null;
  1396. for (int j = 0; j < this.DSTable.Tables[productionDataEntity.Barcode].Rows.Count; j++) //缺陷列表
  1397. {
  1398. productionDefectEntity = new ProductionDefectEntity();
  1399. productionDefectEntity.SpecialDefect = this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["IsOtherDefect"].ToString();
  1400. //if (this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectDeductionID"].ToString() != "-1"
  1401. // && this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectDeductionID"].ToString() != string.Empty)
  1402. //{
  1403. // productionDefectEntity.DefectDeductionNum = Convert.ToDecimal(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectDeductionNum"]);
  1404. //}
  1405. if (!string.IsNullOrEmpty(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectDeductionNum"] + ""))
  1406. {
  1407. productionDefectEntity.DefectDeductionNum = Convert.ToDecimal(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectDeductionNum"]);
  1408. }
  1409. productionDefectEntity.ScrapResponFlag = "0";
  1410. productionDefectEntity.DefectID =
  1411. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectID"]);
  1412. productionDefectEntity.DefectCode =
  1413. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectCode"].ToString();
  1414. productionDefectEntity.DefectName =
  1415. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectName"].ToString().Replace(productionDefectEntity.DefectCode + "->", "");
  1416. productionDefectEntity.DefectPositionID =
  1417. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectPositionID"]);
  1418. productionDefectEntity.DefectPositionCode =
  1419. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectPositionCode"].ToString();
  1420. productionDefectEntity.DefectPositionName =
  1421. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectPositionName"].ToString().Replace(productionDefectEntity.DefectPositionCode + "->", "");
  1422. productionDefectEntity.DefectProductionDataID =
  1423. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["ProductionDataID"].ToString());
  1424. if (productionDefectEntity.DefectProductionDataID == 0)
  1425. {
  1426. productionDefectEntity.DefectProductionDataID = null;
  1427. }
  1428. if (this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectProcedureID"].ToString() != string.Empty &&
  1429. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectProcedureID"]) > Constant.INT_IS_ZERO)
  1430. {
  1431. productionDefectEntity.DefectProcedureID =
  1432. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectProcedureID"]);
  1433. }
  1434. productionDefectEntity.DefectProcedureCode =
  1435. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectProcedureCode"].ToString();
  1436. productionDefectEntity.DefectProcedureName =
  1437. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectProcedureName"].ToString();
  1438. productionDefectEntity.DefectUserID =
  1439. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectUserID"]);
  1440. productionDefectEntity.DefectUserCode =
  1441. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectUserCode"].ToString();
  1442. productionDefectEntity.DefectUserName =
  1443. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectUserName"].ToString();
  1444. productionDefectEntity.DefectJobs =
  1445. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["Jobs"].ToString());
  1446. productionDefectEntity.Remarks =
  1447. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectRemarks"].ToString();
  1448. productionDefectEntity.Remarks =
  1449. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectRemarks"].ToString();
  1450. if (this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectFineID"].ToString() != "-1"
  1451. && this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectFineID"].ToString() != string.Empty)
  1452. {
  1453. productionDefectEntity.DefectFine = Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectFineID"]);
  1454. }
  1455. if (this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["CheckTime"].ToString() != string.Empty)
  1456. {
  1457. //if (Convert.ToInt32(this.TableProductionData.Rows[i]["OrgGoodsLevelTypeID"]) == Convert.ToInt32(this.TableProductionData.Rows[i]["GoodsLevelTypeID"]))
  1458. //{
  1459. productionDefectEntity.CheckTime = Convert.ToDateTime(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["CheckTime"]);
  1460. //}
  1461. }
  1462. if (this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["MissedUserID"].ToString() != "-1"
  1463. && this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["MissedUserID"].ToString() != string.Empty)
  1464. {
  1465. productionDefectEntity.MissedUserID = Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["MissedUserID"]);
  1466. productionDefectEntity.MissedUserCode = this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["MissedUserCode"].ToString();
  1467. productionDefectEntity.MissedUserName = this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["MissedUserName"].ToString();
  1468. }
  1469. // 遍历责任员工
  1470. List<DefectResponsibleEntity> DefectResponsibles = new List<DefectResponsibleEntity>();
  1471. if (this.DSTableStaff.Tables.Contains(string.Format("TempTable{0}",
  1472. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["TempCount"].ToString())))
  1473. {
  1474. DefectResponsibleEntity defectResponsibleEntity = null;
  1475. DataTable dtTemp = this.DSTableStaff.Tables[string.Format("TempTable{0}",
  1476. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["TempCount"].ToString())];
  1477. foreach (DataRow drStaff in dtTemp.Rows)
  1478. {
  1479. if (Convert.ToInt32(drStaff["IsSelected"]) == Constant.INT_IS_ONE)
  1480. {
  1481. defectResponsibleEntity = new DefectResponsibleEntity();
  1482. defectResponsibleEntity.StaffID = Convert.ToInt32(drStaff["StaffID"]);
  1483. defectResponsibleEntity.UserID = Convert.ToInt32(productionDefectEntity.DefectUserID);
  1484. defectResponsibleEntity.UserCode = productionDefectEntity.DefectUserCode;
  1485. defectResponsibleEntity.UJobsID =
  1486. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["Jobs"].ToString());
  1487. defectResponsibleEntity.SJobsID =
  1488. Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["Jobs"].ToString());
  1489. defectResponsibleEntity.StaffStatus = Convert.ToInt32(drStaff["StaffStatus"]);
  1490. DefectResponsibles.Add(defectResponsibleEntity);
  1491. }
  1492. }
  1493. //productionDefectEntity.DefectResponsibles = DefectResponsibles.ToArray();//每个缺陷对应的责任员工
  1494. productionDefectEntity.DefectResponsibles = DefectResponsibles;//每个缺陷对应的责任员工
  1495. }
  1496. if (DefectResponsibles.Count == Constant.INT_IS_ZERO) // 并没有责任员工
  1497. {
  1498. isError = true;
  1499. this.dgvDefect.DataSource = this.DSTable.Tables[productionDataEntity.Barcode];
  1500. this.dgvDefect.CurrentCell = null;
  1501. this.dgvDefect.Rows[j].Selected = true;
  1502. if (this.DSTableStaff.Tables.Contains(string.Format("TempTable{0}",
  1503. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["TempCount"].ToString())))
  1504. {
  1505. this.dgvDefectStaff.DataSource = this.DSTableStaff.Tables[string.Format("TempTable{0}",
  1506. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["TempCount"].ToString())];
  1507. }
  1508. else
  1509. {
  1510. this.dgvDefectStaff.DataSource = null;
  1511. }
  1512. break;
  1513. }
  1514. // 遍历漏检责任员工
  1515. List<DefectMissedResponsibleEntity> DefectMissedResponsibles = new List<DefectMissedResponsibleEntity>();
  1516. if (this.DSTableMissedStaff.Tables.Contains(string.Format("TempTable{0}",
  1517. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["TempCount"].ToString())))
  1518. {
  1519. DefectMissedResponsibleEntity defectMissedResponsibleEntity = null;
  1520. DataTable dtTemp = this.DSTableMissedStaff.Tables[string.Format("TempTable{0}",
  1521. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["TempCount"].ToString())];
  1522. foreach (DataRow drStaff in dtTemp.Rows)
  1523. {
  1524. if (Convert.ToInt32(drStaff["IsSelected"]) == Constant.INT_IS_ONE)
  1525. {
  1526. defectMissedResponsibleEntity = new DefectMissedResponsibleEntity();
  1527. defectMissedResponsibleEntity.StaffID = Convert.ToInt32(drStaff["StaffID"]);
  1528. defectMissedResponsibleEntity.UserID = Convert.ToInt32(productionDefectEntity.DefectUserID);
  1529. defectMissedResponsibleEntity.UserCode = productionDefectEntity.DefectUserCode;
  1530. defectMissedResponsibleEntity.UJobsID = Convert.ToInt32(drStaff["UJobsID"]);
  1531. defectMissedResponsibleEntity.SJobsID = Convert.ToInt32(drStaff["SJobsID"]);
  1532. defectMissedResponsibleEntity.StaffStatus = Convert.ToInt32(drStaff["StaffStatus"]);
  1533. DefectMissedResponsibles.Add(defectMissedResponsibleEntity);
  1534. }
  1535. }
  1536. //productionDefectEntity.DefectMissedResponsibles = DefectMissedResponsibles.ToArray();
  1537. productionDefectEntity.DefectMissedResponsibles = DefectMissedResponsibles;
  1538. }
  1539. // 遍历缺陷图片
  1540. if (this.DSTableImage.Tables.Contains(string.Format("TempTable{0}",
  1541. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["TempCount"].ToString())))
  1542. {
  1543. List<DefectImageEntity> defectImageEntitys = new List<DefectImageEntity>();
  1544. DefectImageEntity defectImageEntity = null;
  1545. DataTable dtTemp = this.DSTableImage.Tables[string.Format("TempTable{0}",
  1546. this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["TempCount"].ToString())];
  1547. foreach (DataRow drImage in dtTemp.Rows)
  1548. {
  1549. defectImageEntity = new DefectImageEntity();
  1550. defectImageEntity.Thumbnail = (byte[])drImage["ImageByte"];
  1551. defectImageEntity.Image = (byte[])drImage["orgImageByte"];
  1552. defectImageEntitys.Add(defectImageEntity);
  1553. }
  1554. //productionDefectEntity.DefectImages = defectImageEntitys.ToArray();
  1555. productionDefectEntity.DefectImages = defectImageEntitys;
  1556. }
  1557. productionDefectEntitys.Add(productionDefectEntity);
  1558. }
  1559. if (isError)
  1560. {
  1561. break;
  1562. }
  1563. //productionDataEntitys[i].ProductionDefects = productionDefectEntitys.ToArray();
  1564. productionDataEntitys[i].ProductionDefects = productionDefectEntitys;
  1565. }
  1566. // 有错误
  1567. if (isError)
  1568. {
  1569. if (CurrentRowIndex != -Constant.INT_IS_ONE)
  1570. {
  1571. this._currentDefectFlag = Convert.ToInt32(this.TableProductionData.Rows[CurrentRowIndex]["DefectFlagID"].ToString());
  1572. }
  1573. if (ErrorCount == -Constant.INT_IS_ONE)
  1574. {
  1575. // 提示信息
  1576. MessageBox.Show(Messages.MSG_PM_W002,
  1577. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1578. return;
  1579. }
  1580. else if (ErrorCount == -Constant.INT_IS_TWO)
  1581. {
  1582. // 提示信息
  1583. MessageBox.Show("非良品必须输入缺陷!",
  1584. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1585. return;
  1586. }
  1587. else
  1588. {
  1589. this.dgvProductionData.DataSource = TableProductionData;
  1590. //this.TableProductionData.Columns["ReworkProcedureID"].DataType=typeof(decimal);// data typeof(decimal));
  1591. //this.ReworkProcedureID.DataSource = this.DSREWORK.Tables[0];
  1592. //this.ReworkProcedureID.DisplayMember = "ReworkProcedureName";
  1593. //this.ReworkProcedureID.ValueMember = "ReworkProcedureID";
  1594. // 提示信息
  1595. MessageBox.Show(Messages.MSG_PM_W003,
  1596. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1597. //this.ReworkProcedureID.DataSource = this.DSREWORK.Tables[0];
  1598. //this.ReworkProcedureID.DisplayMember = "ReworkProcedureName";
  1599. //this.ReworkProcedureID.ValueMember = "ReworkProcedureID";
  1600. return;
  1601. }
  1602. }
  1603. // 最外层For循环结束
  1604. if (productionDataEntitys.Length > Constant.INT_IS_ZERO)
  1605. {
  1606. string returnValue = (string)DoAsync(new BaseAsyncMethod(() =>
  1607. {
  1608. return PMModuleProxy.Service.AddCheckBarcode(this._procedureID, productionDataEntitys);
  1609. }));
  1610. if (string.IsNullOrEmpty(returnValue))//成功
  1611. {
  1612. // 提示信息
  1613. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "新建" + this.Text, "保存"),
  1614. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  1615. ////保存成功后,并且为编辑时候,把上次编辑的数据禁用
  1616. //if (this._productiondataid > Constant.INT_IS_ZERO)
  1617. //{
  1618. // int deleteRow = (int)DoAsync(new BaseAsyncMethod(() =>
  1619. // {
  1620. // return PMModuleProxy.Service.DeleteProductionDataByID(this._productiondataid);
  1621. // }));
  1622. //}
  1623. // 保存成功后,清空相应数据源
  1624. this.TableProductionData.Rows.Clear();
  1625. this.dgvProductionData.DataSource = TableProductionData;
  1626. this.DSTable.Tables.Clear();
  1627. this.dgvDefect.DataSource = null;
  1628. this.DSTableStaff.Tables.Clear();
  1629. this.dgvDefectStaff.DataSource = null;
  1630. this.DSTableMissedStaff.Tables.Clear();
  1631. this.dgvMissStaff.DataSource = null;
  1632. this.DSTableImage.Tables.Clear();
  1633. this.lvPic.Clear();
  1634. this._PicByte.Clear();
  1635. this._smallByte.Clear();
  1636. this.txtBarCode.Text = string.Empty;
  1637. if (this._procedureDataEntity.CollectType == (int)Constant.ProcedureCollectType.Togather)
  1638. {
  1639. this.txtUserCode.Text = string.Empty;
  1640. this.txtUserCode.ReadOnly = false;
  1641. }
  1642. //this.DSREWORK.Tables.Clear();
  1643. }
  1644. else
  1645. {
  1646. // 提示信息
  1647. MessageBox.Show(returnValue,
  1648. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1649. }
  1650. }
  1651. }
  1652. catch (Exception ex)
  1653. {
  1654. // 对异常进行共通处理
  1655. ExceptionManager.HandleEventException(this.ToString(),
  1656. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  1657. }
  1658. }
  1659. /// <summary>
  1660. /// 关闭按钮事件
  1661. /// </summary>
  1662. /// <param name="sender"></param>
  1663. /// <param name="e"></param>
  1664. private void tsbCloseTop_Click(object sender, EventArgs e)
  1665. {
  1666. this.Close();
  1667. }
  1668. /// <summary>
  1669. /// 单元格编辑开始时事件
  1670. /// </summary>
  1671. /// <param name="sender"></param>
  1672. /// <param name="e"></param>
  1673. private void dgvProductionData_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
  1674. {
  1675. //if (e.ColumnIndex == Constant.INT_IS_FOUR && e.RowIndex != -Constant.INT_IS_ONE)
  1676. //{
  1677. // DataGridView dgv = (DataGridView)sender;
  1678. // string value = this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["GoodsLevelTypeID"].Value.ToString();
  1679. // if (value != Constant.GoodsLevelType.ReFire.GetHashCode().ToString())
  1680. // {
  1681. // e.Cancel = true;
  1682. // }
  1683. //}
  1684. //if (e.ColumnIndex == Constant.INT_IS_THREE && e.RowIndex != -Constant.INT_IS_ONE)
  1685. //{
  1686. // if (this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReadOnly"].Value.ToString() == "1")
  1687. // {
  1688. // e.Cancel = true;
  1689. // }
  1690. //}
  1691. if (e.ColumnIndex == Constant.INT_IS_FOUR && e.RowIndex != -Constant.INT_IS_ONE)
  1692. {
  1693. DataGridView dgv = (DataGridView)sender;
  1694. string value = this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["GoodsLevelTypeID"].Value.ToString();
  1695. if (value != Constant.GoodsLevelType.ReFire.GetHashCode().ToString())
  1696. {
  1697. e.Cancel = true;
  1698. }
  1699. }
  1700. if (e.ColumnIndex == Constant.INT_IS_THREE && e.RowIndex != -Constant.INT_IS_ONE)
  1701. {
  1702. if (this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReadOnly"].Value.ToString() == "1")
  1703. {
  1704. e.Cancel = true;
  1705. }
  1706. }
  1707. }
  1708. /// <summary>
  1709. /// 用户编码验证事件
  1710. /// </summary>
  1711. /// <param name="sender"></param>
  1712. /// <param name="e"></param>
  1713. private void txtUserCode_Validating(object sender, System.ComponentModel.CancelEventArgs e)
  1714. {
  1715. try
  1716. {
  1717. if (txtUserCode.Text.Trim() == string.Empty) // 如果未添加数据,则此项获取焦点
  1718. {
  1719. this.txtUserCode.IsMustInput = true;
  1720. this.txtUserCode.SelectAll();
  1721. e.Cancel = true;
  1722. return;
  1723. }
  1724. else if (!this.txtUserCode.ReadOnly)
  1725. {
  1726. SUserEntity userEntity = new SUserEntity();
  1727. userEntity.UserCode = this.txtUserCode.Text.Trim();
  1728. // 此工号是否能生产工序
  1729. CheckProcedureUserResult MsgCheckProcedureUser = (CheckProcedureUserResult)DoAsync(new BaseAsyncMethod(() =>
  1730. {
  1731. return PMModuleProxy.Service.CheckProcedureUser(this._procedureID, this.txtUserCode.Text.Trim());
  1732. }));
  1733. if (MsgCheckProcedureUser != null)
  1734. {
  1735. if (MsgCheckProcedureUser.ErrMsg != null)
  1736. {
  1737. MessageBox.Show(MsgCheckProcedureUser.ErrMsg,
  1738. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1739. this.txtUserCode.SelectAll();
  1740. e.Cancel = true;
  1741. return;
  1742. }
  1743. UserID = Convert.ToInt32(MsgCheckProcedureUser.UserID);
  1744. UserCode = MsgCheckProcedureUser.UserCode;
  1745. UserName = MsgCheckProcedureUser.UserName;
  1746. this.txtUserCode.ReadOnly = true;
  1747. }
  1748. }
  1749. }
  1750. catch (Exception ex)
  1751. {
  1752. // 对异常进行共通处理
  1753. ExceptionManager.HandleEventException(this.ToString(),
  1754. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  1755. }
  1756. }
  1757. /// <summary>
  1758. /// 鼠标单击事件
  1759. /// </summary>
  1760. /// <param name="sender"></param>
  1761. /// <param name="e"></param>
  1762. private void txtUserCode_MouseClick(object sender, MouseEventArgs e)
  1763. {
  1764. if (this.txtUserCode.Text.Trim() != string.Empty)
  1765. {
  1766. this.txtUserCode.SelectAll();
  1767. }
  1768. }
  1769. #endregion
  1770. #region 私有方法
  1771. /// <summary>
  1772. /// 设置数据源
  1773. /// </summary>
  1774. /// <param name="tempCount"></param>
  1775. public void SetDataSource(int tempCount)
  1776. {
  1777. this.dgvDefect.DataSource = DSTable.Tables[this._currentBarCode];
  1778. this.dgvDefectStaff.DataSource = DSTableStaff.Tables[string.Format("TempTable{0}", this._tempCount.ToString())];
  1779. this.dgvMissStaff.DataSource = DSTableMissedStaff.Tables[string.Format("TempTable{0}", this._tempCount.ToString())];
  1780. this._tempCount = tempCount;
  1781. }
  1782. /// <summary>
  1783. /// 设置编辑产品为时设置只读
  1784. /// </summary>
  1785. private void SetSubstandard()
  1786. {
  1787. this.btnSave.Enabled = false;
  1788. this.dgvProductionData.ReadOnly = true;
  1789. this.tsbtnAdd.Enabled = false;
  1790. this.tsbtnEdit.Enabled = false;
  1791. this.dgvDefect.ReadOnly = true;
  1792. this.dgvDefectStaff.ReadOnly = true;
  1793. this.dgvMissStaff.ReadOnly = true;
  1794. this.btnDelete.Enabled = false;
  1795. this.btnUpload.Enabled = false;
  1796. }
  1797. /// <summary>
  1798. /// 编辑后设置数据源
  1799. /// </summary>
  1800. private void SetEditDataSource()
  1801. {
  1802. try
  1803. {
  1804. this.txtUserCode.Enabled = false;
  1805. this.txtBarCode.Enabled = false;
  1806. DataSet dsProductionDataByID = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  1807. {
  1808. return PMModuleProxy.Service.GetProductionDataByID(this._productiondataid);
  1809. }));
  1810. if (dsProductionDataByID != null && dsProductionDataByID.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  1811. {
  1812. #region wangx 2016-10-10 校验是否可以成检登记改判 xuwei modify 2019-12-13 半检中取消判定
  1813. //if (_settingvaluedays > 0)
  1814. //{
  1815. // ServiceResultEntity resultEntity = (ServiceResultEntity)DoAsync(new BaseAsyncMethod(() =>
  1816. // {
  1817. // return PMModuleProxy.Service.BarcodeAllowCancel(
  1818. // Convert.ToDateTime(dsProductionDataByID.Tables[0].Rows[0]["createtime"]),
  1819. // _settingvaluedays, Constant.SettingType.S_PM_009.ToString());
  1820. // }));
  1821. // if (Convert.ToInt32(resultEntity.Result) < 0)
  1822. // {
  1823. // MessageBox.Show(resultEntity.Message,
  1824. // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1825. // this.txtBarCode.Text = "";
  1826. // this.btnSave.Visible = false;
  1827. // }
  1828. //}
  1829. #endregion wangx 2016-10-10 end
  1830. #region 如果是废品,不允许编辑 xuwei modify 2019-12-13
  1831. if (Convert.ToInt32(dsProductionDataByID.Tables[0].Rows[0]["GoodsLevelTypeID"]) == 3)//废品
  1832. {
  1833. int recyclingflag = (int)DoAsync(new BaseAsyncMethod(() =>
  1834. {
  1835. return PMModuleProxy.Service.GetRecyclingflagByBarcode(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString());
  1836. }));
  1837. if (recyclingflag > 0)
  1838. {
  1839. MessageBox.Show("条码【" + dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString() + "】已经回收,不允许改判", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1840. this.txtBarCode.Enabled = true;
  1841. this.txtBarCode.Focus();
  1842. return;
  1843. }
  1844. }
  1845. #endregion
  1846. int SpecialRepairflag = (int)DoAsync(new BaseAsyncMethod(() =>
  1847. {
  1848. return PMModuleProxy.Service.GetSpecialRepairflagByBarcode(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString());
  1849. }));
  1850. // 产品数据
  1851. DataRow drNew = TableProductionData.NewRow();
  1852. drNew["ProductionDataID"] = this._productiondataid;
  1853. drNew["BarCode"] = dsProductionDataByID.Tables[0].Rows[0]["BarCode"];
  1854. drNew["GoodsID"] = dsProductionDataByID.Tables[0].Rows[0]["GoodsID"];
  1855. drNew["GoodsCode"] = dsProductionDataByID.Tables[0].Rows[0]["GoodsCode"];
  1856. drNew["GoodsName"] = dsProductionDataByID.Tables[0].Rows[0]["GoodsName"];
  1857. drNew["DefectFlagID"] = dsProductionDataByID.Tables[0].Rows[0]["DefectFlagID"];
  1858. drNew["ReworkProcedureID"] = dsProductionDataByID.Tables[0].Rows[0]["ReworkProcedureID"];
  1859. drNew["Remarks"] = dsProductionDataByID.Tables[0].Rows[0]["Remarks"];
  1860. drNew["UserID"] = dsProductionDataByID.Tables[0].Rows[0]["UserID"];
  1861. drNew["GoodsLevelTypeID"] = dsProductionDataByID.Tables[0].Rows[0]["GoodsLevelTypeID"];
  1862. drNew["UserCode"] = dsProductionDataByID.Tables[0].Rows[0]["UserCode"];
  1863. drNew["UserName"] = dsProductionDataByID.Tables[0].Rows[0]["UserName"];
  1864. UserID = Convert.ToInt32(dsProductionDataByID.Tables[0].Rows[0]["UserID"]);
  1865. UserCode = dsProductionDataByID.Tables[0].Rows[0]["UserCode"].ToString();
  1866. UserName = dsProductionDataByID.Tables[0].Rows[0]["UserName"].ToString();
  1867. drNew["OrgGoodsLevelTypeID"] = dsProductionDataByID.Tables[0].Rows[0]["GoodsLevelTypeID"];
  1868. drNew["ReadOnly"] = this._ReadOnly;
  1869. drNew["KilnCarCode"] = dsProductionDataByID.Tables[0].Rows[0]["KilnCarCode"];
  1870. drNew["KilnCode"] = dsProductionDataByID.Tables[0].Rows[0]["KilnCode"];
  1871. drNew["Dictionaryvalue"] = dsProductionDataByID.Tables[0].Rows[0]["Dictionaryvalue"];
  1872. drNew["UserCode"] = dsProductionDataByID.Tables[0].Rows[0]["UserCode"];
  1873. drNew["MouldCode"] = dsProductionDataByID.Tables[0].Rows[0]["MouldCode"];
  1874. drNew["GroutingUserCode"] = dsProductionDataByID.Tables[0].Rows[0]["GroutingUserCode"];
  1875. drNew["GroutingNum"] = dsProductionDataByID.Tables[0].Rows[0]["GroutingNum"];
  1876. drNew["IsPublicBody"] = dsProductionDataByID.Tables[0].Rows[0]["IsPublicBody"].ToString() != "1" ? 0 : 1;
  1877. drNew["GroutingDate"] = Convert.ToDateTime(dsProductionDataByID.Tables[0].Rows[0]["GroutingDate"]);
  1878. drNew["LogoCodeName"] = dsProductionDataByID.Tables[0].Rows[0]["LogoName"] + "[" + dsProductionDataByID.Tables[0].Rows[0]["LogoCode"] + "]";
  1879. drNew["LogoId"] = dsProductionDataByID.Tables[0].Rows[0]["LogoId"];
  1880. drNew["CheckTime"] = dsProductionDataByID.Tables[0].Rows[0]["CheckTime"];
  1881. DataSet dsOPTimeStamp = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  1882. {
  1883. return PMModuleProxy.Service.GetCompleteProcedureIDPDA(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString());
  1884. }));
  1885. if (dsOPTimeStamp != null && dsOPTimeStamp.Tables[0].Rows.Count > 0)
  1886. {
  1887. drNew["OPTimeStamp"] = Convert.ToDateTime(dsOPTimeStamp.Tables[0].Rows[0]["OPTimeStamp"]);
  1888. }
  1889. //drNew["OPTimeStamp"]
  1890. // 校验条码是否重烧过,这个地方必须重新读取,因为防止编辑重烧以前的成检数据,如果直接取表里的就不准了
  1891. DataSet dsReFine = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  1892. {
  1893. return PMModuleProxy.Service.GetReFine(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString());
  1894. }));
  1895. if (dsReFine != null && dsReFine.Tables[0].Rows.Count > 0 && dsReFine.Tables[0].Rows[0]["IsReFire"].ToString() == "6")
  1896. {
  1897. drNew["ReFine"] = 1;
  1898. }
  1899. else
  1900. {
  1901. drNew["ReFine"] = 0;
  1902. }
  1903. drNew["SpecialRepairflag"] = SpecialRepairflag.ToString() == "1" ? 1 : 0;
  1904. //原产品类别
  1905. //UserID = Convert.ToInt32(dsProductionDataByID.Tables[0].Rows[0]["UserID"]);
  1906. //UserCode = dsProductionDataByID.Tables[0].Rows[0]["UserCode"].ToString();
  1907. //UserName = dsProductionDataByID.Tables[0].Rows[0]["UserName"].ToString();
  1908. TableProductionData.Rows.Add(drNew);
  1909. this.dgvProductionData.Rows[TableProductionData.Rows.Count - 1].Selected = true;
  1910. this._selectedRowIndex = TableProductionData.Rows.Count - 1;
  1911. this._currentBarCode = dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString();
  1912. this._currentGoodsID = Convert.ToInt32(dsProductionDataByID.Tables[0].Rows[0]["GoodsID"]);
  1913. if (dsProductionDataByID.Tables[0].Rows[0]["GoodsLevelTypeID"].ToString() == Constant.INT_IS_SEVEN.ToString())
  1914. {
  1915. //次品设置只读的时候,原来默认不允许修改,目前注释掉
  1916. //SetSubstandard();
  1917. DataSet dsReturn = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  1918. {
  1919. return PMModuleProxy.Service.GetSubstandardInfo(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString());
  1920. }));
  1921. if (dsReturn != null && dsReturn.Tables[0].Rows.Count == 0) //防止回收站里没有此条码
  1922. {
  1923. // 提示信息
  1924. MessageBox.Show("次品条码:" + dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString() + "不允许修改",
  1925. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1926. return;
  1927. }
  1928. this.tsbtnAdd.Enabled = true;
  1929. }
  1930. else
  1931. {
  1932. this.tsbtnAdd.Enabled = true;
  1933. if (dsProductionDataByID != null && dsProductionDataByID.Tables[1].Rows.Count > Constant.INT_IS_ZERO)
  1934. {
  1935. this.tsbtnEdit.Enabled = true;
  1936. }
  1937. }
  1938. }
  1939. if (DSTable.Tables.IndexOf(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString()) == -Constant.INT_IS_ONE)
  1940. {
  1941. DataTable dtProductionDefectData = new DataTable(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString());
  1942. dtProductionDefectData.Columns.Add("BarCode");
  1943. dtProductionDefectData.Columns.Add("DefectID", typeof(decimal));
  1944. dtProductionDefectData.Columns.Add("DefectName");
  1945. dtProductionDefectData.Columns.Add("DefectCode");
  1946. dtProductionDefectData.Columns.Add("DefectPositionID", typeof(decimal));
  1947. dtProductionDefectData.Columns.Add("DefectPositionName");
  1948. dtProductionDefectData.Columns.Add("DefectPositionCode");
  1949. dtProductionDefectData.Columns.Add("DefectProcedureID", typeof(decimal));
  1950. dtProductionDefectData.Columns.Add("DefectProcedureName");
  1951. dtProductionDefectData.Columns.Add("DefectProcedureCode");
  1952. dtProductionDefectData.Columns.Add("DefectUserID", typeof(decimal));//责任员工
  1953. dtProductionDefectData.Columns.Add("DefectUserName");//责任员工
  1954. dtProductionDefectData.Columns.Add("DefectUserCode");//
  1955. dtProductionDefectData.Columns.Add("Jobs", typeof(decimal));//工种
  1956. dtProductionDefectData.Columns.Add("JobsText");//工种
  1957. dtProductionDefectData.Columns.Add("DefectRemarks");
  1958. dtProductionDefectData.Columns.Add("TempCount");
  1959. dtProductionDefectData.Columns.Add("ProductionDataID"); //生产数据ID
  1960. dtProductionDefectData.Columns.Add("DefectFineID"); //缺陷扣罚ID
  1961. dtProductionDefectData.Columns.Add("DefectFineValue"); //缺陷扣罚
  1962. dtProductionDefectData.Columns.Add("MissedUserID"); //漏检工号ID
  1963. dtProductionDefectData.Columns.Add("MissedUserCode"); //漏检工号编码
  1964. dtProductionDefectData.Columns.Add("MissedUserName"); //漏检工号名称
  1965. dtProductionDefectData.Columns.Add("IsAllowEdit"); //是否允许编辑 0 不允许,1允许
  1966. //新添加的 wangx 2016/1/6
  1967. dtProductionDefectData.Columns.Add("DefectDeductionID"); //缺陷扣除数ID
  1968. dtProductionDefectData.Columns.Add("DefectDeductionNum"); //缺陷扣除数
  1969. dtProductionDefectData.Columns.Add("IsOtherDefect"); //特殊缺陷
  1970. dtProductionDefectData.Columns.Add("CheckTime"); //缺陷检验时间
  1971. //新添加的 wangx 2016/1/6 end
  1972. DSTable.Tables.Add(dtProductionDefectData);
  1973. }
  1974. if (dsProductionDataByID != null && dsProductionDataByID.Tables[1].Rows.Count > Constant.INT_IS_ZERO)
  1975. {
  1976. // 产品缺陷
  1977. if (DSTable.Tables.IndexOf(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString()) == -Constant.INT_IS_ONE)
  1978. {
  1979. DataTable dtProductionDefectData = new DataTable(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString());
  1980. dtProductionDefectData.Columns.Add("BarCode");
  1981. dtProductionDefectData.Columns.Add("DefectID", typeof(decimal));
  1982. dtProductionDefectData.Columns.Add("DefectName");
  1983. dtProductionDefectData.Columns.Add("DefectCode");
  1984. dtProductionDefectData.Columns.Add("DefectPositionID", typeof(decimal));
  1985. dtProductionDefectData.Columns.Add("DefectPositionName");
  1986. dtProductionDefectData.Columns.Add("DefectPositionCode");
  1987. dtProductionDefectData.Columns.Add("DefectProcedureID", typeof(decimal));
  1988. dtProductionDefectData.Columns.Add("DefectProcedureName");
  1989. dtProductionDefectData.Columns.Add("DefectProcedureCode");
  1990. dtProductionDefectData.Columns.Add("DefectUserID", typeof(decimal));//责任员工
  1991. dtProductionDefectData.Columns.Add("DefectUserName");//责任员工
  1992. dtProductionDefectData.Columns.Add("DefectUserCode");//
  1993. dtProductionDefectData.Columns.Add("Jobs", typeof(decimal));//工种
  1994. dtProductionDefectData.Columns.Add("JobsText");//工种
  1995. dtProductionDefectData.Columns.Add("DefectRemarks");
  1996. dtProductionDefectData.Columns.Add("TempCount");
  1997. dtProductionDefectData.Columns.Add("ProductionDataID"); //生产数据ID
  1998. dtProductionDefectData.Columns.Add("DefectFineID"); //缺席扣罚ID
  1999. dtProductionDefectData.Columns.Add("DefectFineValue"); //缺席扣罚
  2000. dtProductionDefectData.Columns.Add("MissedUserID"); //漏检工号ID
  2001. dtProductionDefectData.Columns.Add("MissedUserCode"); //漏检工号编码
  2002. dtProductionDefectData.Columns.Add("MissedUserName"); //漏检工号名称
  2003. dtProductionDefectData.Columns.Add("IsAllowEdit"); //是否允许编辑 0 不允许,1允许
  2004. //新添加的 wangx 2016/1/6
  2005. dtProductionDefectData.Columns.Add("DefectDeductionID"); //缺陷扣除数ID
  2006. dtProductionDefectData.Columns.Add("DefectDeductionNum"); //缺陷扣除数
  2007. dtProductionDefectData.Columns.Add("IsOtherDefect"); //特殊缺陷
  2008. dtProductionDefectData.Columns.Add("CheckTime"); //缺陷检验时间
  2009. //新添加的 wangx 2016/1/6 end
  2010. DSTable.Tables.Add(dtProductionDefectData);
  2011. }
  2012. this.dgvProductionData.Rows[TableProductionData.Rows.Count - 1].Selected = true;
  2013. this._selectedRowIndex = TableProductionData.Rows.Count - 1;
  2014. this._currentDefectFlag = Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["GoodsLevelTypeID"].Value.ToString());
  2015. this._currentGoodsID = Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["GoodsID"].Value);
  2016. this._currentBarCode = this.dgvProductionData.Rows[_selectedRowIndex].Cells["BarCode"].Value.ToString();
  2017. //-----------------------
  2018. //DataSet ds = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2019. //{
  2020. // return PMModuleProxy.Service.GetReworkProcedureByProcedureID(this._procedureID);
  2021. //}));
  2022. //ds.Tables[0].TableName = dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString();
  2023. //if (this.DSREWORK == null)
  2024. //{
  2025. // this.DSREWORK = new DataSet();
  2026. //}
  2027. //this.DSREWORK.Tables.Add(ds.Tables[0].Copy());
  2028. //C_DGV_Cell_ListBoxComboBox C_DGV_Cell_ListBoxComboBox = dgvProductionData.Rows[_selectedRowIndex].Cells[4] as C_DGV_Cell_ListBoxComboBox;
  2029. //C_DGV_Cell_ListBoxComboBox.DataSource = ds.Tables[0];
  2030. //C_DGV_Cell_ListBoxComboBox.DisplayMember = "ReworkProcedureName";
  2031. //C_DGV_Cell_ListBoxComboBox.ValueMember = "ReworkProcedureID";
  2032. for (int i = 0; i < dsProductionDataByID.Tables[1].Rows.Count; i++)
  2033. {
  2034. DataRow dr = DSTable.Tables[dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString()].NewRow();
  2035. dr["BarCode"] = dsProductionDataByID.Tables[1].Rows[i]["BarCode"];
  2036. dr["DefectID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectID"];
  2037. dr["DefectName"] = dsProductionDataByID.Tables[1].Rows[i]["DefectName"];
  2038. dr["DefectCode"] = dsProductionDataByID.Tables[1].Rows[i]["DefectCode"];
  2039. dr["DefectPositionID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectPositionID"];
  2040. dr["DefectPositionName"] = dsProductionDataByID.Tables[1].Rows[i]["DefectPositionName"];
  2041. dr["DefectPositionCode"] = dsProductionDataByID.Tables[1].Rows[i]["DefectPositionCode"];
  2042. dr["DefectProcedureID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectProcedureID"];
  2043. dr["DefectProcedureName"] = dsProductionDataByID.Tables[1].Rows[i]["DefectProcedureName"];
  2044. dr["DefectProcedureCode"] = dsProductionDataByID.Tables[1].Rows[i]["DefectProcedureCode"];
  2045. dr["DefectUserID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectUserID"];
  2046. dr["DefectUserName"] = dsProductionDataByID.Tables[1].Rows[i]["DefectUserName"];
  2047. dr["DefectUserCode"] = dsProductionDataByID.Tables[1].Rows[i]["DefectUserCode"];
  2048. dr["Jobs"] = dsProductionDataByID.Tables[1].Rows[i]["Jobs"];
  2049. dr["JobsText"] = dsProductionDataByID.Tables[1].Rows[i]["JobsText"];
  2050. dr["DefectRemarks"] = dsProductionDataByID.Tables[1].Rows[i]["DefectRemarks"];
  2051. dr["TempCount"] = this._tempCount;
  2052. dr["ProductionDataID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectProductionDataID"];// dsProductionDataByID.Tables[1].Rows[i]["ProductionDataID"];
  2053. dr["DefectFineID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectFineID"];
  2054. dr["DefectFineValue"] = dsProductionDataByID.Tables[1].Rows[i]["DefectFineValue"];
  2055. dr["MissedUserID"] = dsProductionDataByID.Tables[1].Rows[i]["MissedUserID"];
  2056. dr["MissedUserCode"] = dsProductionDataByID.Tables[1].Rows[i]["MissedUserCode"];
  2057. dr["MissedUserName"] = dsProductionDataByID.Tables[1].Rows[i]["MissedUserName"];
  2058. dr["IsAllowEdit"] = this._AllowEdit;
  2059. //dr["DefectDeductionID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectDeductionID"];
  2060. dr["DefectDeductionNum"] = dsProductionDataByID.Tables[1].Rows[i]["DefectDeductionNum"];
  2061. dr["IsOtherDefect"] = dsProductionDataByID.Tables[1].Rows[i]["SpecialDefect"];
  2062. dr["CheckTime"] = dsProductionDataByID.Tables[1].Rows[i]["CheckTime"];
  2063. DSTable.Tables[dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString()].Rows.Add(dr);
  2064. // 防止工种不选择的话,直接New一个
  2065. if (!this.DSTableStaff.Tables.Contains(string.Format("TempTable{0}", this._tempCount)))
  2066. {
  2067. DataTable dtStaff = new DataTable(string.Format("TempTable{0}", this._tempCount));
  2068. dtStaff.Columns.Add("IsSelected");
  2069. dtStaff.Columns.Add("StaffID");
  2070. dtStaff.Columns.Add("StaffCode");
  2071. dtStaff.Columns.Add("StaffName");
  2072. dtStaff.Columns.Add("StaffTempCount");
  2073. dtStaff.Columns.Add("StaffStatus");
  2074. this.DSTableStaff.Tables.Add(dtStaff);
  2075. }
  2076. // 责任员工
  2077. DataRow[] drRow = dsProductionDataByID.Tables[2].Select("ProductionDefectID=" + dsProductionDataByID.Tables[1].Rows[i]["ProductionDefectID"]);
  2078. if (drRow.Length > Constant.INT_IS_ZERO)
  2079. {
  2080. foreach (DataRow r in drRow)
  2081. {
  2082. DataRow drStaff = this.DSTableStaff.Tables[string.Format("TempTable{0}", this._tempCount)].NewRow();
  2083. drStaff["IsSelected"] = 1;
  2084. drStaff["StaffID"] = r["StaffID"];
  2085. drStaff["StaffCode"] = r["StaffCode"];
  2086. drStaff["StaffName"] = r["StaffName"];
  2087. drStaff["StaffTempCount"] = this._tempCount;
  2088. drStaff["StaffStatus"] = r["StaffStatus"];
  2089. this.DSTableStaff.Tables[string.Format("TempTable{0}", this._tempCount)].Rows.Add(drStaff);
  2090. }
  2091. }
  2092. // 漏检员工临时表
  2093. if (!this.DSTableMissedStaff.Tables.Contains(string.Format("TempTable{0}", this._tempCount)))
  2094. {
  2095. DataTable dtMissedStaff = new DataTable(string.Format("TempTable{0}", this._tempCount));
  2096. dtMissedStaff.Columns.Add("IsSelected");
  2097. dtMissedStaff.Columns.Add("StaffID");
  2098. dtMissedStaff.Columns.Add("StaffCode");
  2099. dtMissedStaff.Columns.Add("StaffName");
  2100. dtMissedStaff.Columns.Add("StaffTempCount");
  2101. dtMissedStaff.Columns.Add("StaffStatus");
  2102. dtMissedStaff.Columns.Add("UJobsID");
  2103. dtMissedStaff.Columns.Add("SJobsID");
  2104. this.DSTableMissedStaff.Tables.Add(dtMissedStaff);
  2105. }
  2106. //漏检员工临时表数据
  2107. DataRow[] drMissedRow = dsProductionDataByID.Tables[4].Select("ProductionDefectID=" + dsProductionDataByID.Tables[1].Rows[i]["ProductionDefectID"]);
  2108. if (drMissedRow.Length > Constant.INT_IS_ZERO)
  2109. {
  2110. foreach (DataRow r in drMissedRow)
  2111. {
  2112. DataRow drMissedStaff = this.DSTableMissedStaff.Tables[string.Format("TempTable{0}", this._tempCount)].NewRow();
  2113. drMissedStaff["IsSelected"] = 1;
  2114. drMissedStaff["StaffID"] = r["StaffID"];
  2115. drMissedStaff["StaffCode"] = r["StaffCode"];
  2116. drMissedStaff["StaffName"] = r["StaffName"];
  2117. drMissedStaff["StaffTempCount"] = this._tempCount;
  2118. drMissedStaff["StaffStatus"] = r["StaffStatus"];
  2119. drMissedStaff["UJobsID"] = r["UJobsID"];
  2120. drMissedStaff["SJobsID"] = r["SJobsID"];
  2121. this.DSTableMissedStaff.Tables[string.Format("TempTable{0}", this._tempCount)].Rows.Add(drMissedStaff);
  2122. }
  2123. }
  2124. if (!this.DSTableImage.Tables.Contains(string.Format("TempTable{0}", this._tempCount.ToString())))
  2125. {
  2126. DataTable dtImage = new DataTable(string.Format("TempTable{0}", this._tempCount.ToString()));
  2127. dtImage.Columns.Add("StaffTempCount");
  2128. dtImage.Columns.Add("ImageByte", typeof(byte[]));
  2129. dtImage.Columns.Add("OrgImageByte", typeof(byte[]));
  2130. this.DSTableImage.Tables.Add(dtImage);
  2131. }
  2132. this._currentTempSign = i.ToString();
  2133. // 缺陷图片
  2134. DataRow[] drImageRow = dsProductionDataByID.Tables[3].Select("ProductionDefectID=" + dsProductionDataByID.Tables[1].Rows[i]["ProductionDefectID"]);
  2135. if (drImageRow.Length > Constant.INT_IS_ZERO)
  2136. {
  2137. foreach (DataRow r in drImageRow)
  2138. {
  2139. if (r["SourcePathByte"] != DBNull.Value)
  2140. {
  2141. byte[] orgImageByte = (byte[])r["SourcePathByte"];
  2142. this._PicByte.Add(orgImageByte);
  2143. //this._smallByte.Add(orgImageByte);
  2144. if (!this.DSTableImage.Tables.Contains(string.Format("TempTable{0}", this._currentTempSign.ToString())))
  2145. {
  2146. DataTable dtImage = new DataTable(string.Format("TempTable{0}", this._currentTempSign.ToString()));
  2147. dtImage.Columns.Add("StaffTempCount");
  2148. dtImage.Columns.Add("ImageByte", typeof(byte[]));
  2149. dtImage.Columns.Add("OrgImageByte", typeof(byte[]));
  2150. this.DSTableImage.Tables.Add(dtImage);
  2151. }
  2152. DataRow drrow = DSTableImage.Tables[string.Format("TempTable{0}", this._currentTempSign)].NewRow();
  2153. drrow["StaffTempCount"] = this._currentTempSign;
  2154. drrow["ImageByte"] = orgImageByte;
  2155. drrow["OrgImageByte"] = orgImageByte;
  2156. DSTableImage.Tables[string.Format("TempTable{0}", this._currentTempSign)].Rows.Add(drrow);
  2157. BindImg();
  2158. }
  2159. }
  2160. }
  2161. this._tempCount = this._tempCount + 1;
  2162. }
  2163. this.dgvDefect.DataSource = DSTable.Tables[dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString()];//根据条码产生不同数据源
  2164. //控制产品等级,只有编辑权限的人才能随便改
  2165. if (this._AllowEdit == 0) //
  2166. {
  2167. for (int i = 0; i < this.dgvProductionData.Rows.Count; i++)
  2168. {
  2169. int goodsLevelTypeID = Convert.ToInt32(this.TableProductionData.Rows[i]["GoodsLevelTypeID"]);
  2170. if (this._dsGoodsLevel != null)
  2171. {
  2172. DataTable dt = this._dsGoodsLevel.Tables[0].Copy();
  2173. DataView dv = dt.DefaultView;
  2174. //xuwei modify 2019-12-13 不限制 产品分级
  2175. //dv.RowFilter = "GoodsLevelTypeID>=" + goodsLevelTypeID;
  2176. DataGridViewComboBoxCell dgcbc = (DataGridViewComboBoxCell)dgvProductionData.Rows[i].Cells[3];
  2177. //xuwei modify 2019-12-12
  2178. //dgcbc.DisplayMember = "DefectFlagName";
  2179. //dgcbc.ValueMember = "DefectFlagID";
  2180. dgcbc.DisplayMember = "GOODSLEVELNAME";
  2181. dgcbc.ValueMember = "GOODSLEVELID";
  2182. dgcbc.DataSource = dv.ToTable();
  2183. }
  2184. }
  2185. }
  2186. }
  2187. if (!this.btnSave.Visible)
  2188. {
  2189. this.tsbtnAdd.Enabled = false;
  2190. this.tsbtnEdit.Enabled = false;
  2191. }
  2192. }
  2193. catch (Exception ex)
  2194. {
  2195. throw ex;
  2196. }
  2197. }
  2198. /// <summary>
  2199. /// 绑定到第一个DataGriwView数据源
  2200. /// </summary>
  2201. private void BindProductionDataReFine(DataSet dsCheckBarcode)
  2202. {
  2203. try
  2204. {
  2205. DataRow[] dr = TableProductionData.Select("BarCode='" + this.txtBarCode.Text.Trim() + "'");
  2206. if (dr.Length > Constant.INT_IS_ZERO)
  2207. {
  2208. // 不允许重复添加
  2209. return;
  2210. }
  2211. int SpecialRepairflag = (int)DoAsync(new BaseAsyncMethod(() =>
  2212. {
  2213. return PMModuleProxy.Service.GetSpecialRepairflagByBarcode(this.txtBarCode.Text.Trim());
  2214. }));
  2215. string KilnCarCode = string.Empty;
  2216. string KilnCode = string.Empty;
  2217. string Dictionaryvalue = string.Empty;
  2218. DataSet dsKilnCar = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2219. {
  2220. return PMModuleProxy.Service.GetKilnCarByBarCode(txtBarCode.Text.Trim());
  2221. }));
  2222. if (dsKilnCar != null && dsKilnCar.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  2223. {
  2224. KilnCarCode = dsKilnCar.Tables[0].Rows[0]["KilnCarCode"].ToString();
  2225. KilnCode = dsKilnCar.Tables[0].Rows[0]["KilnCode"].ToString();
  2226. Dictionaryvalue = dsKilnCar.Tables[0].Rows[0]["Dictionaryvalue"].ToString();
  2227. }
  2228. DataRow drNew = TableProductionData.NewRow();
  2229. drNew["BarCode"] = this.txtBarCode.Text.Trim();
  2230. drNew["ProductionDataID"] = this._productiondataid;
  2231. drNew["GoodsID"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsID.ToString()];
  2232. drNew["GoodsCode"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsCode.ToString()];
  2233. drNew["GoodsName"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsName.ToString()];
  2234. drNew["DefectFlagID"] = _dsGoodsLevel.Tables[0].Rows[0]["DefectFlagID"];
  2235. drNew["ReworkProcedureID"] = DBNull.Value;
  2236. drNew["Remarks"] = "";
  2237. drNew["UserID"] = UserID;
  2238. drNew["UserCode"] = UserCode;
  2239. drNew["UserName"] = UserName;
  2240. drNew["GoodsLevelTypeID"] = _dsGoodsLevel.Tables[0].Rows[0]["GoodsLevelTypeID"];
  2241. drNew["OrgGoodsLevelTypeID"] = -1;
  2242. drNew["SpecialRepairflag"] = SpecialRepairflag == 1 ? 1 : 0;
  2243. drNew["KilnCarCode"] = KilnCarCode;
  2244. drNew["KilnCode"] = KilnCode;
  2245. drNew["Dictionaryvalue"] = Dictionaryvalue;
  2246. // 校验条码是否重烧过
  2247. DataSet dsReFine = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2248. {
  2249. return PMModuleProxy.Service.GetReFine(this.txtBarCode.Text.Trim());
  2250. }));
  2251. if (dsReFine != null && dsReFine.Tables[0].Rows.Count > 0 && dsReFine.Tables[0].Rows[0]["IsReFire"].ToString() == "6")
  2252. {
  2253. drNew["ReFine"] = 1;
  2254. }
  2255. else
  2256. {
  2257. drNew["ReFine"] = 0;
  2258. }
  2259. drNew["UserCode"] = this.txtUserCode.Text.Trim();
  2260. // 由产品条码获取注浆信息
  2261. DataSet dsGroutingProduct = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2262. {
  2263. return PMModuleProxy.Service.GetGroutingProducttByBarCode(txtBarCode.Text.Trim());
  2264. }));
  2265. drNew["MouldCode"] = dsGroutingProduct.Tables[0].Rows[0]["MouldCode"];
  2266. drNew["GroutingUserCode"] = dsGroutingProduct.Tables[0].Rows[0]["GroutingUserCode"];
  2267. drNew["GroutingNum"] = dsGroutingProduct.Tables[0].Rows[0]["GroutingNum"];
  2268. drNew["IsPublicBody"] = dsGroutingProduct.Tables[0].Rows[0]["IsPublicBody"].ToString() != "1" ? 0 : 1;
  2269. drNew["GroutingDate"] = Convert.ToDateTime(dsGroutingProduct.Tables[0].Rows[0]["GroutingDate"]);
  2270. drNew["LogoCodeName"] = dsGroutingProduct.Tables[0].Rows[0]["LogoName"] + "[" + dsGroutingProduct.Tables[0].Rows[0]["LogoCode"] + "]";
  2271. drNew["LogoID"] = dsGroutingProduct.Tables[0].Rows[0]["LogoID"];
  2272. TableProductionData.Rows.Add(drNew);
  2273. if (DSTable.Tables.IndexOf(this.txtBarCode.Text.Trim()) == -Constant.INT_IS_ONE)
  2274. {
  2275. DataTable dtProductionDefectData = new DataTable(this.txtBarCode.Text.Trim());
  2276. dtProductionDefectData.Columns.Add("BarCode");
  2277. dtProductionDefectData.Columns.Add("DefectID", typeof(decimal));
  2278. dtProductionDefectData.Columns.Add("DefectName");
  2279. dtProductionDefectData.Columns.Add("DefectCode");
  2280. dtProductionDefectData.Columns.Add("DefectPositionID", typeof(decimal));
  2281. dtProductionDefectData.Columns.Add("DefectPositionName");
  2282. dtProductionDefectData.Columns.Add("DefectPositionCode");
  2283. dtProductionDefectData.Columns.Add("DefectProcedureID", typeof(decimal));
  2284. dtProductionDefectData.Columns.Add("DefectProcedureName");
  2285. dtProductionDefectData.Columns.Add("DefectProcedureCode");
  2286. dtProductionDefectData.Columns.Add("DefectUserID", typeof(decimal));//责任员工
  2287. dtProductionDefectData.Columns.Add("DefectUserName");//责任员工
  2288. dtProductionDefectData.Columns.Add("DefectUserCode");//
  2289. dtProductionDefectData.Columns.Add("Jobs", typeof(decimal));//工种
  2290. dtProductionDefectData.Columns.Add("JobsText");//工种
  2291. dtProductionDefectData.Columns.Add("DefectRemarks");
  2292. dtProductionDefectData.Columns.Add("TempCount");
  2293. dtProductionDefectData.Columns.Add("ProductionDataID"); //生产数据ID
  2294. dtProductionDefectData.Columns.Add("DefectFineID"); //缺席扣罚ID
  2295. dtProductionDefectData.Columns.Add("DefectFineValue"); //缺席扣罚
  2296. dtProductionDefectData.Columns.Add("MissedUserID"); //漏检工号ID
  2297. dtProductionDefectData.Columns.Add("MissedUserCode"); //漏检工号编码
  2298. dtProductionDefectData.Columns.Add("MissedUserName"); //漏检工号名称
  2299. dtProductionDefectData.Columns.Add("IsAllowEdit"); //漏检工号名称
  2300. //新添加的 wangx 2016/1/6
  2301. dtProductionDefectData.Columns.Add("DefectDeductionID"); //缺陷扣除数ID
  2302. dtProductionDefectData.Columns.Add("DefectDeductionNum"); //缺陷扣除数
  2303. dtProductionDefectData.Columns.Add("IsOtherDefect"); //特殊缺陷
  2304. dtProductionDefectData.Columns.Add("CheckTime"); //缺陷检验时间
  2305. DSTable.Tables.Add(dtProductionDefectData);
  2306. }
  2307. this.dgvDefect.DataSource = DSTable.Tables[this.txtBarCode.Text.Trim()];//根据条码产生不同数据源
  2308. this.dgvProductionData.Rows[TableProductionData.Rows.Count - 1].Selected = true;
  2309. this.dgvDefect.DataSource = null;
  2310. this.dgvDefectStaff.DataSource = null;
  2311. this.lvPic.Clear();
  2312. // 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
  2313. this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
  2314. // 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
  2315. this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
  2316. // 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
  2317. this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
  2318. this._selectedRowIndex = TableProductionData.Rows.Count - 1;
  2319. //DataSet ds = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2320. //{
  2321. // return PMModuleProxy.Service.GetReworkProcedureByProcedureID(this._procedureID);
  2322. //}));
  2323. //ds.Tables[0].TableName = this.txtBarCode.Text.Trim();
  2324. //if (this.DSREWORK == null)
  2325. //{
  2326. // this.DSREWORK = new DataSet();
  2327. //}
  2328. //this.DSREWORK.Tables.Add(ds.Tables[0].Copy());
  2329. //// 返工工序数据源
  2330. //C_DGV_Cell_ListBoxComboBox C_DGV_Cell_ListBoxComboBox = dgvProductionData.Rows[_selectedRowIndex].Cells[4] as C_DGV_Cell_ListBoxComboBox;
  2331. //C_DGV_Cell_ListBoxComboBox.DataSource = ds.Tables[0];
  2332. //C_DGV_Cell_ListBoxComboBox.DisplayMember = "ReworkProcedureName";
  2333. //C_DGV_Cell_ListBoxComboBox.ValueMember = "ReworkProcedureID";
  2334. }
  2335. catch (Exception ex)
  2336. {
  2337. throw ex;
  2338. }
  2339. }
  2340. /// <summary>
  2341. /// 绑定到第一个DataGriwView数据源
  2342. /// </summary>
  2343. private void BindProductionDataEdit(DataSet dsCheckBarcode)
  2344. {
  2345. try
  2346. {
  2347. DataRow[] dr = TableProductionData.Select("BarCode='" + this.txtBarCode.Text.Trim() + "'");
  2348. if (dr.Length > Constant.INT_IS_ZERO)
  2349. {
  2350. // 不允许重复添加
  2351. return;
  2352. }
  2353. int SpecialRepairflag = (int)DoAsync(new BaseAsyncMethod(() =>
  2354. {
  2355. return PMModuleProxy.Service.GetSpecialRepairflagByBarcode(this.txtBarCode.Text.Trim());
  2356. }));
  2357. string KilnCarCode = string.Empty;
  2358. string KilnCode = string.Empty;
  2359. string Dictionaryvalue = string.Empty;
  2360. DataSet dsKilnCar = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2361. {
  2362. return PMModuleProxy.Service.GetKilnCarByBarCode(txtBarCode.Text.Trim());
  2363. }));
  2364. if (dsKilnCar != null && dsKilnCar.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  2365. {
  2366. KilnCarCode = dsKilnCar.Tables[0].Rows[0]["KilnCarCode"].ToString();
  2367. KilnCode = dsKilnCar.Tables[0].Rows[0]["KilnCode"].ToString();
  2368. Dictionaryvalue = dsKilnCar.Tables[0].Rows[0]["Dictionaryvalue"].ToString();
  2369. }
  2370. DataRow drNew = TableProductionData.NewRow();
  2371. drNew["ProductionDataID"] = this._productiondataid;
  2372. drNew["BarCode"] = this.txtBarCode.Text.Trim();
  2373. DataSet ds = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2374. {
  2375. return PMModuleProxy.Service.GetGoodsInfoBybarcode(this.txtBarCode.Text.Trim());
  2376. }));
  2377. if (ds != null && ds.Tables[0].Rows.Count > 0)
  2378. {
  2379. drNew["GoodsID"] = ds.Tables[0].Rows[0]["GoodsID"];
  2380. drNew["GoodsCode"] = ds.Tables[0].Rows[0]["GoodsCode"];
  2381. drNew["GoodsName"] = ds.Tables[0].Rows[0]["GoodsName"];
  2382. }
  2383. drNew["DefectFlagID"] = _dsGoodsLevel.Tables[0].Rows[0]["DefectFlagID"];
  2384. drNew["ReworkProcedureID"] = DBNull.Value;
  2385. drNew["Remarks"] = "";
  2386. drNew["UserID"] = UserID;
  2387. drNew["UserCode"] = UserCode;
  2388. drNew["UserName"] = UserName;
  2389. drNew["GoodsLevelTypeID"] = _dsGoodsLevel.Tables[0].Rows[0]["GoodsLevelTypeID"];
  2390. drNew["OrgGoodsLevelTypeID"] = -1;
  2391. drNew["SpecialRepairflag"] = SpecialRepairflag == 1 ? 1 : 0;
  2392. drNew["KilnCarCode"] = KilnCarCode;
  2393. drNew["KilnCode"] = KilnCode;
  2394. drNew["Dictionaryvalue"] = Dictionaryvalue;
  2395. // 校验条码是否重烧过
  2396. DataSet dsReFine = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2397. {
  2398. return PMModuleProxy.Service.GetReFine(this.txtBarCode.Text.Trim());
  2399. }));
  2400. if (dsReFine != null && dsReFine.Tables[0].Rows.Count > 0 && dsReFine.Tables[0].Rows[0]["IsReFire"].ToString() == "6")
  2401. {
  2402. drNew["ReFine"] = 1;
  2403. }
  2404. else
  2405. {
  2406. drNew["ReFine"] = 0;
  2407. }
  2408. drNew["UserCode"] = this.txtUserCode.Text.Trim();
  2409. // 由产品条码获取注浆信息
  2410. DataSet dsGroutingProduct = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2411. {
  2412. return PMModuleProxy.Service.GetGroutingProducttByBarCode(txtBarCode.Text.Trim());
  2413. }));
  2414. drNew["MouldCode"] = dsGroutingProduct.Tables[0].Rows[0]["MouldCode"];
  2415. drNew["GroutingUserCode"] = dsGroutingProduct.Tables[0].Rows[0]["GroutingUserCode"];
  2416. drNew["GroutingNum"] = dsGroutingProduct.Tables[0].Rows[0]["GroutingNum"];
  2417. drNew["IsPublicBody"] = dsGroutingProduct.Tables[0].Rows[0]["IsPublicBody"].ToString() != "1" ? 0 : 1;
  2418. drNew["GroutingDate"] = Convert.ToDateTime(dsGroutingProduct.Tables[0].Rows[0]["GroutingDate"]);
  2419. drNew["LogoCodeName"] = dsGroutingProduct.Tables[0].Rows[0]["LogoName"] + "[" + dsGroutingProduct.Tables[0].Rows[0]["LogoCode"] + "]";
  2420. drNew["LogoId"] = dsGroutingProduct.Tables[0].Rows[0]["LogoId"];
  2421. TableProductionData.Rows.Add(drNew);
  2422. if (DSTable.Tables.IndexOf(this.txtBarCode.Text.Trim()) == -Constant.INT_IS_ONE)
  2423. {
  2424. DataTable dtProductionDefectData = new DataTable(this.txtBarCode.Text.Trim());
  2425. dtProductionDefectData.Columns.Add("BarCode");
  2426. dtProductionDefectData.Columns.Add("DefectID", typeof(decimal));
  2427. dtProductionDefectData.Columns.Add("DefectName");
  2428. dtProductionDefectData.Columns.Add("DefectCode");
  2429. dtProductionDefectData.Columns.Add("DefectPositionID", typeof(decimal));
  2430. dtProductionDefectData.Columns.Add("DefectPositionName");
  2431. dtProductionDefectData.Columns.Add("DefectPositionCode");
  2432. dtProductionDefectData.Columns.Add("DefectProcedureID", typeof(decimal));
  2433. dtProductionDefectData.Columns.Add("DefectProcedureName");
  2434. dtProductionDefectData.Columns.Add("DefectProcedureCode");
  2435. dtProductionDefectData.Columns.Add("DefectUserID", typeof(decimal));//责任员工
  2436. dtProductionDefectData.Columns.Add("DefectUserName");//责任员工
  2437. dtProductionDefectData.Columns.Add("DefectUserCode");//
  2438. dtProductionDefectData.Columns.Add("Jobs", typeof(decimal));//工种
  2439. dtProductionDefectData.Columns.Add("JobsText");//工种
  2440. dtProductionDefectData.Columns.Add("DefectRemarks");
  2441. dtProductionDefectData.Columns.Add("TempCount");
  2442. dtProductionDefectData.Columns.Add("ProductionDataID"); //生产数据ID
  2443. dtProductionDefectData.Columns.Add("DefectFineID"); //缺席扣罚ID
  2444. dtProductionDefectData.Columns.Add("DefectFineValue"); //缺席扣罚
  2445. dtProductionDefectData.Columns.Add("MissedUserID"); //漏检工号ID
  2446. dtProductionDefectData.Columns.Add("MissedUserCode"); //漏检工号编码
  2447. dtProductionDefectData.Columns.Add("MissedUserName"); //漏检工号名称
  2448. dtProductionDefectData.Columns.Add("IsAllowEdit"); //允许编辑
  2449. //新添加的 wangx 2016/1/6
  2450. dtProductionDefectData.Columns.Add("DefectDeductionID"); //缺陷扣除数ID
  2451. dtProductionDefectData.Columns.Add("DefectDeductionNum"); //缺陷扣除数
  2452. dtProductionDefectData.Columns.Add("IsOtherDefect"); //特殊缺陷
  2453. dtProductionDefectData.Columns.Add("CheckTime"); //缺陷检验时间
  2454. DSTable.Tables.Add(dtProductionDefectData);
  2455. }
  2456. this.dgvDefect.DataSource = DSTable.Tables[this.txtBarCode.Text.Trim()];//根据条码产生不同数据源
  2457. this.dgvProductionData.Rows[TableProductionData.Rows.Count - 1].Selected = true;
  2458. this.dgvDefect.DataSource = null;
  2459. this.dgvDefectStaff.DataSource = null;
  2460. this.lvPic.Clear();
  2461. // 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
  2462. this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
  2463. // 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
  2464. this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
  2465. // 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
  2466. this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
  2467. this._selectedRowIndex = TableProductionData.Rows.Count - 1;
  2468. }
  2469. catch (Exception ex)
  2470. {
  2471. throw ex;
  2472. }
  2473. }
  2474. /// <summary>
  2475. /// 绑定到第一个DataGriwView数据源
  2476. /// </summary>
  2477. private void BindProductionData(DataSet dsCheckBarcode)
  2478. {
  2479. try
  2480. {
  2481. DataRow[] dr = TableProductionData.Select("BarCode='" + this.txtBarCode.Text.Trim() + "'");
  2482. if (dr.Length > Constant.INT_IS_ZERO)
  2483. {
  2484. // 不允许重复添加
  2485. return;
  2486. }
  2487. int SpecialRepairflag = 0;
  2488. if (dsCheckBarcode == null || dsCheckBarcode.Tables[0].Rows.Count == 0)
  2489. {
  2490. SpecialRepairflag = (int)DoAsync(new BaseAsyncMethod(() =>
  2491. {
  2492. return PMModuleProxy.Service.GetSpecialRepairflagByBarcode(this.txtBarCode.Text.Trim());
  2493. }));
  2494. }
  2495. else
  2496. {
  2497. SpecialRepairflag = Convert.ToInt32(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_specialRepairFlag.ToString()]);
  2498. }
  2499. string KilnCarCode = string.Empty;
  2500. string KilnCode = string.Empty;
  2501. string Dictionaryvalue = string.Empty;
  2502. DataSet dsKilnCar = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2503. {
  2504. return PMModuleProxy.Service.GetKilnCarByBarCode(txtBarCode.Text.Trim());
  2505. }));
  2506. if (dsKilnCar != null && dsKilnCar.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  2507. {
  2508. KilnCarCode = dsKilnCar.Tables[0].Rows[0]["KilnCarCode"].ToString();
  2509. KilnCode = dsKilnCar.Tables[0].Rows[0]["KilnCode"].ToString();
  2510. Dictionaryvalue = dsKilnCar.Tables[0].Rows[0]["Dictionaryvalue"].ToString();
  2511. }
  2512. DataRow drNew = TableProductionData.NewRow();
  2513. drNew["BarCode"] = this.txtBarCode.Text.Trim();
  2514. if (dsCheckBarcode != null)
  2515. {
  2516. drNew["GoodsID"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsID.ToString()];
  2517. drNew["GoodsCode"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsCode.ToString()];
  2518. drNew["GoodsName"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsName.ToString()];
  2519. }
  2520. else
  2521. {
  2522. DataSet ds = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2523. {
  2524. return PMModuleProxy.Service.GetGoodsInfoBybarcode(this.txtBarCode.Text.Trim());
  2525. }));
  2526. if (ds != null && ds.Tables[0].Rows.Count > 0)
  2527. {
  2528. drNew["GoodsID"] = ds.Tables[0].Rows[0]["GoodsID"];
  2529. drNew["GoodsCode"] = ds.Tables[0].Rows[0]["GoodsCode"];
  2530. drNew["GoodsName"] = ds.Tables[0].Rows[0]["GoodsName"];
  2531. }
  2532. }
  2533. drNew["UserID"] = UserID;
  2534. drNew["KilnCarCode"] = KilnCarCode;
  2535. drNew["KilnCode"] = KilnCode;
  2536. drNew["Dictionaryvalue"] = Dictionaryvalue;
  2537. //xuwei modify 2019-12-12
  2538. //drNew["DefectFlagID"] = _dsGoodsLevel.Tables[0].Rows[0]["DefectFlagID"];
  2539. drNew["DefectFlagID"] = _dsGoodsLevel.Tables[0].Rows[0]["GOODSLEVELID"];
  2540. drNew["ReworkProcedureID"] = DBNull.Value;
  2541. drNew["Remarks"] = "";
  2542. drNew["UserID"] = UserID;
  2543. drNew["UserCode"] = UserCode;
  2544. drNew["UserName"] = UserName;
  2545. drNew["GoodsLevelTypeID"] = _dsGoodsLevel.Tables[0].Rows[0]["GoodsLevelTypeID"];
  2546. drNew["OrgGoodsLevelTypeID"] = -1;
  2547. drNew["SpecialRepairflag"] = SpecialRepairflag == 1 ? 1 : 0;
  2548. drNew["LogoCodeName"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoName.ToString()]
  2549. + "[" + dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoCode.ToString()] + "]";
  2550. drNew["LogoID"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoID.ToString()];
  2551. // 校验条码是否重烧过
  2552. DataSet dsReFine = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2553. {
  2554. return PMModuleProxy.Service.GetReFine(this.txtBarCode.Text.Trim());
  2555. }));
  2556. if (dsReFine != null && dsReFine.Tables[0].Rows.Count > 0 && dsReFine.Tables[0].Rows[0]["IsReFire"].ToString() == "6")
  2557. {
  2558. drNew["ReFine"] = 1;
  2559. }
  2560. else
  2561. {
  2562. drNew["ReFine"] = 0;
  2563. }
  2564. if (dsCheckBarcode == null || dsCheckBarcode.Tables[0].Rows.Count == 0)
  2565. {
  2566. // 由产品条码获取注浆信息
  2567. DataSet dsGroutingProduct = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2568. {
  2569. return PMModuleProxy.Service.GetGroutingProducttByBarCode(txtBarCode.Text.Trim());
  2570. }));
  2571. drNew["UserCode"] = this.txtUserCode.Text.Trim();
  2572. drNew["MouldCode"] = dsGroutingProduct.Tables[0].Rows[0]["MouldCode"];
  2573. drNew["GroutingUserCode"] = dsGroutingProduct.Tables[0].Rows[0]["GroutingUserCode"];
  2574. drNew["GroutingNum"] = dsGroutingProduct.Tables[0].Rows[0]["GroutingNum"];
  2575. drNew["IsPublicBody"] = dsGroutingProduct.Tables[0].Rows[0]["IsPublicBody"].ToString() != "1" ? 0 : 1;
  2576. drNew["GroutingDate"] = Convert.ToDateTime(dsGroutingProduct.Tables[0].Rows[0]["GroutingDate"]);
  2577. }
  2578. else
  2579. {
  2580. drNew["UserCode"] = this.txtUserCode.Text.Trim();
  2581. drNew["MouldCode"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_mouldCode.ToString()];
  2582. drNew["GroutingUserCode"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()];
  2583. drNew["GroutingNum"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingNum.ToString()];
  2584. drNew["IsPublicBody"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_ispublicbody.ToString()].ToString() != "1" ? 0 : 1;
  2585. drNew["GroutingDate"] = Convert.ToDateTime(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingdate.ToString()]);
  2586. }
  2587. TableProductionData.Rows.Add(drNew);
  2588. if (DSTable.Tables.IndexOf(this.txtBarCode.Text.Trim()) == -Constant.INT_IS_ONE)
  2589. {
  2590. DataTable dtProductionDefectData = new DataTable(this.txtBarCode.Text.Trim());
  2591. dtProductionDefectData.Columns.Add("BarCode");
  2592. dtProductionDefectData.Columns.Add("DefectID", typeof(decimal));
  2593. dtProductionDefectData.Columns.Add("DefectName");
  2594. dtProductionDefectData.Columns.Add("DefectCode");
  2595. dtProductionDefectData.Columns.Add("DefectPositionID", typeof(decimal));
  2596. dtProductionDefectData.Columns.Add("DefectPositionName");
  2597. dtProductionDefectData.Columns.Add("DefectPositionCode");
  2598. dtProductionDefectData.Columns.Add("DefectProcedureID", typeof(decimal));
  2599. dtProductionDefectData.Columns.Add("DefectProcedureName");
  2600. dtProductionDefectData.Columns.Add("DefectProcedureCode");
  2601. dtProductionDefectData.Columns.Add("DefectUserID", typeof(decimal));//责任员工
  2602. dtProductionDefectData.Columns.Add("DefectUserName");//责任员工
  2603. dtProductionDefectData.Columns.Add("DefectUserCode");//
  2604. dtProductionDefectData.Columns.Add("Jobs", typeof(decimal));//工种
  2605. dtProductionDefectData.Columns.Add("JobsText");//工种
  2606. dtProductionDefectData.Columns.Add("DefectRemarks");
  2607. dtProductionDefectData.Columns.Add("TempCount");
  2608. dtProductionDefectData.Columns.Add("ProductionDataID"); //生产数据ID
  2609. dtProductionDefectData.Columns.Add("DefectFineID"); //缺席扣罚ID
  2610. dtProductionDefectData.Columns.Add("DefectFineValue"); //缺席扣罚
  2611. dtProductionDefectData.Columns.Add("MissedUserID"); //漏检工号ID
  2612. dtProductionDefectData.Columns.Add("MissedUserCode"); //漏检工号编码
  2613. dtProductionDefectData.Columns.Add("MissedUserName"); //漏检工号名称
  2614. dtProductionDefectData.Columns.Add("IsAllowEdit"); //允许编辑
  2615. //新添加的 wangx 2016/1/6
  2616. dtProductionDefectData.Columns.Add("DefectDeductionID"); //缺陷扣除数ID
  2617. dtProductionDefectData.Columns.Add("DefectDeductionNum"); //缺陷扣除数
  2618. dtProductionDefectData.Columns.Add("IsOtherDefect"); //特殊缺陷
  2619. dtProductionDefectData.Columns.Add("CheckTime"); //缺陷检验时间
  2620. DSTable.Tables.Add(dtProductionDefectData);
  2621. }
  2622. this.dgvDefect.DataSource = DSTable.Tables[this.txtBarCode.Text.Trim()];//根据条码产生不同数据源
  2623. this.dgvProductionData.Rows[TableProductionData.Rows.Count - 1].Selected = true;
  2624. this.dgvDefect.DataSource = null;
  2625. this.dgvDefectStaff.DataSource = null;
  2626. this.lvPic.Clear();
  2627. // 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
  2628. this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
  2629. // 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
  2630. this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
  2631. // 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
  2632. this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
  2633. this._selectedRowIndex = TableProductionData.Rows.Count - 1;
  2634. //DataTable dt = this._dsGoodsLevel.Tables[0];
  2635. //DataView dv = dt.DefaultView;
  2636. //dv.RowFilter = "GoodsLevelTypeID>=" + goodsLevelTypeID;
  2637. //DataSet ds = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  2638. //{
  2639. // return PMModuleProxy.Service.GetReworkProcedureByProcedureID(this._procedureID);
  2640. //}));
  2641. //ds.Tables[0].TableName = this.txtBarCode.Text.Trim();
  2642. //if (this.DSREWORK == null)
  2643. //{
  2644. // this.DSREWORK = new DataSet();
  2645. //}
  2646. //this.DSREWORK.Tables.Add(ds.Tables[0].Copy());
  2647. //// 返工工序数据源
  2648. //C_DGV_Cell_ListBoxComboBox C_DGV_Cell_ListBoxComboBox = dgvProductionData.Rows[_selectedRowIndex].Cells[4] as C_DGV_Cell_ListBoxComboBox;
  2649. //C_DGV_Cell_ListBoxComboBox.DataSource = ds.Tables[0];
  2650. //C_DGV_Cell_ListBoxComboBox.DisplayMember = "ReworkProcedureName";
  2651. //C_DGV_Cell_ListBoxComboBox.ValueMember = "ReworkProcedureID";
  2652. }
  2653. catch (Exception ex)
  2654. {
  2655. throw ex;
  2656. }
  2657. }
  2658. /// <summary>
  2659. /// 通过是否有缺陷来启用或禁用
  2660. /// </summary>
  2661. /// <param name="DefectFlag"></param>
  2662. private void SetGridView(int GoodsLevelID)
  2663. {
  2664. DataTable dtDefectFlag = this.DefectFlag.DataSource as DataTable;//获取缺陷数据源
  2665. int GoodsLevelTypeID = -1;
  2666. //xuwei modify 2019-12-12
  2667. //DataRow[] dr = dtDefectFlag.Select("DefectFlagID=" + GoodsLevelID);
  2668. DataRow[] dr = dtDefectFlag.Select("GoodsLevelID=" + GoodsLevelID);
  2669. if (dr.Length > Constant.INT_IS_ZERO)
  2670. {
  2671. GoodsLevelTypeID = Convert.ToInt32(dr[0]["GoodsLevelTypeID"]);
  2672. this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["GoodsLevelTypeID"].Value = GoodsLevelTypeID;
  2673. }
  2674. if (GoodsLevelTypeID != -Constant.INT_IS_ONE)
  2675. {
  2676. this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureID"].Value = DBNull.Value;
  2677. this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureCode"].Value = string.Empty;
  2678. this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureName"].Value = string.Empty;
  2679. //xuwei modify 2019-12-13
  2680. if (GoodsLevelTypeID == (int)Constant.GoodsLevelType.NoDefects) //良品
  2681. {
  2682. this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureID"].ReadOnly = true;
  2683. try
  2684. {
  2685. string BarCode = this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["BarCode"].Value.ToString();
  2686. if (DSTable.Tables.Contains(BarCode))
  2687. {
  2688. DSTable.Tables[BarCode].Rows.Clear();//清空行
  2689. }
  2690. this.dgvDefectStaff.DataSource = null;
  2691. this.lvPic.Clear();
  2692. }
  2693. catch (Exception ex)
  2694. {
  2695. throw ex;
  2696. }
  2697. }
  2698. else if (GoodsLevelTypeID == (int)Constant.GoodsLevelType.NoDefects) //次品 或者正品
  2699. {
  2700. this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureID"].ReadOnly = true;
  2701. }
  2702. else if (GoodsLevelTypeID == (int)Constant.GoodsLevelType.ReFire)//重烧
  2703. {
  2704. this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureID"].ReadOnly = false;
  2705. }
  2706. else if (GoodsLevelTypeID == (int)Constant.GoodsLevelType.Substandard)//重烧
  2707. {
  2708. // this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["GoodsLevelTypeID"].Value = GoodsLevelTypeID;
  2709. this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureID"].ReadOnly = false;
  2710. }
  2711. }
  2712. }
  2713. /// <summary>
  2714. /// 清空以前所选中的缺陷
  2715. /// </summary>
  2716. /// <param name="checkValue"></param>
  2717. private void SetCheckBoxSelected(int checkValue, int rowIndex)
  2718. {
  2719. DataTable dtOrgDataSource = this.dgvDefect.DataSource as DataTable;
  2720. for (int i = 0; i < DSTable.Tables[dtOrgDataSource.TableName].Rows.Count; i++)
  2721. {
  2722. if (i == rowIndex)
  2723. {
  2724. dtOrgDataSource.Rows[i]["discarde"] = 1;
  2725. }
  2726. else
  2727. {
  2728. dtOrgDataSource.Rows[i]["discarde"] = 0;
  2729. }
  2730. }
  2731. }
  2732. /// <summary>
  2733. /// 绑定并显示图片
  2734. /// </summary>
  2735. /// <param name="ImageData"></param>
  2736. public void BindByteImage(DataTable ImageData)
  2737. {
  2738. this._smallByte.Clear();
  2739. foreach (DataRow dr in ImageData.Rows)
  2740. {
  2741. //将数据库中的缩略图取出
  2742. this._smallByte.Add((byte[])dr[1]);
  2743. }
  2744. //绑定缩略图
  2745. BindImg();
  2746. }
  2747. /// <summary>
  2748. /// 将图片文件转换成二进制
  2749. /// </summary>
  2750. /// <param name="img"></param>
  2751. /// <returns></returns>
  2752. public static byte[] ImageToByte(Image img)
  2753. {
  2754. byte[] smallbuffer = null;
  2755. using (MemoryStream ms = new MemoryStream())
  2756. {
  2757. img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
  2758. ms.Position = Constant.INT_IS_ZERO;
  2759. smallbuffer = new byte[ms.Length];
  2760. ms.Read(smallbuffer, Constant.INT_IS_ZERO, Convert.ToInt32(ms.Length));
  2761. ms.Flush();
  2762. }
  2763. return smallbuffer;
  2764. }
  2765. /// <SUMMARY>
  2766. /// 重绘缩略图并把缩略图转为二进制储存
  2767. /// </SUMMARY>
  2768. /// <PARAM name="sourceFile">图片源路径</PARAM>
  2769. /// <PARAM name="destHeight">缩放后图片高度</PARAM>
  2770. /// <PARAM name="destWidth">缩放后图片宽度</PARAM>
  2771. /// <RETURNS></RETURNS>
  2772. public void GetThumbnail(FileInfo sourceFile, byte[] orgImageByte)
  2773. {
  2774. Image imgSource = Image.FromStream(sourceFile.OpenRead());
  2775. ImageFormat thisFormat = imgSource.RawFormat;
  2776. int sW = 0, sH = 0;
  2777. // 按比例缩放
  2778. int sWidth = imgSource.Width;
  2779. int sHeight = imgSource.Height;
  2780. int destWidth = 100;
  2781. int destHeight = getSmallImageHeight(sWidth, sHeight, destWidth);
  2782. if (sHeight > destHeight || sWidth > destWidth)
  2783. {
  2784. if ((sWidth * destHeight) > (sHeight * destWidth))
  2785. {
  2786. sW = destWidth;
  2787. sH = (destWidth * sHeight) / sWidth;
  2788. }
  2789. else
  2790. {
  2791. sH = destHeight;
  2792. sW = (sWidth * destHeight) / sHeight;
  2793. }
  2794. }
  2795. else
  2796. {
  2797. sW = sWidth;
  2798. sH = sHeight;
  2799. }
  2800. Bitmap outBmp = new Bitmap(destWidth, destHeight);
  2801. Graphics g = Graphics.FromImage(outBmp);
  2802. g.Clear(Color.Black);
  2803. // 设置画布的描绘质量
  2804. g.CompositingQuality = CompositingQuality.HighQuality;
  2805. g.SmoothingMode = SmoothingMode.HighQuality;
  2806. g.InterpolationMode = InterpolationMode.HighQualityBicubic;
  2807. g.DrawImage(imgSource, new Rectangle((destWidth - sW) / 2, (destHeight - sH) / 2, sW, sH), 0, 0, imgSource.Width, imgSource.Height, GraphicsUnit.Pixel);
  2808. g.Dispose();
  2809. //将重绘的图片转为二进制并保存
  2810. Image image = (Image)outBmp;
  2811. byte[] smallbuffer = ImageToByte(image);
  2812. if (this._currentTempSign != string.Empty)
  2813. {
  2814. if (!this.DSTableImage.Tables.Contains(string.Format("TempTable{0}", this._currentTempSign.ToString())))
  2815. {
  2816. DataTable dtImage = new DataTable(string.Format("TempTable{0}", this._currentTempSign.ToString()));
  2817. dtImage.Columns.Add("StaffTempCount");
  2818. dtImage.Columns.Add("ImageByte", typeof(byte[]));
  2819. dtImage.Columns.Add("OrgImageByte", typeof(byte[]));
  2820. this.DSTableImage.Tables.Add(dtImage);
  2821. }
  2822. DataRow dr = DSTableImage.Tables[string.Format("TempTable{0}", this._currentTempSign)].NewRow();
  2823. dr["StaffTempCount"] = this._currentTempSign;
  2824. dr["ImageByte"] = smallbuffer;
  2825. dr["OrgImageByte"] = orgImageByte;
  2826. DSTableImage.Tables[string.Format("TempTable{0}", this._currentTempSign)].Rows.Add(dr);
  2827. }
  2828. this._smallByte.Add(smallbuffer);
  2829. imgSource.Dispose();
  2830. outBmp.Dispose();
  2831. }
  2832. /// <summary>
  2833. /// 根据原图片宽高比获取缩略图的高(根据宽)
  2834. /// </summary>
  2835. /// <param name="BigWidth"></param>
  2836. /// <param name="BigHeight"></param>
  2837. /// <param name="SmallWidth"></param>
  2838. /// <returns></returns>
  2839. protected int getSmallImageHeight(int BigWidth, int BigHeight, int SmallWidth)
  2840. {
  2841. decimal scale = Convert.ToDecimal(BigWidth) / Convert.ToDecimal(BigHeight);
  2842. return Convert.ToInt32(SmallWidth / scale);
  2843. }
  2844. /// <summary>
  2845. /// 绑定缩略图到控件中
  2846. /// </summary>
  2847. protected void BindImg()
  2848. {
  2849. ImageList ilPic = new ImageList();
  2850. //每次绑定要清空数据源
  2851. ilPic.Images.Clear();
  2852. //将缩略图二进制集合中的数据转换成图片文件
  2853. List<Image> LSImageList = new List<Image>();
  2854. foreach (byte[] smallby in _smallByte)
  2855. {
  2856. LSImageList.Add(byteArrayToImage(smallby));
  2857. }
  2858. //添加数据源
  2859. foreach (Image img in LSImageList)
  2860. {
  2861. ilPic.Images.Add(img);
  2862. }
  2863. ilPic.ImageSize = new Size(100, 100);
  2864. this.lvPic.LargeImageList = ilPic;
  2865. this.lvPic.BeginUpdate();
  2866. //清空列表的数据源
  2867. lvPic.Items.Clear();
  2868. //添加列表的数据源
  2869. for (int i = 0; i < ilPic.Images.Count; i++)
  2870. {
  2871. ListViewItem lvi = new ListViewItem();
  2872. lvi.ImageIndex = i;
  2873. this.lvPic.Items.Add(lvi);
  2874. }
  2875. this.lvPic.EndUpdate();
  2876. }
  2877. /// <summary>
  2878. /// 将数据库中的二进制转换成图片
  2879. /// </summary>
  2880. /// <param name="data"></param>
  2881. /// <returns></returns>
  2882. public static Image byteArrayToImage(object data)
  2883. {
  2884. System.IO.MemoryStream ms = new System.IO.MemoryStream((byte[])data);
  2885. System.Drawing.Image returnImage = System.Drawing.Image.FromStream(ms);
  2886. return returnImage;
  2887. }
  2888. #endregion
  2889. /// <summary>
  2890. /// 责任员工
  2891. /// </summary>
  2892. /// <param name="sender"></param>
  2893. /// <param name="e"></param>
  2894. private void dgvDefectStaff_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
  2895. {
  2896. try
  2897. {
  2898. if (e.Row.Index != -1)
  2899. {
  2900. if (this.dgvDefect.CurrentCell != null)
  2901. {
  2902. //是新增进来,加载条码是不允许删除的,只是编辑权限才能可以删除
  2903. 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")
  2904. {
  2905. e.Cancel = true;
  2906. return;
  2907. }
  2908. }
  2909. }
  2910. }
  2911. catch (Exception ex)
  2912. {
  2913. throw ex;
  2914. }
  2915. }
  2916. /// <summary>
  2917. /// 漏扫责任员工
  2918. /// </summary>
  2919. /// <param name="sender"></param>
  2920. /// <param name="e"></param>
  2921. private void dgvMissStaff_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
  2922. {
  2923. try
  2924. {
  2925. if (e.Row.Index != -1)
  2926. {
  2927. if (this.dgvDefect.CurrentCell != null)
  2928. {
  2929. //是新增进来,加载条码是不允许删除的,只是编辑权限才能可以删除
  2930. 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")
  2931. {
  2932. e.Cancel = true;
  2933. return;
  2934. }
  2935. }
  2936. }
  2937. }
  2938. catch (Exception ex)
  2939. {
  2940. throw ex;
  2941. }
  2942. }
  2943. }
  2944. }