| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486 |
- /*******************************************************************************
- * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_PM_3402.cs
- * 2.功能描述:成品检验
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 秦祺 2021/11/1 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.Basics.Library;
- using Dongke.IBOSS.PRD.Client.CommonModule;
- using Dongke.IBOSS.PRD.Client.Controls;
- 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_3402 : DKDockPanelBase
- {
- #region 成员变量
- // 工序ID
- private int _procedureID;
- // 生产工号
- private int _userID = -1;
- // 生产编号
- private string _userCode;
- // 生产名称
- private string _userName;
- // 工序实体类
- //ProcedureEntity _procedureDataEntity;
- DataTable _procedureDataTable = null;
- // 产品数据表
- 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;
- private int _finishedCheckProcedureID;
- private DataTable scrapReasonDataSource;
- #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("LengBu");//冷补标识
- _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_3402()
- {
- InitializeComponent();
- }
- public F_PM_3402(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_3402(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_1202_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);
- // 获取工序明细数据
- //ClientRequestEntity cre = new ClientRequestEntity();
- //cre.NameSpace = "F_PM_3402";
- //cre.Name = "GetProcedureDataEntityByID";
- //cre.Properties["ProcedureID"] = this._procedureID;
- //ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
- //{
- // return PCModuleProxyNew.Service.HandleRequest(cre);
- //});
- //this._procedureDataTable = sre.Data.Tables[0];
- //ProcedureEntity procedureDataEntity = (ProcedureEntity)DoAsync(new BaseAsyncMethod(() =>
- //{
- // return PMModuleProxy.Service.GetProcedureDataEntityByID(this._procedureID);
- //}));
- //this._procedureDataEntity = procedureDataEntity;
- // 产品分级数据源
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "F_PM_3402";
- cre.Name = "GetGoodsLevel"; //半成品检验
- ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
- {
- return PCModuleProxyNew.Service.HandleRequest(cre);
- });
- DataSet dsGoodsLevel = sre.Data;
-
- //DataSet dsGoodsLevel = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- //{
- // return SystemModuleProxy.Service.GetGoodsLevel(2);//半成品检验
- //}));
- // 产品分级数据源
-
- if (dsGoodsLevel != null && dsGoodsLevel.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
- {
- 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._dsGoodsLevel = dsGoodsLevel;
- }
- // 报损原因数据源
- cre = new ClientRequestEntity();
- cre.NameSpace = "F_PM_3402";
- cre.Name = "GetDictionaryData";
- cre.Properties["dicType"] = "TPC016";
- cre.Properties["isLeaf"] = "1";
- sre = DoAsync<ServiceResultEntity>(() =>
- {
- return PCModuleProxyNew.Service.HandleRequest(cre);
- });
- DataSet scrapReason = sre.Data;
- // 报损原因数据源
- if (scrapReason != null && scrapReason.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
- {
- this.SCRAPREASON.DisplayMember = "DICTIONARYVALUE";
- this.SCRAPREASON.ValueMember = "DICTIONARYID";
- this.SCRAPREASON.DataSource = scrapReason.Tables[0];
- scrapReasonDataSource = scrapReason.Tables[0];
- }
- if (this.DSREWORK == null)
- {
- this.DSREWORK = new DataSet();
- }
- this.ReworkProcedureID.DisplayMember = "ReworkProcedureName";
- this.ReworkProcedureID.ValueMember = "ReworkProcedureID";
- // 2016-10-10 是否启用成检登记改判限制天数 wangx
- cre = new ClientRequestEntity();
- cre.NameSpace = "F_PM_3402";
- cre.Name = "GetSystemSettingDataByCode";
- cre.Properties["SettingType"] = Constant.SettingType.S_PM_009.ToString();
- sre = DoAsync<ServiceResultEntity>(() =>
- {
- return PCModuleProxyNew.Service.HandleRequest(cre);
- });
- DataSet dsSetting = sre.Data;
- //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._procedureDataTable != null)
- //{
- // if (Convert.ToInt32(this._procedureDataTable.Rows[0]["CollectType"]) == (int)Constant.ProcedureCollectType.Togather)
- // {
- // this.txtUserCode.Enabled = true;
- // this.btnSave.Visible = true;
- // }
- // else
- {
- this.txtUserCode.Enabled = true;
- this.txtUserCode.ReadOnly = true;
- // 此工号是否能生产工序
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "F_PM_3402";
- cre.Name = "CheckProcedureUser";
- cre.Properties["UserCode"] = DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserCode;
- ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
- {
- return PCModuleProxyNew.Service.HandleRequest(cre);
- });
- DataTable checkProcedureUser = sre.Data.Tables[0];
- //CheckProcedureUserResult checkProcedureUser = (CheckProcedureUserResult)DoAsync(new BaseAsyncMethod(() =>
- //{
- // return PMModuleProxy.Service.CheckProcedureUser(this._procedureID,
- // DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserCode);
- //}));
- //if (checkProcedureUser != null)
- //{
- // if (!string.IsNullOrEmpty(checkProcedureUser.Rows[0]["ErrMsg"] + ""))
- // {
- // // 此工号不允许生产工序
- // MessageBox.Show(checkProcedureUser.Rows[0]["ErrMsg"] + "",
- // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- // this.Close();
- // return;
- // }
- //}
- UserID = Convert.ToInt32(checkProcedureUser.Rows[0]["UserID"]);
- UserCode = checkProcedureUser.Rows[0]["UserCode"] + "";
- UserName = checkProcedureUser.Rows[0]["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;
- }
- //根据barcode取工序ID,procedureID
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "F_PM_3402";
- cre.Name = "GetProductionID";
- cre.Properties["BarCode"] = this.txtBarCode.Text.Trim();
- ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
- {
- return PCModuleProxyNew.Service.HandleRequest(cre);
- });
- if (sre.Data != null &&sre.Data.Tables.Count > 0 && sre.Data.Tables[0].Rows.Count > 0 )
- {
- DataSet ds = sre.Data;
- this._finishedCheckProcedureID = Convert.ToInt32(ds.Tables[0].Rows[0]["finishedcheckprocedureid"]);
- cre = new ClientRequestEntity();
- cre.NameSpace = "F_PM_3402";
- cre.Name = "GetReworkProcedureByProcedureID";
- cre.Properties["ProcedureID"] = this._finishedCheckProcedureID;
- sre = DoAsync<ServiceResultEntity>(() =>
- {
- return PCModuleProxyNew.Service.HandleRequest(cre);
- });
- DataSet ds1 = sre.Data;
- // 分离出重烧和冷补
- DataTable dtReworkProcedure = ds1.Tables[0].Copy();
- dtReworkProcedure.DefaultView.RowFilter = "ReworkProcedureName like '%重烧%'";
- DataTable dtRefire = dtReworkProcedure.DefaultView.ToTable();
- dtRefire.TableName = "Refire";
- dtReworkProcedure = ds1.Tables[0].Copy();
- dtReworkProcedure.DefaultView.RowFilter = "ReworkProcedureName like '%冷补%'";
- DataTable dtLengBu = dtReworkProcedure.DefaultView.ToTable();
- dtLengBu.TableName = "LengBu";
- if (this.DSREWORK == null)
- {
- this.DSREWORK = new DataSet();
- }
- if (this.DSREWORK.Tables.Count == 0)
- {
- this.DSREWORK.Tables.Add(dtRefire);
- this.DSREWORK.Tables.Add(dtLengBu);
- }
- // 返工工序数据源
- //C_DGV_Cell_ListBoxComboBox C_DGV_Cell_ListBoxComboBox = dgvProductionData.Rows[_selectedRowIndex].Cells[4] as C_DGV_Cell_ListBoxComboBox;
- //C_DGV_Cell_ListBoxComboBox.DataSource = ds1.Tables[0];
- //C_DGV_Cell_ListBoxComboBox.DisplayMember = "ReworkProcedureName";
- //C_DGV_Cell_ListBoxComboBox.ValueMember = "ReworkProcedureID";
- this.ReworkProcedureID.DisplayMember = "ReworkProcedureName";
- this.ReworkProcedureID.ValueMember = "ReworkProcedureID";
- ReworkProcedureID.DataSource = DSREWORK.Tables["Refire"];
- cre = new ClientRequestEntity();
- cre.NameSpace = "F_PM_3402";
- cre.Name = "CheckBarcode";
- cre.Properties["ProcedureID"] = this._finishedCheckProcedureID;
- cre.Properties["BarCode"] = this.txtBarCode.Text.Trim();
- sre = DoAsync<ServiceResultEntity>(() =>
- {
- return PCModuleProxyNew.Service.HandleRequest(cre);
- });
- DataSet dsCheckBarcode = sre.Data;
- // 校验条码 获取校验条码信
- //DataSet dsCheckBarcode = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- //{
- // return PMModuleProxy.Service.CheckBarcode(this._procedureID, this.txtBarCode.Text.Trim());
- //}));
- if (dsCheckBarcode != null && dsCheckBarcode.Tables.Count > Constant.INT_IS_ZERO)
- {
- if (dsCheckBarcode.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
- {
- this.txtProcedureName.Text = dsCheckBarcode.Tables[0].Rows[0]["ProcedureName"] + "";
- if (dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString() != string.Empty)
- {
- 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
- {
- this._procedureID = Convert.ToInt32(ds.Tables[0].Rows[0]["procedureid"]);
- //this._finishedCheckProcedureID = Convert.ToInt32(dsCheckBarcode.Tables[0].Rows[0]["FinishedCheckProcedureid"]);
- BindProductionData(dsCheckBarcode);//从来未走过此工序
- this._currentBarCode = txtBarCode.Text.Trim();
- //this.txtBarCode.Text = string.Empty;
- }
- if (dsCheckBarcode.Tables[1].Rows.Count > Constant.INT_IS_ZERO)
- {
- this.dgvPackingBomDetail.DataSource = dsCheckBarcode.Tables[1];
- }
- if (dsCheckBarcode.Tables.Count > 2 && dsCheckBarcode.Tables[2].Rows.Count > Constant.INT_IS_ZERO)
- {
- this.dgvDefect.DataSource = dsCheckBarcode.Tables[2];
- for (int i = 0; i < dsCheckBarcode.Tables[2].Rows.Count; i++)
- {
- DataRow dr = DSTable.Tables[this.txtBarCode.Text.Trim() + ""].NewRow();
- dr["BarCode"] = this.txtBarCode.Text.Trim() + "";
- dr["DefectID"] = dsCheckBarcode.Tables[2].Rows[i]["DefectID"];
- dr["DefectName"] = dsCheckBarcode.Tables[2].Rows[i]["DefectName"];
- dr["DefectCode"] = dsCheckBarcode.Tables[2].Rows[i]["DefectCode"];
- dr["DefectPositionID"] = dsCheckBarcode.Tables[2].Rows[i]["DefectPositionID"];
- dr["DefectPositionName"] = dsCheckBarcode.Tables[2].Rows[i]["DefectPositionName"];
- dr["DefectPositionCode"] = dsCheckBarcode.Tables[2].Rows[i]["DefectPositionCode"];
- dr["DefectProcedureID"] = dsCheckBarcode.Tables[2].Rows[i]["DefectProcedureID"];
- dr["DefectProcedureName"] = dsCheckBarcode.Tables[2].Rows[i]["DefectProcedureName"];
- dr["DefectProcedureCode"] = dsCheckBarcode.Tables[2].Rows[i]["DefectProcedureCode"];
- dr["DefectUserID"] = dsCheckBarcode.Tables[2].Rows[i]["DefectUserID"];
- dr["DefectUserName"] = dsCheckBarcode.Tables[2].Rows[i]["DefectUserName"];
- dr["DefectUserCode"] = dsCheckBarcode.Tables[2].Rows[i]["DefectUserCode"];
- dr["Jobs"] = dsCheckBarcode.Tables[2].Rows[i]["Jobs"];
- dr["JobsText"] = dsCheckBarcode.Tables[2].Rows[i]["JobsText"];
- dr["DefectRemarks"] = dsCheckBarcode.Tables[2].Rows[i]["DefectRemarks"];
- dr["TempCount"] = this._tempCount;
- if (string.IsNullOrEmpty(dsCheckBarcode.Tables[2].Rows[i]["DefectProductionDataID"]+""))
- {
- dr["ProductionDataID"] = 0;
- }
- else
- {
- dr["ProductionDataID"] = dsCheckBarcode.Tables[2].Rows[i]["DefectProductionDataID"];// dsCheckBarcode.Tables[2].Rows[i]["ProductionDataID"];
- }
- dr["DefectFineID"] = dsCheckBarcode.Tables[2].Rows[i]["DefectFineID"];
- dr["DefectFineValue"] = dsCheckBarcode.Tables[2].Rows[i]["DefectFineValue"];
- dr["MissedUserID"] = dsCheckBarcode.Tables[2].Rows[i]["MissedUserID"];
- dr["MissedUserCode"] = dsCheckBarcode.Tables[2].Rows[i]["MissedUserCode"];
- dr["MissedUserName"] = dsCheckBarcode.Tables[2].Rows[i]["MissedUserName"];
- dr["IsAllowEdit"] = this._AllowEdit;
- dr["DefectDeductionNum"] = dsCheckBarcode.Tables[2].Rows[i]["DefectDeductionNum"];
- dr["IsOtherDefect"] = dsCheckBarcode.Tables[2].Rows[i]["SpecialDefect"];
- dr["CheckTime"] = dsCheckBarcode.Tables[2].Rows[i]["CheckTime"];
- DSTable.Tables[this.txtBarCode.Text.Trim()+""].Rows.Add(dr);
- #region 获取责任员工
- 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);
- }
- cre = new ClientRequestEntity();
- cre.NameSpace = "F_PM_3402";
- cre.Name = "GetDutyStaffByUserJobsID";
- cre.Properties["Jobs"] = Convert.ToInt32(dr["Jobs"]);
- cre.Properties["UserID"] = Convert.ToInt32(dr["DefectUserID"]);
- sre = DoAsync<ServiceResultEntity>(() =>
- {
- return PCModuleProxyNew.Service.HandleRequest(cre);
- });
- DataSet dsDutyStaff = sre.Data;
- if (dsDutyStaff != null && dsDutyStaff.Tables.Count > Constant.INT_IS_ZERO
- && dsDutyStaff.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
- {
-
- foreach (DataRow dstaff in dsDutyStaff.Tables[0].Rows)
- {
- DataRow addDr = DSTableStaff.Tables[string.Format("TempTable{0}", this._tempCount)].NewRow();
- addDr["IsSelected"] = 1;
- addDr["StaffID"] = dstaff["StaffID"];
- addDr["StaffCode"] = dstaff["StaffCode"];
- addDr["StaffName"] = dstaff["StaffName"];
- addDr["StaffTempCount"] = StaffTempCount;
- addDr["StaffStatus"] = dstaff["StaffStatus"];
- DSTableStaff.Tables[string.Format("TempTable{0}", this._tempCount)].Rows.Add(addDr);
- }
- this.dgvDefectStaff.DataSource = DSTableStaff.Tables[string.Format("TempTable{0}", this._tempCount)];
- }
- #endregion
- #region 获取漏检责任员工
- 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);
- }
- if (!string.IsNullOrEmpty(dr["MissedUserID"]+"") && Convert.ToInt32(dr["MissedUserID"]) > 0)
- {
- cre = new ClientRequestEntity();
- cre.NameSpace = "F_PM_3402";
- cre.Name = "GetMissedStaffByUserID";
- cre.Properties["UserID"] = Convert.ToInt32(dr["MissedUserID"]);
- sre = DoAsync<ServiceResultEntity>(() =>
- {
- return PCModuleProxyNew.Service.HandleRequest(cre);
- });
- DataSet dsMissedDutyStaff = sre.Data;
- if (dsMissedDutyStaff != null && dsMissedDutyStaff.Tables.Count > Constant.INT_IS_ZERO
- && dsMissedDutyStaff.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
- {
- foreach (DataRow dmiss in dsMissedDutyStaff.Tables[0].Rows)
- {
- DataRow addDr = DSTableMissedStaff.Tables[string.Format("TempTable{0}", this._tempCount)].NewRow();
- addDr["IsSelected"] = 1;
- addDr["StaffID"] = dmiss["StaffID"];
- addDr["StaffCode"] = dmiss["StaffCode"];
- addDr["StaffName"] = dmiss["StaffName"];
- addDr["StaffTempCount"] = StaffTempCount;
- addDr["StaffStatus"] = dmiss["StaffStatus"];
- addDr["UJobsID"] = dmiss["UJobsID"];
- addDr["SJobsID"] = dmiss["SJobsID"];
- DSTableMissedStaff.Tables[string.Format("TempTable{0}", this._tempCount)].Rows.Add(addDr);
- }
- this.dgvMissStaff.DataSource = DSTableMissedStaff.Tables[string.Format("TempTable{0}", this._tempCount)];
- }
- }
- #endregion
- this._tempCount = this._tempCount + 1;
- }
- }
- }
-
- }
-
- }
- else
- {
- MessageBox.Show("该条码为无效条码", 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 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";
- int goodsLevelTypeID = Convert.ToInt32(dgvProductionData.CurrentRow.Cells["GoodsLevelTypeID"].Value);
- if (goodsLevelTypeID == 6)
- {
- ReworkProcedureID.DataSource = DSREWORK.Tables["Refire"];
- dkListBoxComboBox.DataSource = DSREWORK.Tables["Refire"];
- }
- else if (goodsLevelTypeID == 16)
- {
- ReworkProcedureID.DataSource = DSREWORK.Tables["LengBu"];
- dkListBoxComboBox.DataSource = DSREWORK.Tables["LengBu"];
- }
- //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_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>
- /// 上传图片按钮事件
- /// </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_3403 frm3403 = new F_PM_3403(
- 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);
- frm3403.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_3403 frm3403 = new F_PM_3403(
- 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);
- frm3403.ShowDialog();
- }
- }
- }
- /// <summary>
- /// 产品数据源值改变后
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvProductionData_CellValueChanged(object sender, DataGridViewCellEventArgs e)
- {
- if (this.dgvProductionData.CurrentRow == null
- || this.dgvProductionData.Rows.Count < 1)
- {
- return;
- }
- DataGridViewRow rowItem = this.dgvProductionData.Rows[e.RowIndex];
- DataGridViewColumn columnItem = this.dgvProductionData.Columns[e.ColumnIndex];
- if ("DefectFlag".Equals(columnItem.Name))
- {
- SetGridView(Convert.ToInt32(rowItem.Cells["DefectFlag"].Value));
- if (Convert.ToInt32(rowItem.Cells["DefectFlag"].Value) == 7)
- {
- dgvPackingBomDetail.Columns["NewCheck"].ReadOnly = true;
- dgvPackingBomDetail.Columns["NEWIDNRKONLYCODE"].ReadOnly = true;
- dgvPackingBomDetail.Columns["FrmLossCheck"].ReadOnly = false;
- dgvPackingBomDetail.Columns["RecoverCheck"].ReadOnly = false;
- foreach (DataGridViewRow itemRow in dgvPackingBomDetail.Rows)
- {
- itemRow.Cells["NewCheck"].Value = 0;
- itemRow.Cells["NEWIDNRKONLYCODE"].Value = "";
- }
- }
- else
- {
- dgvPackingBomDetail.Columns["FrmLossCheck"].ReadOnly = true;
- dgvPackingBomDetail.Columns["RecoverCheck"].ReadOnly = true;
- dgvPackingBomDetail.Columns["NewCheck"].ReadOnly = false;
- dgvPackingBomDetail.Columns["NEWIDNRKONLYCODE"].ReadOnly = false;
- foreach (DataGridViewRow itemRow in dgvPackingBomDetail.Rows)
- {
- itemRow.Cells["FrmLossCheck"].Value = 0;
- itemRow.Cells["RecoverCheck"].Value = 0;
- }
- }
- }
- }
- /// <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(); ;
- productionDataEntity.DefectFlag = Convert.ToInt32(this.TableProductionData.Rows[i]["GoodsLevelTypeID"]) == 4 ? 1 : 2;
- 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.Quality) //正品
- {
- // 不是正品
- 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;
- }
- }
- if (dgvPackingBomDetail.DataSource != null )
- {
- DataTable packingBomDetailTable = dgvPackingBomDetail.DataSource as DataTable;
- for (int j = 0; j < packingBomDetailTable.Rows.Count; j++)
- {
- if (!string.IsNullOrWhiteSpace(packingBomDetailTable.Rows[j]["IDNRKONLYCODE"] + ""))
- {
- if (packingBomDetailTable.Rows[j]["NewCheck"] + "" == "1" && string.IsNullOrWhiteSpace(packingBomDetailTable.Rows[j]["NEWIDNRKONLYCODE"] + ""))
- {
- isError = true;
- ErrorCount = -3;
- break;
- }
- }
- //报损必须选择报损原因
- if (packingBomDetailTable.Rows[j]["FrmLossCheck"] + "" == "1" || packingBomDetailTable.Rows[j]["RecoverCheck"] + "" == "1" || packingBomDetailTable.Rows[j]["NewCheck"] + "" == "1")
- {
- if (string.IsNullOrWhiteSpace(packingBomDetailTable.Rows[j]["DICTIONARYID"] +""))
- {
- isError = true;
- ErrorCount = -4;
- break;
- }
- else
- {
- int dictionaryID = Convert.ToInt32(packingBomDetailTable.Rows[j]["DICTIONARYID"]);
- for (int index = 0; index < scrapReasonDataSource.Rows.Count; index++)
- {
- if (Convert.ToInt32(scrapReasonDataSource.Rows[index]["DICTIONARYID"]) == dictionaryID)
- {
- packingBomDetailTable.Rows[j]["SCRAPREASON"] = scrapReasonDataSource.Rows[index]["DICTIONARYVALUE"];
- }
- }
- }
- }
- else
- {
- packingBomDetailTable.Rows[j]["DICTIONARYID"] = 0;
- }
- }
- }
- 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"] + "");
- 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(Messages.MSG_PM_W004,
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- else if (ErrorCount == -Constant.INT_IS_THREE)
- {
- // 提示信息
- MessageBox.Show("报损并换新必须输入新组件唯一编码",
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- else if (ErrorCount == -Constant.INT_IS_FOUR)
- {
- // 提示信息
- MessageBox.Show("报损必须选择报损原因",
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- else
- {
- this.dgvProductionData.DataSource = TableProductionData;
- // 提示信息
- MessageBox.Show(Messages.MSG_PM_W003,
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- }
- // 最外层For循环结束
- if (productionDataEntitys.Length > Constant.INT_IS_ZERO)
- {
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "F_PM_3402";
- cre.Name = "AddCheckBarcode";
- cre.Properties["ProcedureID"] = this._finishedCheckProcedureID;
- cre.Properties.Add("productionDataEntitys", JsonHelper.ToJson(productionDataEntitys));
- if (this.dgvPackingBomDetail.DataSource != null )
- {
- DataTable bomDetailTable = (DataTable)this.dgvPackingBomDetail.DataSource;
- bomDetailTable.TableName = "bomDetailTable";
- cre.Data = new DataSet();
- cre.Data.Tables.Add(bomDetailTable.Copy());
- }
-
- ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
- {
- return PCModuleProxyNew.Service.HandleRequest(cre);
- });
- if (sre.Status == Constant.ServiceResultStatus.Success)
- {
- // 提示信息
- MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "新建" + this.Text, "保存"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
-
- // 保存成功后,清空相应数据源
- 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;
- this.dgvPackingBomDetail.DataSource = null;
- this.txtProcedureName.Text = string.Empty;
- //if (Convert.ToInt32( this._procedureDataTable.Rows[0]["CollectType"]) == (int)Constant.ProcedureCollectType.Togather)
- //{
- // this.txtUserCode.Text = string.Empty;
- // this.txtUserCode.ReadOnly = false;
- //}
- //this.DSREWORK.Tables.Clear();
- }
- // 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 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() && value != Constant.GoodsLevelType.LengBu.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();
- // 此工号是否能生产工序
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "F_PM_3402";
- cre.Name = "CheckProcedureUser";
- cre.Properties["ProcedureID"] = this._procedureID;
- cre.Properties["UserCode"] = DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserCode;
- ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
- {
- return PCModuleProxyNew.Service.HandleRequest(cre);
- });
- DataTable MsgCheckProcedureUser = sre.Data.Tables[0];
- //CheckProcedureUserResult MsgCheckProcedureUser = (CheckProcedureUserResult)DoAsync(new BaseAsyncMethod(() =>
- //{
- // return PMModuleProxy.Service.CheckProcedureUser(this._procedureID, this.txtUserCode.Text.Trim());
- //}));
- if (MsgCheckProcedureUser != null)
- {
- if (MsgCheckProcedureUser.Rows[0]["ErrMsg"] != null)
- {
- MessageBox.Show(MsgCheckProcedureUser.Rows[0]["ErrMsg"] + "",
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- this.txtUserCode.SelectAll();
- e.Cancel = true;
- return;
- }
- UserID = Convert.ToInt32(MsgCheckProcedureUser.Rows[0]["UserID"]);
- UserCode = MsgCheckProcedureUser.Rows[0]["UserCode"] + "";
- UserName = MsgCheckProcedureUser.Rows[0]["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();
- }
- }
- /// <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;
- }
- }
- /// <summary>
- /// 报损值改变事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvPackingBomDetail_CurrentCellDirtyStateChanged(object sender, EventArgs e)
- {
- try
- {
- if (this.dgvPackingBomDetail.CurrentRow == null
- || this.dgvPackingBomDetail.Rows.Count < 1)
- {
- return;
- }
- this.dgvPackingBomDetail.CommitEdit(DataGridViewDataErrorContexts.Commit);
- DataGridViewRow rowItem = this.dgvPackingBomDetail.CurrentRow;
- //DataGridViewColumn columnItem = this.dgvPackingBomDetail.Columns[e.ColumnIndex];
- //次品,则可以选“单报损”和“回收”两项。其它等级时,只能选择“报损并换新、空”两项。
- //单报损
- if ("FrmLossCheck".Equals(this.dgvPackingBomDetail.Columns[this.dgvPackingBomDetail.CurrentCell.ColumnIndex].Name))
- {
- if (rowItem.Cells["FrmLossCheck"].Value.ToString() == "1")
- {
- rowItem.Cells["RecoverCheck"].Value = 0;
- }
- }
- //回收
- else if ("RecoverCheck".Equals(this.dgvPackingBomDetail.Columns[this.dgvPackingBomDetail.CurrentCell.ColumnIndex].Name))
- {
- if (rowItem.Cells["RecoverCheck"].Value.ToString() == "1")
- {
- rowItem.Cells["FrmLossCheck"].Value = 0;
- }
- }
- //换新
- else if ("NewCheck".Equals(this.dgvPackingBomDetail.Columns[this.dgvPackingBomDetail.CurrentCell.ColumnIndex].Name))
- {
- if (rowItem.Cells["NewCheck"].Value.ToString() == "1")
- {
- rowItem.Cells["FrmLossCheck"].Value = 0;
- rowItem.Cells["RecoverCheck"].Value = 0;
- }
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- #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;
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "F_PM_3402";
- cre.Name = "GetProductionDataByID";
- cre.Properties["ProcedureID"] = this._productiondataid;
- ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
- {
- return PCModuleProxyNew.Service.HandleRequest(cre);
- });
- DataSet dsProductionDataByID = sre.Data;
- //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 校验是否可以成检登记改判
- if (_settingvaluedays > 0)
- {
- cre = new ClientRequestEntity();
- cre.NameSpace = "F_PM_3402";
- cre.Name = "BarcodeAllowCancel";
- cre.Properties["Createtime"] = Convert.ToDateTime(dsProductionDataByID.Tables[0].Rows[0]["createtime"]);
- cre.Properties["Settingvaluedays"] = _settingvaluedays;
- cre.Properties["SettingCode"] = Constant.SettingType.S_PM_009.ToString();
- sre = DoAsync<ServiceResultEntity>(() =>
- {
- return PCModuleProxyNew.Service.HandleRequest(cre);
- });
- ServiceResultEntity resultEntity = sre;
- //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 如果是次品,回收后不允许编辑
- if (Convert.ToInt32(dsProductionDataByID.Tables[0].Rows[0]["GoodsLevelTypeID"]) == 7)//次品
- {
- cre = new ClientRequestEntity();
- cre.NameSpace = "F_PM_3402";
- cre.Name = "GetRecyclingflagByBarcode";
- cre.Properties["BarCode"] = dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString();
- sre = DoAsync<ServiceResultEntity>(() =>
- {
- return PCModuleProxyNew.Service.HandleRequest(cre);
- });
- int recyclingflag = 0;
- if (sre.Data != null && sre.Data.Tables[0].Rows.Count > 0)
- {
- recyclingflag = Convert.ToInt32(sre.Data.Tables[0].Rows[0]["recyclingflag"]);
- }
- //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
- cre = new ClientRequestEntity();
- cre.NameSpace = "F_PM_3402";
- cre.Name = "GetSpecialRepairflagByBarcode";
- cre.Properties["BarCode"] = dsProductionDataByID.Tables[0].Rows[0]["BarCode"].ToString();
- sre = DoAsync<ServiceResultEntity>(() =>
- {
- return PCModuleProxyNew.Service.HandleRequest(cre);
- });
- int SpecialRepairflag = 0;
- if (sre.Data != null && sre.Data.Tables[0].Rows.Count > 0)
- {
- SpecialRepairflag = Convert.ToInt32(sre.Data.Tables[0].Rows[0]["SpecialRepairflag"]);
- }
- //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]["GLAZEName"];
- 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"];
- cre = new ClientRequestEntity();
- cre.NameSpace = "F_PM_3402";
- cre.Name = "GetCompleteProcedureIDPDA";
- cre.Properties["BarCode"] = dsProductionDataByID.Tables[0].Rows[0]["BarCode"] +"";
- sre = DoAsync<ServiceResultEntity>(() =>
- {
- return PCModuleProxyNew.Service.HandleRequest(cre);
- });
- DataSet dsOPTimeStamp = sre.Data;
- //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"]
- // 校验条码是否重烧过,这个地方必须重新读取,因为防止编辑重烧以前的成检数据,如果直接取表里的就不准了
- cre = new ClientRequestEntity();
- cre.NameSpace = "F_PM_3402";
- cre.Name = "GetReFine";
- cre.Properties["BarCode"] = dsProductionDataByID.Tables[0].Rows[0]["BarCode"] + "";
- sre = DoAsync<ServiceResultEntity>(() =>
- {
- return PCModuleProxyNew.Service.HandleRequest(cre);
- });
- DataSet dsReFine = sre.Data;
- //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();
- cre = new ClientRequestEntity();
- cre.NameSpace = "F_PM_3402";
- cre.Name = "GetSubstandardInfo";
- cre.Properties["BarCode"] = dsProductionDataByID.Tables[0].Rows[0]["BarCode"] + "";
- sre = DoAsync<ServiceResultEntity>(() =>
- {
- return PCModuleProxyNew.Service.HandleRequest(cre);
- });
- DataSet dsReturn = sre.Data;
- //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 (dsProductionDataByID != null && dsProductionDataByID.Tables[0].Rows.Count > 0 &&
- 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;
- dv.RowFilter = "GoodsLevelTypeID>=" + goodsLevelTypeID;
- DataGridViewComboBoxCell dgcbc = (DataGridViewComboBoxCell)dgvProductionData.Rows[i].Cells[3];
- dgcbc.DisplayMember = "DefectFlagName";
- dgcbc.ValueMember = "DefectFlagID";
- 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;
- }
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "F_PM_3402";
- cre.Name = "GetSpecialRepairflagByBarcode";
- cre.Properties["BarCode"] = this.txtBarCode.Text.Trim();
- ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
- {
- return PCModuleProxyNew.Service.HandleRequest(cre);
- });
- int SpecialRepairflag = 0;
- if (sre.Data != null && sre.Data.Tables[0].Rows.Count > 0)
- {
- SpecialRepairflag = Convert.ToInt32(sre.Data.Tables[0].Rows[0]["SpecialRepairflag"]);
- }
- //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;
- cre = new ClientRequestEntity();
- cre.NameSpace = "F_PM_3402";
- cre.Name = "GetKilnCarByBarCode";
- cre.Properties["BarCode"] = this.txtBarCode.Text.Trim();
- sre = DoAsync<ServiceResultEntity>(() =>
- {
- return PCModuleProxyNew.Service.HandleRequest(cre);
- });
- DataSet dsKilnCar = sre.Data;
- //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;
- // 校验条码是否重烧过
- cre = new ClientRequestEntity();
- cre.NameSpace = "F_PM_3402";
- cre.Name = "GetReFine";
- cre.Properties["BarCode"] = this.txtBarCode.Text.Trim();
- sre = DoAsync<ServiceResultEntity>(() =>
- {
- return PCModuleProxyNew.Service.HandleRequest(cre);
- });
- DataSet dsReFine = sre.Data;
- //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 (dsReFine != null && dsReFine.Tables[0].Rows.Count > 0 && dsReFine.Tables[0].Rows[0]["IsLengBu"].ToString() == "1")
- {
- drNew["LengBu"] = 1;
- }
- else
- {
- drNew["LengBu"] = 0;
- }
- drNew["UserCode"] = this.txtUserCode.Text.Trim();
- // 由产品条码获取注浆信息
- cre = new ClientRequestEntity();
- cre.NameSpace = "F_PM_3402";
- cre.Name = "GetGroutingProducttByBarCode";
- cre.Properties["BarCode"] = this.txtBarCode.Text.Trim();
- sre = DoAsync<ServiceResultEntity>(() =>
- {
- return PCModuleProxyNew.Service.HandleRequest(cre);
- });
- DataSet dsGroutingProduct = sre.Data;
- //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;
- }
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "F_PM_3402";
- cre.Name = "GetSpecialRepairflagByBarcode";
- cre.Properties["BarCode"] = this.txtBarCode.Text.Trim();
- ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
- {
- return PCModuleProxyNew.Service.HandleRequest(cre);
- });
- int SpecialRepairflag = 0;
- if (sre.Data != null && sre.Data.Tables[0].Rows.Count > 0)
- {
- SpecialRepairflag = Convert.ToInt32(sre.Data.Tables[0].Rows[0]["SpecialRepairflag"]);
- }
- //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;
- cre = new ClientRequestEntity();
- cre.NameSpace = "F_PM_3402";
- cre.Name = "GetKilnCarByBarCode";
- cre.Properties["BarCode"] = this.txtBarCode.Text.Trim();
- sre = DoAsync<ServiceResultEntity>(() =>
- {
- return PCModuleProxyNew.Service.HandleRequest(cre);
- });
- DataSet dsKilnCar = sre.Data;
- //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();
- cre = new ClientRequestEntity();
- cre.NameSpace = "F_PM_3402";
- cre.Name = "GetGoodsInfoBybarcode";
- cre.Properties["BarCode"] = this.txtBarCode.Text.Trim();
- sre = DoAsync<ServiceResultEntity>(() =>
- {
- return PCModuleProxyNew.Service.HandleRequest(cre);
- });
- DataSet ds = sre.Data;
- //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;
- // 校验条码是否重烧过
- cre = new ClientRequestEntity();
- cre.NameSpace = "F_PM_3402";
- cre.Name = "GetReFine";
- cre.Properties["BarCode"] = this.txtBarCode.Text.Trim();
- sre = DoAsync<ServiceResultEntity>(() =>
- {
- return PCModuleProxyNew.Service.HandleRequest(cre);
- });
- DataSet dsReFine = sre.Data;
- //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 (dsReFine != null && dsReFine.Tables[0].Rows.Count > 0 && dsReFine.Tables[0].Rows[0]["IsLengBu"].ToString() == "1")
- {
- drNew["LengBu"] = 1;
- }
- else
- {
- drNew["LengBu"] = 0;
- }
- drNew["UserCode"] = this.txtUserCode.Text.Trim();
- // 由产品条码获取注浆信息
- cre = new ClientRequestEntity();
- cre.NameSpace = "F_PM_3402";
- cre.Name = "GetGroutingProducttByBarCode";
- cre.Properties["BarCode"] = this.txtBarCode.Text.Trim();
- sre = DoAsync<ServiceResultEntity>(() =>
- {
- return PCModuleProxyNew.Service.HandleRequest(cre);
- });
- DataSet dsGroutingProduct = sre.Data;
- //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)
- {
- ClientRequestEntity cre1 = new ClientRequestEntity();
- cre1.NameSpace = "F_PM_3402";
- cre1.Name = "GetSpecialRepairflagByBarcode";
- cre1.Properties["BarCode"] = this.txtBarCode.Text.Trim();
- ServiceResultEntity sre1 = DoAsync<ServiceResultEntity>(() =>
- {
- return PCModuleProxyNew.Service.HandleRequest(cre1);
- });
- if (sre1.Data != null && sre1.Data.Tables[0].Rows.Count > 0)
- {
- SpecialRepairflag = Convert.ToInt32(sre1.Data.Tables[0].Rows[0]["SpecialRepairflag"]);
- }
- //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;
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "F_PM_3402";
- cre.Name = "GetKilnCarByBarCode";
- cre.Properties["BarCode"] = this.txtBarCode.Text.Trim();
- ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
- {
- return PCModuleProxyNew.Service.HandleRequest(cre);
- });
- DataSet dsKilnCar = sre.Data;
- //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
- {
- ClientRequestEntity cre1 = new ClientRequestEntity();
- cre1.NameSpace = "F_PM_3402";
- cre1.Name = "GetGoodsInfoBybarcode";
- cre1.Properties["BarCode"] = this.txtBarCode.Text.Trim();
- ServiceResultEntity sre1 = DoAsync<ServiceResultEntity>(() =>
- {
- return PCModuleProxyNew.Service.HandleRequest(cre1);
- });
- DataSet ds = sre1.Data;
- //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;
- if (dsCheckBarcode.Tables[0].Columns.Contains("DefectFlagID") && !string.IsNullOrWhiteSpace(dsCheckBarcode.Tables[0].Rows[0]["DefectFlagID"] + ""))
- {
- drNew["DefectFlagID"] = dsCheckBarcode.Tables[0].Rows[0]["DefectFlagID"];
- drNew["GoodsLevelTypeID"] = dsCheckBarcode.Tables[0].Rows[0]["DefectFlagID"];
- //控制报损
- if (!string.IsNullOrWhiteSpace(dsCheckBarcode.Tables[0].Rows[0]["DefectFlagID"]+"") && Convert.ToInt32(drNew["GoodsLevelTypeID"]) == 7)
- {
- dgvPackingBomDetail.Columns["NewCheck"].ReadOnly = true;
- dgvPackingBomDetail.Columns["NEWIDNRKONLYCODE"].ReadOnly = true;
- dgvPackingBomDetail.Columns["FrmLossCheck"].ReadOnly = false;
- dgvPackingBomDetail.Columns["RecoverCheck"].ReadOnly = false;
- }
- else
- {
- dgvPackingBomDetail.Columns["FrmLossCheck"].ReadOnly = true;
- dgvPackingBomDetail.Columns["RecoverCheck"].ReadOnly = true;
- dgvPackingBomDetail.Columns["NewCheck"].ReadOnly = false;
- dgvPackingBomDetail.Columns["NEWIDNRKONLYCODE"].ReadOnly = false;
- }
- }
- else
- {
- drNew["DefectFlagID"] = _dsGoodsLevel.Tables[0].Rows[0]["DefectFlagID"];
- drNew["GoodsLevelTypeID"] = _dsGoodsLevel.Tables[0].Rows[0]["GoodsLevelTypeID"];
- }
- drNew["ReworkProcedureID"] = DBNull.Value;
- drNew["Remarks"] = "";
- drNew["UserID"] = UserID;
- drNew["UserCode"] = UserCode;
- drNew["UserName"] = UserName;
-
- 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()];
- // 校验条码是否重烧过
- cre = new ClientRequestEntity();
- cre.NameSpace = "F_PM_3402";
- cre.Name = "GetReFine";
- cre.Properties["BarCode"] = this.txtBarCode.Text.Trim();
- sre = DoAsync<ServiceResultEntity>(() =>
- {
- return PCModuleProxyNew.Service.HandleRequest(cre);
- });
- DataSet dsReFine = sre.Data;
- //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 (dsReFine != null && dsReFine.Tables[0].Rows.Count > 0 && dsReFine.Tables[0].Rows[0]["IsLengBu"].ToString() == "1")
- {
- drNew["LengBu"] = 1;
- }
- else
- {
- drNew["LengBu"] = 0;
- }
- if (dsCheckBarcode == null || dsCheckBarcode.Tables[0].Rows.Count == 0)
- {
- // 由产品条码获取注浆信息
- cre = new ClientRequestEntity();
- cre.NameSpace = "F_PM_3402";
- cre.Name = "GetGroutingProducttByBarCode";
- cre.Properties["BarCode"] = this.txtBarCode.Text.Trim();
- sre = DoAsync<ServiceResultEntity>(() =>
- {
- return PCModuleProxyNew.Service.HandleRequest(cre);
- });
- DataSet dsGroutingProduct = sre.Data;
- //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.dgvPackingBomDetail.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;
- DataRow[] dr = dtDefectFlag.Select("DefectFlagID=" + 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;
- if (GoodsLevelTypeID == (int)Constant.GoodsLevelType.Quality) //正品
- {
- 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.Quality) //次品 或者正品
- {
- 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;
- }
- else if (GoodsLevelTypeID == (int)Constant.GoodsLevelType.LengBu)//冷补
- {
- 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();
- if (ImageData != null && ImageData.Rows.Count > 0)
- {
- 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
-
- }
- }
|