| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307 |
- /*******************************************************************************
- * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_PM_0901.cs
- * 2.功能描述:工序检验
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 王鑫 2014/09/28 1.00 新建
- *******************************************************************************/
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Drawing;
- using System.Drawing.Drawing2D;
- using System.Drawing.Imaging;
- using System.IO;
- using System.Windows.Forms;
- using Dongke.IBOSS.PRD.Basics.BaseControls;
- using Dongke.IBOSS.PRD.Basics.BaseResources;
- using Dongke.IBOSS.PRD.Basics.Library;
- using Dongke.IBOSS.PRD.Client.CommonModule;
- using Dongke.IBOSS.PRD.WCF.DataModels;
- using Dongke.IBOSS.PRD.WCF.Proxys;
- using Dongke.IBOSS.PRD.WCF.Proxys.PMModuleService;
- using Dongke.IBOSS.PRD.WCF.Proxys.SystemModuleService;
- namespace Dongke.IBOSS.PRD.Client.PMModule
- {
- /// <summary>
- /// 工序检验一览
- /// </summary>
- public partial class F_PM_0902 : FormBase
- {
- #region 成员变量
- // 工序ID
- private int _procedureID;
- // 生产工号
- private int _userID = -1;
- // 生产编号
- private string _userCode;
- // 生产名称
- private string _userName;
- // 工序实体类
- ProcedureEntity _procedureDataEntity;
- // 产品数据表
- DataTable _dtProductionData = null;
- // 产品缺陷数据表
- DataTable _dtProductionDefectData = null;
- // 当前选择的行
- private int _selectedRowIndex;
- // ComBoxEditingControl
- private DataGridViewComboBoxEditingControl _dataGridViewComboBox = null;
- // 当前产品条码的产品ID,用来查询缺陷位置
- private int _currentGoodsID = 0;
- // 当前产品条码,用来切换筛选列表数据
- private string _currentBarCode = "";
- // 返工工序搜索列表对象
- C_DGV_Cell_ListBoxComboBox _C_DGV_Cell_ListBoxComboBox = null;
- // 过滤结果集
- private DataSet _ds = null;
- // 过滤员工结果集
- private DataSet _dsStaff = null;
- // 过滤缺陷图片
- private DataSet _dsImage = null;
- // 临时数,用来过滤责任员工数据源标识
- private int _tempCount = 0;
- // 当前临时标记
- private string _currentTempSign = "";
- // 图片字节集
- private List<byte[]> _PicByte = new List<byte[]>();
- // 缩略图片字节集
- private List<byte[]> _smallByte = new List<byte[]>();
- #endregion
- #region 属性
- /// <summary>
- /// 生产工号
- /// </summary>
- public int UserID
- {
- set
- {
- _userID = value;
- }
- get
- {
- return _userID;
- }
- }
- /// <summary>
- /// 生产编号
- /// </summary>
- public string UserCode
- {
- set
- {
- _userCode = value;
- }
- get
- {
- return _userCode;
- }
- }
- /// <summary>
- /// 用户名称
- /// </summary>
- public string UserName
- {
- set
- {
- _userName = value;
- }
- get
- {
- return _userName;
- }
- }
- /// <summary>
- /// 产品数据表
- /// </summary>
- public DataTable TableProductionData
- {
- set
- {
- _dtProductionData = value;
- }
- get
- {
- if (_dtProductionData == null)
- {
- _dtProductionData = new DataTable("ProductionData");
- _dtProductionData.Columns.Add("BarCode");
- _dtProductionData.Columns.Add("GoodsID");
- _dtProductionData.Columns.Add("GoodsCode");
- _dtProductionData.Columns.Add("GoodsName");
- _dtProductionData.Columns.Add("DefectFlagID");
- _dtProductionData.Columns.Add("ReworkProcedureID");
- _dtProductionData.Columns.Add("Remarks");
- _dtProductionData.Columns.Add("UserID");
- return _dtProductionData;
- }
- else
- {
- return _dtProductionData;
- }
- }
- }
- /// <summary>
- /// 产品缺陷表
- /// </summary>
- public DataTable TableProductionDefectData
- {
- set
- {
- _dtProductionDefectData = value;
- }
- get
- {
- if (_dtProductionDefectData == null)
- {
- _dtProductionDefectData = new DataTable("ProductionDefectData");
- _dtProductionDefectData.Columns.Add("ProductionBarCode");
- _dtProductionDefectData.Columns.Add("discarde");
- _dtProductionDefectData.Columns.Add("DefectFlag", typeof(decimal));
- _dtProductionDefectData.Columns.Add("DefectLocation", typeof(decimal));
- _dtProductionDefectData.Columns.Add("DutyProcedureUserID", typeof(decimal));
- _dtProductionDefectData.Columns.Add("DutyUserCode");
- _dtProductionDefectData.Columns.Add("DefectRemarks");
- return _dtProductionDefectData;
- }
- else
- {
- return _dtProductionDefectData;
- }
- }
- }
- /// <summary>
- /// 缺陷数据集
- /// </summary>
- public DataSet DSTable
- {
- set
- {
- _ds = value;
- }
- get
- {
- if (_ds == null)
- {
- _ds = new DataSet();
- return _ds;
- }
- else
- {
- return _ds;
- }
- }
- }
- /// <summary>
- /// 员工数据集
- /// </summary>
- public DataSet DSTableStaff
- {
- set
- {
- _dsStaff = value;
- }
- get
- {
- if (_dsStaff == null)
- {
- _dsStaff = new DataSet();
- return _dsStaff;
- }
- else
- {
- return _dsStaff;
- }
- }
- }
- /// <summary>
- /// 缺陷图片
- /// </summary>
- public DataSet DSTableImage
- {
- set
- {
- _dsImage = value;
- }
- get
- {
- if (_dsImage == null)
- {
- _dsImage = new DataSet();
- return _dsImage;
- }
- else
- {
- return _dsImage;
- }
- }
- }
- #endregion
- #region 构造函数
- public F_PM_0902()
- {
- InitializeComponent();
- }
- public F_PM_0902(int procedureID, string fromTitle)
- {
- InitializeComponent();
- this._procedureID = procedureID;
- this.Text = fromTitle;
- //this.tsbtnDelete.Text = Constant.BUTTON_TEXT_DELETE;
- //自动适应列宽
- //this.tsbtnAdaptive.Text = Constant.TOOLBAR_BUTTON_TEXT_AUTOCOLUMNWIDTH;
- //关闭
- //this.tsbtnClose.Text = Constant.TOOLBAR_BUTTON_TEXT_CLOSE;
- //this.btnSave.Text = Constant.BUTTON_TEXT_SAVE;
- //this.btnCancel.Text = Constant.BUTTON_TEXT_CANCEL;
- }
- #endregion
- #region 事件
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void F_PM_0901_Load(object sender, System.EventArgs e)
- {
- try
- {
- this.dgvProductionData.AutoGenerateColumns = false;
- this.dgvProductionData.DataSource = TableProductionData;
- this.dgvDefect.AutoGenerateColumns = false;
- this.dgvDefectStaff.AutoGenerateColumns = false;
- // 加载权限
- FormPermissionManager.FormPermissionControl(this.Name, this,
- Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
- Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
- // 获取工序明细数据
- ProcedureEntity procedureDataEntity = (ProcedureEntity)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetProcedureDataEntityByID(this._procedureID);
- }));
- this._procedureDataEntity = procedureDataEntity;
- DataSet dsDefectByProcedure = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetDefectByProcedure(this._procedureID);
- }));
- if (dsDefectByProcedure != null && dsDefectByProcedure.Tables.Count > 0
- && dsDefectByProcedure.Tables[0].Rows.Count > 0)
- {
- this.Column1.DisplayMember = "DEFECTFLAGNAME";
- this.Column1.ValueMember = "DEFECTFLAGID";
- this.Column1.DataSource = dsDefectByProcedure.Tables[0].Copy();
- }
- // 缺陷数据源
- this.DefectFlag.DisplayMember = "DefectFlagName";
- this.DefectFlag.ValueMember = "DefectFlagID";
- this.DefectFlag.DataSource = CreateDataSource.GetDefectFlagTable();
- //DataTable dtReworkProcedure = new DataTable(); // 默认返回工序数据源,为空
- //dtReworkProcedure.Columns.Add("ReworkProcedureID", typeof(decimal));
- //dtReworkProcedure.Columns.Add("ReworkProcedureName");
- //this.ReworkProcedureID.DisplayMember = "ReworkProcedureName";
- //this.ReworkProcedureID.ValueMember = "ReworkProcedureID";
- //this.ReworkProcedureID.DataSource = dtReworkProcedure;
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 工号文本离开焦点后事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></par
- private void txtUserCode_Leave(object sender, EventArgs e)
- {
- try
- {
- if (txtUserCode.Text.Trim() == string.Empty) // 如果未添加数据,则此项获取焦点
- {
- this.txtUserCode.IsMustInput = true;
- this.txtUserCode.Focus();
- return;
- }
- else
- {
- SUserEntity userEntity = new SUserEntity();
- userEntity.UserCode = this.txtUserCode.Text.Trim();
- // 此工号是否能生产工序
- CheckProcedureUserResult MsgCheckProcedureUser = (CheckProcedureUserResult)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.CheckProcedureUser(this._procedureID, this.txtUserCode.Text.Trim());
- }));
- if (MsgCheckProcedureUser != null)
- {
- if (MsgCheckProcedureUser.ErrMsg != null)
- {
- MessageBox.Show(MsgCheckProcedureUser.ErrMsg,
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- this.txtUserCode.Focus();
- return;
- }
- UserID = Convert.ToInt32(MsgCheckProcedureUser.UserID);
- UserCode = MsgCheckProcedureUser.UserCode;
- UserName = MsgCheckProcedureUser.UserName;
- }
- }
- }
- 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 txtBarCode_KeyPress(object sender, KeyPressEventArgs e)
- {
- try
- {
- if ((int)e.KeyChar == 13) // 按了回车键
- {
- if (this.txtBarCode.Text.Trim() == string.Empty)
- {
- this.txtBarCode.Focus();
- return;
- }
- // 校验条码 获取校验条码信
- DataSet dsCheckBarcode = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.CheckBarcode(this._procedureID, this.txtBarCode.Text.Trim());
- }));
- if (dsCheckBarcode != null && dsCheckBarcode.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
- {
- if (dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString() != string.Empty)
- {
- // 表示有错误
- MessageBox.Show(string.Format(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString(), this.txtBarCode.Text.Trim(), "产品条码"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- this.txtBarCode.Focus();
- return;
- }
- else
- {
- BindProductionData(dsCheckBarcode);
- this._currentBarCode = txtBarCode.Text.Trim();
- BindDefectLocation(); // 绑定缺陷位置
- this.txtBarCode.Text = string.Empty;
- FilterTableRow();
- }
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- #endregion
- #region 绑定到第一个DataGriwView数据源
- /// <summary>
- /// 绑定到第一个DataGriwView数据源
- /// </summary>
- private void BindProductionData(DataSet dsCheckBarcode)
- {
- try
- {
- DataRow[] dr = TableProductionData.Select("BarCode='" + this.txtBarCode.Text.Trim() + "'");
- if (dr.Length > 0)
- {
- // 不允许重复添加
- return;
- }
- DataRow drNew = TableProductionData.NewRow();
- drNew["BarCode"] = this.txtBarCode.Text.Trim();
- drNew["GoodsID"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsID.ToString()];
- drNew["GoodsCode"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsCode.ToString()];
- drNew["GoodsName"] = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsName.ToString()];
- drNew["DefectFlagID"] = 0; ;
- // drNew["ReworkProcedureID"] = 0;
- drNew["ReworkProcedureID"] = null;
- drNew["Remarks"] = "";
- drNew["UserID"] = UserID;
- TableProductionData.Rows.Add(drNew);
- if (DSTable.Tables.IndexOf(this.txtBarCode.Text.Trim()) == -1)
- {
- DataTable dtProductionDefectData = new DataTable(this.txtBarCode.Text.Trim());
- dtProductionDefectData.Columns.Add("ProductionBarCode");
- dtProductionDefectData.Columns.Add("discarde");
- dtProductionDefectData.Columns.Add("DefectFlag", typeof(decimal));
- dtProductionDefectData.Columns.Add("DefectLocation", typeof(decimal));
- dtProductionDefectData.Columns.Add("DutyProcedureID", typeof(decimal));
- dtProductionDefectData.Columns.Add("DutyProcedureUserID", typeof(decimal));//责任员工
- dtProductionDefectData.Columns.Add("Jobs", typeof(decimal));//工种
- dtProductionDefectData.Columns.Add("DefectRemarks");
- dtProductionDefectData.Columns.Add("TempCount");
- dtProductionDefectData.Columns.Add("ProductionDataID"); //生产数据ID
- DSTable.Tables.Add(dtProductionDefectData);
- }
- this.dgvDefect.DataSource = DSTable.Tables[this.txtBarCode.Text.Trim()];
- this.dgvProductionData.CurrentCell = null;
- this.dgvProductionData.Rows[dgvProductionData.RowCount - 1].Selected = true;
- this.dgvDefect.ReadOnly = true;
- this.dgvDefectStaff.ReadOnly = true;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- #endregion
- #region 私有方法
- /// <summary>
- /// 通过是否有缺陷来启用或禁用
- /// </summary>
- /// <param name="DefectFlag"></param>
- private void SetGridView(int DefectFlag)
- {
- if (DefectFlag == 0) //没有缺陷
- {
- dgvDefect.ReadOnly = true;
- dgvDefectStaff.ReadOnly = true;
- }
- else
- {
- dgvDefect.ReadOnly = false; ;
- dgvDefectStaff.ReadOnly = false;
- }
- }
- #endregion
- /// <summary>
- /// 生产数据编辑控件显示事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvProductionData_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
- {
- if (e.Control is DataGridViewComboBoxEditingControl
- && this.dgvProductionData.CurrentCell.ColumnIndex == 3
- && this.dgvProductionData.CurrentCell.RowIndex != -1)
- {
- this._dataGridViewComboBox = (DataGridViewComboBoxEditingControl)e.Control;
- //增加委托处理
- _dataGridViewComboBox.SelectionChangeCommitted += new EventHandler(this.dataGridViewComboBox_SelectionChangeCommitted);
- }
- }
- /// <summary>
- /// 生产数据下拉列表改变事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dataGridViewComboBox_SelectionChangeCommitted(object sender, EventArgs e)
- {
- SetGridView(Convert.ToInt32(((ComboBox)sender).SelectedValue.ToString()));
- }
- /// <summary>
- /// 产品数据单元格进入事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvProductionData_CellEnter(object sender, DataGridViewCellEventArgs e)
- {
- try
- {
- if (this.dgvProductionData.CurrentCell != null)
- {
- // 记录最后选择行
- this._selectedRowIndex = this.dgvProductionData.CurrentCell.RowIndex;
- _currentBarCode = this.dgvProductionData.Rows[_selectedRowIndex].Cells["BarCode"].Value.ToString();
- _C_DGV_Cell_ListBoxComboBox = dgvProductionData.Rows[_selectedRowIndex].Cells[4] as C_DGV_Cell_ListBoxComboBox;
- DataSet ds = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetReworkProcedureByBarcode(this._procedureID, this.dgvProductionData.Rows[_selectedRowIndex].Cells["BarCode"].Value.ToString());
- }));
- _currentGoodsID = Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["GoodsID"].Value);
- _currentBarCode = this.dgvProductionData.Rows[_selectedRowIndex].Cells["BarCode"].Value.ToString();
- _C_DGV_Cell_ListBoxComboBox.DisplayMember = "ReworkProcedureName";
- _C_DGV_Cell_ListBoxComboBox.ValueMember = "ReworkProcedureID";
- _C_DGV_Cell_ListBoxComboBox.DataSource = ds.Tables[0];
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 产品数据选定项改变事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvProductionData_SelectionChanged(object sender, EventArgs e)
- {
- try
- {
- if (this.dgvProductionData.CurrentCell != null)
- {
- SetGridView(Convert.ToInt32(this.dgvProductionData.Rows[_selectedRowIndex].Cells["DefectFlag"].Value));
- FilterTableRow();
- BindDefectLocation();
- this.dgvDefectStaff.DataSource = null;
- _smallByte.Clear();//防止重复绑定图片
- this.lvPic.Clear();//
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 保存按钮事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnSave_Click(object sender, EventArgs e)
- {
- DataTable dt = this.TableProductionData;
- DataTable dt2 = this.TableProductionDefectData;
- DataSet ds = DSTable;
- }
- /// <summary>
- /// 绑定缺陷数据源
- /// </summary>
- private void BindDefectDataSource()
- {
- try
- {
- DataSet dsDefectByProcedure = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetDefectByProcedure(this._procedureID);
- }));
- if (dsDefectByProcedure != null && dsDefectByProcedure.Tables.Count > 0
- && dsDefectByProcedure.Tables[0].Rows.Count > 0)
- {
- // 缺陷数据源
- this.Column1.DisplayMember = "DefectFlagName";
- this.Column1.ValueMember = "DefectFlagID";
- this.Column1.DataSource = dsDefectByProcedure.Tables[0];
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- ///
- /// </summary>
- private void FilterTableRow()
- {
- this.dgvDefect.DataSource = DSTable.Tables[_currentBarCode];
- if (this.dgvDefect.DataSource != null)
- {
- if (DSTable.Tables[_currentBarCode].Rows.Count > 0)
- {
- for (int i = 0; i < DSTable.Tables[_currentBarCode].Rows.Count; i++)
- {
- string currentBarCode = DSTable.Tables[_currentBarCode].Rows[i]["ProductionBarCode"].ToString();
- if (DSTable.Tables[_currentBarCode].Rows[i]["DefectFlag"].ToString() != "")
- {
- int defectid = Convert.ToInt32(DSTable.Tables[_currentBarCode].Rows[i]["DefectFlag"].ToString());
- DataGridViewComboBoxCell aa = dgvDefect.Rows[i].Cells[3] as DataGridViewComboBoxCell;
- DataSet dsDutyDefect = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetDutyProcedureByBarCode(currentBarCode, defectid);
- }));
- aa.DisplayMember = "DutyProcedureName";
- aa.ValueMember = "DutyProcedureID";
- aa.DataSource = dsDutyDefect.Tables[0];
- }
- }
- }
- }
- }
- private void dgvDefect_UserAddedRow(object sender, DataGridViewRowEventArgs e)
- {
- this.dgvDefect.Rows[e.Row.Index - 1].Cells["ProductionBarCode"].Value = _currentBarCode;
- this.dgvDefect.Rows[e.Row.Index - 1].Cells["TempCount"].Value = (this._tempCount++);
- // 添加行后,默认创建对应的临时表
- DataTable dtStaff = new DataTable(string.Format("TempTable{0}", this.dgvDefect.Rows[e.Row.Index - 1].Cells["TempCount"].Value.ToString()));
- dtStaff.Columns.Add("IsSelected");
- dtStaff.Columns.Add("StaffID");
- dtStaff.Columns.Add("StaffCode");
- dtStaff.Columns.Add("StaffName");
- dtStaff.Columns.Add("StaffTempCount");
- DSTableStaff.Tables.Add(dtStaff);
- this.dgvDefectStaff.DataSource = null; // 创建新行后,责任员工列表清空
- // 添加行后,默认创建对应的缺陷图片临时表
- DataTable dtImage = new DataTable(string.Format("TempTable{0}", this.dgvDefect.Rows[e.Row.Index - 1].Cells["TempCount"].Value.ToString()));
- dtImage.Columns.Add("StaffTempCount");
- dtImage.Columns.Add("ImageByte", typeof(byte[]));
- DSTableImage.Tables.Add(dtImage);
- this.lvPic.Items.Clear();//当前上传的图片显示清空
- }
- /// <summary>
- /// 单元格CheckBox事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvDefect_CellContentClick(object sender, DataGridViewCellEventArgs e)
- {
- if (e.ColumnIndex == 0 && e.RowIndex != -1)
- {
- int checkValue = Convert.ToInt32(this.dgvDefect.Rows[e.RowIndex].Cells[0].EditedFormattedValue);
- SetCheckBoxSelected(checkValue, e.RowIndex);
- }
- }
- /// <summary>
- /// 清空以前所选中的缺陷
- /// </summary>
- /// <param name="checkValue"></param>
- private void SetCheckBoxSelected(int checkValue, int rowIndex)
- {
- DataTable dtOrgDataSource = this.dgvDefect.DataSource as DataTable;
- for (int i = 0; i < DSTable.Tables[dtOrgDataSource.TableName].Rows.Count; i++)
- {
- if (i == rowIndex)
- {
- dtOrgDataSource.Rows[i]["discarde"] = 1;
- }
- else
- {
- dtOrgDataSource.Rows[i]["discarde"] = 0;
- }
- }
- }
- /// <summary>
- /// 绑定缺陷位置
- /// </summary>
- private void BindDefectLocation()
- {
- int goodsID = 0;
- DataRow[] dr = TableProductionData.Select("BarCode='" + this._currentBarCode + "'");
- if (dr.Length > 0)
- {
- goodsID = Convert.ToInt32(dr[0]["GoodsID"]);
- }
- DataSet dsDefectLocation = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetDefectLocaionByGoodsID(goodsID);
- }));
- this.DefectLocationColumn.DisplayMember = "DEFECTPOSITIONNAME";
- this.DefectLocationColumn.ValueMember = "DEFECTPOSITIONID";
- this.DefectLocationColumn.DataSource = dsDefectLocation.Tables[0];
- }
- /// <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 > 0
- && dsDutyDefect.Tables[0].Rows.Count > 0)
- {
- this.DutyProcedureIDLocation.DisplayMember = "ProcedureName";
- this.DutyProcedureIDLocation.ValueMember = "ProcedureID";
- this.DutyProcedureIDLocation.DataSource = dsDutyDefect.Tables[0];//DutyProcedure
- }
- }
- /// <summary>
- /// 缺陷数据下拉列表改变事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dataGridViewComboBox_DutyDefect_SelectionChangeCommitted(object sender, EventArgs e)
- {
- if (((ComboBox)sender).SelectedValue != null)
- {
- BindDutyDefect(_currentBarCode, Convert.ToInt32(((ComboBox)sender).SelectedValue.ToString()));
- }
- }
- /// <summary>
- /// 缺陷产品单元格进入事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvDefect_CellEnter(object sender, DataGridViewCellEventArgs e)
- {
- try
- {
- if (this.dgvDefect.CurrentCell != null)
- {
- // 记录最后选择行
- //this.dgvDefect.CurrentCell.RowIndex;
- if (this.dgvDefect.CurrentCell.ColumnIndex == 3
- && this.dgvDefect.CurrentCell.RowIndex != -1)
- {
- string currentBarCode = this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["ProductionBarCode"].Value.ToString();
- if (this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["Column1"].Value.ToString() != "")
- {
- int defectid = Convert.ToInt32(this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["Column1"].Value.ToString());
- DataGridViewComboBoxCell aa = dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells[3] as DataGridViewComboBoxCell;
- DataSet dsDutyDefect = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetDutyProcedureByBarCode(currentBarCode, defectid);
- }));
- aa.DisplayMember = "DutyProcedureName";
- aa.ValueMember = "DutyProcedureID";
- aa.DataSource = dsDutyDefect.Tables[0];
- }
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 根据责任工序读出责任员工,并绑定到数据源
- /// </summary>
- /// <param name="barcode"></param>
- /// <param name="dutyProcedureID"></param>
- private void SetDutyCode(string barcode, int dutyProcedureID, int rowIndex)
- {
- DataSet dsDutyCode = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetDutyProcedureCodeByBarCode(barcode, dutyProcedureID);
- }));
- if (dsDutyCode != null && dsDutyCode.Tables.Count > 0
- && dsDutyCode.Tables[0].Rows.Count > 0)
- {
- this.DutyProcedureCodeLocation.DisplayMember = "UserCode";
- this.DutyProcedureCodeLocation.ValueMember = "UserID";
- this.DutyProcedureCodeLocation.DataSource = dsDutyCode.Tables[0];
- this.dgvDefect.CurrentCell = null;
- this.dgvDefect.Rows[rowIndex].Cells["DutyProcedureCodeLocation"].Value = dsDutyCode.Tables[0].Rows[0]["UserID"].ToString();
- this.dgvDefect.Rows[rowIndex].Cells["ProductionDataID"].Value = dsDutyCode.Tables[0].Rows[0]["ProductionDataID"].ToString();
- SetDutyJobs(Convert.ToInt32(dsDutyCode.Tables[0].Rows[0]["UserID"]), dutyProcedureID, rowIndex, Convert.ToInt32(dsDutyCode.Tables[0].Rows[0]["ProductionDataID"]));
- }
- }
- /// <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 > 0
- && dsDutyJobs.Tables[0].Rows.Count > 0)
- {
- this.JobsLocation.DisplayMember = "JobsName";
- this.JobsLocation.ValueMember = "JobsID";
- this.JobsLocation.DataSource = dsDutyJobs.Tables[0];
- this.dgvDefect.CurrentCell = null;
- this.dgvDefect.Rows[rowIndex].Cells["JobsLocation"].Value = dsDutyJobs.Tables[0].Rows[0]["JobsID"].ToString();
- _currentTempSign = this.dgvDefect.Rows[rowIndex].Cells["TempCount"].Value.ToString(); //当前临时标记
- // 通过工种来搜索缺陷责任员工列表
- BindDutyStaff(ProductionDataID, UserID, Convert.ToInt32(dsDutyJobs.Tables[0].Rows[0]["JobsID"]), Convert.ToInt32(this.dgvDefect.Rows[rowIndex].Cells["TempCount"].Value));
- }
- }
- /// <summary>
- /// 缺陷产品当前是否有未提交数据事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvDefect_CurrentCellDirtyStateChanged(object sender, EventArgs e)
- {
- try
- {
- if (this.dgvDefect.CurrentCell != null)
- {
- // 记录最后选择行
- if (this.dgvDefect.CurrentCell.ColumnIndex == 3
- && this.dgvDefect.CurrentCell.RowIndex != -1)
- {
- if (dgvDefect.IsCurrentCellDirty)
- {
- dgvDefect.CommitEdit(DataGridViewDataErrorContexts.Commit);
- }
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 缺陷单元格值改变事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvDefect_CellValueChanged(object sender, DataGridViewCellEventArgs e)
- {
- try
- {
- if (this.dgvDefect.CurrentCell != null)
- {
- if (this.dgvDefect.CurrentCell.ColumnIndex == 3
- && this.dgvDefect.CurrentCell.RowIndex != -1)
- {
- string currentBarCode = this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["ProductionBarCode"].Value.ToString();
- if (this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["DutyProcedureIDLocation"].Value.ToString() != "")
- {
- int dutyProcedureID = Convert.ToInt32(this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["DutyProcedureIDLocation"].Value.ToString());
- SetDutyCode(currentBarCode, dutyProcedureID, this.dgvDefect.CurrentCell.RowIndex);
- }
- }
- else if (this.dgvDefect.CurrentCell.ColumnIndex == 4
- && this.dgvDefect.CurrentCell.RowIndex != -1)
- {
- if (this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["DutyProcedureIDLocation"].Value.ToString() != ""
- && this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["DutyProcedureCodeLocation"].Value.ToString() != "")
- {
- int userID = Convert.ToInt32(this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["DutyProcedureCodeLocation"].Value.ToString());
- int dutyProcedureID = Convert.ToInt32(this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["DutyProcedureIDLocation"].Value.ToString());
- int productionDataID = Convert.ToInt32(this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["ProductionDataID"].Value.ToString());
- SetDutyJobs(userID, dutyProcedureID, this.dgvDefect.CurrentCell.RowIndex, productionDataID);
- }
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <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)
- {
- // 获取临时表是否有数据,如果有行,则删除,
- DataTable dtTemp = DSTableStaff.Tables[string.Format("TempTable{0}", StaffTempCount.ToString())];
- if (dtTemp.Rows.Count > 0)
- {
- // 清空临时表数据
- DSTableStaff.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 > 0
- && dsDutyStaff.Tables[0].Rows.Count > 0)
- {
- foreach (DataRow dr in dsDutyStaff.Tables[0].Rows)
- {
- DataRow addDr = DSTableStaff.Tables[string.Format("TempTable{0}", StaffTempCount.ToString())].NewRow();
- addDr["IsSelected"] = 0;
- addDr["StaffID"] = dr["StaffID"];
- addDr["StaffCode"] = dr["StaffCode"];
- addDr["StaffName"] = dr["StaffName"];
- addDr["StaffTempCount"] = StaffTempCount;
- DSTableStaff.Tables[string.Format("TempTable{0}", StaffTempCount.ToString())].Rows.Add(addDr);
- }
- this.dgvDefectStaff.DataSource = DSTableStaff.Tables[string.Format("TempTable{0}", StaffTempCount.ToString())];
- }
- }
- /// <summary>
- /// 缺陷数据源选定项改变事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvDefect_SelectionChanged(object sender, EventArgs e)
- {
- try
- {
- if (this.dgvDefect.CurrentCell != null)
- {
- if (this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["TempCount"].Value.ToString() != string.Empty)
- {
- int staffTempCount = Convert.ToInt32(this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["TempCount"].Value.ToString());
- this.dgvDefectStaff.DataSource = DSTableStaff.Tables[string.Format("TempTable{0}", staffTempCount.ToString())];
- _currentTempSign = this.dgvDefect.Rows[this.dgvDefect.CurrentCell.RowIndex].Cells["TempCount"].Value.ToString(); //当前临时标记
- _smallByte.Clear();//防止重复绑定图片
- BindByteImage(DSTableImage.Tables[string.Format("TempTable{0}", staffTempCount.ToString())]);
- }
- else
- {
- this.dgvDefectStaff.DataSource = null;
- _smallByte.Clear();//防止重复绑定图片
- this.lvPic.Clear();//
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 绑定并显示图片
- /// </summary>
- /// <param name="ImageData"></param>
- protected void BindByteImage(DataTable ImageData)
- {
- _smallByte.Clear();
- foreach (DataRow dr in ImageData.Rows)
- {
- //将数据库中的缩略图取出
- _smallByte.Add((byte[])dr[1]);
- }
- //绑定缩略图
- BindImg();
- }
- /// <summary>
- /// 上传图片按钮事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnUpload_Click(object sender, EventArgs e)
- {
- try
- {
- this.odlgFile.Filter = Constant.FILTER_PIC;
- this.odlgFile.FilterIndex = Constant.INT_IS_ZERO;
- this.odlgFile.RestoreDirectory = true;
- this.odlgFile.Title = "选择缺陷图片";
- this.odlgFile.FileName = null;
- this.odlgFile.RestoreDirectory = true;
- if (this.odlgFile.ShowDialog() == DialogResult.OK)
- {
- FileInfo file = new FileInfo(odlgFile.FileName);
- if (Constant.UPLOAD_PIC_MAX_SIZE < file.Length)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W013, "缺陷图片", "大小", "1M"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- else
- {
- Image PicImage = Image.FromStream(file.OpenRead());
- this._PicByte.Add(ImageToByte(PicImage));
- GetThumbnail(file);
- BindImg();
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <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)
- {
- Image imgSource = Image.FromStream(sourceFile.OpenRead());
- ImageFormat thisFormat = imgSource.RawFormat;
- int sW = 0, sH = 0;
- // 按比例缩放
- int sWidth = imgSource.Width;
- int sHeight = imgSource.Height;
- int destWidth = 100;
- int destHeight = getSmallImageHeight(sWidth, sHeight, destWidth);
- if (sHeight > destHeight || sWidth > destWidth)
- {
- if ((sWidth * destHeight) > (sHeight * destWidth))
- {
- sW = destWidth;
- sH = (destWidth * sHeight) / sWidth;
- }
- else
- {
- sH = destHeight;
- sW = (sWidth * destHeight) / sHeight;
- }
- }
- else
- {
- sW = sWidth;
- sH = sHeight;
- }
- Bitmap outBmp = new Bitmap(destWidth, destHeight);
- Graphics g = Graphics.FromImage(outBmp);
- g.Clear(Color.Black);
- // 设置画布的描绘质量
- g.CompositingQuality = CompositingQuality.HighQuality;
- g.SmoothingMode = SmoothingMode.HighQuality;
- g.InterpolationMode = InterpolationMode.HighQualityBicubic;
- g.DrawImage(imgSource, new Rectangle((destWidth - sW) / 2, (destHeight - sH) / 2, sW, sH), 0, 0, imgSource.Width, imgSource.Height, GraphicsUnit.Pixel);
- g.Dispose();
- //将重绘的图片转为二进制并保存
- Image image = (Image)outBmp;
- byte[] smallbuffer = ImageToByte(image);
- if (this._currentTempSign != "")
- {
- DataRow dr = DSTableImage.Tables[string.Format("TempTable{0}", this._currentTempSign)].NewRow();
- dr["StaffTempCount"] = this._currentTempSign;
- dr["ImageByte"] = smallbuffer;
- DSTableImage.Tables[string.Format("TempTable{0}", this._currentTempSign)].Rows.Add(dr);
- }
- _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="sender"></param>
- /// <param name="e"></param>
- private void btnDelete_Click(object sender, EventArgs e)
- {
- foreach (ListViewItem lvSelect in lvPic.SelectedItems)
- {
- int index = lvSelect.Index;
- if (index < Constant.INT_IS_ZERO)
- {
- index = Constant.INT_IS_ZERO;
- }
- if (this._currentTempSign != "")
- {
- DSTableImage.Tables[string.Format("TempTable{0}", this._currentTempSign)].Rows.RemoveAt(lvSelect.Index);
- DSTableImage.Tables[string.Format("TempTable{0}", this._currentTempSign)].AcceptChanges();
- }
- BindByteImage(DSTableImage.Tables[string.Format("TempTable{0}", this._currentTempSign)]);
- }
- }
- /// <summary>
- /// 关闭按钮事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- /// <summary>
- /// 产品条码列表删除事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvProductionData_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
- {
- try
- {
- string BarCode = this.dgvProductionData.Rows[e.Row.Index].Cells["BarCode"].Value.ToString();
- DSTable.Tables[BarCode].Rows.Clear();//清空行
- this.dgvDefectStaff.DataSource = null;
- this.lvPic.Clear();
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 产品缺陷删除行事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvDefect_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
- {
- try
- {
- string TempCount = this.dgvDefect.Rows[e.Row.Index].Cells["TempCount"].Value.ToString();
- DSTableStaff.Tables[string.Format("TempTable{0}", TempCount.ToString())].Rows.Clear();//清空行
- this.dgvDefectStaff.DataSource = null;
- this.lvPic.Clear();
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- }
- }
|