| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051 |
- /*******************************************************************************
- * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_PM_1303.cs
- * 2.功能描述:新建入窑前检验-新建、编辑
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 王鑫 2014/10/06 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.Proxys;
- namespace Dongke.IBOSS.PRD.Client.PMModule
- {
- /// <summary>
- /// 新建入窑前检验-新建、编辑
- /// </summary>
- public partial class F_PM_1303 : 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_1302 _frm1302 = null;
- // 员工数据集
- private DataSet _dsStaff = 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 = "";
- // 当前缺陷工号ID
- private int _currentDefectUserID = 0;
- // 是否干补
- private int SpecialRepairflag = 0;//0未干补 1干补
- #endregion
- #region 构造函数
- public F_PM_1303()
- {
- 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="frm0903">调用实例对象</param>
- /// <param name="dsStaff">员工数据集</param>
- /// <param name="dsImage">图片数据集</param>
- /// <param name="picByte">原图字节数组</param>
- /// <param name="smallByte">缩略图字节数组</param>
- /// <param name="rowIndex">编辑行号标识</param>
- public F_PM_1303(DataTable dtBarCode
- , string barcode
- , int goodsID
- , int tempcount
- , int procedureID
- , string titleText
- , bool isEdit
- , F_PM_1302 frm1302
- , DataSet dsStaff
- , 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._frm1302 = frm1302;
- this._dsStaff = dsStaff;
- 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 事件
- private void F_PM_1303_Load(object sender, EventArgs e)
- {
- this.dgvDefectStaff.AutoGenerateColumns = false;
- //获取干补标识
- SpecialRepairflag = (int)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetSpecialRepairflagByBarcode(this._barcode);
- }));
- 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.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;
- }
- if (this._isEdit)
- {
- this.dropDuty.SelectedValue = this._dtBarCode.Rows[this._rowIndex]["DefectID"].ToString();
- this._currentDutyCode = this._dtBarCode.Rows[this._rowIndex]["DefectCode"].ToString();
- // 缺陷选定后事件
- 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();
- // 责任工序
- this.dropDutyProcedure.SelectedValue = this._dtBarCode.Rows[this._rowIndex]["DefectProcedureID"].ToString();
- this._currentDefectProcedureCode = this._dtBarCode.Rows[this._rowIndex]["DefectProcedureCode"].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();
- }
- }
- this.txtRemarks.Text = this._dtBarCode.Rows[this._rowIndex]["DefectRemarks"].ToString();
- this.dgvDefectStaff.DataSource = this._dsStaff.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();
- }
- }
- }
- /// <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();
- BindDutyDefect(this._barcode, Convert.ToInt32(DutyValue));
- DataTable dtDuty = this.dropDuty.DataSource as DataTable;
- if (dtDuty.Rows.Count > Constant.INT_IS_ZERO)
- {
- DataRow[] dr = dtDuty.Select("DefectFlagID=" + DutyValue);
- if (dr.Length > Constant.INT_IS_ZERO)
- {
- this._currentDutyCode = dr[0]["DefectCode"].ToString();
- }
- }
- }
- }
- }
- /// <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.dropDutyProcedure.ReadOnly)
- {
- 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();
- }
- }
- }
- }
- }
- /// <summary>
- /// 保存按钮事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnSave_Click(object sender, EventArgs e)
- {
- 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.dropDutyProcedure.SelectedValue == null || this.dropDutyProcedure.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}",
- 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
- )
- );
- 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["discarde"] = 0;
- 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.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;
- }
- 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"]) ==
- (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]["discarde"] = 0;
- 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.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.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");
- dtStaff.Columns.Add("Jobs");
- this._dsStaff.Tables.Add(dtStaff);
- }
- 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._frm1302.BindByteImage(this._dsImage.Tables[string.Format("TempTable{0}", _tempcount.ToString())]);
- this._tempcount = _tempcount + 1;
- this._frm1302.SetDataSource(_tempcount);
- ClearText();
- if (this._isEdit)
- {
- // 保存后如果是编辑进来的,更改后可以继续录入,当前改为插入了
- this._isEdit = false;
- }
- }
- /// <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._frm1302.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.dropDutyUser.ReadOnly)
- {
- 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._currentDefectUserID = Convert.ToInt32(dr[0]["UserID"].ToString());
- int jobs = 0;
- if (this.dropJobs.SelectedValue != null && this.dropJobs.SelectedValue.ToString() != string.Empty)
- {
- jobs = Convert.ToInt32(this.dropJobs.SelectedValue);
- }
- BindDutyStaff(this._productionDataID, Convert.ToInt32(dr[0]["UserID"].ToString()), jobs, this._tempcount);
- }
- }
- }
- }
- }
- /// <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.dropJobs.ReadOnly)
- {
- BindDutyStaff(this._productionDataID, this._currentDefectUserID, Convert.ToInt32(this.dropJobs.SelectedValue), this._tempcount);
- }
- }
- }
- #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()
- {
- DataTable dtDutyProcedureUser = new DataTable();
- dtDutyProcedureUser.Columns.Add("UserCode");
- dtDutyProcedureUser.Columns.Add("UserID");
- return dtDutyProcedureUser;
- }
- /// <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)
- {
- //this.dropDutyProcedure.DataSource = null;
- //this.dropDutyProcedure.DisplayMember = "DutyProcedureName";
- //this.dropDutyProcedure.ValueMember = "DutyProcedureID";
- //this.dropDutyProcedure.DataSource = dsDutyDefect.Tables[0];
- 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];
- }
- }
- else
- {
- this.dropDutyProcedure.DisplayMember = "DutyProcedureName";
- this.dropDutyProcedure.ValueMember = "DutyProcedureID";
- this.dropDutyProcedure.DataSource = GetDutyProcedure();
- this.dropDutyProcedure.Text = "";
- this.dropDutyUser.DisplayMember = "UserCode";
- this.dropDutyUser.ValueMember = "UserID";
- this.dropDutyUser.DataSource = GetDutyProcedureUser();
- this.dropDutyUser.Text = "";
- this.dropJobs.DisplayMember = "JobsName";
- this.dropJobs.ValueMember = "Jobs";
- this.dropJobs.DataSource = GetDutyProcedureJobs();
- this.dropJobs.Text = "";
- }
- }
- /// <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.DisplayMember = "UserCode";
- this.dropDutyUser.ValueMember = "UserID";
- this.dropDutyUser.DataSource = dsDutyCode.Tables[0];
- this.dropDutyUser.SelectedValue = dsDutyCode.Tables[0].Rows[0]["UserID"].ToString();
- this.dropDutyUser.Text = dsDutyCode.Tables[0].Rows[0]["UserCode"].ToString();
- 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.DisplayMember = "JobsName";
- this.dropJobs.ValueMember = "JobsID";
- this.dropJobs.DataSource = dsDutyJobs.Tables[0];
- this.dropJobs.SelectedValue = dsDutyJobs.Tables[0].Rows[0]["JobsID"].ToString();
- //// 通过工种来搜索缺陷责任员工列表
- BindDutyStaff(ProductionDataID, UserID, Convert.ToInt32(dsDutyJobs.Tables[0].Rows[0]["JobsID"]), 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");
- dtStaff.Columns.Add("Jobs");
- 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"];
- addDr["Jobs"] = dr["SJobsID"];
- 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 = string.Empty;
- this.dropDutyProcedure.Text = string.Empty;
- this.dropDutyUser.SelectedValue = string.Empty;
- this.dropDutyUser.Text = string.Empty;
- this.dropJobs.SelectedValue = string.Empty;
- this.dropJobs.Text = string.Empty;
- this.txtRemarks.Text = string.Empty;
- this.dgvDefectStaff.DataSource = null;
- this._smallByte.Clear();
- this.lvPic.Clear();
- this.cmbDefectFine.SelectedValue = -1;
- }
- /// <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();
- }
- #endregion
- }
- }
|