| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079 |
- /*******************************************************************************
- * Copyright(c) 2019 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_PM_3202.cs
- * 2.功能描述:半检
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * xuwei 2019/12/12 1.00 新建
- *******************************************************************************/
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Drawing;
- using System.Drawing.Drawing2D;
- using System.Drawing.Imaging;
- using System.IO;
- using System.Windows.Forms;
- using Dongke.IBOSS.PRD.Basics.BaseControls;
- using Dongke.IBOSS.PRD.Basics.BaseResources;
- using Dongke.IBOSS.PRD.Client.CommonModule;
- using Dongke.IBOSS.PRD.Client.Controls.FormCommon;
- using Dongke.IBOSS.PRD.WCF.DataModels;
- using Dongke.IBOSS.PRD.WCF.DataModels.PMModule;
- using Dongke.IBOSS.PRD.WCF.Proxys;
- using Dongke.IBOSS.PRD.WCF.Proxys.PMModuleService;
- using Dongke.IBOSS.PRD.WCF.Proxys.SystemModuleService;
- namespace Dongke.IBOSS.PRD.Client.PMModule
- {
- /// <summary>
- /// 成品检验
- /// </summary>
- public partial class F_PM_3202 : FormBase
- {
- #region 成员变量
- // 工序ID
- private int _procedureID;
- // 生产工号
- private int _userID = -1;
- // 生产编号
- private string _userCode;
- // 生产名称
- private string _userName;
- // 工序实体类
- ProcedureEntity _procedureDataEntity;
- // 产品数据表
- DataTable _dtProductionData = null;
- // 产品缺陷数据表
- DataTable _dtProductionDefectData = null;
- // 当前选择的行
- private int _selectedRowIndex;
- // ComBoxEditingControl
- private DataGridViewComboBoxEditingControl _dataGridViewComboBox = null;
- // 当前产品条码的产品ID,用来查询缺陷位置
- private int _currentGoodsID = 0;
- // 当前产品条码,用来切换筛选列表数据
- private string _currentBarCode = "";
- // 当前产品缺陷
- private int _currentDefectFlag = 0;
- // 返工工序搜索列表对象
- C_DGV_Cell_ListBoxComboBox _C_DGV_Cell_ListBoxComboBox = null;
- // 过滤结果集
- private DataSet _ds = null;
- // 过滤员工结果集
- private DataSet _dsStaff = null;
- // 过滤缺陷图片
- private DataSet _dsImage = null;
- // 过滤漏检员工结果集
- private DataSet _dsMissdeStaff = null;
- // 临时数,用来过滤责任员工数据源标识
- private int _tempCount = 0;
- // 当前临时标记
- private string _currentTempSign = "";
- // 图片字节集
- private List<byte[]> _PicByte = new List<byte[]>();
- // 缩略图片字节集
- private List<byte[]> _smallByte = new List<byte[]>();
- // 当前产品缺陷
- private int _currentDefaultDefectFlag = 0;
- // 当前默认产品分级ID
- private int _currentGoodsLevelTypeID = 0;
- // 返工工序数据源
- private DataSet _dsRework = null;
- // 产品等级数据源
- private DataSet _dsGoodsLevel = null;
- //编辑生产数据ID
- private int _productiondataid = 0;
- // 是否查看
- private bool _isView = false;
- // 允许编辑
- private int _AllowEdit = 0;
- // 是否只读
- private int _ReadOnly = 0;// 1为只读
- // 时间戳
- private DateTime _optimestamp;
- // 成检登记改判限制天数
- private int _settingvaluedays = 0;
- #endregion
- #region 属性
- /// <summary>
- /// 条码返工工序数据源
- /// </summary>
- public DataSet DSREWORK
- {
- set
- {
- _dsRework = value;
- }
- get
- {
- if (_dsRework == null)
- {
- return _dsRework = new DataSet();
- }
- return _dsRework;
- }
- }
- /// <summary>
- /// 生产工号
- /// </summary>
- public int UserID
- {
- set
- {
- _userID = value;
- }
- get
- {
- return _userID;
- }
- }
- /// <summary>
- /// 生产编号
- /// </summary>
- public string UserCode
- {
- set
- {
- _userCode = value;
- }
- get
- {
- return _userCode;
- }
- }
- /// <summary>
- /// 用户名称
- /// </summary>
- public string UserName
- {
- set
- {
- _userName = value;
- }
- get
- {
- return _userName;
- }
- }
- /// <summary>
- /// 时间戳
- /// </summary>
- public DateTime PTimeStamp
- {
- get
- {
- return _optimestamp;
- }
- set
- {
- _optimestamp = value;
- }
- }
- /// <summary>
- /// 产品数据表
- /// </summary>
- public DataTable TableProductionData
- {
- set
- {
- _dtProductionData = value;
- }
- get
- {
- if (_dtProductionData == null)
- {
- _dtProductionData = new DataTable("ProductionData");
- _dtProductionData.Columns.Add("ProductionDataID");
- _dtProductionData.Columns.Add("BarCode");
- _dtProductionData.Columns.Add("GoodsID");
- _dtProductionData.Columns.Add("GoodsCode");
- _dtProductionData.Columns.Add("GoodsName");
- _dtProductionData.Columns.Add("DefectFlagID", typeof(decimal));
- _dtProductionData.Columns.Add("ReworkProcedureID", typeof(decimal));
- _dtProductionData.Columns.Add("Remarks");
- _dtProductionData.Columns.Add("UserID");
- _dtProductionData.Columns.Add("UserCode");
- _dtProductionData.Columns.Add("UserName");
- _dtProductionData.Columns.Add("GoodsLevelTypeID");
- _dtProductionData.Columns.Add("OrgGoodsLevelTypeID");//原产品分级ID
- _dtProductionData.Columns.Add("ReFine");//重烧标识
- _dtProductionData.Columns.Add("SpecialRepairflag");//干补标识
- _dtProductionData.Columns.Add("ReadOnly");//1 为 只读
- _dtProductionData.Columns.Add("KilnCarCode");
- _dtProductionData.Columns.Add("KilnCode");
- _dtProductionData.Columns.Add("Dictionaryvalue");
- _dtProductionData.Columns.Add("MouldCode");//模具编号
- _dtProductionData.Columns.Add("GroutingDate", typeof(DateTime));//注浆日期
- _dtProductionData.Columns.Add("GroutingUserCode");//成型工号
- _dtProductionData.Columns.Add("IsPublicBody");//公坯标识
- _dtProductionData.Columns.Add("GroutingNum");//注浆次数
- _dtProductionData.Columns.Add("OPTimeStamp", typeof(DateTime));//时间戳 记录在产记录的时间戳
- _dtProductionData.Columns.Add("LogoCodeName");//
- _dtProductionData.Columns.Add("LogoID");//
- _dtProductionData.Columns.Add("CheckTime");//
- return _dtProductionData;
- }
- else
- {
- return _dtProductionData;
- }
- }
- }
- /// <summary>
- /// 缺陷数据集
- /// </summary>
- public DataSet DSTable
- {
- set
- {
- _ds = value;
- }
- get
- {
- if (_ds == null)
- {
- _ds = new DataSet();
- return _ds;
- }
- else
- {
- return _ds;
- }
- }
- }
- /// <summary>
- /// 员工数据集
- /// </summary>
- public DataSet DSTableStaff
- {
- set
- {
- _dsStaff = value;
- }
- get
- {
- if (_dsStaff == null)
- {
- _dsStaff = new DataSet();
- return _dsStaff;
- }
- else
- {
- return _dsStaff;
- }
- }
- }
- /// <summary>
- /// 漏检员工数据集
- /// </summary>
- public DataSet DSTableMissedStaff
- {
- set
- {
- _dsMissdeStaff = value;
- }
- get
- {
- if (_dsMissdeStaff == null)
- {
- _dsMissdeStaff = new DataSet();
- return _dsMissdeStaff;
- }
- else
- {
- return _dsMissdeStaff;
- }
- }
- }
- /// <summary>
- /// 缺陷图片
- /// </summary>
- public DataSet DSTableImage
- {
- set
- {
- _dsImage = value;
- }
- get
- {
- if (_dsImage == null)
- {
- _dsImage = new DataSet();
- return _dsImage;
- }
- else
- {
- return _dsImage;
- }
- }
- }
- #endregion
- #region 构造函数
- public F_PM_3202()
- {
- InitializeComponent();
- }
- public F_PM_3202(int procedureID, string fromTitle)
- {
- InitializeComponent();
- this._procedureID = procedureID;
- this.Text = fromTitle;
- this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
- this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
- this.btnSave.Text = ButtonText.BTN_SAVE;
- this.btnCancel.Text = ButtonText.BTN_CLOSE;
- this.tsbtnClose.Text = ButtonText.TSBTN_TOOL_CLOSE;
- this.btnUpload.Text = ButtonText.BTN_UPLOAD;
- this.btnDelete.Text = ButtonText.BTN_DELETE;
- }
- public F_PM_3202(int procedureID, string fromTitle, int productiondataID, bool isView)
- {
- InitializeComponent();
- this._AllowEdit = 1;//允许编辑
- this._productiondataid = productiondataID;
- this._procedureID = procedureID;
- this.Text = fromTitle;
- this._isView = isView;
- this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
- this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
- this.btnSave.Text = ButtonText.BTN_SAVE;
- this.btnCancel.Text = ButtonText.BTN_CLOSE;
- this.tsbtnClose.Text = ButtonText.TSBTN_TOOL_CLOSE;
- this.btnUpload.Text = ButtonText.BTN_UPLOAD;
- this.btnDelete.Text = ButtonText.BTN_DELETE;
- }
- #endregion
- #region 事件
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void F_PM_3202_Load(object sender, System.EventArgs e)
- {
- try
- {
- this.dgvProductionData.AutoGenerateColumns = false;
- this.dgvProductionData.DataSource = null;
- this.dgvProductionData.DataSource = TableProductionData;
- this.dgvDefect.AutoGenerateColumns = false;
- this.dgvDefectStaff.AutoGenerateColumns = false;
- // 加载权限
- FormPermissionManager.FormPermissionControl(this.Name, this,
- Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
- Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
- // 获取工序明细数据
- ProcedureEntity procedureDataEntity = (ProcedureEntity)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetProcedureDataEntityByID(this._procedureID);
- }));
- this._procedureDataEntity = procedureDataEntity;
- // 产品分级数据源
- DataSet dsGoodsLevel = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- //xuwei modify 2019-12-12
- //return SystemModuleProxy.Service.GetGoodsLevel(2);//半成品检验
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "ProcedureSemi";
- cre.Name = "GetGoodsGradeDataSemi";
- cre.Properties["procedureId"] = procedureDataEntity.ProcedureID;
- return PMModuleProxyNew.Service.HandleRequest(cre).Data;
- }));
- if (dsGoodsLevel != null && dsGoodsLevel.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
- {
- //xuwei modify 2019-12-12
- //this.DefectFlag.DisplayMember = "DefectFlagName";
- //this.DefectFlag.ValueMember = "DefectFlagID";
- //this.DefectFlag.DataSource = dsGoodsLevel.Tables[0];
- //this._currentDefaultDefectFlag = Convert.ToInt32(dsGoodsLevel.Tables[0].Rows[0]["DefectFlagID"]);
- //this._currentGoodsLevelTypeID = Convert.ToInt32(dsGoodsLevel.Tables[0].Rows[0]["GoodsLevelTypeID"]);
- this.DefectFlag.DisplayMember = "GOODSLEVELNAME";
- this.DefectFlag.ValueMember = "GOODSLEVELID";
- this.DefectFlag.DataSource = dsGoodsLevel.Tables[0];
- this._currentDefaultDefectFlag = Convert.ToInt32(dsGoodsLevel.Tables[0].Rows[0]["GOODSLEVELID"]);
- this._currentGoodsLevelTypeID = Convert.ToInt32(dsGoodsLevel.Tables[0].Rows[0]["GOODSLEVELTYPEID"]);
- this._dsGoodsLevel = dsGoodsLevel;
- }
- DataSet ds = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetReworkProcedureByProcedureID(this._procedureID);
- }));
- //ds.Tables[0].TableName = this.txtBarCode.Text.Trim();
- if (this.DSREWORK == null)
- {
- this.DSREWORK = new DataSet();
- }
- this.DSREWORK.Tables.Add(ds.Tables[0].Copy());
- // 返工工序数据源
- //C_DGV_Cell_ListBoxComboBox C_DGV_Cell_ListBoxComboBox = dgvProductionData.Rows[_selectedRowIndex].Cells[4] as C_DGV_Cell_ListBoxComboBox;
- //C_DGV_Cell_ListBoxComboBox.DataSource = ds.Tables[0];
- //C_DGV_Cell_ListBoxComboBox.DisplayMember = "ReworkProcedureName";
- //C_DGV_Cell_ListBoxComboBox.ValueMember = "ReworkProcedureID";
- this.ReworkProcedureID.DataSource = ds.Tables[0];
- this.ReworkProcedureID.DisplayMember = "ReworkProcedureName";
- this.ReworkProcedureID.ValueMember = "ReworkProcedureID";
- // 2016-10-10 是否启用成检登记改判限制天数 wangx
- DataSet dsSetting = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return SystemModuleProxy.Service.GetSystemSettingDataByCode(Constant.SettingType.S_PM_009.ToString());
- }));
- if (dsSetting != null && dsSetting.Tables[0].Rows.Count > 0)
- {
- _settingvaluedays = Convert.ToInt32(dsSetting.Tables[0].Rows[0]["SettingValue"]);
- }
- // end
- // 设置控件禁用或启用
- SetControlEnable(); //判断此生产工号是否能成检
- if (this._productiondataid > Constant.INT_IS_ZERO)
- {
- SetEditDataSource();
- if (this._isView)
- {
- SetSubstandard();
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 设置控件禁用或启用
- /// </summary>
- private void SetControlEnable()
- {
- if (this._procedureDataEntity != null)
- {
- if (this._procedureDataEntity.CollectType == (int)Constant.ProcedureCollectType.Togather)
- {
- this.txtUserCode.Enabled = true;
- this.btnSave.Visible = true;
- }
- else
- {
- this.txtUserCode.Enabled = true;
- this.txtUserCode.ReadOnly = true;
- // 此工号是否能生产工序
- CheckProcedureUserResult checkProcedureUser = (CheckProcedureUserResult)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.CheckProcedureUser(this._procedureID,
- Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserCode);
- }));
- if (checkProcedureUser != null)
- {
- if (!string.IsNullOrEmpty(checkProcedureUser.ErrMsg))
- {
- // 此工号不允许生产工序
- MessageBox.Show(checkProcedureUser.ErrMsg,
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- this.Close();
- return;
- }
- }
- UserID = checkProcedureUser.UserID;
- UserCode = checkProcedureUser.UserCode;
- UserName = checkProcedureUser.UserName;
- }
- this.txtUserCode.Text = UserCode;
- }
- }
- /// <summary>
- /// 条形码按键事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void txtBarCode_KeyPress(object sender, KeyPressEventArgs e)
- {
- try
- {
- this._ReadOnly = 0;//防止输入前一个条码为只读时,在输入另一个条码永远是只读
- if (this.txtBarCode.ReadOnly)
- {
- return;
- }
- if ((int)e.KeyChar == 13) // 按了回车键
- {
- if (this.txtUserCode.Text.Trim() == string.Empty)
- {
- this.txtUserCode.Focus();
- this.txtBarCode.Text = string.Empty;
- return;
- }
- if (this.txtBarCode.Text.Trim() == string.Empty)
- {
- this.txtBarCode.Focus();
- return;
- }
- //检验之前查是否编辑还是新增
- SearchProductionDataEntity searchProductionDataEntity = new SearchProductionDataEntity();
- searchProductionDataEntity.ProcedureID = this._procedureID;
- searchProductionDataEntity.BarCode = this.txtBarCode.Text.Trim();
- DataTable ProductionData = (DataTable)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetProductionDataPDA(searchProductionDataEntity);
- }));
- if (ProductionData != null && ProductionData.Rows.Count > 0) //走过当前的工序,从大到小排序,取行一永远是最后一条数据,获取生产数据ID
- {
- // 尽管等于当前工序,但是如果该条码又插入了一条生产数据,在编辑此数据时,也应该为只读,即重烧后添加的生产数据,编辑上一次生产数据ID
- int CompleteProductionDataID = (int)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetCompleteProductionDataID(this.txtBarCode.Text.Trim());
- }));
- // 走过的当前工序与在产工序相同,即在此工序上,未走到其它工序上,应该直接编辑,
- // 走过的当前工序与在产工序不相同时,首先校验条码,如果条码通过,还需判断是否重烧,及干补
- if (Convert.ToInt32(ProductionData.Rows[0]["ProductionDataID"]) == CompleteProductionDataID)
- {
- this._productiondataid = Convert.ToInt32(ProductionData.Rows[0]["productiondataid"]);
- ////是否己报损,如果已经报损也是查看记录
- //DataSet dsReturn = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- //{
- // return PMModuleProxy.Service.GetSubstandardInfo(this.txtBarCode.Text.Trim());
- //}));
- //if (dsReturn != null && dsReturn.Tables[0].Rows.Count > 0) //有报损记录
- //{
- // this._ReadOnly = 1;
- //}
- //if (dsReturn != null && dsReturn.Tables[0].Rows.Count == 0)
- //{
- int auditstatus = (int)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.CheckScrapProduct(this.txtBarCode.Text.Trim());
- }));
- if (auditstatus != -100)
- {
- //this._ReadOnly = 1;
- if (auditstatus == 0)
- {
- MessageBox.Show("该条码:" + this.txtBarCode.Text.Trim() + "存在报损记录(待审批)", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- else
- {
- MessageBox.Show("该条码:" + this.txtBarCode.Text.Trim() + "存在报损记录(审批通过)", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- this.txtBarCode.SelectAll();
- this.txtBarCode.Focus();
- return;
- }
- //}
- DataRow[] dr = TableProductionData.Select("BarCode='" + this.txtBarCode.Text.Trim() + "'");
- if (dr.Length > Constant.INT_IS_ZERO)
- {
- // 不允许重复添加
- this.txtBarCode.Text = "";
- return;
- }
- SetEditDataSource();
- this._currentBarCode = txtBarCode.Text.Trim();
- this.txtBarCode.Text = string.Empty;
- if (this._procedureDataEntity.CollectType == (int)Constant.ProcedureCollectType.Togather)//集中
- {
- this.txtUserCode.Enabled = true;
- this.txtBarCode.Enabled = true;
- }
- else
- {
- this.txtBarCode.Enabled = true;
- }
- }
- else
- {
- DataSet dsProductionDataByID = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetProductionDataByID(this._productiondataid);
- }));
- if (dsProductionDataByID != null && dsProductionDataByID.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
- {
- #region 如果是次品,回收后不允许编辑
- if (Convert.ToInt32(dsProductionDataByID.Tables[0].Rows[0]["GoodsLevelTypeID"]) == 7)//次品
- {
- int recyclingflag = (int)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetRecyclingflagByBarcode(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString());
- }));
- if (recyclingflag > 0)
- {
- MessageBox.Show("此产品已经回收,不能改判", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- this.txtBarCode.Enabled = true;
- this.txtBarCode.Focus();
- return;
- }
- }
- #endregion
- }
- //int recyclingflag = (int)DoAsync(new BaseAsyncMethod(() =>
- //{
- // return PMModuleProxy.Service.GetRecyclingflagByBarcode(this.txtBarCode.Text.Trim());
- //}));
- //if (recyclingflag > 0)
- //{
- // MessageBox.Show("【此产品已经回收,不能改判】", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- // this.txtBarCode.Enabled = true;
- // this.txtBarCode.Focus();
- // return;
- //}
- DataSet dsInProductionDataList = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetInProductionDataList(this.txtBarCode.Text.Trim());
- }));
- //当生产数据ID与当前工序生产数据ID不等时,还有一种况就是正品报废干补回来
- if (dsInProductionDataList.Tables[0].Rows.Count > 0 && dsInProductionDataList.Tables[0].Rows[0]["FlowProcedureID"].ToString() == this._procedureID.ToString())
- {
- //新增
- this._productiondataid = Convert.ToInt32(ProductionData.Rows[0]["ProductionDataID"]);
- BindProductionDataEdit(null);
- this._currentBarCode = txtBarCode.Text.Trim();
- this.txtBarCode.Text = string.Empty;
- }
- else
- {
- //如果不相等的应该提示不允许编辑,因为尽管条码有效,但是并不在此工序流程中,只能列表搜索后进行编辑(只读查看)
- //但是还需要判断当前产品,是否重烧及干补,如果这两个都不是从而进行提示
- //1.校验条码是否有效
- // 校验条码 获取校验条码
- DataSet dsCheckBarcode = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.CheckBarcode(this._procedureID, this.txtBarCode.Text.Trim());
- }));
- if (dsCheckBarcode != null && dsCheckBarcode.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
- {
- if (dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString() != string.Empty)
- {
- //MessageBox.Show(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString(), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- //this.txtBarCode.SelectAll();
- //this.txtBarCode.Focus();
- //return;
- if (dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_missFlag.ToString()].ToString() == "0")
- {
- // 表示有错误
- MessageBox.Show(string.Format(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString(), this.txtBarCode.Text.Trim(), "产品条码"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- else
- {
- S_CMN_020 frmscmn020 = new S_CMN_020(Convert.ToInt32(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_missFlag.ToString()])
- , dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString());
- frmscmn020.ShowDialog();
- }
- this.txtBarCode.Focus();
- this.txtBarCode.SelectAll();
- return;
- }
- else
- {
- #region 校验条码无错误 无论干补或者重烧只查在产表就可以
- //DataSet dsInProductionDataList = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- //{
- // return PMModuleProxy.Service.GetInProductionDataList(this.txtBarCode.Text.Trim());
- //}));
- // 只有干补才会出现这种情况
- if (dsInProductionDataList.Tables[0].Rows[0]["FlowProcedureID"].ToString() != dsInProductionDataList.Tables[0].Rows[0]["ProcedureID"].ToString())
- {
- //新增
- BindProductionData(dsCheckBarcode);
- this._currentBarCode = txtBarCode.Text.Trim();
- this.txtBarCode.Text = string.Empty;
- }
- else if (dsInProductionDataList.Tables[0].Rows[0]["FlowProcedureID"].ToString() == dsInProductionDataList.Tables[0].Rows[0]["ProcedureID"].ToString()
- && dsInProductionDataList.Tables[0].Rows[0]["IsReFire"].ToString() == "6") //重烧
- {
- //新增
- this._productiondataid = Convert.ToInt32(ProductionData.Rows[0]["productiondataid"]);
- BindProductionDataReFine(dsCheckBarcode);//说明重烧后回来成检
- this._currentBarCode = txtBarCode.Text.Trim();
- this.txtBarCode.Text = string.Empty;
- }
- else
- {
- // 要不不显示,要不显示,应该过滤掉
- this._productiondataid = Convert.ToInt32(ProductionData.Rows[0]["productiondataid"]);
- this._ReadOnly = 1;
- SetEditDataSource();
- this._currentBarCode = txtBarCode.Text.Trim();
- this.txtBarCode.Text = string.Empty;//////////但是只是显示,这个应该不能编辑,及提交的时候不应该保存
- }
- #endregion
- }
- }//--------------------------校验条码结束括号---------------------------------------------------------------
- }//--------------------------else结束括号---------------------------------------------------------------
- }
- }
- else //未走过当前工序
- {
- // 校验条码 获取校验条码信
- DataSet dsCheckBarcode = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.CheckBarcode(this._procedureID, this.txtBarCode.Text.Trim());
- }));
- if (dsCheckBarcode != null && dsCheckBarcode.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
- {
- if (dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString() != string.Empty)
- {
- // 表示有错误
- //MessageBox.Show(string.Format(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString(), this.txtBarCode.Text.Trim(), "产品条码"),
- // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- //this.txtBarCode.Focus();
- //return;
- if (dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_missFlag.ToString()].ToString() == "0")
- {
- // 表示有错误
- MessageBox.Show(string.Format(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString(), this.txtBarCode.Text.Trim(), "产品条码"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- else
- {
- S_CMN_020 frmscmn020 = new S_CMN_020(Convert.ToInt32(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_missFlag.ToString()])
- , dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString());
- frmscmn020.ShowDialog();
- }
- this.txtBarCode.Focus();
- this.txtBarCode.SelectAll();
- return;
- }
- else
- {
- BindProductionData(dsCheckBarcode);//从来未走过此工序
- this._currentBarCode = txtBarCode.Text.Trim();
- this.txtBarCode.Text = string.Empty;
- }
- }
- }
- //if (ProductionData != null && ProductionData.Rows.Count > 0) //走过当前的工序,从大到小排序,取行一永远是最后一条数据,获取生产数据ID
- //{
- // DataSet dsReFine = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- // {
- // return PMModuleProxy.Service.GetReFine(this.txtBarCode.Text.Trim()); //生产数据取重烧标识
- // }));
- // // 重烧标识
- // if (dsReFine != null && dsReFine.Tables[0].Rows.Count > 0 && dsReFine.Tables[0].Rows[0]["IsReFire"].ToString() == "6")
- // {
- // int GetCompleteProcedureID = (int)DoAsync(new BaseAsyncMethod(() =>
- // {
- // return PMModuleProxy.Service.GetCompleteProcedureID(this.txtBarCode.Text.Trim());
- // }));
- // if (GetCompleteProcedureID != this._procedureID)//流程工序不等于当前工序
- // {
- // // 校验条码 获取校验条码
- // DataSet dsCheckBarcode = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- // {
- // return PMModuleProxy.Service.CheckBarcode(this._procedureID, this.txtBarCode.Text.Trim());
- // }));
- // if (dsCheckBarcode != null && dsCheckBarcode.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
- // {
- // if (dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString() != string.Empty)
- // // 表示有错误
- // {
- // MessageBox.Show(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString(), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- // this.txtBarCode.SelectAll();
- // this.txtBarCode.Focus();
- // return;
- // }
- // else
- // {
- // //生产数据ID
- // this._productiondataid = Convert.ToInt32(ProductionData.Rows[0]["productiondataid"]);
- // BindProductionDataReFine(dsCheckBarcode);//说明重烧后回来成检
- // this._currentBarCode = txtBarCode.Text.Trim();
- // this.txtBarCode.Text = string.Empty;
- // }
- // }
- // } // GetCompleteProcedureID != this._procedureID
- // else //流程工序与当前工序相,代码进行编辑
- // {
- // this._productiondataid = Convert.ToInt32(ProductionData.Rows[0]["productiondataid"]);
- // SetEditDataSource();
- // this._currentBarCode = txtBarCode.Text.Trim();
- // this.txtBarCode.Text = string.Empty;
- // }
- // }
- // else // 不是重烧
- // {
- // int GetCompleteProcedureID = (int)DoAsync(new BaseAsyncMethod(() =>
- // {
- // return PMModuleProxy.Service.GetCompleteProcedureID(this.txtBarCode.Text.Trim());
- // }));
- // if (GetCompleteProcedureID != this._procedureID)
- // {
- // // 表示有错误
- // MessageBox.Show("当前条码己不在此工序不允许编辑", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- // this.txtBarCode.SelectAll();
- // this.txtBarCode.Focus();
- // return;
- // }
- // else
- // {
- // this._productiondataid = Convert.ToInt32(ProductionData.Rows[0]["productiondataid"]);
- // SetEditDataSource();
- // this.txtUserCode.Enabled = true;
- // this.txtBarCode.Enabled = true;
- // this.txtBarCode.Text = string.Empty;
- // }
- // }
- //}
- //else
- //{
- // // 校验条码 获取校验条码信
- // DataSet dsCheckBarcode = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- // {
- // return PMModuleProxy.Service.CheckBarcode(this._procedureID, this.txtBarCode.Text.Trim());
- // }));
- // if (dsCheckBarcode != null && dsCheckBarcode.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
- // {
- // if (dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString() != string.Empty)
- // {
- // // 表示有错误
- // MessageBox.Show(string.Format(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString(), this.txtBarCode.Text.Trim(), "产品条码"),
- // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- // this.txtBarCode.Focus();
- // return;
- // }
- // else
- // {
- // BindProductionData(dsCheckBarcode);//从来未走过此工序
- // this._currentBarCode = txtBarCode.Text.Trim();
- // this.txtBarCode.Text = string.Empty;
- // }
- // }
- //}
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 生产数据编辑控件显示事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvProductionData_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
- {
- if (e.Control is DataGridViewComboBoxEditingControl
- && this.dgvProductionData.CurrentCell.ColumnIndex == Constant.INT_IS_THREE
- && this.dgvProductionData.CurrentCell.RowIndex != -Constant.INT_IS_ONE)
- {
- this._dataGridViewComboBox = (DataGridViewComboBoxEditingControl)e.Control;
- //增加委托处理
- this._dataGridViewComboBox.SelectionChangeCommitted += new EventHandler(this.dataGridViewComboBox_SelectionChangeCommitted);
- }
- if (e.Control is DKListBoxComboBox
- && this.dgvProductionData.CurrentCell.ColumnIndex == Constant.INT_IS_FOUR
- && this.dgvProductionData.CurrentCell.RowIndex != -Constant.INT_IS_ONE)
- {
- //_selectedRowIndex = TableProductionData.Rows.Count - 1;
- _selectedRowIndex = this.dgvProductionData.CurrentCell.RowIndex;
- DKListBoxComboBox dkListBoxComboBox = (DKListBoxComboBox)e.Control;
- _currentGoodsID = Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["GoodsID"].Value);
- _currentBarCode = this.dgvProductionData.Rows[_selectedRowIndex].Cells["BarCode"].Value.ToString();
- dkListBoxComboBox.DisplayMember = "ReworkProcedureName";
- dkListBoxComboBox.ValueMember = "ReworkProcedureID";
- dkListBoxComboBox.DataSource = DSREWORK.Tables[0];// DSREWORK.Tables[_currentBarCode];
- }
- }
- /// <summary>
- /// 生产数据下拉列表改变事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dataGridViewComboBox_SelectionChangeCommitted(object sender, EventArgs e)
- {
- this._currentDefectFlag = Convert.ToInt32(((ComboBox)sender).SelectedValue.ToString());//当前缺陷类型
- SetGridView(this._currentDefectFlag);
- }
- /// <summary>
- /// 产品数据单元格进入事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvProductionData_CellEnter(object sender, DataGridViewCellEventArgs e)
- {
- try
- {
- if (this.dgvProductionData.CurrentCell != null)
- {
- // 记录最后选择行
- if (e.ColumnIndex == Constant.INT_IS_FOUR && e.RowIndex != -Constant.INT_IS_ONE)
- {
- this._selectedRowIndex = this.dgvProductionData.CurrentCell.RowIndex;
- this._currentBarCode = this.dgvProductionData.Rows[_selectedRowIndex].Cells["BarCode"].Value.ToString();
- this._C_DGV_Cell_ListBoxComboBox = dgvProductionData.Rows[_selectedRowIndex].Cells[4] as C_DGV_Cell_ListBoxComboBox;
- DataSet ds = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetReworkProcedureByProcedureID(this._procedureID);
- }));
- this._currentGoodsID = Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["GoodsID"].Value);
- this._currentBarCode = this.dgvProductionData.Rows[_selectedRowIndex].Cells["BarCode"].Value.ToString();
- this._C_DGV_Cell_ListBoxComboBox.DisplayMember = "ReworkProcedureName";
- this._C_DGV_Cell_ListBoxComboBox.ValueMember = "ReworkProcedureID";
- this._C_DGV_Cell_ListBoxComboBox.DataSource = ds.Tables[0];
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 产品数据选定项改变事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvProductionData_SelectionChanged(object sender, EventArgs e)
- {
- try
- {
- if (this.dgvProductionData.CurrentCell != null)
- {
- this._selectedRowIndex = this.dgvProductionData.CurrentCell.RowIndex;
- // 有无缺陷 0无缺陷 1有缺陷
- this._currentDefectFlag = Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["GoodsLevelTypeID"].Value.ToString());
- this._currentGoodsID = Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["GoodsID"].Value);
- this._currentBarCode = this.dgvProductionData.Rows[_selectedRowIndex].Cells["BarCode"].Value.ToString();
- this.dgvDefect.DataSource = DSTable.Tables[this._currentBarCode];
- this.dgvDefectStaff.CurrentCell = null;
- this.dgvDefectStaff.DataSource = null;
- this._smallByte.Clear();//防止重复绑定图片
- this.lvPic.Clear();//
- //设置只读数据,交不显示数据
- string readonlyFlag = this.dgvProductionData.Rows[_selectedRowIndex].Cells["ReadOnly"].Value.ToString();
- if (readonlyFlag == "1")
- {
- tsbtnAdd.Enabled = false;
- tsbtnEdit.Enabled = false;
- }
- else
- {
- tsbtnAdd.Enabled = true;
- tsbtnEdit.Enabled = true;
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 缺陷数据源选定项改变事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvDefect_SelectionChanged(object sender, EventArgs e)
- {
- try
- {
- if (this.dgvDefect.CurrentCell != null)
- {
- DataRow[] dr = this.TableProductionData.Select("barcode='" + this._currentBarCode + "'");
- if (dr.Length > 0)
- {
- if (dr[0]["ReadOnly"].ToString() == "1")
- {
- this.tsbtnEdit.Enabled = false;
- this.tsbtnAdd.Enabled = false;
- this.btnDelete.Enabled = false;
- this.btnUpload.Enabled = false;
- }
- else
- {
- this.tsbtnEdit.Enabled = true;
- this.tsbtnAdd.Enabled = true;
- this.btnDelete.Enabled = true;
- this.btnUpload.Enabled = true;
- }
- }
- else
- {
- //if (this._productiondataid > Constant.INT_IS_ZERO)
- //{
- if (this.btnSave.Enabled)
- {
- this.tsbtnEdit.Enabled = true;
- this.tsbtnAdd.Enabled = true;
- this.btnDelete.Enabled = true;
- this.btnUpload.Enabled = true;
- }
- }
- // }
- if (this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["TempCount"].Value.ToString() != string.Empty)
- {
- int staffTempCount = Convert.ToInt32(this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["TempCount"].Value.ToString());
- this.dgvDefectStaff.DataSource = DSTableStaff.Tables[string.Format("TempTable{0}", staffTempCount.ToString())];
- this.dgvMissStaff.DataSource = DSTableMissedStaff.Tables[string.Format("TempTable{0}", staffTempCount.ToString())];
- this._currentTempSign = this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["TempCount"].Value.ToString(); //当前临时标记
- this._smallByte.Clear();//防止重复绑定图片
- BindByteImage(DSTableImage.Tables[string.Format("TempTable{0}", staffTempCount.ToString())]);
- }
- else
- {
- this.dgvDefectStaff.DataSource = null;
- this.dgvMissStaff.DataSource = null;
- this._smallByte.Clear();//防止重复绑定图片
- this.lvPic.Clear();//
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 单元格CheckBox事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvDefect_CellContentClick(object sender, DataGridViewCellEventArgs e)
- {
- if (e.ColumnIndex == Constant.INT_IS_ZERO && e.RowIndex != -Constant.INT_IS_ONE)
- {
- int checkValue = Convert.ToInt32(this.dgvDefect.Rows[e.RowIndex].Cells[0].EditedFormattedValue);
- if (checkValue == Constant.INT_IS_ZERO)
- {
- SetCheckBoxSelected(checkValue, e.RowIndex);
- }
- else
- {
- this.dgvDefect.Rows[e.RowIndex].Cells[0].Value = 0;
- }
- }
- }
- /// <summary>
- /// 上传图片按钮事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnUpload_Click(object sender, EventArgs e)
- {
- try
- {
- this.odlgFile.Filter = Constant.FILTER_PIC;
- this.odlgFile.FilterIndex = Constant.INT_IS_ZERO;
- this.odlgFile.RestoreDirectory = true;
- this.odlgFile.Title = "选择缺陷图片";
- this.odlgFile.FileName = null;
- this.odlgFile.RestoreDirectory = true;
- if (this.odlgFile.ShowDialog() == DialogResult.OK)
- {
- FileInfo file = new FileInfo(odlgFile.FileName);
- if (Constant.UPLOAD_PIC_MAX_SIZE < file.Length)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W013, "缺陷图片", "大小", "1M"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- else
- {
- Image PicImage = Image.FromStream(file.OpenRead());
- byte[] orgImageByte = ImageToByte(PicImage);
- this._PicByte.Add(orgImageByte);
- GetThumbnail(file, orgImageByte);
- BindImg();
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 删除图片按钮事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnDelete_Click(object sender, EventArgs e)
- {
- foreach (ListViewItem lvSelect in lvPic.SelectedItems)
- {
- int index = lvSelect.Index;
- if (index < Constant.INT_IS_ZERO)
- {
- index = Constant.INT_IS_ZERO;
- }
- if (this._currentTempSign != string.Empty)
- {
- DSTableImage.Tables[string.Format("TempTable{0}", this._currentTempSign)].Rows.RemoveAt(lvSelect.Index);
- DSTableImage.Tables[string.Format("TempTable{0}", this._currentTempSign)].AcceptChanges();
- }
- BindByteImage(DSTableImage.Tables[string.Format("TempTable{0}", this._currentTempSign)]);
- }
- }
- /// <summary>
- /// 关闭按钮事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- /// <summary>
- /// 产品条码列表删除事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvProductionData_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
- {
- try
- {
- string BarCode = this.dgvProductionData.Rows[e.Row.Index].Cells["BarCode"].Value.ToString();
- DSTable.Tables[BarCode].Rows.Clear();//清空行
- this.dgvDefectStaff.DataSource = null;//责任员工数据源
- this.dgvMissStaff.DataSource = null; //漏检员工数据源
- this.lvPic.Clear();
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 产品缺陷删除行事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvDefect_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
- {
- try
- {
- if (e.Row.Index != -1)
- {
- //ProductionDataID
- if (this.dgvDefect.CurrentCell != null)
- {
- //是新增进来,加载条码是不允许删除的,只是编辑权限才能可以删除
- 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")
- {
- e.Cancel = true;
- return;
- }
- string TempCount = this.dgvDefect.Rows[e.Row.Index].Cells["TempCount"].Value.ToString();
- DSTableStaff.Tables[string.Format("TempTable{0}", TempCount.ToString())].Rows.Clear();//清空行
- this.dgvDefectStaff.DataSource = null;
- DSTableMissedStaff.Tables[string.Format("TempTable{0}", TempCount.ToString())].Rows.Clear();//清空行
- this.dgvMissStaff.DataSource = null;
- this.lvPic.Clear();
- if (Convert.ToInt32(TempCount) > 0)
- {
- if (this.dgvDefect.CurrentCell != null)
- {
- DataRow[] dr = this.TableProductionData.Select("barcode='" + this._currentBarCode + "'");
- if (dr.Length > 0)
- {
- if (dr[0]["ReadOnly"].ToString() == "1")
- {
- this.tsbtnEdit.Enabled = false;
- this.tsbtnAdd.Enabled = false;
- this.btnDelete.Enabled = false;
- this.btnUpload.Enabled = false;
- }
- else
- {
- this.tsbtnEdit.Enabled = true;
- this.tsbtnAdd.Enabled = true;
- this.btnDelete.Enabled = true;
- this.btnUpload.Enabled = true;
- }
- }
- else
- {
- //if (this._productiondataid > Constant.INT_IS_ZERO)
- //{
- if (this.btnSave.Enabled)
- {
- this.tsbtnEdit.Enabled = true;
- this.tsbtnAdd.Enabled = true;
- this.btnDelete.Enabled = true;
- this.btnUpload.Enabled = true;
- }
- }
- // }
- if (this.dgvDefect.Rows[0].Cells["TempCount"].Value.ToString() != string.Empty)
- {
- int staffTempCount = Convert.ToInt32(this.dgvDefect.Rows[0].Cells["TempCount"].Value.ToString());
- this.dgvDefectStaff.DataSource = DSTableStaff.Tables[string.Format("TempTable{0}", staffTempCount.ToString())];
- this.dgvMissStaff.DataSource = DSTableMissedStaff.Tables[string.Format("TempTable{0}", staffTempCount.ToString())];
- this._currentTempSign = this.dgvDefect.Rows[0].Cells["TempCount"].Value.ToString(); //当前临时标记
- this._smallByte.Clear();//防止重复绑定图片
- BindByteImage(DSTableImage.Tables[string.Format("TempTable{0}", staffTempCount.ToString())]);
- }
- else
- {
- this.dgvDefectStaff.DataSource = null;
- this.dgvMissStaff.DataSource = null;
- this._smallByte.Clear();//防止重复绑定图片
- this.lvPic.Clear();//
- }
- }
- }
- }
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 新建按钮事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnAdd_Click(object sender, EventArgs e)
- {
- if (this.dgvProductionData.CurrentCell != null)
- {
- int allow = Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["GoodsLevelTypeID"].Value.ToString());
- if (allow != Constant.INT_IS_FOUR) // 有缺陷才能新建
- {
- F_PM_3203 frm3203 = new F_PM_3203(
- DSTable.Tables[this._currentBarCode], this._currentBarCode,
- this._currentGoodsID, this._tempCount, this._procedureID, this.Text, false, this, this.DSTableStaff, this.DSTableMissedStaff, this.DSTableImage, this._PicByte, this._smallByte, -1);
- frm3203.ShowDialog();
- }
- }
- }
- /// <summary>
- /// 编辑按钮事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnEdit_Click(object sender, EventArgs e)
- {
- if (this.dgvDefect.CurrentCell != null)
- {
- //int isallowedit = Convert.ToInt32(this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["IsAllowEdit"].Value.ToString());
- if (Convert.ToInt32(this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["IsAllowEdit"].Value.ToString()) == 1) //如果_AllowEdit=1,则是编辑状态,肯定允许编辑,因为分权限的时候就定义了
- {
- string barcode = this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["ProductionBarCode"].Value.ToString();
- int tempcount = Convert.ToInt32(this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["TempCount"].Value.ToString());
- int goodsID = 0;
- DataRow[] dr = this.TableProductionData.Select("BarCode='" + barcode + "'");
- if (dr.Length > Constant.INT_IS_ZERO)
- {
- goodsID = Convert.ToInt32(dr[0]["GoodsID"]);
- }
- F_PM_3203 frm3203 = new F_PM_3203(
- DSTable.Tables[barcode], barcode,
- goodsID, tempcount, this._procedureID, this.Text, true, this, this.DSTableStaff, this.DSTableMissedStaff, this.DSTableImage, this._PicByte, this._smallByte, this.dgvDefect.CurrentCell.RowIndex);
- frm3203.ShowDialog();
- }
- }
- }
- /// <summary>
- /// 产品数据源值改变后
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvProductionData_CellValueChanged(object sender, DataGridViewCellEventArgs e)
- {
- if (e.ColumnIndex == Constant.INT_IS_FOUR && e.RowIndex != -Constant.INT_IS_ONE)
- {
- //if (this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureID"].Value.ToString() != string.Empty)
- //{
- // string barcode = dgvProductionData.Rows[e.RowIndex].Cells["BarCode"].Value.ToString();
- // DataTable dt = this.DSREWORK.Tables[barcode];
- // if (dt != null && dt.Rows.Count > Constant.INT_IS_ZERO)
- // {
- // DataRow[] dr = dt.Select("ReworkProcedureID=" + this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureID"].Value);
- // if (dr.Length > Constant.INT_IS_ZERO)
- // {
- // this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureName"].Value = dr[0]["ReworkProcedureName"];
- // }
- // }
- //}
- }
- }
- /// <summary>
- /// 保存按钮事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnSave_Click(object sender, EventArgs e)
- {
- try
- {
- //ProductionDataEntity[] productionDataEntitys = new ProductionDataEntity[this.TableProductionData.Rows.Count];
- if (this.TableProductionData.Select("ReadOnly<>1").Length > 0)
- {
- this.TableProductionData = this.TableProductionData.Select("ReadOnly<>1").CopyToDataTable();
- }
- ProductionDataEntity[] productionDataEntitys = new ProductionDataEntity[this.TableProductionData.Rows.Count];
- bool isError = false; // 是否存在缺陷员工
- int ErrorCount = -1;
- int CurrentRowIndex = -1;
- for (int i = 0; i < this.TableProductionData.Rows.Count; i++)
- {
- if (this.TableProductionData.Rows[i]["ReadOnly"].ToString() == "1") //只读数据不进行保存
- {
- continue;
- }
- ProductionDataEntity productionDataEntity = new ProductionDataEntity();
- //if (this._productiondataid > 0)
- //{
- // productionDataEntity.ProductionDataID = this._productiondataid;
- //}
- if (this.TableProductionData.Rows[i]["ProductionDataID"].ToString() != "")
- {
- productionDataEntity.ProductionDataID = Convert.ToInt32(this.TableProductionData.Rows[i]["ProductionDataID"]);
- }
- productionDataEntity.Barcode = this.TableProductionData.Rows[i]["BarCode"].ToString();
- productionDataEntity.UserID = UserID;// Convert.ToInt32(this.TableProductionData.Rows[i]["UserID"]);
- productionDataEntity.UserCode = UserCode;// this.TableProductionData.Rows[i]["UserCode"].ToString();
- productionDataEntity.UserName = UserName;// this.TableProductionData.Rows[i]["UserName"].ToString(); ;
- //1没缺陷 2有缺陷
- productionDataEntity.DefectFlag = Convert.ToInt32(this.TableProductionData.Rows[i]["GoodsLevelTypeID"]) == 1 ? 1 : 2;
- //xuwei modify 2019-12-12
- productionDataEntity.GoodsLevelID = Convert.ToInt32(this.TableProductionData.Rows[i]["DefectFlagID"]);
- productionDataEntity.GoodsLevelTypeID = Convert.ToInt32(this.TableProductionData.Rows[i]["GoodsLevelTypeID"]);
- productionDataEntity.Remarks = this.TableProductionData.Rows[i]["Remarks"].ToString();
- if (this.TableProductionData.Rows[i]["LogoID"].ToString() != "")
- {
- productionDataEntity.LogoID = Convert.ToInt32(this.TableProductionData.Rows[i]["LogoID"]);
- }
- if (this.TableProductionData.Rows[i]["OPTimeStamp"].ToString() != "")
- {
- productionDataEntity.OPTimeStamp = Convert.ToDateTime(this.TableProductionData.Rows[i]["OPTimeStamp"]);
- }
- if (this.TableProductionData.Rows[i]["CheckTime"].ToString() != "")
- {
- productionDataEntity.CheckTime = Convert.ToDateTime(this.TableProductionData.Rows[i]["CheckTime"]);
- }
- if (this.TableProductionData.Rows[i]["OrgGoodsLevelTypeID"].ToString() != "-1")
- {
- productionDataEntity.OrgGoodsLevelTypeID = Convert.ToInt32(this.TableProductionData.Rows[i]["OrgGoodsLevelTypeID"]);
- }
- if (!string.IsNullOrEmpty(this.TableProductionData.Rows[i]["ReworkProcedureID"].ToString()))
- {
- productionDataEntity.ReworkProcedureID = int.Parse(this.TableProductionData.Rows[i]["ReworkProcedureID"].ToString());
- productionDataEntity.IsReworked = 1;
- }
- productionDataEntitys[i] = productionDataEntity;
- if (Convert.ToInt32(this.TableProductionData.Rows[i]["GoodsLevelTypeID"]) == (int)Constant.GoodsLevelType.ReFire) //重烧
- {
- if (this.TableProductionData.Rows[i]["ReworkProcedureID"].ToString() == "" ||
- Convert.ToInt32(this.TableProductionData.Rows[i]["ReworkProcedureID"].ToString()) == -Constant.INT_IS_ONE)
- {
- isError = true;
- ErrorCount = 1;
- CurrentRowIndex = i;
- this.dgvProductionData.Rows[i].Selected = true;
- break;
- }
- }
- if (Convert.ToInt32(this.TableProductionData.Rows[i]["GoodsLevelTypeID"]) != (int)Constant.GoodsLevelType.NoDefects
- &&
- Convert.ToInt32(this.TableProductionData.Rows[i]["GoodsLevelTypeID"]) != 15
- ) //良品 或 复检 xuwei modify 2019-12-13
- {
- // 不是 良品 和 复检
- if (this.DSTable.Tables[productionDataEntity.Barcode].Rows.Count == Constant.INT_IS_ZERO)
- {
- isError = true;
- ErrorCount = -2;
- CurrentRowIndex = i;
- this.dgvProductionData.Rows[i].Selected = true;
- break;
- }
- }
- List<ProductionDefectEntity> productionDefectEntitys = new List<ProductionDefectEntity>();
- ProductionDefectEntity productionDefectEntity = null;
- for (int j = 0; j < this.DSTable.Tables[productionDataEntity.Barcode].Rows.Count; j++) //缺陷列表
- {
- productionDefectEntity = new ProductionDefectEntity();
- productionDefectEntity.SpecialDefect = this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["IsOtherDefect"].ToString();
- //if (this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectDeductionID"].ToString() != "-1"
- // && this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectDeductionID"].ToString() != string.Empty)
- //{
- // productionDefectEntity.DefectDeductionNum = Convert.ToDecimal(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectDeductionNum"]);
- //}
- if (!string.IsNullOrEmpty(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectDeductionNum"] + ""))
- {
- productionDefectEntity.DefectDeductionNum = Convert.ToDecimal(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectDeductionNum"]);
- }
- productionDefectEntity.ScrapResponFlag = "0";
- productionDefectEntity.DefectID =
- Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectID"]);
- productionDefectEntity.DefectCode =
- this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectCode"].ToString();
- productionDefectEntity.DefectName =
- this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectName"].ToString().Replace(productionDefectEntity.DefectCode + "->", "");
- productionDefectEntity.DefectPositionID =
- Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectPositionID"]);
- productionDefectEntity.DefectPositionCode =
- this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectPositionCode"].ToString();
- productionDefectEntity.DefectPositionName =
- this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectPositionName"].ToString().Replace(productionDefectEntity.DefectPositionCode + "->", "");
- productionDefectEntity.DefectProductionDataID =
- Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["ProductionDataID"].ToString());
- if (productionDefectEntity.DefectProductionDataID == 0)
- {
- productionDefectEntity.DefectProductionDataID = null;
- }
- if (this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectProcedureID"].ToString() != string.Empty &&
- Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectProcedureID"]) > Constant.INT_IS_ZERO)
- {
- productionDefectEntity.DefectProcedureID =
- Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectProcedureID"]);
- }
- productionDefectEntity.DefectProcedureCode =
- this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectProcedureCode"].ToString();
- productionDefectEntity.DefectProcedureName =
- this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectProcedureName"].ToString();
- productionDefectEntity.DefectUserID =
- Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectUserID"]);
- productionDefectEntity.DefectUserCode =
- this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectUserCode"].ToString();
- productionDefectEntity.DefectUserName =
- this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectUserName"].ToString();
- productionDefectEntity.DefectJobs =
- Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["Jobs"].ToString());
- productionDefectEntity.Remarks =
- this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectRemarks"].ToString();
- productionDefectEntity.Remarks =
- this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectRemarks"].ToString();
- if (this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectFineID"].ToString() != "-1"
- && this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectFineID"].ToString() != string.Empty)
- {
- productionDefectEntity.DefectFine = Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["DefectFineID"]);
- }
- if (this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["CheckTime"].ToString() != string.Empty)
- {
- //if (Convert.ToInt32(this.TableProductionData.Rows[i]["OrgGoodsLevelTypeID"]) == Convert.ToInt32(this.TableProductionData.Rows[i]["GoodsLevelTypeID"]))
- //{
- productionDefectEntity.CheckTime = Convert.ToDateTime(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["CheckTime"]);
- //}
- }
- if (this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["MissedUserID"].ToString() != "-1"
- && this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["MissedUserID"].ToString() != string.Empty)
- {
- productionDefectEntity.MissedUserID = Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["MissedUserID"]);
- productionDefectEntity.MissedUserCode = this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["MissedUserCode"].ToString();
- productionDefectEntity.MissedUserName = this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["MissedUserName"].ToString();
- }
- // 遍历责任员工
- List<DefectResponsibleEntity> DefectResponsibles = new List<DefectResponsibleEntity>();
- if (this.DSTableStaff.Tables.Contains(string.Format("TempTable{0}",
- this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["TempCount"].ToString())))
- {
- DefectResponsibleEntity defectResponsibleEntity = null;
- DataTable dtTemp = this.DSTableStaff.Tables[string.Format("TempTable{0}",
- this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["TempCount"].ToString())];
- foreach (DataRow drStaff in dtTemp.Rows)
- {
- if (Convert.ToInt32(drStaff["IsSelected"]) == Constant.INT_IS_ONE)
- {
- defectResponsibleEntity = new DefectResponsibleEntity();
- defectResponsibleEntity.StaffID = Convert.ToInt32(drStaff["StaffID"]);
- defectResponsibleEntity.UserID = Convert.ToInt32(productionDefectEntity.DefectUserID);
- defectResponsibleEntity.UserCode = productionDefectEntity.DefectUserCode;
- defectResponsibleEntity.UJobsID =
- Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["Jobs"].ToString());
- defectResponsibleEntity.SJobsID =
- Convert.ToInt32(this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["Jobs"].ToString());
- defectResponsibleEntity.StaffStatus = Convert.ToInt32(drStaff["StaffStatus"]);
- DefectResponsibles.Add(defectResponsibleEntity);
- }
- }
- //productionDefectEntity.DefectResponsibles = DefectResponsibles.ToArray();//每个缺陷对应的责任员工
- productionDefectEntity.DefectResponsibles = DefectResponsibles;//每个缺陷对应的责任员工
- }
- if (DefectResponsibles.Count == Constant.INT_IS_ZERO) // 并没有责任员工
- {
- isError = true;
- this.dgvDefect.DataSource = this.DSTable.Tables[productionDataEntity.Barcode];
- this.dgvDefect.CurrentCell = null;
- this.dgvDefect.Rows[j].Selected = true;
- if (this.DSTableStaff.Tables.Contains(string.Format("TempTable{0}",
- this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["TempCount"].ToString())))
- {
- this.dgvDefectStaff.DataSource = this.DSTableStaff.Tables[string.Format("TempTable{0}",
- this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["TempCount"].ToString())];
- }
- else
- {
- this.dgvDefectStaff.DataSource = null;
- }
- break;
- }
- // 遍历漏检责任员工
- List<DefectMissedResponsibleEntity> DefectMissedResponsibles = new List<DefectMissedResponsibleEntity>();
- if (this.DSTableMissedStaff.Tables.Contains(string.Format("TempTable{0}",
- this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["TempCount"].ToString())))
- {
- DefectMissedResponsibleEntity defectMissedResponsibleEntity = null;
- DataTable dtTemp = this.DSTableMissedStaff.Tables[string.Format("TempTable{0}",
- this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["TempCount"].ToString())];
- foreach (DataRow drStaff in dtTemp.Rows)
- {
- if (Convert.ToInt32(drStaff["IsSelected"]) == Constant.INT_IS_ONE)
- {
- defectMissedResponsibleEntity = new DefectMissedResponsibleEntity();
- defectMissedResponsibleEntity.StaffID = Convert.ToInt32(drStaff["StaffID"]);
- defectMissedResponsibleEntity.UserID = Convert.ToInt32(productionDefectEntity.DefectUserID);
- defectMissedResponsibleEntity.UserCode = productionDefectEntity.DefectUserCode;
- defectMissedResponsibleEntity.UJobsID = Convert.ToInt32(drStaff["UJobsID"]);
- defectMissedResponsibleEntity.SJobsID = Convert.ToInt32(drStaff["SJobsID"]);
- defectMissedResponsibleEntity.StaffStatus = Convert.ToInt32(drStaff["StaffStatus"]);
- DefectMissedResponsibles.Add(defectMissedResponsibleEntity);
- }
- }
- //productionDefectEntity.DefectMissedResponsibles = DefectMissedResponsibles.ToArray();
- productionDefectEntity.DefectMissedResponsibles = DefectMissedResponsibles;
- }
- // 遍历缺陷图片
- if (this.DSTableImage.Tables.Contains(string.Format("TempTable{0}",
- this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["TempCount"].ToString())))
- {
- List<DefectImageEntity> defectImageEntitys = new List<DefectImageEntity>();
- DefectImageEntity defectImageEntity = null;
- DataTable dtTemp = this.DSTableImage.Tables[string.Format("TempTable{0}",
- this.DSTable.Tables[productionDataEntity.Barcode].Rows[j]["TempCount"].ToString())];
- foreach (DataRow drImage in dtTemp.Rows)
- {
- defectImageEntity = new DefectImageEntity();
- defectImageEntity.Thumbnail = (byte[])drImage["ImageByte"];
- defectImageEntity.Image = (byte[])drImage["orgImageByte"];
- defectImageEntitys.Add(defectImageEntity);
- }
- //productionDefectEntity.DefectImages = defectImageEntitys.ToArray();
- productionDefectEntity.DefectImages = defectImageEntitys;
- }
- productionDefectEntitys.Add(productionDefectEntity);
- }
- if (isError)
- {
- break;
- }
- //productionDataEntitys[i].ProductionDefects = productionDefectEntitys.ToArray();
- productionDataEntitys[i].ProductionDefects = productionDefectEntitys;
- }
- // 有错误
- if (isError)
- {
- if (CurrentRowIndex != -Constant.INT_IS_ONE)
- {
- this._currentDefectFlag = Convert.ToInt32(this.TableProductionData.Rows[CurrentRowIndex]["DefectFlagID"].ToString());
- }
- if (ErrorCount == -Constant.INT_IS_ONE)
- {
- // 提示信息
- MessageBox.Show(Messages.MSG_PM_W002,
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- else if (ErrorCount == -Constant.INT_IS_TWO)
- {
- // 提示信息
- MessageBox.Show("非良品必须输入缺陷!",
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- else
- {
- this.dgvProductionData.DataSource = TableProductionData;
- //this.TableProductionData.Columns["ReworkProcedureID"].DataType=typeof(decimal);// data typeof(decimal));
- //this.ReworkProcedureID.DataSource = this.DSREWORK.Tables[0];
- //this.ReworkProcedureID.DisplayMember = "ReworkProcedureName";
- //this.ReworkProcedureID.ValueMember = "ReworkProcedureID";
- // 提示信息
- MessageBox.Show(Messages.MSG_PM_W003,
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- //this.ReworkProcedureID.DataSource = this.DSREWORK.Tables[0];
- //this.ReworkProcedureID.DisplayMember = "ReworkProcedureName";
- //this.ReworkProcedureID.ValueMember = "ReworkProcedureID";
- return;
- }
- }
- // 最外层For循环结束
- if (productionDataEntitys.Length > Constant.INT_IS_ZERO)
- {
- string returnValue = (string)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.AddCheckBarcode(this._procedureID, productionDataEntitys);
- }));
- if (string.IsNullOrEmpty(returnValue))//成功
- {
- // 提示信息
- MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "新建" + this.Text, "保存"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
- ////保存成功后,并且为编辑时候,把上次编辑的数据禁用
- //if (this._productiondataid > Constant.INT_IS_ZERO)
- //{
- // int deleteRow = (int)DoAsync(new BaseAsyncMethod(() =>
- // {
- // return PMModuleProxy.Service.DeleteProductionDataByID(this._productiondataid);
- // }));
- //}
- // 保存成功后,清空相应数据源
- this.TableProductionData.Rows.Clear();
- this.dgvProductionData.DataSource = TableProductionData;
- this.DSTable.Tables.Clear();
- this.dgvDefect.DataSource = null;
- this.DSTableStaff.Tables.Clear();
- this.dgvDefectStaff.DataSource = null;
- this.DSTableMissedStaff.Tables.Clear();
- this.dgvMissStaff.DataSource = null;
- this.DSTableImage.Tables.Clear();
- this.lvPic.Clear();
- this._PicByte.Clear();
- this._smallByte.Clear();
- this.txtBarCode.Text = string.Empty;
- if (this._procedureDataEntity.CollectType == (int)Constant.ProcedureCollectType.Togather)
- {
- this.txtUserCode.Text = string.Empty;
- this.txtUserCode.ReadOnly = false;
- }
- //this.DSREWORK.Tables.Clear();
- }
- else
- {
- // 提示信息
- MessageBox.Show(returnValue,
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 关闭按钮事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbCloseTop_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- /// <summary>
- /// 单元格编辑开始时事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvProductionData_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
- {
- //if (e.ColumnIndex == Constant.INT_IS_FOUR && e.RowIndex != -Constant.INT_IS_ONE)
- //{
- // DataGridView dgv = (DataGridView)sender;
- // string value = this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["GoodsLevelTypeID"].Value.ToString();
- // if (value != Constant.GoodsLevelType.ReFire.GetHashCode().ToString())
- // {
- // e.Cancel = true;
- // }
- //}
- //if (e.ColumnIndex == Constant.INT_IS_THREE && e.RowIndex != -Constant.INT_IS_ONE)
- //{
- // if (this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReadOnly"].Value.ToString() == "1")
- // {
- // e.Cancel = true;
- // }
- //}
- if (e.ColumnIndex == Constant.INT_IS_FOUR && e.RowIndex != -Constant.INT_IS_ONE)
- {
- DataGridView dgv = (DataGridView)sender;
- string value = this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["GoodsLevelTypeID"].Value.ToString();
- if (value != Constant.GoodsLevelType.ReFire.GetHashCode().ToString())
- {
- e.Cancel = true;
- }
- }
- if (e.ColumnIndex == Constant.INT_IS_THREE && e.RowIndex != -Constant.INT_IS_ONE)
- {
- if (this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReadOnly"].Value.ToString() == "1")
- {
- e.Cancel = true;
- }
- }
- }
- /// <summary>
- /// 用户编码验证事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void txtUserCode_Validating(object sender, System.ComponentModel.CancelEventArgs e)
- {
- try
- {
- if (txtUserCode.Text.Trim() == string.Empty) // 如果未添加数据,则此项获取焦点
- {
- this.txtUserCode.IsMustInput = true;
- this.txtUserCode.SelectAll();
- e.Cancel = true;
- return;
- }
- else if (!this.txtUserCode.ReadOnly)
- {
- SUserEntity userEntity = new SUserEntity();
- userEntity.UserCode = this.txtUserCode.Text.Trim();
- // 此工号是否能生产工序
- CheckProcedureUserResult MsgCheckProcedureUser = (CheckProcedureUserResult)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.CheckProcedureUser(this._procedureID, this.txtUserCode.Text.Trim());
- }));
- if (MsgCheckProcedureUser != null)
- {
- if (MsgCheckProcedureUser.ErrMsg != null)
- {
- MessageBox.Show(MsgCheckProcedureUser.ErrMsg,
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- this.txtUserCode.SelectAll();
- e.Cancel = true;
- return;
- }
- UserID = Convert.ToInt32(MsgCheckProcedureUser.UserID);
- UserCode = MsgCheckProcedureUser.UserCode;
- UserName = MsgCheckProcedureUser.UserName;
- this.txtUserCode.ReadOnly = true;
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 鼠标单击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void txtUserCode_MouseClick(object sender, MouseEventArgs e)
- {
- if (this.txtUserCode.Text.Trim() != string.Empty)
- {
- this.txtUserCode.SelectAll();
- }
- }
- #endregion
- #region 私有方法
- /// <summary>
- /// 设置数据源
- /// </summary>
- /// <param name="tempCount"></param>
- public void SetDataSource(int tempCount)
- {
- this.dgvDefect.DataSource = DSTable.Tables[this._currentBarCode];
- this.dgvDefectStaff.DataSource = DSTableStaff.Tables[string.Format("TempTable{0}", this._tempCount.ToString())];
- this.dgvMissStaff.DataSource = DSTableMissedStaff.Tables[string.Format("TempTable{0}", this._tempCount.ToString())];
- this._tempCount = tempCount;
- }
- /// <summary>
- /// 设置编辑产品为时设置只读
- /// </summary>
- private void SetSubstandard()
- {
- this.btnSave.Enabled = false;
- this.dgvProductionData.ReadOnly = true;
- this.tsbtnAdd.Enabled = false;
- this.tsbtnEdit.Enabled = false;
- this.dgvDefect.ReadOnly = true;
- this.dgvDefectStaff.ReadOnly = true;
- this.dgvMissStaff.ReadOnly = true;
- this.btnDelete.Enabled = false;
- this.btnUpload.Enabled = false;
- }
- /// <summary>
- /// 编辑后设置数据源
- /// </summary>
- private void SetEditDataSource()
- {
- try
- {
- this.txtUserCode.Enabled = false;
- this.txtBarCode.Enabled = false;
- DataSet dsProductionDataByID = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetProductionDataByID(this._productiondataid);
- }));
- if (dsProductionDataByID != null && dsProductionDataByID.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
- {
- #region wangx 2016-10-10 校验是否可以成检登记改判 xuwei modify 2019-12-13 半检中取消判定
- //if (_settingvaluedays > 0)
- //{
- // ServiceResultEntity resultEntity = (ServiceResultEntity)DoAsync(new BaseAsyncMethod(() =>
- // {
- // return PMModuleProxy.Service.BarcodeAllowCancel(
- // Convert.ToDateTime(dsProductionDataByID.Tables[0].Rows[0]["createtime"]),
- // _settingvaluedays, Constant.SettingType.S_PM_009.ToString());
- // }));
- // if (Convert.ToInt32(resultEntity.Result) < 0)
- // {
- // MessageBox.Show(resultEntity.Message,
- // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- // this.txtBarCode.Text = "";
- // this.btnSave.Visible = false;
- // }
- //}
- #endregion wangx 2016-10-10 end
- #region 如果是废品,不允许编辑 xuwei modify 2019-12-13
- if (Convert.ToInt32(dsProductionDataByID.Tables[0].Rows[0]["GoodsLevelTypeID"]) == 3)//废品
- {
- int recyclingflag = (int)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetRecyclingflagByBarcode(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString());
- }));
- if (recyclingflag > 0)
- {
- MessageBox.Show("条码【" + dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString() + "】已经回收,不允许改判", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- this.txtBarCode.Enabled = true;
- this.txtBarCode.Focus();
- return;
- }
- }
- #endregion
- int SpecialRepairflag = (int)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetSpecialRepairflagByBarcode(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString());
- }));
- // 产品数据
- DataRow drNew = TableProductionData.NewRow();
- drNew["ProductionDataID"] = this._productiondataid;
- drNew["BarCode"] = dsProductionDataByID.Tables[0].Rows[0]["BarCode"];
- drNew["GoodsID"] = dsProductionDataByID.Tables[0].Rows[0]["GoodsID"];
- drNew["GoodsCode"] = dsProductionDataByID.Tables[0].Rows[0]["GoodsCode"];
- drNew["GoodsName"] = dsProductionDataByID.Tables[0].Rows[0]["GoodsName"];
- drNew["DefectFlagID"] = dsProductionDataByID.Tables[0].Rows[0]["DefectFlagID"];
- drNew["ReworkProcedureID"] = dsProductionDataByID.Tables[0].Rows[0]["ReworkProcedureID"];
- drNew["Remarks"] = dsProductionDataByID.Tables[0].Rows[0]["Remarks"];
- drNew["UserID"] = dsProductionDataByID.Tables[0].Rows[0]["UserID"];
- drNew["GoodsLevelTypeID"] = dsProductionDataByID.Tables[0].Rows[0]["GoodsLevelTypeID"];
- drNew["UserCode"] = dsProductionDataByID.Tables[0].Rows[0]["UserCode"];
- drNew["UserName"] = dsProductionDataByID.Tables[0].Rows[0]["UserName"];
- UserID = Convert.ToInt32(dsProductionDataByID.Tables[0].Rows[0]["UserID"]);
- UserCode = dsProductionDataByID.Tables[0].Rows[0]["UserCode"].ToString();
- UserName = dsProductionDataByID.Tables[0].Rows[0]["UserName"].ToString();
- drNew["OrgGoodsLevelTypeID"] = dsProductionDataByID.Tables[0].Rows[0]["GoodsLevelTypeID"];
- drNew["ReadOnly"] = this._ReadOnly;
- drNew["KilnCarCode"] = dsProductionDataByID.Tables[0].Rows[0]["KilnCarCode"];
- drNew["KilnCode"] = dsProductionDataByID.Tables[0].Rows[0]["KilnCode"];
- drNew["Dictionaryvalue"] = dsProductionDataByID.Tables[0].Rows[0]["Dictionaryvalue"];
- drNew["UserCode"] = dsProductionDataByID.Tables[0].Rows[0]["UserCode"];
- drNew["MouldCode"] = dsProductionDataByID.Tables[0].Rows[0]["MouldCode"];
- drNew["GroutingUserCode"] = dsProductionDataByID.Tables[0].Rows[0]["GroutingUserCode"];
- drNew["GroutingNum"] = dsProductionDataByID.Tables[0].Rows[0]["GroutingNum"];
- drNew["IsPublicBody"] = dsProductionDataByID.Tables[0].Rows[0]["IsPublicBody"].ToString() != "1" ? 0 : 1;
- drNew["GroutingDate"] = Convert.ToDateTime(dsProductionDataByID.Tables[0].Rows[0]["GroutingDate"]);
- drNew["LogoCodeName"] = dsProductionDataByID.Tables[0].Rows[0]["LogoName"] + "[" + dsProductionDataByID.Tables[0].Rows[0]["LogoCode"] + "]";
- drNew["LogoId"] = dsProductionDataByID.Tables[0].Rows[0]["LogoId"];
- drNew["CheckTime"] = dsProductionDataByID.Tables[0].Rows[0]["CheckTime"];
- DataSet dsOPTimeStamp = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetCompleteProcedureIDPDA(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString());
- }));
- if (dsOPTimeStamp != null && dsOPTimeStamp.Tables[0].Rows.Count > 0)
- {
- drNew["OPTimeStamp"] = Convert.ToDateTime(dsOPTimeStamp.Tables[0].Rows[0]["OPTimeStamp"]);
- }
- //drNew["OPTimeStamp"]
- // 校验条码是否重烧过,这个地方必须重新读取,因为防止编辑重烧以前的成检数据,如果直接取表里的就不准了
- DataSet dsReFine = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetReFine(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString());
- }));
- if (dsReFine != null && dsReFine.Tables[0].Rows.Count > 0 && dsReFine.Tables[0].Rows[0]["IsReFire"].ToString() == "6")
- {
- drNew["ReFine"] = 1;
- }
- else
- {
- drNew["ReFine"] = 0;
- }
- drNew["SpecialRepairflag"] = SpecialRepairflag.ToString() == "1" ? 1 : 0;
- //原产品类别
- //UserID = Convert.ToInt32(dsProductionDataByID.Tables[0].Rows[0]["UserID"]);
- //UserCode = dsProductionDataByID.Tables[0].Rows[0]["UserCode"].ToString();
- //UserName = dsProductionDataByID.Tables[0].Rows[0]["UserName"].ToString();
- TableProductionData.Rows.Add(drNew);
- this.dgvProductionData.Rows[TableProductionData.Rows.Count - 1].Selected = true;
- this._selectedRowIndex = TableProductionData.Rows.Count - 1;
- this._currentBarCode = dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString();
- this._currentGoodsID = Convert.ToInt32(dsProductionDataByID.Tables[0].Rows[0]["GoodsID"]);
- if (dsProductionDataByID.Tables[0].Rows[0]["GoodsLevelTypeID"].ToString() == Constant.INT_IS_SEVEN.ToString())
- {
- //次品设置只读的时候,原来默认不允许修改,目前注释掉
- //SetSubstandard();
- DataSet dsReturn = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetSubstandardInfo(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString());
- }));
- if (dsReturn != null && dsReturn.Tables[0].Rows.Count == 0) //防止回收站里没有此条码
- {
- // 提示信息
- MessageBox.Show("次品条码:" + dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString() + "不允许修改",
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- this.tsbtnAdd.Enabled = true;
- }
- else
- {
- this.tsbtnAdd.Enabled = true;
- if (dsProductionDataByID != null && dsProductionDataByID.Tables[1].Rows.Count > Constant.INT_IS_ZERO)
- {
- this.tsbtnEdit.Enabled = true;
- }
- }
- }
- if (DSTable.Tables.IndexOf(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString()) == -Constant.INT_IS_ONE)
- {
- DataTable dtProductionDefectData = new DataTable(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString());
- dtProductionDefectData.Columns.Add("BarCode");
- dtProductionDefectData.Columns.Add("DefectID", typeof(decimal));
- dtProductionDefectData.Columns.Add("DefectName");
- dtProductionDefectData.Columns.Add("DefectCode");
- dtProductionDefectData.Columns.Add("DefectPositionID", typeof(decimal));
- dtProductionDefectData.Columns.Add("DefectPositionName");
- dtProductionDefectData.Columns.Add("DefectPositionCode");
- dtProductionDefectData.Columns.Add("DefectProcedureID", typeof(decimal));
- dtProductionDefectData.Columns.Add("DefectProcedureName");
- dtProductionDefectData.Columns.Add("DefectProcedureCode");
- dtProductionDefectData.Columns.Add("DefectUserID", typeof(decimal));//责任员工
- dtProductionDefectData.Columns.Add("DefectUserName");//责任员工
- dtProductionDefectData.Columns.Add("DefectUserCode");//
- dtProductionDefectData.Columns.Add("Jobs", typeof(decimal));//工种
- dtProductionDefectData.Columns.Add("JobsText");//工种
- dtProductionDefectData.Columns.Add("DefectRemarks");
- dtProductionDefectData.Columns.Add("TempCount");
- dtProductionDefectData.Columns.Add("ProductionDataID"); //生产数据ID
- dtProductionDefectData.Columns.Add("DefectFineID"); //缺陷扣罚ID
- dtProductionDefectData.Columns.Add("DefectFineValue"); //缺陷扣罚
- dtProductionDefectData.Columns.Add("MissedUserID"); //漏检工号ID
- dtProductionDefectData.Columns.Add("MissedUserCode"); //漏检工号编码
- dtProductionDefectData.Columns.Add("MissedUserName"); //漏检工号名称
- dtProductionDefectData.Columns.Add("IsAllowEdit"); //是否允许编辑 0 不允许,1允许
- //新添加的 wangx 2016/1/6
- dtProductionDefectData.Columns.Add("DefectDeductionID"); //缺陷扣除数ID
- dtProductionDefectData.Columns.Add("DefectDeductionNum"); //缺陷扣除数
- dtProductionDefectData.Columns.Add("IsOtherDefect"); //特殊缺陷
- dtProductionDefectData.Columns.Add("CheckTime"); //缺陷检验时间
- //新添加的 wangx 2016/1/6 end
- DSTable.Tables.Add(dtProductionDefectData);
- }
- if (dsProductionDataByID != null && dsProductionDataByID.Tables[1].Rows.Count > Constant.INT_IS_ZERO)
- {
- // 产品缺陷
- if (DSTable.Tables.IndexOf(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString()) == -Constant.INT_IS_ONE)
- {
- DataTable dtProductionDefectData = new DataTable(dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString());
- dtProductionDefectData.Columns.Add("BarCode");
- dtProductionDefectData.Columns.Add("DefectID", typeof(decimal));
- dtProductionDefectData.Columns.Add("DefectName");
- dtProductionDefectData.Columns.Add("DefectCode");
- dtProductionDefectData.Columns.Add("DefectPositionID", typeof(decimal));
- dtProductionDefectData.Columns.Add("DefectPositionName");
- dtProductionDefectData.Columns.Add("DefectPositionCode");
- dtProductionDefectData.Columns.Add("DefectProcedureID", typeof(decimal));
- dtProductionDefectData.Columns.Add("DefectProcedureName");
- dtProductionDefectData.Columns.Add("DefectProcedureCode");
- dtProductionDefectData.Columns.Add("DefectUserID", typeof(decimal));//责任员工
- dtProductionDefectData.Columns.Add("DefectUserName");//责任员工
- dtProductionDefectData.Columns.Add("DefectUserCode");//
- dtProductionDefectData.Columns.Add("Jobs", typeof(decimal));//工种
- dtProductionDefectData.Columns.Add("JobsText");//工种
- dtProductionDefectData.Columns.Add("DefectRemarks");
- dtProductionDefectData.Columns.Add("TempCount");
- dtProductionDefectData.Columns.Add("ProductionDataID"); //生产数据ID
- dtProductionDefectData.Columns.Add("DefectFineID"); //缺席扣罚ID
- dtProductionDefectData.Columns.Add("DefectFineValue"); //缺席扣罚
- dtProductionDefectData.Columns.Add("MissedUserID"); //漏检工号ID
- dtProductionDefectData.Columns.Add("MissedUserCode"); //漏检工号编码
- dtProductionDefectData.Columns.Add("MissedUserName"); //漏检工号名称
- dtProductionDefectData.Columns.Add("IsAllowEdit"); //是否允许编辑 0 不允许,1允许
- //新添加的 wangx 2016/1/6
- dtProductionDefectData.Columns.Add("DefectDeductionID"); //缺陷扣除数ID
- dtProductionDefectData.Columns.Add("DefectDeductionNum"); //缺陷扣除数
- dtProductionDefectData.Columns.Add("IsOtherDefect"); //特殊缺陷
- dtProductionDefectData.Columns.Add("CheckTime"); //缺陷检验时间
- //新添加的 wangx 2016/1/6 end
- DSTable.Tables.Add(dtProductionDefectData);
- }
- this.dgvProductionData.Rows[TableProductionData.Rows.Count - 1].Selected = true;
- this._selectedRowIndex = TableProductionData.Rows.Count - 1;
- this._currentDefectFlag = Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["GoodsLevelTypeID"].Value.ToString());
- this._currentGoodsID = Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["GoodsID"].Value);
- this._currentBarCode = this.dgvProductionData.Rows[_selectedRowIndex].Cells["BarCode"].Value.ToString();
- //-----------------------
- //DataSet ds = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- //{
- // return PMModuleProxy.Service.GetReworkProcedureByProcedureID(this._procedureID);
- //}));
- //ds.Tables[0].TableName = dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString();
- //if (this.DSREWORK == null)
- //{
- // this.DSREWORK = new DataSet();
- //}
- //this.DSREWORK.Tables.Add(ds.Tables[0].Copy());
- //C_DGV_Cell_ListBoxComboBox C_DGV_Cell_ListBoxComboBox = dgvProductionData.Rows[_selectedRowIndex].Cells[4] as C_DGV_Cell_ListBoxComboBox;
- //C_DGV_Cell_ListBoxComboBox.DataSource = ds.Tables[0];
- //C_DGV_Cell_ListBoxComboBox.DisplayMember = "ReworkProcedureName";
- //C_DGV_Cell_ListBoxComboBox.ValueMember = "ReworkProcedureID";
- for (int i = 0; i < dsProductionDataByID.Tables[1].Rows.Count; i++)
- {
- DataRow dr = DSTable.Tables[dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString()].NewRow();
- dr["BarCode"] = dsProductionDataByID.Tables[1].Rows[i]["BarCode"];
- dr["DefectID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectID"];
- dr["DefectName"] = dsProductionDataByID.Tables[1].Rows[i]["DefectName"];
- dr["DefectCode"] = dsProductionDataByID.Tables[1].Rows[i]["DefectCode"];
- dr["DefectPositionID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectPositionID"];
- dr["DefectPositionName"] = dsProductionDataByID.Tables[1].Rows[i]["DefectPositionName"];
- dr["DefectPositionCode"] = dsProductionDataByID.Tables[1].Rows[i]["DefectPositionCode"];
- dr["DefectProcedureID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectProcedureID"];
- dr["DefectProcedureName"] = dsProductionDataByID.Tables[1].Rows[i]["DefectProcedureName"];
- dr["DefectProcedureCode"] = dsProductionDataByID.Tables[1].Rows[i]["DefectProcedureCode"];
- dr["DefectUserID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectUserID"];
- dr["DefectUserName"] = dsProductionDataByID.Tables[1].Rows[i]["DefectUserName"];
- dr["DefectUserCode"] = dsProductionDataByID.Tables[1].Rows[i]["DefectUserCode"];
- dr["Jobs"] = dsProductionDataByID.Tables[1].Rows[i]["Jobs"];
- dr["JobsText"] = dsProductionDataByID.Tables[1].Rows[i]["JobsText"];
- dr["DefectRemarks"] = dsProductionDataByID.Tables[1].Rows[i]["DefectRemarks"];
- dr["TempCount"] = this._tempCount;
- dr["ProductionDataID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectProductionDataID"];// dsProductionDataByID.Tables[1].Rows[i]["ProductionDataID"];
- dr["DefectFineID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectFineID"];
- dr["DefectFineValue"] = dsProductionDataByID.Tables[1].Rows[i]["DefectFineValue"];
- dr["MissedUserID"] = dsProductionDataByID.Tables[1].Rows[i]["MissedUserID"];
- dr["MissedUserCode"] = dsProductionDataByID.Tables[1].Rows[i]["MissedUserCode"];
- dr["MissedUserName"] = dsProductionDataByID.Tables[1].Rows[i]["MissedUserName"];
- dr["IsAllowEdit"] = this._AllowEdit;
- //dr["DefectDeductionID"] = dsProductionDataByID.Tables[1].Rows[i]["DefectDeductionID"];
- dr["DefectDeductionNum"] = dsProductionDataByID.Tables[1].Rows[i]["DefectDeductionNum"];
- dr["IsOtherDefect"] = dsProductionDataByID.Tables[1].Rows[i]["SpecialDefect"];
- dr["CheckTime"] = dsProductionDataByID.Tables[1].Rows[i]["CheckTime"];
- DSTable.Tables[dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString()].Rows.Add(dr);
- // 防止工种不选择的话,直接New一个
- if (!this.DSTableStaff.Tables.Contains(string.Format("TempTable{0}", this._tempCount)))
- {
- DataTable dtStaff = new DataTable(string.Format("TempTable{0}", this._tempCount));
- dtStaff.Columns.Add("IsSelected");
- dtStaff.Columns.Add("StaffID");
- dtStaff.Columns.Add("StaffCode");
- dtStaff.Columns.Add("StaffName");
- dtStaff.Columns.Add("StaffTempCount");
- dtStaff.Columns.Add("StaffStatus");
- this.DSTableStaff.Tables.Add(dtStaff);
- }
- // 责任员工
- DataRow[] drRow = dsProductionDataByID.Tables[2].Select("ProductionDefectID=" + dsProductionDataByID.Tables[1].Rows[i]["ProductionDefectID"]);
- if (drRow.Length > Constant.INT_IS_ZERO)
- {
- foreach (DataRow r in drRow)
- {
- DataRow drStaff = this.DSTableStaff.Tables[string.Format("TempTable{0}", this._tempCount)].NewRow();
- drStaff["IsSelected"] = 1;
- drStaff["StaffID"] = r["StaffID"];
- drStaff["StaffCode"] = r["StaffCode"];
- drStaff["StaffName"] = r["StaffName"];
- drStaff["StaffTempCount"] = this._tempCount;
- drStaff["StaffStatus"] = r["StaffStatus"];
- this.DSTableStaff.Tables[string.Format("TempTable{0}", this._tempCount)].Rows.Add(drStaff);
- }
- }
- // 漏检员工临时表
- if (!this.DSTableMissedStaff.Tables.Contains(string.Format("TempTable{0}", this._tempCount)))
- {
- DataTable dtMissedStaff = new DataTable(string.Format("TempTable{0}", this._tempCount));
- dtMissedStaff.Columns.Add("IsSelected");
- dtMissedStaff.Columns.Add("StaffID");
- dtMissedStaff.Columns.Add("StaffCode");
- dtMissedStaff.Columns.Add("StaffName");
- dtMissedStaff.Columns.Add("StaffTempCount");
- dtMissedStaff.Columns.Add("StaffStatus");
- dtMissedStaff.Columns.Add("UJobsID");
- dtMissedStaff.Columns.Add("SJobsID");
- this.DSTableMissedStaff.Tables.Add(dtMissedStaff);
- }
- //漏检员工临时表数据
- DataRow[] drMissedRow = dsProductionDataByID.Tables[4].Select("ProductionDefectID=" + dsProductionDataByID.Tables[1].Rows[i]["ProductionDefectID"]);
- if (drMissedRow.Length > Constant.INT_IS_ZERO)
- {
- foreach (DataRow r in drMissedRow)
- {
- DataRow drMissedStaff = this.DSTableMissedStaff.Tables[string.Format("TempTable{0}", this._tempCount)].NewRow();
- drMissedStaff["IsSelected"] = 1;
- drMissedStaff["StaffID"] = r["StaffID"];
- drMissedStaff["StaffCode"] = r["StaffCode"];
- drMissedStaff["StaffName"] = r["StaffName"];
- drMissedStaff["StaffTempCount"] = this._tempCount;
- drMissedStaff["StaffStatus"] = r["StaffStatus"];
- drMissedStaff["UJobsID"] = r["UJobsID"];
- drMissedStaff["SJobsID"] = r["SJobsID"];
- this.DSTableMissedStaff.Tables[string.Format("TempTable{0}", this._tempCount)].Rows.Add(drMissedStaff);
- }
- }
- if (!this.DSTableImage.Tables.Contains(string.Format("TempTable{0}", this._tempCount.ToString())))
- {
- DataTable dtImage = new DataTable(string.Format("TempTable{0}", this._tempCount.ToString()));
- dtImage.Columns.Add("StaffTempCount");
- dtImage.Columns.Add("ImageByte", typeof(byte[]));
- dtImage.Columns.Add("OrgImageByte", typeof(byte[]));
- this.DSTableImage.Tables.Add(dtImage);
- }
- this._currentTempSign = i.ToString();
- // 缺陷图片
- DataRow[] drImageRow = dsProductionDataByID.Tables[3].Select("ProductionDefectID=" + dsProductionDataByID.Tables[1].Rows[i]["ProductionDefectID"]);
- if (drImageRow.Length > Constant.INT_IS_ZERO)
- {
- foreach (DataRow r in drImageRow)
- {
- if (r["SourcePathByte"] != DBNull.Value)
- {
- byte[] orgImageByte = (byte[])r["SourcePathByte"];
- this._PicByte.Add(orgImageByte);
- //this._smallByte.Add(orgImageByte);
- if (!this.DSTableImage.Tables.Contains(string.Format("TempTable{0}", this._currentTempSign.ToString())))
- {
- DataTable dtImage = new DataTable(string.Format("TempTable{0}", this._currentTempSign.ToString()));
- dtImage.Columns.Add("StaffTempCount");
- dtImage.Columns.Add("ImageByte", typeof(byte[]));
- dtImage.Columns.Add("OrgImageByte", typeof(byte[]));
- this.DSTableImage.Tables.Add(dtImage);
- }
- DataRow drrow = DSTableImage.Tables[string.Format("TempTable{0}", this._currentTempSign)].NewRow();
- drrow["StaffTempCount"] = this._currentTempSign;
- drrow["ImageByte"] = orgImageByte;
- drrow["OrgImageByte"] = orgImageByte;
- DSTableImage.Tables[string.Format("TempTable{0}", this._currentTempSign)].Rows.Add(drrow);
- BindImg();
- }
- }
- }
- this._tempCount = this._tempCount + 1;
- }
- this.dgvDefect.DataSource = DSTable.Tables[dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString()];//根据条码产生不同数据源
- //控制产品等级,只有编辑权限的人才能随便改
- if (this._AllowEdit == 0) //
- {
- for (int i = 0; i < this.dgvProductionData.Rows.Count; i++)
- {
- int goodsLevelTypeID = Convert.ToInt32(this.TableProductionData.Rows[i]["GoodsLevelTypeID"]);
- if (this._dsGoodsLevel != null)
- {
- DataTable dt = this._dsGoodsLevel.Tables[0].Copy();
- DataView dv = dt.DefaultView;
- //xuwei modify 2019-12-13 不限制 产品分级
- //dv.RowFilter = "GoodsLevelTypeID>=" + goodsLevelTypeID;
- DataGridViewComboBoxCell dgcbc = (DataGridViewComboBoxCell)dgvProductionData.Rows[i].Cells[3];
- //xuwei modify 2019-12-12
- //dgcbc.DisplayMember = "DefectFlagName";
- //dgcbc.ValueMember = "DefectFlagID";
- dgcbc.DisplayMember = "GOODSLEVELNAME";
- dgcbc.ValueMember = "GOODSLEVELID";
- dgcbc.DataSource = dv.ToTable();
- }
- }
- }
- }
- if (!this.btnSave.Visible)
- {
- this.tsbtnAdd.Enabled = false;
- this.tsbtnEdit.Enabled = false;
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 绑定到第一个DataGriwView数据源
- /// </summary>
- private void BindProductionDataReFine(DataSet dsCheckBarcode)
- {
- try
- {
- DataRow[] dr = TableProductionData.Select("BarCode='" + this.txtBarCode.Text.Trim() + "'");
- if (dr.Length > Constant.INT_IS_ZERO)
- {
- // 不允许重复添加
- return;
- }
- int SpecialRepairflag = (int)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetSpecialRepairflagByBarcode(this.txtBarCode.Text.Trim());
- }));
- string KilnCarCode = string.Empty;
- string KilnCode = string.Empty;
- string Dictionaryvalue = string.Empty;
- DataSet dsKilnCar = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetKilnCarByBarCode(txtBarCode.Text.Trim());
- }));
- if (dsKilnCar != null && dsKilnCar.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
- {
- KilnCarCode = dsKilnCar.Tables[0].Rows[0]["KilnCarCode"].ToString();
- KilnCode = dsKilnCar.Tables[0].Rows[0]["KilnCode"].ToString();
- Dictionaryvalue = dsKilnCar.Tables[0].Rows[0]["Dictionaryvalue"].ToString();
- }
- DataRow drNew = TableProductionData.NewRow();
- drNew["BarCode"] = this.txtBarCode.Text.Trim();
- drNew["ProductionDataID"] = this._productiondataid;
- drNew["GoodsID"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsID.ToString()];
- drNew["GoodsCode"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsCode.ToString()];
- drNew["GoodsName"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsName.ToString()];
- drNew["DefectFlagID"] = _dsGoodsLevel.Tables[0].Rows[0]["DefectFlagID"];
- drNew["ReworkProcedureID"] = DBNull.Value;
- drNew["Remarks"] = "";
- drNew["UserID"] = UserID;
- drNew["UserCode"] = UserCode;
- drNew["UserName"] = UserName;
- drNew["GoodsLevelTypeID"] = _dsGoodsLevel.Tables[0].Rows[0]["GoodsLevelTypeID"];
- drNew["OrgGoodsLevelTypeID"] = -1;
- drNew["SpecialRepairflag"] = SpecialRepairflag == 1 ? 1 : 0;
- drNew["KilnCarCode"] = KilnCarCode;
- drNew["KilnCode"] = KilnCode;
- drNew["Dictionaryvalue"] = Dictionaryvalue;
- // 校验条码是否重烧过
- DataSet dsReFine = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetReFine(this.txtBarCode.Text.Trim());
- }));
- if (dsReFine != null && dsReFine.Tables[0].Rows.Count > 0 && dsReFine.Tables[0].Rows[0]["IsReFire"].ToString() == "6")
- {
- drNew["ReFine"] = 1;
- }
- else
- {
- drNew["ReFine"] = 0;
- }
- drNew["UserCode"] = this.txtUserCode.Text.Trim();
- // 由产品条码获取注浆信息
- DataSet dsGroutingProduct = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetGroutingProducttByBarCode(txtBarCode.Text.Trim());
- }));
- drNew["MouldCode"] = dsGroutingProduct.Tables[0].Rows[0]["MouldCode"];
- drNew["GroutingUserCode"] = dsGroutingProduct.Tables[0].Rows[0]["GroutingUserCode"];
- drNew["GroutingNum"] = dsGroutingProduct.Tables[0].Rows[0]["GroutingNum"];
- drNew["IsPublicBody"] = dsGroutingProduct.Tables[0].Rows[0]["IsPublicBody"].ToString() != "1" ? 0 : 1;
- drNew["GroutingDate"] = Convert.ToDateTime(dsGroutingProduct.Tables[0].Rows[0]["GroutingDate"]);
- drNew["LogoCodeName"] = dsGroutingProduct.Tables[0].Rows[0]["LogoName"] + "[" + dsGroutingProduct.Tables[0].Rows[0]["LogoCode"] + "]";
- drNew["LogoID"] = dsGroutingProduct.Tables[0].Rows[0]["LogoID"];
- TableProductionData.Rows.Add(drNew);
- if (DSTable.Tables.IndexOf(this.txtBarCode.Text.Trim()) == -Constant.INT_IS_ONE)
- {
- DataTable dtProductionDefectData = new DataTable(this.txtBarCode.Text.Trim());
- dtProductionDefectData.Columns.Add("BarCode");
- dtProductionDefectData.Columns.Add("DefectID", typeof(decimal));
- dtProductionDefectData.Columns.Add("DefectName");
- dtProductionDefectData.Columns.Add("DefectCode");
- dtProductionDefectData.Columns.Add("DefectPositionID", typeof(decimal));
- dtProductionDefectData.Columns.Add("DefectPositionName");
- dtProductionDefectData.Columns.Add("DefectPositionCode");
- dtProductionDefectData.Columns.Add("DefectProcedureID", typeof(decimal));
- dtProductionDefectData.Columns.Add("DefectProcedureName");
- dtProductionDefectData.Columns.Add("DefectProcedureCode");
- dtProductionDefectData.Columns.Add("DefectUserID", typeof(decimal));//责任员工
- dtProductionDefectData.Columns.Add("DefectUserName");//责任员工
- dtProductionDefectData.Columns.Add("DefectUserCode");//
- dtProductionDefectData.Columns.Add("Jobs", typeof(decimal));//工种
- dtProductionDefectData.Columns.Add("JobsText");//工种
- dtProductionDefectData.Columns.Add("DefectRemarks");
- dtProductionDefectData.Columns.Add("TempCount");
- dtProductionDefectData.Columns.Add("ProductionDataID"); //生产数据ID
- dtProductionDefectData.Columns.Add("DefectFineID"); //缺席扣罚ID
- dtProductionDefectData.Columns.Add("DefectFineValue"); //缺席扣罚
- dtProductionDefectData.Columns.Add("MissedUserID"); //漏检工号ID
- dtProductionDefectData.Columns.Add("MissedUserCode"); //漏检工号编码
- dtProductionDefectData.Columns.Add("MissedUserName"); //漏检工号名称
- dtProductionDefectData.Columns.Add("IsAllowEdit"); //漏检工号名称
- //新添加的 wangx 2016/1/6
- dtProductionDefectData.Columns.Add("DefectDeductionID"); //缺陷扣除数ID
- dtProductionDefectData.Columns.Add("DefectDeductionNum"); //缺陷扣除数
- dtProductionDefectData.Columns.Add("IsOtherDefect"); //特殊缺陷
- dtProductionDefectData.Columns.Add("CheckTime"); //缺陷检验时间
- DSTable.Tables.Add(dtProductionDefectData);
- }
- this.dgvDefect.DataSource = DSTable.Tables[this.txtBarCode.Text.Trim()];//根据条码产生不同数据源
- this.dgvProductionData.Rows[TableProductionData.Rows.Count - 1].Selected = true;
- this.dgvDefect.DataSource = null;
- this.dgvDefectStaff.DataSource = null;
- this.lvPic.Clear();
- // 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
- this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
- // 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
- this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
- // 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
- this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
- this._selectedRowIndex = TableProductionData.Rows.Count - 1;
- //DataSet ds = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- //{
- // return PMModuleProxy.Service.GetReworkProcedureByProcedureID(this._procedureID);
- //}));
- //ds.Tables[0].TableName = this.txtBarCode.Text.Trim();
- //if (this.DSREWORK == null)
- //{
- // this.DSREWORK = new DataSet();
- //}
- //this.DSREWORK.Tables.Add(ds.Tables[0].Copy());
- //// 返工工序数据源
- //C_DGV_Cell_ListBoxComboBox C_DGV_Cell_ListBoxComboBox = dgvProductionData.Rows[_selectedRowIndex].Cells[4] as C_DGV_Cell_ListBoxComboBox;
- //C_DGV_Cell_ListBoxComboBox.DataSource = ds.Tables[0];
- //C_DGV_Cell_ListBoxComboBox.DisplayMember = "ReworkProcedureName";
- //C_DGV_Cell_ListBoxComboBox.ValueMember = "ReworkProcedureID";
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 绑定到第一个DataGriwView数据源
- /// </summary>
- private void BindProductionDataEdit(DataSet dsCheckBarcode)
- {
- try
- {
- DataRow[] dr = TableProductionData.Select("BarCode='" + this.txtBarCode.Text.Trim() + "'");
- if (dr.Length > Constant.INT_IS_ZERO)
- {
- // 不允许重复添加
- return;
- }
- int SpecialRepairflag = (int)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetSpecialRepairflagByBarcode(this.txtBarCode.Text.Trim());
- }));
- string KilnCarCode = string.Empty;
- string KilnCode = string.Empty;
- string Dictionaryvalue = string.Empty;
- DataSet dsKilnCar = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetKilnCarByBarCode(txtBarCode.Text.Trim());
- }));
- if (dsKilnCar != null && dsKilnCar.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
- {
- KilnCarCode = dsKilnCar.Tables[0].Rows[0]["KilnCarCode"].ToString();
- KilnCode = dsKilnCar.Tables[0].Rows[0]["KilnCode"].ToString();
- Dictionaryvalue = dsKilnCar.Tables[0].Rows[0]["Dictionaryvalue"].ToString();
- }
- DataRow drNew = TableProductionData.NewRow();
- drNew["ProductionDataID"] = this._productiondataid;
- drNew["BarCode"] = this.txtBarCode.Text.Trim();
- DataSet ds = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetGoodsInfoBybarcode(this.txtBarCode.Text.Trim());
- }));
- if (ds != null && ds.Tables[0].Rows.Count > 0)
- {
- drNew["GoodsID"] = ds.Tables[0].Rows[0]["GoodsID"];
- drNew["GoodsCode"] = ds.Tables[0].Rows[0]["GoodsCode"];
- drNew["GoodsName"] = ds.Tables[0].Rows[0]["GoodsName"];
- }
- drNew["DefectFlagID"] = _dsGoodsLevel.Tables[0].Rows[0]["DefectFlagID"];
- drNew["ReworkProcedureID"] = DBNull.Value;
- drNew["Remarks"] = "";
- drNew["UserID"] = UserID;
- drNew["UserCode"] = UserCode;
- drNew["UserName"] = UserName;
- drNew["GoodsLevelTypeID"] = _dsGoodsLevel.Tables[0].Rows[0]["GoodsLevelTypeID"];
- drNew["OrgGoodsLevelTypeID"] = -1;
- drNew["SpecialRepairflag"] = SpecialRepairflag == 1 ? 1 : 0;
- drNew["KilnCarCode"] = KilnCarCode;
- drNew["KilnCode"] = KilnCode;
- drNew["Dictionaryvalue"] = Dictionaryvalue;
- // 校验条码是否重烧过
- DataSet dsReFine = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetReFine(this.txtBarCode.Text.Trim());
- }));
- if (dsReFine != null && dsReFine.Tables[0].Rows.Count > 0 && dsReFine.Tables[0].Rows[0]["IsReFire"].ToString() == "6")
- {
- drNew["ReFine"] = 1;
- }
- else
- {
- drNew["ReFine"] = 0;
- }
- drNew["UserCode"] = this.txtUserCode.Text.Trim();
- // 由产品条码获取注浆信息
- DataSet dsGroutingProduct = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetGroutingProducttByBarCode(txtBarCode.Text.Trim());
- }));
- drNew["MouldCode"] = dsGroutingProduct.Tables[0].Rows[0]["MouldCode"];
- drNew["GroutingUserCode"] = dsGroutingProduct.Tables[0].Rows[0]["GroutingUserCode"];
- drNew["GroutingNum"] = dsGroutingProduct.Tables[0].Rows[0]["GroutingNum"];
- drNew["IsPublicBody"] = dsGroutingProduct.Tables[0].Rows[0]["IsPublicBody"].ToString() != "1" ? 0 : 1;
- drNew["GroutingDate"] = Convert.ToDateTime(dsGroutingProduct.Tables[0].Rows[0]["GroutingDate"]);
- drNew["LogoCodeName"] = dsGroutingProduct.Tables[0].Rows[0]["LogoName"] + "[" + dsGroutingProduct.Tables[0].Rows[0]["LogoCode"] + "]";
- drNew["LogoId"] = dsGroutingProduct.Tables[0].Rows[0]["LogoId"];
- TableProductionData.Rows.Add(drNew);
- if (DSTable.Tables.IndexOf(this.txtBarCode.Text.Trim()) == -Constant.INT_IS_ONE)
- {
- DataTable dtProductionDefectData = new DataTable(this.txtBarCode.Text.Trim());
- dtProductionDefectData.Columns.Add("BarCode");
- dtProductionDefectData.Columns.Add("DefectID", typeof(decimal));
- dtProductionDefectData.Columns.Add("DefectName");
- dtProductionDefectData.Columns.Add("DefectCode");
- dtProductionDefectData.Columns.Add("DefectPositionID", typeof(decimal));
- dtProductionDefectData.Columns.Add("DefectPositionName");
- dtProductionDefectData.Columns.Add("DefectPositionCode");
- dtProductionDefectData.Columns.Add("DefectProcedureID", typeof(decimal));
- dtProductionDefectData.Columns.Add("DefectProcedureName");
- dtProductionDefectData.Columns.Add("DefectProcedureCode");
- dtProductionDefectData.Columns.Add("DefectUserID", typeof(decimal));//责任员工
- dtProductionDefectData.Columns.Add("DefectUserName");//责任员工
- dtProductionDefectData.Columns.Add("DefectUserCode");//
- dtProductionDefectData.Columns.Add("Jobs", typeof(decimal));//工种
- dtProductionDefectData.Columns.Add("JobsText");//工种
- dtProductionDefectData.Columns.Add("DefectRemarks");
- dtProductionDefectData.Columns.Add("TempCount");
- dtProductionDefectData.Columns.Add("ProductionDataID"); //生产数据ID
- dtProductionDefectData.Columns.Add("DefectFineID"); //缺席扣罚ID
- dtProductionDefectData.Columns.Add("DefectFineValue"); //缺席扣罚
- dtProductionDefectData.Columns.Add("MissedUserID"); //漏检工号ID
- dtProductionDefectData.Columns.Add("MissedUserCode"); //漏检工号编码
- dtProductionDefectData.Columns.Add("MissedUserName"); //漏检工号名称
- dtProductionDefectData.Columns.Add("IsAllowEdit"); //允许编辑
- //新添加的 wangx 2016/1/6
- dtProductionDefectData.Columns.Add("DefectDeductionID"); //缺陷扣除数ID
- dtProductionDefectData.Columns.Add("DefectDeductionNum"); //缺陷扣除数
- dtProductionDefectData.Columns.Add("IsOtherDefect"); //特殊缺陷
- dtProductionDefectData.Columns.Add("CheckTime"); //缺陷检验时间
- DSTable.Tables.Add(dtProductionDefectData);
- }
- this.dgvDefect.DataSource = DSTable.Tables[this.txtBarCode.Text.Trim()];//根据条码产生不同数据源
- this.dgvProductionData.Rows[TableProductionData.Rows.Count - 1].Selected = true;
- this.dgvDefect.DataSource = null;
- this.dgvDefectStaff.DataSource = null;
- this.lvPic.Clear();
- // 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
- this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
- // 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
- this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
- // 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
- this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
- this._selectedRowIndex = TableProductionData.Rows.Count - 1;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 绑定到第一个DataGriwView数据源
- /// </summary>
- private void BindProductionData(DataSet dsCheckBarcode)
- {
- try
- {
- DataRow[] dr = TableProductionData.Select("BarCode='" + this.txtBarCode.Text.Trim() + "'");
- if (dr.Length > Constant.INT_IS_ZERO)
- {
- // 不允许重复添加
- return;
- }
- int SpecialRepairflag = 0;
- if (dsCheckBarcode == null || dsCheckBarcode.Tables[0].Rows.Count == 0)
- {
- SpecialRepairflag = (int)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetSpecialRepairflagByBarcode(this.txtBarCode.Text.Trim());
- }));
- }
- else
- {
- SpecialRepairflag = Convert.ToInt32(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_specialRepairFlag.ToString()]);
- }
- string KilnCarCode = string.Empty;
- string KilnCode = string.Empty;
- string Dictionaryvalue = string.Empty;
- DataSet dsKilnCar = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetKilnCarByBarCode(txtBarCode.Text.Trim());
- }));
- if (dsKilnCar != null && dsKilnCar.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
- {
- KilnCarCode = dsKilnCar.Tables[0].Rows[0]["KilnCarCode"].ToString();
- KilnCode = dsKilnCar.Tables[0].Rows[0]["KilnCode"].ToString();
- Dictionaryvalue = dsKilnCar.Tables[0].Rows[0]["Dictionaryvalue"].ToString();
- }
- DataRow drNew = TableProductionData.NewRow();
- drNew["BarCode"] = this.txtBarCode.Text.Trim();
- if (dsCheckBarcode != null)
- {
- drNew["GoodsID"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsID.ToString()];
- drNew["GoodsCode"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsCode.ToString()];
- drNew["GoodsName"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsName.ToString()];
- }
- else
- {
- DataSet ds = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetGoodsInfoBybarcode(this.txtBarCode.Text.Trim());
- }));
- if (ds != null && ds.Tables[0].Rows.Count > 0)
- {
- drNew["GoodsID"] = ds.Tables[0].Rows[0]["GoodsID"];
- drNew["GoodsCode"] = ds.Tables[0].Rows[0]["GoodsCode"];
- drNew["GoodsName"] = ds.Tables[0].Rows[0]["GoodsName"];
- }
- }
- drNew["UserID"] = UserID;
- drNew["KilnCarCode"] = KilnCarCode;
- drNew["KilnCode"] = KilnCode;
- drNew["Dictionaryvalue"] = Dictionaryvalue;
- //xuwei modify 2019-12-12
- //drNew["DefectFlagID"] = _dsGoodsLevel.Tables[0].Rows[0]["DefectFlagID"];
- drNew["DefectFlagID"] = _dsGoodsLevel.Tables[0].Rows[0]["GOODSLEVELID"];
- drNew["ReworkProcedureID"] = DBNull.Value;
- drNew["Remarks"] = "";
- drNew["UserID"] = UserID;
- drNew["UserCode"] = UserCode;
- drNew["UserName"] = UserName;
- drNew["GoodsLevelTypeID"] = _dsGoodsLevel.Tables[0].Rows[0]["GoodsLevelTypeID"];
- drNew["OrgGoodsLevelTypeID"] = -1;
- drNew["SpecialRepairflag"] = SpecialRepairflag == 1 ? 1 : 0;
- drNew["LogoCodeName"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoName.ToString()]
- + "[" + dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoCode.ToString()] + "]";
- drNew["LogoID"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoID.ToString()];
- // 校验条码是否重烧过
- DataSet dsReFine = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetReFine(this.txtBarCode.Text.Trim());
- }));
- if (dsReFine != null && dsReFine.Tables[0].Rows.Count > 0 && dsReFine.Tables[0].Rows[0]["IsReFire"].ToString() == "6")
- {
- drNew["ReFine"] = 1;
- }
- else
- {
- drNew["ReFine"] = 0;
- }
- if (dsCheckBarcode == null || dsCheckBarcode.Tables[0].Rows.Count == 0)
- {
- // 由产品条码获取注浆信息
- DataSet dsGroutingProduct = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetGroutingProducttByBarCode(txtBarCode.Text.Trim());
- }));
- drNew["UserCode"] = this.txtUserCode.Text.Trim();
- drNew["MouldCode"] = dsGroutingProduct.Tables[0].Rows[0]["MouldCode"];
- drNew["GroutingUserCode"] = dsGroutingProduct.Tables[0].Rows[0]["GroutingUserCode"];
- drNew["GroutingNum"] = dsGroutingProduct.Tables[0].Rows[0]["GroutingNum"];
- drNew["IsPublicBody"] = dsGroutingProduct.Tables[0].Rows[0]["IsPublicBody"].ToString() != "1" ? 0 : 1;
- drNew["GroutingDate"] = Convert.ToDateTime(dsGroutingProduct.Tables[0].Rows[0]["GroutingDate"]);
- }
- else
- {
- drNew["UserCode"] = this.txtUserCode.Text.Trim();
- drNew["MouldCode"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_mouldCode.ToString()];
- drNew["GroutingUserCode"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()];
- drNew["GroutingNum"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingNum.ToString()];
- drNew["IsPublicBody"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_ispublicbody.ToString()].ToString() != "1" ? 0 : 1;
- drNew["GroutingDate"] = Convert.ToDateTime(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingdate.ToString()]);
- }
- TableProductionData.Rows.Add(drNew);
- if (DSTable.Tables.IndexOf(this.txtBarCode.Text.Trim()) == -Constant.INT_IS_ONE)
- {
- DataTable dtProductionDefectData = new DataTable(this.txtBarCode.Text.Trim());
- dtProductionDefectData.Columns.Add("BarCode");
- dtProductionDefectData.Columns.Add("DefectID", typeof(decimal));
- dtProductionDefectData.Columns.Add("DefectName");
- dtProductionDefectData.Columns.Add("DefectCode");
- dtProductionDefectData.Columns.Add("DefectPositionID", typeof(decimal));
- dtProductionDefectData.Columns.Add("DefectPositionName");
- dtProductionDefectData.Columns.Add("DefectPositionCode");
- dtProductionDefectData.Columns.Add("DefectProcedureID", typeof(decimal));
- dtProductionDefectData.Columns.Add("DefectProcedureName");
- dtProductionDefectData.Columns.Add("DefectProcedureCode");
- dtProductionDefectData.Columns.Add("DefectUserID", typeof(decimal));//责任员工
- dtProductionDefectData.Columns.Add("DefectUserName");//责任员工
- dtProductionDefectData.Columns.Add("DefectUserCode");//
- dtProductionDefectData.Columns.Add("Jobs", typeof(decimal));//工种
- dtProductionDefectData.Columns.Add("JobsText");//工种
- dtProductionDefectData.Columns.Add("DefectRemarks");
- dtProductionDefectData.Columns.Add("TempCount");
- dtProductionDefectData.Columns.Add("ProductionDataID"); //生产数据ID
- dtProductionDefectData.Columns.Add("DefectFineID"); //缺席扣罚ID
- dtProductionDefectData.Columns.Add("DefectFineValue"); //缺席扣罚
- dtProductionDefectData.Columns.Add("MissedUserID"); //漏检工号ID
- dtProductionDefectData.Columns.Add("MissedUserCode"); //漏检工号编码
- dtProductionDefectData.Columns.Add("MissedUserName"); //漏检工号名称
- dtProductionDefectData.Columns.Add("IsAllowEdit"); //允许编辑
- //新添加的 wangx 2016/1/6
- dtProductionDefectData.Columns.Add("DefectDeductionID"); //缺陷扣除数ID
- dtProductionDefectData.Columns.Add("DefectDeductionNum"); //缺陷扣除数
- dtProductionDefectData.Columns.Add("IsOtherDefect"); //特殊缺陷
- dtProductionDefectData.Columns.Add("CheckTime"); //缺陷检验时间
- DSTable.Tables.Add(dtProductionDefectData);
- }
- this.dgvDefect.DataSource = DSTable.Tables[this.txtBarCode.Text.Trim()];//根据条码产生不同数据源
- this.dgvProductionData.Rows[TableProductionData.Rows.Count - 1].Selected = true;
- this.dgvDefect.DataSource = null;
- this.dgvDefectStaff.DataSource = null;
- this.lvPic.Clear();
- // 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
- this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
- // 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
- this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
- // 添加一个产品条码时除了第一个显示在数据表中,其它的全部清空
- this.tsbtnAdd.Enabled = true;//添加完条码后,可以新建其它信息
- this._selectedRowIndex = TableProductionData.Rows.Count - 1;
- //DataTable dt = this._dsGoodsLevel.Tables[0];
- //DataView dv = dt.DefaultView;
- //dv.RowFilter = "GoodsLevelTypeID>=" + goodsLevelTypeID;
- //DataSet ds = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- //{
- // return PMModuleProxy.Service.GetReworkProcedureByProcedureID(this._procedureID);
- //}));
- //ds.Tables[0].TableName = this.txtBarCode.Text.Trim();
- //if (this.DSREWORK == null)
- //{
- // this.DSREWORK = new DataSet();
- //}
- //this.DSREWORK.Tables.Add(ds.Tables[0].Copy());
- //// 返工工序数据源
- //C_DGV_Cell_ListBoxComboBox C_DGV_Cell_ListBoxComboBox = dgvProductionData.Rows[_selectedRowIndex].Cells[4] as C_DGV_Cell_ListBoxComboBox;
- //C_DGV_Cell_ListBoxComboBox.DataSource = ds.Tables[0];
- //C_DGV_Cell_ListBoxComboBox.DisplayMember = "ReworkProcedureName";
- //C_DGV_Cell_ListBoxComboBox.ValueMember = "ReworkProcedureID";
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 通过是否有缺陷来启用或禁用
- /// </summary>
- /// <param name="DefectFlag"></param>
- private void SetGridView(int GoodsLevelID)
- {
- DataTable dtDefectFlag = this.DefectFlag.DataSource as DataTable;//获取缺陷数据源
- int GoodsLevelTypeID = -1;
- //xuwei modify 2019-12-12
- //DataRow[] dr = dtDefectFlag.Select("DefectFlagID=" + GoodsLevelID);
- DataRow[] dr = dtDefectFlag.Select("GoodsLevelID=" + GoodsLevelID);
- if (dr.Length > Constant.INT_IS_ZERO)
- {
- GoodsLevelTypeID = Convert.ToInt32(dr[0]["GoodsLevelTypeID"]);
- this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["GoodsLevelTypeID"].Value = GoodsLevelTypeID;
- }
- if (GoodsLevelTypeID != -Constant.INT_IS_ONE)
- {
- this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureID"].Value = DBNull.Value;
- this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureCode"].Value = string.Empty;
- this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureName"].Value = string.Empty;
- //xuwei modify 2019-12-13
- if (GoodsLevelTypeID == (int)Constant.GoodsLevelType.NoDefects) //良品
- {
- this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureID"].ReadOnly = true;
- try
- {
- string BarCode = this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["BarCode"].Value.ToString();
- if (DSTable.Tables.Contains(BarCode))
- {
- DSTable.Tables[BarCode].Rows.Clear();//清空行
- }
- this.dgvDefectStaff.DataSource = null;
- this.lvPic.Clear();
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- else if (GoodsLevelTypeID == (int)Constant.GoodsLevelType.NoDefects) //次品 或者正品
- {
- this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureID"].ReadOnly = true;
- }
- else if (GoodsLevelTypeID == (int)Constant.GoodsLevelType.ReFire)//重烧
- {
- this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureID"].ReadOnly = false;
- }
- else if (GoodsLevelTypeID == (int)Constant.GoodsLevelType.Substandard)//重烧
- {
- // this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["GoodsLevelTypeID"].Value = GoodsLevelTypeID;
- this.dgvProductionData.Rows[this.dgvProductionData.CurrentCell.RowIndex].Cells["ReworkProcedureID"].ReadOnly = false;
- }
- }
- }
- /// <summary>
- /// 清空以前所选中的缺陷
- /// </summary>
- /// <param name="checkValue"></param>
- private void SetCheckBoxSelected(int checkValue, int rowIndex)
- {
- DataTable dtOrgDataSource = this.dgvDefect.DataSource as DataTable;
- for (int i = 0; i < DSTable.Tables[dtOrgDataSource.TableName].Rows.Count; i++)
- {
- if (i == rowIndex)
- {
- dtOrgDataSource.Rows[i]["discarde"] = 1;
- }
- else
- {
- dtOrgDataSource.Rows[i]["discarde"] = 0;
- }
- }
- }
- /// <summary>
- /// 绑定并显示图片
- /// </summary>
- /// <param name="ImageData"></param>
- public void BindByteImage(DataTable ImageData)
- {
- this._smallByte.Clear();
- foreach (DataRow dr in ImageData.Rows)
- {
- //将数据库中的缩略图取出
- this._smallByte.Add((byte[])dr[1]);
- }
- //绑定缩略图
- BindImg();
- }
- /// <summary>
- /// 将图片文件转换成二进制
- /// </summary>
- /// <param name="img"></param>
- /// <returns></returns>
- public static byte[] ImageToByte(Image img)
- {
- byte[] smallbuffer = null;
- using (MemoryStream ms = new MemoryStream())
- {
- img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
- ms.Position = Constant.INT_IS_ZERO;
- smallbuffer = new byte[ms.Length];
- ms.Read(smallbuffer, Constant.INT_IS_ZERO, Convert.ToInt32(ms.Length));
- ms.Flush();
- }
- return smallbuffer;
- }
- /// <SUMMARY>
- /// 重绘缩略图并把缩略图转为二进制储存
- /// </SUMMARY>
- /// <PARAM name="sourceFile">图片源路径</PARAM>
- /// <PARAM name="destHeight">缩放后图片高度</PARAM>
- /// <PARAM name="destWidth">缩放后图片宽度</PARAM>
- /// <RETURNS></RETURNS>
- public void GetThumbnail(FileInfo sourceFile, byte[] orgImageByte)
- {
- Image imgSource = Image.FromStream(sourceFile.OpenRead());
- ImageFormat thisFormat = imgSource.RawFormat;
- int sW = 0, sH = 0;
- // 按比例缩放
- int sWidth = imgSource.Width;
- int sHeight = imgSource.Height;
- int destWidth = 100;
- int destHeight = getSmallImageHeight(sWidth, sHeight, destWidth);
- if (sHeight > destHeight || sWidth > destWidth)
- {
- if ((sWidth * destHeight) > (sHeight * destWidth))
- {
- sW = destWidth;
- sH = (destWidth * sHeight) / sWidth;
- }
- else
- {
- sH = destHeight;
- sW = (sWidth * destHeight) / sHeight;
- }
- }
- else
- {
- sW = sWidth;
- sH = sHeight;
- }
- Bitmap outBmp = new Bitmap(destWidth, destHeight);
- Graphics g = Graphics.FromImage(outBmp);
- g.Clear(Color.Black);
- // 设置画布的描绘质量
- g.CompositingQuality = CompositingQuality.HighQuality;
- g.SmoothingMode = SmoothingMode.HighQuality;
- g.InterpolationMode = InterpolationMode.HighQualityBicubic;
- g.DrawImage(imgSource, new Rectangle((destWidth - sW) / 2, (destHeight - sH) / 2, sW, sH), 0, 0, imgSource.Width, imgSource.Height, GraphicsUnit.Pixel);
- g.Dispose();
- //将重绘的图片转为二进制并保存
- Image image = (Image)outBmp;
- byte[] smallbuffer = ImageToByte(image);
- if (this._currentTempSign != string.Empty)
- {
- if (!this.DSTableImage.Tables.Contains(string.Format("TempTable{0}", this._currentTempSign.ToString())))
- {
- DataTable dtImage = new DataTable(string.Format("TempTable{0}", this._currentTempSign.ToString()));
- dtImage.Columns.Add("StaffTempCount");
- dtImage.Columns.Add("ImageByte", typeof(byte[]));
- dtImage.Columns.Add("OrgImageByte", typeof(byte[]));
- this.DSTableImage.Tables.Add(dtImage);
- }
- DataRow dr = DSTableImage.Tables[string.Format("TempTable{0}", this._currentTempSign)].NewRow();
- dr["StaffTempCount"] = this._currentTempSign;
- dr["ImageByte"] = smallbuffer;
- dr["OrgImageByte"] = orgImageByte;
- DSTableImage.Tables[string.Format("TempTable{0}", this._currentTempSign)].Rows.Add(dr);
- }
- this._smallByte.Add(smallbuffer);
- imgSource.Dispose();
- outBmp.Dispose();
- }
- /// <summary>
- /// 根据原图片宽高比获取缩略图的高(根据宽)
- /// </summary>
- /// <param name="BigWidth"></param>
- /// <param name="BigHeight"></param>
- /// <param name="SmallWidth"></param>
- /// <returns></returns>
- protected int getSmallImageHeight(int BigWidth, int BigHeight, int SmallWidth)
- {
- decimal scale = Convert.ToDecimal(BigWidth) / Convert.ToDecimal(BigHeight);
- return Convert.ToInt32(SmallWidth / scale);
- }
- /// <summary>
- /// 绑定缩略图到控件中
- /// </summary>
- protected void BindImg()
- {
- ImageList ilPic = new ImageList();
- //每次绑定要清空数据源
- ilPic.Images.Clear();
- //将缩略图二进制集合中的数据转换成图片文件
- List<Image> LSImageList = new List<Image>();
- foreach (byte[] smallby in _smallByte)
- {
- LSImageList.Add(byteArrayToImage(smallby));
- }
- //添加数据源
- foreach (Image img in LSImageList)
- {
- ilPic.Images.Add(img);
- }
- ilPic.ImageSize = new Size(100, 100);
- this.lvPic.LargeImageList = ilPic;
- this.lvPic.BeginUpdate();
- //清空列表的数据源
- lvPic.Items.Clear();
- //添加列表的数据源
- for (int i = 0; i < ilPic.Images.Count; i++)
- {
- ListViewItem lvi = new ListViewItem();
- lvi.ImageIndex = i;
- this.lvPic.Items.Add(lvi);
- }
- this.lvPic.EndUpdate();
- }
- /// <summary>
- /// 将数据库中的二进制转换成图片
- /// </summary>
- /// <param name="data"></param>
- /// <returns></returns>
- public static Image byteArrayToImage(object data)
- {
- System.IO.MemoryStream ms = new System.IO.MemoryStream((byte[])data);
- System.Drawing.Image returnImage = System.Drawing.Image.FromStream(ms);
- return returnImage;
- }
- #endregion
- /// <summary>
- /// 责任员工
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvDefectStaff_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
- {
- try
- {
- if (e.Row.Index != -1)
- {
- if (this.dgvDefect.CurrentCell != null)
- {
- //是新增进来,加载条码是不允许删除的,只是编辑权限才能可以删除
- 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")
- {
- e.Cancel = true;
- return;
- }
- }
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 漏扫责任员工
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvMissStaff_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
- {
- try
- {
- if (e.Row.Index != -1)
- {
- if (this.dgvDefect.CurrentCell != null)
- {
- //是新增进来,加载条码是不允许删除的,只是编辑权限才能可以删除
- 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")
- {
- e.Cancel = true;
- return;
- }
- }
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- }
- }
|