| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620 |
- /*******************************************************************************
- * Copyright(c) 2019 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_PM_3203.cs
- * 2.功能描述:半检-新增、编辑
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * xuwei 2019/12/12 1.00 新建
- *******************************************************************************/
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Drawing;
- using System.Drawing.Drawing2D;
- using System.Drawing.Imaging;
- using System.IO;
- using System.Windows.Forms;
- using Dongke.IBOSS.PRD.Basics.BaseControls;
- using Dongke.IBOSS.PRD.Basics.BaseResources;
- using Dongke.IBOSS.PRD.Client.CommonModule;
- using Dongke.IBOSS.PRD.WCF.DataModels;
- using Dongke.IBOSS.PRD.WCF.Proxys;
- using Dongke.IBOSS.PRD.WCF.Proxys.SystemModuleService;
- namespace Dongke.IBOSS.PRD.Client.PMModule
- {
- /// <summary>
- /// 成品检验-新增、编辑
- /// </summary>
- public partial class F_PM_3203 : FormBase
- {
- #region 成员变量
- // 当前操作数据表
- private DataTable _dtBarCode = null;
- // 当前产品条码
- private string _barcode;
- // 当前产品ID
- private int _goodsID = 0;
- // 当前工序ID
- private int _procedureID = 0;
- // 当前是否为编辑 true
- private bool _isEdit = false;
- // 临时数
- private int _tempcount = 0;
- // 调用实例对象
- F_PM_3202 _frm3202 = null;
- // 员工数据集
- private DataSet _dsStaff = null;
- // 漏检员工数据集
- private DataSet _dsMissedStaff = null;
- // 图片数据集
- private DataSet _dsImage = null;
- // 生产数据ID
- private int _productionDataID = 0;
- // 图片字节集
- private List<byte[]> _PicByte = new List<byte[]>();
- // 缩略图片字节集
- private List<byte[]> _smallByte = new List<byte[]>();
- // 行索引
- private int _rowIndex = 0;
- // 当前缺陷编码
- private string _currentDutyCode = "";
- // 当前缺陷位置编码
- private string _currentDefectPositionCode = "";
- // 当前缺陷责任工序编码
- private string _currentDefectProcedureCode = "";
- // 当前缺陷工号编码
- private string _currentDefectUserCode = "";
- // 当前漏检工号
- private string _currentMissedUserCode = "";
- // 默认责任工号数据源
- private DataTable _dtDutyProcedureUser = null;
- // 是否干补
- private int SpecialRepairflag = 0;//0未干补 1干补
- //默认缺陷对应的工种
- private DataTable _defaultJobsID = null;
- // 缺陷扣罚关系所有数据源
- private DataTable _dtDefectFineRelation = null;
- // 缺陷扣除数关系所有数据源
- private DataTable _dtDefectDeductionRelation = null;
- // 默认缺陷扣罚关系所有数据源
- private DataTable _dtDefaultDefectFineRelation = null;
- // 默认缺陷扣除数关系所有数据源
- private DataTable _dtDefaultDefectDeductionRelation = null;
- #endregion
- #region 构造函数
- public F_PM_3203()
- {
- InitializeComponent();
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="dtBarCode">当前操作的数据表</param>
- /// <param name="barcode">当前产品条码</param>
- /// <param name="goodsID">当前产品ID</param>
- /// <param name="tempcount">当前累加数,防止重复</param>
- /// <param name="procedureID">当前工序</param>
- /// <param name="titleText">当前窗体名称</param>
- /// <param name="isEdit">false 新建 true编辑</param>
- /// <param name="frm3202">调用实例对象</param>
- /// <param name="dsStaff">员工数据集</param>
- /// <param name="dsImage">图片数据集</param>
- /// <param name="picByte">原图字节数组</param>
- /// <param name="smallByte">缩略图字节数组</param>
- /// <param name="rowIndex">编辑行号标识</param>
- public F_PM_3203(DataTable dtBarCode
- , string barcode
- , int goodsID
- , int tempcount
- , int procedureID
- , string titleText
- , bool isEdit
- , F_PM_3202 frm3202
- , DataSet dsStaff
- , DataSet dsMissedStaff
- , DataSet dsImage
- , List<byte[]> picByte
- , List<byte[]> smallByte
- , int rowIndex)
- {
- InitializeComponent();
- this.Text = titleText;
- this._dtBarCode = dtBarCode;
- this._barcode = barcode;
- this._goodsID = goodsID;
- this._procedureID = procedureID;
- this._isEdit = isEdit;
- this._tempcount = tempcount;
- this._frm3202 = frm3202;
- this._dsStaff = dsStaff;
- this._dsMissedStaff = dsMissedStaff;
- this._dsImage = dsImage;
- this._rowIndex = rowIndex;
- this.btnSave.Text = ButtonText.BTN_SAVE;
- this.btnCancel.Text = ButtonText.BTN_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_3203_Load(object sender, EventArgs e)
- {
- // add 2016/01/06 wangx
- DataSet dsDefectFineRelation = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return SystemModuleProxy.Service.GetAllDefectFineRelation();
- }));
- _dtDefectFineRelation = dsDefectFineRelation.Tables[0];
- DataSet dsDefectDeductionRelation = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return SystemModuleProxy.Service.GetAllDefectDeductionRelation();
- }));
- _dtDefectDeductionRelation = dsDefectDeductionRelation.Tables[0]; ;
- // add end
- this.dgvDefectStaff.AutoGenerateColumns = false;
- //获取干补标识
- SpecialRepairflag = (int)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetSpecialRepairflagByBarcode(this._barcode);
- }));
- //SpecialRepairflag = 1;
- DataSet dsDefectByProcedure = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetDefectByProcedure(this._procedureID);
- }));
- if (dsDefectByProcedure != null && dsDefectByProcedure.Tables.Count > Constant.INT_IS_ZERO
- && dsDefectByProcedure.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
- {
- this.dropDuty.DisplayMember = "DEFECTFLAGNAME";
- this.dropDuty.ValueMember = "DEFECTFLAGID";
- this.dropDuty.DataSource = dsDefectByProcedure.Tables[0];
- }
- else
- {
- this.dropDuty.DisplayMember = "DEFECTFLAGNAME";
- this.dropDuty.ValueMember = "DEFECTFLAGID";
- this.dropDuty.DataSource = GetDuty();
- }
- // 缺陷位置
- DataSet dsDefectLocation = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetDefectLocaionByGoodsID(this._goodsID);
- }));
- this.dropDefectLocation.DisplayMember = "DEFECTPOSITIONCODEANDNAME";
- this.dropDefectLocation.ValueMember = "DEFECTPOSITIONID";
- this.dropDefectLocation.DataSource = dsDefectLocation.Tables[0];
- this.dropDutyProcedure.DisplayMember = "DutyProcedureName";
- this.dropDutyProcedure.ValueMember = "DutyProcedureID";
- this.dropDutyProcedure.DataSource = GetDutyProcedure();
- this.dropDutyUser.DisplayMember = "UserCode";
- this.dropDutyUser.ValueMember = "UserID";
- this.dropDutyUser.DataSource = GetDutyProcedureUser();
- //漏检工号数据源
- this.dropMissUser.DisplayMember = "UserCode";
- this.dropMissUser.ValueMember = "UserID";
- this.dropMissUser.DataSource = this._dtDutyProcedureUser;
- this.dropJobs.DisplayMember = "JobsName";
- this.dropJobs.ValueMember = "Jobs";
- this.dropJobs.DataSource = GetDutyProcedureJobs(); // 默认空数据源,随着责任工号而改变
- // 缺陷扣罚
- //DataSet dsDefectFine = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- //{
- // return SystemModuleProxy.Service.GetDictionaryData(0, "ASE002");
- //}));
- //DataRow dr = dsDefectFine.Tables[0].NewRow();
- //dr["DictionaryID"] = -1;
- //dr["DictionaryValue"] = "";
- //dsDefectFine.Tables[0].Rows.InsertAt(dr, 0);
- //dsDefectFine.Tables[0].AcceptChanges();
- //this.cmbDefectFine.DisplayMember = "DictionaryValue";
- //this.cmbDefectFine.ValueMember = "DictionaryID";
- //this.cmbDefectFine.DataSource = dsDefectFine.Tables[0];
- DataSet dsResultAccount = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return SystemModuleProxy.Service.GetAllDefectFine();
- }));
- if (dsResultAccount != null && dsResultAccount.Tables[0].Rows.Count > 0)
- {
- DataView dv = dsResultAccount.Tables[0].DefaultView;
- dv.RowFilter = "valueflag=1";
- this.cmbDefectFine.DisplayMember = "DefectFineCode";
- this.cmbDefectFine.ValueMember = "DefectFineID";
- DataTable dtNew = dv.ToTable();
- DataRow dr = dtNew.NewRow();
- dr["DefectFineID"] = -1;
- dr["DefectFineCode"] = "";
- dtNew.Rows.InsertAt(dr, 0);
- dtNew.AcceptChanges();
- this.cmbDefectFine.DisplayMember = "DefectFineCode";
- this.cmbDefectFine.ValueMember = "DefectFineID";
- this.cmbDefectFine.DataSource = dtNew;
- this._dtDefaultDefectFineRelation = dtNew;
- }
- // 获取缺陷扣除数数据源
- DataSet dsDefectDeduction = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return SystemModuleProxy.Service.GetAllDefectDeduction();
- }));
- if (dsDefectDeduction != null && dsDefectDeduction.Tables[0].Rows.Count > 0)
- {
- DataView dv = dsDefectDeduction.Tables[0].DefaultView;
- dv.RowFilter = "valueflag=1";
- this.cmbDefectDeduction.DisplayMember = "DefectDeductionNum";
- this.cmbDefectDeduction.ValueMember = "DefectDeductionID";
- DataTable dtNew = dv.ToTable();
- DataRow dr = dtNew.NewRow();
- dr["DefectDeductionID"] = -1;
- //dr["DefectDeductionNum"] = "0";
- dtNew.Rows.InsertAt(dr, 0);
- dtNew.AcceptChanges();
- this.cmbDefectDeduction.DisplayMember = "DefectDeductionNum";
- this.cmbDefectDeduction.ValueMember = "DefectDeductionID";
- this.cmbDefectDeduction.DataSource = dtNew;
- this._dtDefaultDefectDeductionRelation = dtNew;
- }
- if (this._isEdit)
- {
- this.dropDuty.SelectedValue = this._dtBarCode.Rows[this._rowIndex]["DefectID"].ToString();
- this._currentDutyCode = this._dtBarCode.Rows[this._rowIndex]["DefectCode"].ToString();
- // 新添加的
- if (this._dtBarCode.Rows[this._rowIndex]["IsOtherDefect"].ToString() == "1")
- {
- this.chkDefect.Checked = true;
- }
- //
- // add 2016/01/06 wangx
- if (this._dtDefectFineRelation != null)
- {
- DataRow[] r7 = this._dtDefectFineRelation.Select("defectid=" + this.dropDuty.SelectedValue);
- if (r7.Length > 0)
- {
- DataTable dtNew = r7.CopyToDataTable();
- DataRow dr = dtNew.NewRow();
- dr["DefectFineID"] = -1;
- dr["DefectFineCode"] = "";
- dtNew.Rows.InsertAt(dr, 0);
- dtNew.AcceptChanges();
- this.cmbDefectFine.DisplayMember = "DefectFineCode";
- this.cmbDefectFine.ValueMember = "DefectFineID";
- this.cmbDefectFine.DataSource = dtNew;
- }
- else
- {
- this.cmbDefectFine.DisplayMember = "DefectFineCode";
- this.cmbDefectFine.ValueMember = "DefectFineID";
- this.cmbDefectFine.DataSource = this._dtDefaultDefectFineRelation;
- }
- }
- if (this._dtDefectDeductionRelation != null)
- {
- DataRow[] r7 = this._dtDefectDeductionRelation.Select("defectid=" + this.dropDuty.SelectedValue);
- if (r7.Length > 0)
- {
- DataTable dtNew = r7.CopyToDataTable();
- DataRow dr = dtNew.NewRow();
- dr["DefectDeductionID"] = -1;
- //dr["DefectDeductionNum"] = "";
- dtNew.Rows.InsertAt(dr, 0);
- dtNew.AcceptChanges();
- this.cmbDefectDeduction.DisplayMember = "DefectDeductionNum";
- this.cmbDefectDeduction.ValueMember = "DefectDeductionNum";
- this.cmbDefectDeduction.DataSource = dtNew;
- }
- else
- {
- this.cmbDefectDeduction.DisplayMember = "DefectDeductionNum";
- this.cmbDefectDeduction.ValueMember = "DefectDeductionNum";
- this.cmbDefectDeduction.DataSource = this._dtDefaultDefectDeductionRelation;
- }
- }
- // add end
- // 缺陷选定后事件
- BindDutyDefect(this._barcode, Convert.ToInt32(this.dropDuty.SelectedValue));
- // 缺陷位置
- this.dropDefectLocation.SelectedValue = this._dtBarCode.Rows[this._rowIndex]["DefectPositionID"].ToString();
- this._currentDefectPositionCode = this._dtBarCode.Rows[this._rowIndex]["DefectPositionCode"].ToString();
- // 责任工序
- if (this._dtBarCode.Rows[this._rowIndex]["DefectProcedureID"].ToString() != Constant.INT_IS_ZERO.ToString()
- && this._dtBarCode.Rows[this._rowIndex]["DefectProcedureID"].ToString() != string.Empty)
- {
- this.dropDutyProcedure.SelectedValue = this._dtBarCode.Rows[this._rowIndex]["DefectProcedureID"].ToString();
- this.dropDutyProcedure.Text = this._dtBarCode.Rows[this._rowIndex]["DefectProcedureName"].ToString();
- this._currentDefectProcedureCode = this._dtBarCode.Rows[this._rowIndex]["DefectProcedureCode"].ToString();
- // 责任工种
- SetDutyCode(this._barcode, Convert.ToInt32(this.dropDutyProcedure.SelectedValue));
- string DutyProcedure = this.dropDutyProcedure.SelectedValue.ToString();
- DataTable dtDutyProcedureCode = this.dropDutyProcedure.DataSource as DataTable;
- if (dtDutyProcedureCode.Rows.Count > Constant.INT_IS_ZERO)
- {
- DataRow[] drJobs = dtDutyProcedureCode.Select("DutyProcedureID=" + DutyProcedure);
- if (drJobs.Length > Constant.INT_IS_ZERO)
- {
- this._currentDefectProcedureCode = drJobs[0]["DutyProcedureCode"].ToString();
- }
- }
- DataSet dsDutyCode = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetDutyProcedureCodeByBarCode(this._barcode, Convert.ToInt32(this.dropDutyProcedure.SelectedValue));
- }));
- if (dsDutyCode != null && dsDutyCode.Tables.Count > Constant.INT_IS_ZERO
- && dsDutyCode.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
- {
- this.dropDutyUser.DisplayMember = "UserCode";
- this.dropDutyUser.ValueMember = "UserID";
- this.dropDutyUser.DataSource = dsDutyCode.Tables[0];
- this.dropDutyUser.SelectedValue = this._dtBarCode.Rows[this._rowIndex]["DefectUserID"].ToString();
- this._currentDefectUserCode = this._dtBarCode.Rows[this._rowIndex]["DefectUserCode"].ToString();
- this._productionDataID = Convert.ToInt32(this._dtBarCode.Rows[this._rowIndex]["ProductionDataID"].ToString());
- DataSet dsDutyJobs = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetDutyJobsCodeByUser(Convert.ToInt32(this.dropDutyUser.SelectedValue), this._productionDataID);
- }));
- if (dsDutyJobs != null && dsDutyJobs.Tables.Count > Constant.INT_IS_ZERO
- && dsDutyJobs.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
- {
- this.dropJobs.DisplayMember = "JobsName";
- this.dropJobs.ValueMember = "JobsID";
- this.dropJobs.DataSource = dsDutyJobs.Tables[0];
- this.dropJobs.SelectedValue = this._dtBarCode.Rows[this._rowIndex]["Jobs"].ToString();
- }
- }
- }
- else
- {
- this.dropDutyProcedure.SelectedValue = null;
- this.dropDutyProcedure.Text = "";
- this._currentDefectProcedureCode = "";
- // 没有责任工序,获取号及工种
- if (this._dtDutyProcedureUser != null && this._dtDutyProcedureUser.Rows.Count > Constant.INT_IS_ZERO)
- {
- this.dropDutyUser.SelectedValue = this._dtBarCode.Rows[this._rowIndex]["DefectUserID"].ToString();
- this._currentDefectUserCode = this._dtBarCode.Rows[this._rowIndex]["DefectUserCode"].ToString();
- this._productionDataID = Convert.ToInt32(this._dtBarCode.Rows[this._rowIndex]["ProductionDataID"].ToString());
- DataSet dsDutyJobs = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return SystemModuleProxy.Service.GetAllJobsByUserID(Convert.ToInt32(this.dropDutyUser.SelectedValue));
- }));
- if (dsDutyJobs != null && dsDutyJobs.Tables.Count > Constant.INT_IS_ZERO
- && dsDutyJobs.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
- {
- this.dropJobs.DisplayMember = "JobsName";
- this.dropJobs.ValueMember = "Jobs";
- this.dropJobs.DataSource = dsDutyJobs.Tables[0];
- this.dropJobs.SelectedValue = this._dtBarCode.Rows[this._rowIndex]["Jobs"].ToString();
- }
- }
- }
- // 漏检工号
- if (this._dtBarCode.Rows[this._rowIndex]["MissedUserID"].ToString() != "-1")
- {
- this.dropMissUser.SelectedValue = this._dtBarCode.Rows[this._rowIndex]["MissedUserID"].ToString();
- this.dropMissUser.Text = this._dtBarCode.Rows[this._rowIndex]["MissedUserName"].ToString();
- this._currentMissedUserCode = this._dtBarCode.Rows[this._rowIndex]["MissedUserCode"].ToString();
- }
- this.txtRemarks.Text = this._dtBarCode.Rows[this._rowIndex]["DefectRemarks"].ToString();
- this.dgvDefectStaff.DataSource = this._dsStaff.Tables[string.Format("TempTable{0}", this._tempcount.ToString())];
- this.dgvMissStaff.DataSource = this._dsMissedStaff.Tables[string.Format("TempTable{0}", this._tempcount.ToString())];
- BindByteImage(this._dsImage.Tables[string.Format("TempTable{0}", this._tempcount.ToString())]);
- if (this._dtBarCode.Rows[this._rowIndex]["DefectFineID"].ToString() != "-1"
- && this._dtBarCode.Rows[this._rowIndex]["DefectFineID"].ToString() != string.Empty)
- {
- this.cmbDefectFine.SelectedValue = this._dtBarCode.Rows[this._rowIndex]["DefectFineID"].ToString();
- }
- if (this._dtBarCode.Rows[this._rowIndex]["DefectDeductionNum"].ToString() != "-1"
- && this._dtBarCode.Rows[this._rowIndex]["DefectDeductionNum"].ToString() != string.Empty)
- {
- this.cmbDefectDeduction.SelectedValue = this._dtBarCode.Rows[this._rowIndex]["DefectDeductionNum"].ToString();
- }
- }
- }
- /// <summary>
- /// 缺陷验证事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dropDuty_Validating(object sender, System.ComponentModel.CancelEventArgs e)
- {
- if (this.dropDuty.SelectedValue != null && this.dropDuty.SelectedValue.ToString() != string.Empty)
- {
- if (!this.dropDuty.ReadOnly)
- {
- // 选定缺陷值
- string DutyValue = this.dropDuty.SelectedValue.ToString();
- DataTable dtDuty = this.dropDuty.DataSource as DataTable;
- string newDefectCode = "";
- if (dtDuty.Rows.Count > Constant.INT_IS_ZERO)
- {
- DataRow[] dr = dtDuty.Select("DefectFlagID=" + DutyValue);
- if (dr.Length > Constant.INT_IS_ZERO)
- {
- newDefectCode = dr[0]["DefectCode"].ToString();
- // 当前缺陷编码
- //this._currentDutyCode = dr[0]["DefectCode"].ToString();
- }
- }
- if (newDefectCode != this._currentDutyCode)
- {
- this._currentDutyCode = newDefectCode;
- BindDutyDefect(this._barcode, Convert.ToInt32(DutyValue));
- dropDutyProcedure_Validating(sender, e);
- // add 2016/01/06 wangx
- if (this._dtDefectFineRelation != null)
- {
- DataRow[] r7 = this._dtDefectFineRelation.Select("defectid=" + DutyValue);
- if (r7.Length > 0)
- {
- DataTable dtNew = r7.CopyToDataTable();
- DataRow dr = dtNew.NewRow();
- dr["DefectFineID"] = -1;
- dr["DefectFineCode"] = "";
- dtNew.Rows.InsertAt(dr, 0);
- dtNew.AcceptChanges();
- this.cmbDefectFine.DisplayMember = "DefectFineCode";
- this.cmbDefectFine.ValueMember = "DefectFineID";
- this.cmbDefectFine.DataSource = dtNew;
- }
- else
- {
- this.cmbDefectFine.DisplayMember = "DefectFineCode";
- this.cmbDefectFine.ValueMember = "DefectFineID";
- this.cmbDefectFine.DataSource = this._dtDefaultDefectFineRelation;
- }
- }
- if (this._dtDefectDeductionRelation != null)
- {
- DataRow[] r7 = this._dtDefectDeductionRelation.Select("defectid=" + DutyValue);
- if (r7.Length > 0)
- {
- DataTable dtNew = r7.CopyToDataTable();
- DataRow dr = dtNew.NewRow();
- dr["DefectDeductionID"] = -1;
- //dr["DefectDeductionNum"] = "";
- dtNew.Rows.InsertAt(dr, 0);
- dtNew.AcceptChanges();
- this.cmbDefectDeduction.DisplayMember = "DefectDeductionNum";
- this.cmbDefectDeduction.ValueMember = "DefectDeductionID";
- this.cmbDefectDeduction.DataSource = dtNew;
- }
- else
- {
- this.cmbDefectDeduction.DisplayMember = "DefectDeductionNum";
- this.cmbDefectDeduction.ValueMember = "DefectDeductionID";
- this.cmbDefectDeduction.DataSource = this._dtDefaultDefectDeductionRelation;
- }
- }
- // add end
- }
- }
- }
- }
- /// <summary>
- /// 责任工序验证事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dropDutyProcedure_Validating(object sender, System.ComponentModel.CancelEventArgs e)
- {
- if (this.dropDutyProcedure.SelectedValue != null && this.dropDutyProcedure.SelectedValue.ToString() != string.Empty)
- {
- if (!this.txtRemarks.ReadOnly)
- {
- string DutyProcedure = this.dropDutyProcedure.SelectedValue.ToString();
- DataTable dtDutyProcedureCode = this.dropDutyProcedure.DataSource as DataTable;
- string newDutyProcedureCode = "";
- if (dtDutyProcedureCode.Rows.Count > Constant.INT_IS_ZERO)
- {
- DataRow[] dr = dtDutyProcedureCode.Select("DutyProcedureID=" + DutyProcedure);
- if (dr.Length > Constant.INT_IS_ZERO)
- {
- newDutyProcedureCode = dr[0]["DutyProcedureCode"].ToString();
- //this._currentDefectProcedureCode = dr[0]["DutyProcedureCode"].ToString();
- }
- }
- if (newDutyProcedureCode != this._currentDefectProcedureCode)
- {
- this._currentDefectProcedureCode = newDutyProcedureCode;
- SetDutyCode(this._barcode, Convert.ToInt32(this.dropDutyProcedure.SelectedValue));
- }
- this.txtRemarks.Focus();
- }
- }
- else
- {
- if (this._currentDefectProcedureCode == "")
- return;
- //当前责任工序编码为空串
- this._currentDefectProcedureCode = "";
- //责任工序为空串时,责任工号为当前账套所有生产工号
- this._currentDefectUserCode = "";
- this.dropDutyUser.DataSource = null;
- this.dropDutyUser.DisplayMember = "UserCode";
- this.dropDutyUser.ValueMember = "UserID";
- this.dropDutyUser.DataSource = this._dtDutyProcedureUser;
- this.dropDutyUser.Text = "";
- //责任工序为空串时,责任工种置回空数据源
- this.dropJobs.DataSource = null;
- this.dropJobs.DisplayMember = "JobsName";
- this.dropJobs.ValueMember = "Jobs";
- this.dropJobs.DataSource = GetDutyProcedureJobs();
- this.dropJobs.Text = string.Empty;
- //清空缺陷责任员工
- if (!this._dsStaff.Tables.Contains(string.Format("TempTable{0}", this._tempcount.ToString())))
- {
- DataTable dtStaff = new DataTable(string.Format("TempTable{0}", this._tempcount.ToString()));
- 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._dsStaff.Tables.Add(dtStaff);
- }
- // 获取临时表是否有数据,如果有行,则删除,
- DataTable dtTemp = this._dsStaff.Tables[string.Format("TempTable{0}", this._tempcount.ToString())];
- if (dtTemp != null)
- {
- // 清空临时表数据
- this._dsStaff.Tables[string.Format("TempTable{0}", this._tempcount.ToString())].Clear();
- }
- }
- }
- /// <summary>
- /// 保存按钮事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnSave_Click(object sender, EventArgs e)
- {
- try
- {
- if (this.dropDuty.SelectedValue == null || this.dropDuty.SelectedValue.ToString() == string.Empty)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "缺陷"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (this.dropDefectLocation.SelectedValue == null || this.dropDefectLocation.SelectedValue.ToString() == string.Empty)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "缺陷位置"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (this.dropDutyUser.SelectedValue == null || this.dropDutyUser.SelectedValue.ToString() == string.Empty)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "责任工号"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (this.dropJobs.SelectedValue == null || this.dropJobs.SelectedValue.ToString() == string.Empty)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "工种"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (!this._isEdit)
- {
- // 每次添加不能重复
- if (this._dtBarCode != null && this._dtBarCode.Rows.Count > Constant.INT_IS_ZERO)
- {
- // 缺陷、缺陷位置、责任工序、责任工号、责任工种
- DataRow[] drExist = this._dtBarCode.Select(
- string.Format("DefectID={0} and DefectPositionID={1} and DefectUserID={2} and (({3} = 0 and (DefectProcedureID=0 or DefectProcedureID is null)) or ({3} > 0 and DefectProcedureID={3})) and Jobs={4}",
- this.dropDuty.SelectedValue.ToString() == string.Empty ? 0 : this.dropDuty.SelectedValue,
- this.dropDefectLocation.SelectedValue.ToString() == string.Empty ? 0 : this.dropDefectLocation.SelectedValue,
- this.dropDutyUser.SelectedValue.ToString() == string.Empty ? 0 : this.dropDutyUser.SelectedValue,
- (this.dropDutyProcedure.SelectedValue == null || this.dropDutyProcedure.SelectedValue.ToString() == string.Empty) ? 0 : this.dropDutyProcedure.SelectedValue,
- this.dropJobs.SelectedValue.ToString() == string.Empty ? 0 : this.dropJobs.SelectedValue
- )
- );
- if (drExist.Length > Constant.INT_IS_ZERO)
- {
- // 提示信息
- MessageBox.Show(Messages.MSG_PM_W001,
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- }
- DataRow dr = this._dtBarCode.NewRow();
- dr["BarCode"] = this._dtBarCode;
- dr["DefectID"] = this.dropDuty.SelectedValue.ToString() == string.Empty ? 0 : this.dropDuty.SelectedValue;
- dr["DefectName"] = this.dropDuty.Text;
- dr["DefectCode"] = this._currentDutyCode;
- dr["DefectPositionID"] = this.dropDefectLocation.SelectedValue.ToString() == string.Empty ? 0 : this.dropDefectLocation.SelectedValue;
- dr["DefectPositionName"] = this.dropDefectLocation.Text;
- dr["DefectPositionCode"] = this._currentDefectPositionCode;
- dr["DefectProcedureID"] = (this.dropDutyProcedure.SelectedValue == null || this.dropDutyProcedure.SelectedValue.ToString() == string.Empty) ? 0 : this.dropDutyProcedure.SelectedValue;
- dr["DefectProcedureName"] = this.dropDutyProcedure.Text;
- dr["DefectProcedureCode"] = this._currentDefectProcedureCode;
- dr["DefectUserID"] = this.dropDutyUser.SelectedValue.ToString() == string.Empty ? 0 : this.dropDutyUser.SelectedValue;
- dr["DefectUserName"] = this.dropDutyUser.Text;
- dr["DefectUserCode"] = this._currentDefectUserCode;
- dr["Jobs"] = this.dropJobs.SelectedValue.ToString() == string.Empty ? 0 : this.dropJobs.SelectedValue;
- dr["JobsText"] = this.dropJobs.Text;
- dr["DefectRemarks"] = this.txtRemarks.Text;
- dr["TempCount"] = this._tempcount;
- dr["ProductionDataID"] = this._productionDataID;
- if (this.cmbDefectFine.SelectedValue != null && this.cmbDefectFine.SelectedValue.ToString() != "-1")
- {
- dr["DefectFineID"] = this.cmbDefectFine.SelectedValue;
- dr["DefectFineValue"] = this.cmbDefectFine.Text;
- }
- else
- {
- dr["DefectFineID"] = -1;
- dr["DefectFineValue"] = string.Empty;
- }
- dr["MissedUserID"] = (this.dropMissUser.SelectedValue == null || this.dropMissUser.SelectedValue.ToString() == string.Empty) ? -1 : this.dropMissUser.SelectedValue;
- dr["MissedUserCode"] = this._currentMissedUserCode;
- dr["MissedUserName"] = this.dropMissUser.Text;
- dr["IsAllowEdit"] = 1;
- if (this.cmbDefectDeduction.SelectedValue != null && this.cmbDefectDeduction.SelectedValue.ToString() != "-1")
- {
- dr["DefectDeductionID"] = this.cmbDefectDeduction.SelectedValue;
- dr["DefectDeductionNum"] = this.cmbDefectDeduction.Text;
- }
- else
- {
- dr["DefectDeductionID"] = -1;
- dr["DefectDeductionNum"] = string.Empty;
- }
- dr["IsOtherDefect"] = this.chkDefect.Checked ? 1 : 0;
- this._dtBarCode.Rows.Add(dr);
- }
- else
- {
- if (this._dtBarCode != null && this._dtBarCode.Rows.Count > Constant.INT_IS_ZERO)
- {
- int currentRowIndex = -1; // 用来匹配是否编辑自己
- for (int i = 0; i < this._dtBarCode.Rows.Count; i++)
- {
- if (Convert.ToInt32(this._dtBarCode.Rows[i]["DefectID"]) ==
- (this.dropDuty.SelectedValue.ToString() == string.Empty ? 0 : Convert.ToInt32(this.dropDuty.SelectedValue))
- &&
- Convert.ToInt32(this._dtBarCode.Rows[i]["DefectPositionID"]) ==
- (this.dropDefectLocation.SelectedValue.ToString() == string.Empty ? 0 : Convert.ToInt32(this.dropDefectLocation.SelectedValue))
- &&
- Convert.ToInt32(this._dtBarCode.Rows[i]["DefectProcedureID"].ToString() == "" ? 0 : this._dtBarCode.Rows[i]["DefectProcedureID"]) ==
- ((this.dropDutyProcedure.SelectedValue == null || this.dropDutyProcedure.SelectedValue.ToString() == string.Empty) ? 0 : Convert.ToInt32(this.dropDutyProcedure.SelectedValue))
- )
- {
- currentRowIndex = i;
- break;
- }
- }
- if (currentRowIndex != -Constant.INT_IS_ONE && currentRowIndex != this._rowIndex) // 更新后会有重复
- {
- // 提示信息
- MessageBox.Show(Messages.MSG_PM_W001,
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- }
- this._dtBarCode.Rows[this._rowIndex]["BarCode"] = this._dtBarCode;
- this._dtBarCode.Rows[this._rowIndex]["DefectID"] = this.dropDuty.SelectedValue.ToString() == string.Empty ? 0 : this.dropDuty.SelectedValue;
- this._dtBarCode.Rows[this._rowIndex]["DefectName"] = this.dropDuty.Text;
- this._dtBarCode.Rows[this._rowIndex]["DefectCode"] = this._currentDutyCode;
- this._dtBarCode.Rows[this._rowIndex]["DefectPositionID"] = this.dropDefectLocation.SelectedValue.ToString() == string.Empty ? 0 : this.dropDefectLocation.SelectedValue;
- this._dtBarCode.Rows[this._rowIndex]["DefectPositionName"] = this.dropDefectLocation.Text;
- this._dtBarCode.Rows[this._rowIndex]["DefectPositionCode"] = this._currentDefectPositionCode;
- this._dtBarCode.Rows[this._rowIndex]["DefectProcedureID"] = (this.dropDutyProcedure.SelectedValue == null || this.dropDutyProcedure.SelectedValue.ToString() == string.Empty) ? 0 : this.dropDutyProcedure.SelectedValue;
- this._dtBarCode.Rows[this._rowIndex]["DefectProcedureName"] = this.dropDutyProcedure.Text;
- this._dtBarCode.Rows[this._rowIndex]["DefectProcedureCode"] = this._currentDefectProcedureCode;
- this._dtBarCode.Rows[this._rowIndex]["DefectUserID"] = this.dropDutyUser.SelectedValue.ToString() == string.Empty ? 0 : this.dropDutyUser.SelectedValue;
- this._dtBarCode.Rows[this._rowIndex]["DefectUserName"] = this.dropDutyUser.Text;
- this._dtBarCode.Rows[this._rowIndex]["DefectUserCode"] = this._currentDefectUserCode;
- this._dtBarCode.Rows[this._rowIndex]["Jobs"] = this.dropJobs.SelectedValue.ToString() == string.Empty ? 0 : this.dropJobs.SelectedValue;
- this._dtBarCode.Rows[this._rowIndex]["JobsText"] = this.dropJobs.Text;
- this._dtBarCode.Rows[this._rowIndex]["DefectRemarks"] = this.txtRemarks.Text;
- this._dtBarCode.Rows[this._rowIndex]["TempCount"] = this._tempcount;
- this._dtBarCode.Rows[this._rowIndex]["ProductionDataID"] = this._productionDataID;
- if (this.cmbDefectFine.SelectedValue != null && this.cmbDefectFine.SelectedValue.ToString() != "-1")
- {
- this._dtBarCode.Rows[this._rowIndex]["DefectFineID"] = this.cmbDefectFine.SelectedValue;
- this._dtBarCode.Rows[this._rowIndex]["DefectFineValue"] = this.cmbDefectFine.Text;
- ;
- }
- else
- {
- this._dtBarCode.Rows[this._rowIndex]["DefectFineID"] = -1;
- this._dtBarCode.Rows[this._rowIndex]["DefectFineValue"] = string.Empty;
- }
- this._dtBarCode.Rows[this._rowIndex]["MissedUserID"] = (this.dropMissUser.SelectedValue == null || this.dropMissUser.SelectedValue.ToString() == string.Empty) ? -1 : this.dropMissUser.SelectedValue;
- this._dtBarCode.Rows[this._rowIndex]["MissedUserCode"] = this._currentMissedUserCode;
- ;
- this._dtBarCode.Rows[this._rowIndex]["MissedUserName"] = this.dropMissUser.Text;
- this._dtBarCode.Rows[this._rowIndex]["IsAllowEdit"] = 1;
- if (this.cmbDefectDeduction.SelectedValue != null && this.cmbDefectDeduction.SelectedValue.ToString() != "-1")
- {
- this._dtBarCode.Rows[this._rowIndex]["DefectDeductionID"] = this.cmbDefectDeduction.SelectedValue;
- this._dtBarCode.Rows[this._rowIndex]["DefectDeductionNum"] = this.cmbDefectDeduction.Text;
- ;
- }
- else
- {
- this._dtBarCode.Rows[this._rowIndex]["DefectDeductionID"] = -1;
- this._dtBarCode.Rows[this._rowIndex]["DefectDeductionNum"] = string.Empty;
- }
- this._dtBarCode.Rows[this._rowIndex]["IsOtherDefect"] = this.chkDefect.Checked ? 1 : 0;
- this._dtBarCode.AcceptChanges();
- }
- // 防止工种不选择的话,直接New一个
- if (!this._dsStaff.Tables.Contains(string.Format("TempTable{0}", _tempcount.ToString())))
- {
- DataTable dtStaff = new DataTable(string.Format("TempTable{0}", _tempcount.ToString()));
- 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._dsStaff.Tables.Add(dtStaff);
- }
- // 防止工种不选择的话,直接New一个
- if (!this._dsMissedStaff.Tables.Contains(string.Format("TempTable{0}", _tempcount.ToString())))
- {
- DataTable dtMissedStaff = new DataTable(string.Format("TempTable{0}", _tempcount.ToString()));
- 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._dsMissedStaff.Tables.Add(dtMissedStaff);
- }
- if (!this._dsImage.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._dsImage.Tables.Add(dtImage);
- }
- this._frm3202.BindByteImage(this._dsImage.Tables[string.Format("TempTable{0}", _tempcount.ToString())]);
- this._tempcount = _tempcount + 1;
- this._frm3202.SetDataSource(_tempcount);
- ClearText();
- if (this._isEdit)
- {
- // 保存后如果是编辑进来的,更改后可以继续录入,当前改为插入了
- this._isEdit = false;
- }
- }
- 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
- {
- if (!this._dsImage.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._dsImage.Tables.Add(dtImage);
- }
- 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;
- }
- this._dsImage.Tables[string.Format("TempTable{0}", this._tempcount)].Rows.RemoveAt(lvSelect.Index);
- this._dsImage.Tables[string.Format("TempTable{0}", this._tempcount)].AcceptChanges();
- this._frm3202.BindByteImage(this._dsImage.Tables[string.Format("TempTable{0}", this._tempcount)]);
- this.BindByteImage(this._dsImage.Tables[string.Format("TempTable{0}", this._tempcount)]);
- }
- }
- /// <summary>
- /// 缺陷位置验证事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dropDefectLocation_Validating(object sender, System.ComponentModel.CancelEventArgs e)
- {
- if (this.dropDefectLocation.SelectedValue != null && this.dropDefectLocation.SelectedValue.ToString() != string.Empty)
- {
- string DefectLocationCode = this.dropDefectLocation.SelectedValue.ToString();
- DataTable dtDefectLocationCode = this.dropDefectLocation.DataSource as DataTable;
- if (dtDefectLocationCode.Rows.Count > Constant.INT_IS_ZERO)
- {
- DataRow[] dr = dtDefectLocationCode.Select("DefectPositionID=" + DefectLocationCode);
- if (dr.Length > Constant.INT_IS_ZERO)
- {
- this._currentDefectPositionCode = dr[0]["DefectPositionCode"].ToString();
- }
- }
- }
- }
- /// <summary>
- /// 工号验证事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dropDutyUser_Validating(object sender, System.ComponentModel.CancelEventArgs e)
- {
- if (this.dropDutyUser.SelectedValue != null && this.dropDutyUser.SelectedValue.ToString() != string.Empty)
- {
- if (!this.txtRemarks.ReadOnly)
- {
- string DutyUserID = this.dropDutyUser.SelectedValue.ToString();
- DataTable dtDutyUserCode = this.dropDutyUser.DataSource as DataTable;
- if (dtDutyUserCode.Rows.Count > Constant.INT_IS_ZERO)
- {
- DataRow[] dr = dtDutyUserCode.Select("UserID=" + DutyUserID);
- if (dr.Length > Constant.INT_IS_ZERO)
- {
- this._currentDefectUserCode = dr[0]["UserCode"].ToString();
- }
- }
- // 判断责任工序是否选择,如果未选择,根据责任工号绑定工种
- if (this.dropDutyProcedure.SelectedValue == null || this.dropDutyProcedure.SelectedValue.ToString() == string.Empty)
- {
- // 根据工号查找工种
- DataSet dsAllJobsByUserID = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return SystemModuleProxy.Service.GetAllJobsByUserID(Convert.ToInt32(DutyUserID));
- }));
- if (dsAllJobsByUserID != null && dsAllJobsByUserID.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
- {
- this.dropJobs.DisplayMember = "JobsName";
- this.dropJobs.ValueMember = "Jobs";
- this.dropJobs.DataSource = dsAllJobsByUserID.Tables[0];
- this.dropJobs.SelectedValue = dsAllJobsByUserID.Tables[0].Rows[0]["Jobs"].ToString();
- //// 通过工种来搜索缺陷责任员工列表
- BindNoProcedureDutyStaff(Convert.ToInt32(dsAllJobsByUserID.Tables[0].Rows[0]["Jobs"]), this._tempcount);
- }
- }
- }
- }
- }
- /// <summary>
- /// 无责任工序下绑定缺陷责任员工
- /// </summary>
- /// <param name="productionDataID">生产数据ID</param>
- /// <param name="userID">用户ID</param>
- /// <param name="jobs">工种ID</param>
- /// <param name="StaffTempCount">唯一标识</param>
- private void BindNoProcedureDutyStaff(int jobs, int StaffTempCount)
- {
- if (!this._dsStaff.Tables.Contains(string.Format("TempTable{0}", StaffTempCount.ToString())))
- {
- DataTable dtStaff = new DataTable(string.Format("TempTable{0}", StaffTempCount.ToString()));
- 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._dsStaff.Tables.Add(dtStaff);
- }
- // 获取临时表是否有数据,如果有行,则删除,
- DataTable dtTemp = this._dsStaff.Tables[string.Format("TempTable{0}", StaffTempCount.ToString())];
- if (dtTemp.Rows.Count > Constant.INT_IS_ZERO)
- {
- // 清空临时表数据
- this._dsStaff.Tables[string.Format("TempTable{0}", StaffTempCount.ToString())].Clear();
- }
- //DataSet dsDutyStaff = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- //{
- // return PMModuleProxy.Service.GetDutyStaffByUserID(jobs);
- //}));
- int UserID = Convert.ToInt32(dropDutyUser.SelectedValue);
- DataSet dsDutyStaff = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetDutyStaffByUserJobsID(jobs, UserID);
- }));
- if (dsDutyStaff != null && dsDutyStaff.Tables.Count > Constant.INT_IS_ZERO
- && dsDutyStaff.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
- {
- foreach (DataRow dr in dsDutyStaff.Tables[0].Rows)
- {
- DataRow addDr = this._dsStaff.Tables[string.Format("TempTable{0}", StaffTempCount.ToString())].NewRow();
- addDr["IsSelected"] = 1;
- addDr["StaffID"] = dr["StaffID"];
- addDr["StaffCode"] = dr["StaffCode"];
- addDr["StaffName"] = dr["StaffName"];
- addDr["StaffTempCount"] = StaffTempCount;
- addDr["StaffStatus"] = dr["StaffStatus"];
- this._dsStaff.Tables[string.Format("TempTable{0}", StaffTempCount.ToString())].Rows.Add(addDr);
- }
- this.dgvDefectStaff.DataSource = this._dsStaff.Tables[string.Format("TempTable{0}", StaffTempCount.ToString())];
- }
- }
- /// <summary>
- /// 工种验证事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dropJobs_Validating(object sender, System.ComponentModel.CancelEventArgs e)
- {
- if (this.dropJobs.SelectedValue != null && this.dropJobs.SelectedValue.ToString() != string.Empty)
- {
- if (!this.txtRemarks.ReadOnly)
- {
- if (this.dropDutyProcedure.SelectedValue != null && this.dropDutyProcedure.SelectedValue.ToString() != string.Empty)
- {
- BindDutyStaff(this._productionDataID, Convert.ToInt32(this.dropDutyUser.SelectedValue == null || this.dropDutyUser.SelectedValue.ToString() == "" ? 0 : this.dropDutyUser.SelectedValue), Convert.ToInt32(this.dropJobs.SelectedValue), this._tempcount);
- }
- else
- {
- BindNoProcedureDutyStaff(Convert.ToInt32(this.dropJobs.SelectedValue), this._tempcount);
- }
- }
- }
- }
- /// <summary>
- /// 漏检工号检验事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dropMissUser_Validating(object sender, System.ComponentModel.CancelEventArgs e)
- {
- if (this.dropMissUser.SelectedValue != null && this.dropMissUser.SelectedValue.ToString() != string.Empty)
- {
- if (!this.txtRemarks.ReadOnly)
- {
- string MissedUserID = this.dropMissUser.SelectedValue.ToString();
- DataTable dtMissedUserCode = this.dropMissUser.DataSource as DataTable;
- if (dtMissedUserCode.Rows.Count > Constant.INT_IS_ZERO)
- {
- DataRow[] dr = dtMissedUserCode.Select("UserID=" + MissedUserID);
- if (dr.Length > Constant.INT_IS_ZERO)
- {
- this._currentMissedUserCode = dr[0]["UserCode"].ToString();
- }
- }
- BindMissedDutyStaff(Convert.ToInt32(this.dropMissUser.SelectedValue), this._tempcount);
- }
- }
- }
- /// <summary>
- /// 关闭按钮事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnCancel_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- #endregion
- #region 私有方法
- /// <summary>
- /// 获取缺陷
- /// </summary>
- /// <returns></returns>
- private DataTable GetDuty()
- {
- DataTable dtDuty = new DataTable();
- dtDuty.Columns.Add("DEFECTFLAGNAME");
- dtDuty.Columns.Add("DEFECTFLAGID");
- return dtDuty;
- }
- /// <summary>
- /// 责任工序数据表
- /// </summary>
- /// <returns></returns>
- private DataTable GetDutyProcedure()
- {
- DataTable dtDutyProcedure = new DataTable();
- dtDutyProcedure.Columns.Add("DutyProcedureName");
- dtDutyProcedure.Columns.Add("DutyProcedureID");
- return dtDutyProcedure;
- }
- /// <summary>
- /// 责任工号数据表 责任工序不选择时,默认数据源
- /// </summary>
- /// <returns></returns>
- private DataTable GetDutyProcedureUser()
- {
- SUserEntity userEntity = new SUserEntity();
- userEntity.IsWorker = 1;//生产工号
- DataSet dsDutyProcedureUser = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return SystemModuleProxy.Service.SearchUserData(userEntity);
- }));
- DataRow dr = dsDutyProcedureUser.Tables[0].NewRow();
- dr["UserID"] = -1;
- dr["UserCode"] = "";
- dr["UserName"] = "";
- dsDutyProcedureUser.Tables[0].Rows.InsertAt(dr, 0);
- dsDutyProcedureUser.Tables[0].AcceptChanges();
- this._dtDutyProcedureUser = dsDutyProcedureUser.Tables[0];
- return dsDutyProcedureUser.Tables[0];
- }
- /// <summary>
- /// 责任工种数据表
- /// </summary>
- /// <returns></returns>
- private DataTable GetDutyProcedureJobs()
- {
- DataTable dtDutyProcedureJobs = new DataTable();
- dtDutyProcedureJobs.Columns.Add("JobsName");
- dtDutyProcedureJobs.Columns.Add("Jobs");
- return dtDutyProcedureJobs;
- }
- /// <summary>
- /// 绑定责任工序
- /// </summary>
- /// <param name="barcode">产品条码</param>
- /// <param name="defectid">责任工序</param>
- private void BindDutyDefect(string barcode, int defectid)
- {
- DataSet dsDutyDefect = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetDutyProcedureByBarCode(barcode, defectid);
- }));
- if (dsDutyDefect != null && dsDutyDefect.Tables.Count > Constant.INT_IS_ZERO
- && dsDutyDefect.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
- {
- //modify wangx 20150629
- if (dsDutyDefect.Tables[1] != null && dsDutyDefect.Tables[1].Rows.Count > 0)
- {
- this._defaultJobsID = dsDutyDefect.Tables[1];
- }
- //modify wangx 20150629 end
- if (SpecialRepairflag == 1) //干补过,去掉首节点,即交坯节
- {
- DataRow[] dr = dsDutyDefect.Tables[0].Select("ModelType<>5");
- DataTable dt = null;
- if (dr.Length > 0)
- {
- dt = dsDutyDefect.Tables[0].Select("ModelType<>5").CopyToDataTable();
- }
- this.dropDutyProcedure.DataSource = null;
- this.dropDutyProcedure.DisplayMember = "DutyProcedureName";
- this.dropDutyProcedure.ValueMember = "DutyProcedureID";
- if (dt != null)
- {
- this.dropDutyProcedure.DataSource = dt;
- }
- else
- {
- this.dropDutyProcedure.DataSource = GetDutyProcedure();
- }
- }
- else
- {
- this.dropDutyProcedure.DataSource = null;
- this.dropDutyProcedure.DisplayMember = "DutyProcedureName";
- this.dropDutyProcedure.ValueMember = "DutyProcedureID";
- this.dropDutyProcedure.DataSource = dsDutyDefect.Tables[0];
- }
- //// 设置责任工号及责任工种
- //SetDutyCode(this._barcode, Convert.ToInt32(this.dropDutyProcedure.SelectedValue));
- //string DutyProcedure = this.dropDutyProcedure.SelectedValue.ToString();
- //DataTable dtDutyProcedureCode = this.dropDutyProcedure.DataSource as DataTable;
- //if (dtDutyProcedureCode.Rows.Count > Constant.INT_IS_ZERO)
- //{
- // DataRow[] dr = dtDutyProcedureCode.Select("DutyProcedureID=" + DutyProcedure);
- // if (dr.Length > Constant.INT_IS_ZERO)
- // {
- // this._currentDefectProcedureCode = dr[0]["DutyProcedureCode"].ToString();
- // }
- //}
- }
- else
- {
- this.dropDutyProcedure.DisplayMember = "DutyProcedureName";
- this.dropDutyProcedure.ValueMember = "DutyProcedureID";
- this.dropDutyProcedure.DataSource = GetDutyProcedure();
- this.dropDutyProcedure.Text = string.Empty;
- }
- this.dropDutyUser.DataSource = null;
- this.dropDutyUser.DisplayMember = "UserCode";
- this.dropDutyUser.ValueMember = "UserID";
- this.dropDutyUser.DataSource = this._dtDutyProcedureUser;//GetDutyProcedureUser();
- this.dropDutyUser.Text = string.Empty;
- this.dropJobs.DataSource = null;
- this.dropJobs.DisplayMember = "JobsName";
- this.dropJobs.ValueMember = "Jobs";
- this.dropJobs.DataSource = GetDutyProcedureJobs();
- this.dropJobs.Text = string.Empty;
- }
- /// <summary>
- /// 根据责任工序读出责任员工,并绑定到数据源
- /// </summary>
- /// <param name="barcode"></param>
- /// <param name="dutyProcedureID"></param>
- private void SetDutyCode(string barcode, int dutyProcedureID)
- {
- //DataSet dsDutyCode = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- //{
- // return PMModuleProxy.Service.GetDutyProcedureCodeByBarCode(barcode, dutyProcedureID);
- //}));
- DataTable dt = this.dropDutyProcedure.DataSource as DataTable;
- int ProductionDataID = Convert.ToInt32(dt.Select("DutyProcedureID=" + dutyProcedureID)[0]["ProductionDataID"]);
- DataSet dsDutyCode = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetDutyProcedureCodeByProductionDataID(ProductionDataID);
- }));
- if (dsDutyCode != null && dsDutyCode.Tables.Count > Constant.INT_IS_ZERO
- && dsDutyCode.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
- {
- this.dropDutyUser.DataSource = null;
- this.dropDutyUser.DisplayMember = "UserCode";
- this.dropDutyUser.ValueMember = "UserID";
- this.dropDutyUser.DataSource = dsDutyCode.Tables[0];
- string DutyUserCode = this.dropDutyUser.SelectedValue.ToString();
- DataTable dtDutyUserCode = this.dropDutyUser.DataSource as DataTable;
- if (dtDutyUserCode.Rows.Count > Constant.INT_IS_ZERO)
- {
- DataRow[] dr = dtDutyUserCode.Select("UserID=" + DutyUserCode);
- if (dr.Length > Constant.INT_IS_ZERO)
- {
- this._currentDefectUserCode = dr[0]["UserCode"].ToString();
- }
- }
- this._productionDataID = Convert.ToInt32(dsDutyCode.Tables[0].Rows[0]["ProductionDataID"].ToString());
- SetDutyJobs(Convert.ToInt32(dsDutyCode.Tables[0].Rows[0]["UserID"]), dutyProcedureID, 0, Convert.ToInt32(dsDutyCode.Tables[0].Rows[0]["ProductionDataID"]));
- }
- else
- {
- this.dropDutyUser.DisplayMember = "UserCode";
- this.dropDutyUser.ValueMember = "UserID";
- this.dropDutyUser.DataSource = GetDutyProcedureUser();
- }
- }
- /// <summary>
- /// 根据责任工序读出工种,并绑定到数据源
- /// </summary>
- private void SetDutyJobs(int UserID, int dutyProcedureID, int rowIndex, int ProductionDataID)
- {
- DataSet dsDutyJobs = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetDutyJobsCodeByUser(UserID, ProductionDataID);
- }));
- if (dsDutyJobs != null && dsDutyJobs.Tables.Count > Constant.INT_IS_ZERO
- && dsDutyJobs.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
- {
- this.dropJobs.DataSource = null;
- this.dropJobs.DisplayMember = "JobsName";
- this.dropJobs.ValueMember = "JobsID";
- this.dropJobs.DataSource = dsDutyJobs.Tables[0];
- this.dropJobs.SelectedValue = dsDutyJobs.Tables[0].Rows[0]["JobsID"].ToString();
- if (this._defaultJobsID != null)
- {
- DataRow[] dr = this._defaultJobsID.Select("procedureid=" + dutyProcedureID);
- if (dr.Length > 0)
- {
- if (dsDutyJobs.Tables[0].Select("JobsID=" + dr[0]["jobsid"].ToString()).Length > 0)
- {
- this.dropJobs.SelectedValue = dr[0]["jobsid"].ToString();
- }
- }
- }
- //// 通过工种来搜索缺陷责任员工列表 dsDutyJobs.Tables[0].Rows[0]["JobsID"]-->this.dropJobs.SelectedValue
- BindDutyStaff(ProductionDataID, UserID, Convert.ToInt32(this.dropJobs.SelectedValue), this._tempcount);
- }
- }
- /// <summary>
- /// 绑定缺陷责任员工
- /// </summary>
- /// <param name="productionDataID">生产数据ID</param>
- /// <param name="userID">用户ID</param>
- /// <param name="jobs">工种ID</param>
- /// <param name="StaffTempCount">唯一标识</param>
- private void BindDutyStaff(int productionDataID, int userID, int jobs, int StaffTempCount)
- {
- if (!this._dsStaff.Tables.Contains(string.Format("TempTable{0}", StaffTempCount.ToString())))
- {
- DataTable dtStaff = new DataTable(string.Format("TempTable{0}", StaffTempCount.ToString()));
- 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._dsStaff.Tables.Add(dtStaff);
- }
- // 获取临时表是否有数据,如果有行,则删除,
- DataTable dtTemp = this._dsStaff.Tables[string.Format("TempTable{0}", StaffTempCount.ToString())];
- if (dtTemp.Rows.Count > Constant.INT_IS_ZERO)
- {
- // 清空临时表数据
- this._dsStaff.Tables[string.Format("TempTable{0}", StaffTempCount.ToString())].Clear();
- }
- DataSet dsDutyStaff = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetDutyStaffByUserIDAndJobs(productionDataID, userID, jobs);
- }));
- if (dsDutyStaff != null && dsDutyStaff.Tables.Count > Constant.INT_IS_ZERO
- && dsDutyStaff.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
- {
- foreach (DataRow dr in dsDutyStaff.Tables[0].Rows)
- {
- DataRow addDr = this._dsStaff.Tables[string.Format("TempTable{0}", StaffTempCount.ToString())].NewRow();
- addDr["IsSelected"] = 1;
- addDr["StaffID"] = dr["StaffID"];
- addDr["StaffCode"] = dr["StaffCode"];
- addDr["StaffName"] = dr["StaffName"];
- addDr["StaffTempCount"] = StaffTempCount;
- addDr["StaffStatus"] = dr["StaffStatus"];
- this._dsStaff.Tables[string.Format("TempTable{0}", StaffTempCount.ToString())].Rows.Add(addDr);
- }
- this.dgvDefectStaff.DataSource = this._dsStaff.Tables[string.Format("TempTable{0}", StaffTempCount.ToString())];
- }
- }
- /// <summary>
- /// 保存后界面数据初始化
- /// </summary>
- private void ClearText()
- {
- this.dropDuty.SelectedValue = string.Empty;
- this.dropDuty.Text = string.Empty;
- this.dropDefectLocation.SelectedValue = string.Empty;
- this.dropDefectLocation.Text = string.Empty;
- this.dropDutyProcedure.SelectedValue = null;
- this.dropDutyProcedure.Text = string.Empty;
- this.dropDutyUser.SelectedValue = null;
- this.dropDutyUser.Text = string.Empty;
- this.dropJobs.SelectedValue = null;
- this.dropJobs.Text = string.Empty;
- this.txtRemarks.Text = string.Empty;
- this.dgvDefectStaff.DataSource = null;
- this.dgvMissStaff.DataSource = null;
- this._smallByte.Clear();
- this.lvPic.Clear();
- this.cmbDefectFine.SelectedValue = -1;
- this.dropMissUser.SelectedValue = null;
- this.dropMissUser.Text = string.Empty;
- }
- /// <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);
- DataRow dr = this._dsImage.Tables[string.Format("TempTable{0}", this._tempcount)].NewRow();
- dr["StaffTempCount"] = this._tempcount;
- dr["ImageByte"] = smallbuffer;
- dr["OrgImageByte"] = orgImageByte;
- this._dsImage.Tables[string.Format("TempTable{0}", this._tempcount)].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;
- }
- /// <summary>
- /// 绑定并显示图片
- /// </summary>
- /// <param name="ImageData"></param>
- private void BindByteImage(DataTable ImageData)
- {
- this._smallByte.Clear();
- foreach (DataRow dr in ImageData.Rows)
- {
- //将数据库中的缩略图取出
- this._smallByte.Add((byte[])dr[1]);
- }
- //绑定缩略图
- BindImg();
- }
- /// <summary>
- /// 根据漏检工号绑定漏检责任员工
- /// </summary>
- /// <param name="jobs">工种ID</param>
- /// <param name="StaffTempCount">唯一标识</param>
- private void BindMissedDutyStaff(int userid, int StaffTempCount)
- {
- if (!this._dsMissedStaff.Tables.Contains(string.Format("TempTable{0}", StaffTempCount.ToString())))
- {
- DataTable dtMissedStaff = new DataTable(string.Format("TempTable{0}", StaffTempCount.ToString()));
- 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._dsMissedStaff.Tables.Add(dtMissedStaff);
- }
- // 获取临时表是否有数据,如果有行,则删除,
- DataTable dtTemp = this._dsMissedStaff.Tables[string.Format("TempTable{0}", StaffTempCount.ToString())];
- if (dtTemp.Rows.Count > Constant.INT_IS_ZERO)
- {
- // 清空临时表数据
- this._dsMissedStaff.Tables[string.Format("TempTable{0}", StaffTempCount.ToString())].Clear();
- }
- DataSet dsMissedDutyStaff = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetMissedStaffByUserID(userid);
- }));
- if (dsMissedDutyStaff != null && dsMissedDutyStaff.Tables.Count > Constant.INT_IS_ZERO
- && dsMissedDutyStaff.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
- {
- foreach (DataRow dr in dsMissedDutyStaff.Tables[0].Rows)
- {
- DataRow addDr = this._dsMissedStaff.Tables[string.Format("TempTable{0}", StaffTempCount.ToString())].NewRow();
- addDr["IsSelected"] = 1;
- addDr["StaffID"] = dr["StaffID"];
- addDr["StaffCode"] = dr["StaffCode"];
- addDr["StaffName"] = dr["StaffName"];
- addDr["StaffTempCount"] = StaffTempCount;
- addDr["StaffStatus"] = dr["StaffStatus"];
- addDr["UJobsID"] = dr["UJobsID"];
- addDr["SJobsID"] = dr["SJobsID"];
- this._dsMissedStaff.Tables[string.Format("TempTable{0}", StaffTempCount.ToString())].Rows.Add(addDr);
- }
- this.dgvMissStaff.DataSource = this._dsMissedStaff.Tables[string.Format("TempTable{0}", StaffTempCount.ToString())];
- }
- }
- #endregion
- }
- }
|