/******************************************************************************* * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential * 类的信息: * 1.程序名称:F_PM_0402.cs * 2.功能描述:交坯计件新建 * 编辑履历: * 作者 日期 版本 修改内容 * 王鑫 2014/09/2 1.00 新建 *******************************************************************************/ using System; using System.Collections.Generic; using System.Data; using System.Windows.Forms; using Dongke.IBOSS.PRD.Basics.BaseControls; using Dongke.IBOSS.PRD.Basics.BaseResources; using Dongke.IBOSS.PRD.Client.CommonModule; using Dongke.IBOSS.PRD.Client.Controls.FormCommon; using Dongke.IBOSS.PRD.WCF.DataModels; using Dongke.IBOSS.PRD.WCF.Proxys; using Dongke.IBOSS.PRD.WCF.Proxys.PMModuleService; using Dongke.IBOSS.PRD.WCF.Proxys.SystemModuleService; namespace Dongke.IBOSS.PRD.Client.PMModule { /// /// 交坯计件新建 /// public partial class F_PM_0402 : FormBase { #region 成员变量 // 工序ID private int _procedureID; // 工序实体类 ProcedureEntity _procedureDataEntity; // 生产数据实体类 List _productionDataEntity = new List(); // 数据源Table private DataTable _dataSourceTable = null; // 添加行数据源 private DataTable _collectType = null; // 生产工号 private int _userID = -1; // 生产编号 private string _userCode; // 生产名称 private string _userName; // 是否公坯 private int _ispublicbody = -1; // 是否设置过期未交坯天数 private int _settingvaluedays = 0; #endregion #region 属性 /// /// 绑定GridView数据源 /// public DataTable DataSourceTable { set { _dataSourceTable = value; } get { if (_dataSourceTable == null) { _dataSourceTable = new DataTable(); _dataSourceTable.Columns.Add("BarCode"); _dataSourceTable.Columns.Add("GoodsCode"); _dataSourceTable.Columns.Add("GoodsName"); _dataSourceTable.Columns.Add("ProductionLineCode"); _dataSourceTable.Columns.Add("ProcedureModel"); _dataSourceTable.Columns.Add("ModelType"); _dataSourceTable.Columns.Add("PieceType"); _dataSourceTable.Columns.Add("IsReworked"); _dataSourceTable.Columns.Add("IsPublicBody"); _dataSourceTable.Columns.Add("OrganizationName"); _dataSourceTable.Columns.Add("Remarks"); _dataSourceTable.Columns.Add("UserCode"); _dataSourceTable.Columns.Add("UserID"); _dataSourceTable.Columns.Add("BarCodeUserCode"); _dataSourceTable.Columns.Add("MouldCode"); _dataSourceTable.Columns.Add("GroutingUserCode"); _dataSourceTable.Columns.Add("GroutingNum"); _dataSourceTable.Columns.Add("GroutingDate", typeof(DateTime)); _dataSourceTable.Columns.Add("LogoID"); _dataSourceTable.Columns.Add("LogoCodeName"); return _dataSourceTable; } else { return _dataSourceTable; } } } /// /// 提交数据源 /// public DataTable DataSourceCollectTypeTable { set { _collectType = value; } get { if (_collectType == null) { _collectType = new DataTable(); _collectType.TableName = "collectType"; _collectType.Columns.Add("BarCode"); _collectType.Columns.Add("IsPublicBody"); _collectType.Columns.Add("UserID"); _collectType.Columns.Add("UserCode"); _collectType.Columns.Add("UserName"); _collectType.Columns.Add("GroutingUserCode"); _collectType.Columns.Add("LogoID"); return _collectType; } else { return _collectType; } } } /// /// 生产工号 /// public int UserID { set { _userID = value; } get { return _userID; } } /// /// 生产工号 /// public int Ispublicbody { set { _ispublicbody = value; } get { return _ispublicbody; } } /// /// 生产编号 /// public string UserCode { set { _userCode = value; } get { return _userCode; } } /// /// 用户名称 /// public string UserName { set { _userName = value; } get { return _userName; } } #endregion #region 构造函数 public F_PM_0402() { InitializeComponent(); } public F_PM_0402(int procedureID, string fromTitle) { InitializeComponent(); this._procedureID = procedureID; this.Text = fromTitle; this.tsbtnDelete.Text = ButtonText.TSBTN_DELETE; //自动适应列宽 this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE; //关闭 this.tsbtnClose.Text = ButtonText.BTN_CLOSE; this.btnSave.Text = ButtonText.BTN_SAVE; this.btnCancel.Text = ButtonText.BTN_CLOSE; } #endregion #region 事件 /// /// 窗体关闭事件 /// /// /// private void btnCancel_Click(object sender, EventArgs e) { this.Close(); } /// /// 窗体关闭事件 /// /// /// private void tsbtnClose_Click(object sender, EventArgs e) { this.Close(); } /// /// 条形码按键事件 /// /// /// private void txtBarcode_KeyPress(object sender, KeyPressEventArgs e) { try { if (this.txtBarcode.ReadOnly) { return; } if ((int)e.KeyChar == 13) // 按了回车键 { if (this._procedureDataEntity.DeliverType == 0) { if (this.txtUserCode.Text.Trim() == string.Empty) { this.txtUserCode.Focus(); this.txtBarcode.Text = string.Empty; return; } //if (this.txtUserCode.Text.Trim() == string.Empty) //{ // this.txtUserCode.Focus(); // this.txtBarcode.Text = string.Empty; // return; //} } if (this.txtBarcode.Text.Trim() == string.Empty) { this.txtBarcode.Focus(); this.txtBarcode.Focus(); return; } DataRow[] drRows = this.DataSourceTable.Select("BarCode='" + this.txtBarcode.Text.Trim() + "'"); if (drRows.Length == 0) { // 校验条码 获取校验条码信 //DataSet dsCheckBarcode = (DataSet)DoAsync(new BaseAsyncMethod(() => //{ // return PMModuleProxy.Service.CheckBarcode(this._procedureID, this.txtBarcode.Text.Trim()); //})); if (this._procedureDataEntity.CollectType == (int)Constant.ProcedureCollectType.Togather) { // modify wangx 2015/7/14 DataSet dsCheckBarcode = (DataSet)DoAsync(new BaseAsyncMethod(() => { return PMModuleProxy.Service.CheckBarcodeDeliverMud(this._procedureID, this.txtBarcode.Text.Trim()); })); // modify wangx 2015/7/14 end 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) { if (dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_missFlag.ToString()].ToString() == "0") { // 表示有错误 MessageBox.Show(string.Format(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString(), this.txtBarcode.Text.Trim(), "产品条码"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { S_CMN_020 frmscmn020 = new S_CMN_020(Convert.ToInt32(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_missFlag.ToString()]) , dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString()); frmscmn020.ShowDialog(); } this.txtBarcode.Focus(); this.txtBarcode.SelectAll(); return; } else { int PublicNormal = (int)Constant.PublicBodyFlag.No; if (Ispublicbody == 1) { PublicNormal = (int)Constant.PublicBodyFlag.Yes; } if (UserID != -Constant.INT_IS_ONE) { if (this._procedureDataEntity.DeliverType == 0) { if (Ispublicbody != 1) { if (dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()].ToString() != UserCode) { // 提示用户确认公坯 //DialogResult msgBoxResult = MessageBox.Show(Messages.MSG_PM_Q001, this.Text, // MessageBoxButtons.OKCancel, MessageBoxIcon.Question,MessageBoxDefaultButton.Button2); //if (msgBoxResult == DialogResult.OK) //{ // PublicNormal = (int)Constant.PublicBodyFlag.Yes; //} //else //{ // this.txtBarcode.Text = ""; // return; //} // 提示信息 MessageBox.Show("成型工号与交坯工号不一致,不允许交坯", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); this.txtBarcode.Text = ""; return; } } } } #region wangx 2016-10-10 校验是否可以交过期未交的坯 if (Convert.ToInt32(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_deliverLimitCycle.ToString()]) > 0) //if (_settingvaluedays > 0) { ServiceResultEntity resultEntity = (ServiceResultEntity)DoAsync(new BaseAsyncMethod(() => { return PMModuleProxy.Service.BarcodeAllowCancel( Convert.ToDateTime(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingdate.ToString()]), Convert.ToInt32(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_deliverLimitCycle.ToString()]), Constant.SettingType.S_PM_002.ToString()); })); if (Convert.ToInt32(resultEntity.Result) < 0) { MessageBox.Show(resultEntity.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); this.txtBarcode.Text = ""; return; } } #endregion wangx 2016-10-10 end // 生产数据实体 ProductionDataEntity procedureDataEntity = new ProductionDataEntity(); procedureDataEntity.Barcode = txtBarcode.Text.Trim(); // 产品条码 procedureDataEntity.CentralizedBatchNo = System.Guid.NewGuid().ToString();// 集中采集批次号 procedureDataEntity.ProductionLineID = this._procedureDataEntity.ProductionLineID;// 生产线ID procedureDataEntity.ProductionLineCode = this._procedureDataEntity.ProductionlineCode;// 生产编码 procedureDataEntity.ProductionLineName = this._procedureDataEntity.ProductionlineName;// 生产名称 procedureDataEntity.CompleteProcedureID = this._procedureID;// 工序ID procedureDataEntity.ProcedureCode = this._procedureDataEntity.ProcedureCode;// 工序编码 procedureDataEntity.ProcedureName = this._procedureDataEntity.ProcedureName;// 工序名称 procedureDataEntity.ProcedureModel = Convert.ToInt32(this._procedureDataEntity.ProcedureModel);// 工序模型 procedureDataEntity.ModelType = this._procedureDataEntity.ModelType;// 工序模型类别 procedureDataEntity.PieceType = Convert.ToInt32(this._procedureDataEntity.PieceType);// 计件模式 procedureDataEntity.IsReworked = Convert.ToInt32(this._procedureDataEntity.IsSpecialRework); // 是否是返工 procedureDataEntity.NodeType = Convert.ToInt32(this._procedureDataEntity.NodeType); // 工序结点类型 procedureDataEntity.IsPublicBody = PublicNormal; procedureDataEntity.OrganizationID = this._procedureDataEntity.OrganizationID; // 组织机构 procedureDataEntity.GoodsID = Convert.ToInt32(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsID.ToString()]); procedureDataEntity.GoodsCode = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsCode.ToString()].ToString(); procedureDataEntity.GoodsName = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsName.ToString()].ToString(); if (this._procedureDataEntity.DeliverType == 0) { procedureDataEntity.UserID = UserID; procedureDataEntity.UserCode = UserCode; procedureDataEntity.UserName = UserName; } else { procedureDataEntity.UserID = Convert.ToInt32(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserID.ToString()]); ; procedureDataEntity.UserCode = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()].ToString(); ; procedureDataEntity.UserName = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserName.ToString()].ToString(); ; UserID = procedureDataEntity.UserID; UserCode = procedureDataEntity.UserCode; UserName = procedureDataEntity.UserName; } procedureDataEntity.ValueFlag = 1; procedureDataEntity.Remarks = this._procedureDataEntity.Remarks; if (this._procedureDataEntity.CollectType == (int)Constant.ProcedureCollectType.SinglePoint) // 单点采集 直接保存 { this.CollectTypeTwo(procedureDataEntity, Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserCode, dsCheckBarcode); // 单点采集 } else { this.CollectTypeOne(procedureDataEntity, Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserCode, dsCheckBarcode); // 集中采集 SetGridViewCellEnable(); } this.txtBarcode.Text = string.Empty; this.txtBarcode.Focus(); } } } else { int PublicNormal = (int)Constant.PublicBodyFlag.No; if (Ispublicbody == 1) { PublicNormal = (int)Constant.PublicBodyFlag.Yes; } //if (UserID != -Constant.INT_IS_ONE) //{ // if (returnString.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()].ToString() != UserCode) // { // // 提示信息 // MessageBox.Show("成型工号与交坯工号不一致,不允许交坯", // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); // this.txtBarcode.Text = ""; // return; // } //} // 生产数据实体 ProductionDataEntity procedureDataEntity = new ProductionDataEntity(); procedureDataEntity.Barcode = txtBarcode.Text.Trim(); // 产品条码 procedureDataEntity.CentralizedBatchNo = System.Guid.NewGuid().ToString();// 集中采集批次号 procedureDataEntity.ProductionLineID = this._procedureDataEntity.ProductionLineID;// 生产线ID procedureDataEntity.ProductionLineCode = this._procedureDataEntity.ProductionlineCode;// 生产编码 procedureDataEntity.ProductionLineName = this._procedureDataEntity.ProductionlineName;// 生产名称 procedureDataEntity.CompleteProcedureID = this._procedureID;// 工序ID procedureDataEntity.ProcedureCode = this._procedureDataEntity.ProcedureCode;// 工序编码 procedureDataEntity.ProcedureName = this._procedureDataEntity.ProcedureName;// 工序名称 procedureDataEntity.ProcedureModel = Convert.ToInt32(this._procedureDataEntity.ProcedureModel);// 工序模型 procedureDataEntity.ModelType = this._procedureDataEntity.ModelType;// 工序模型类别 procedureDataEntity.PieceType = Convert.ToInt32(this._procedureDataEntity.PieceType);// 计件模式 procedureDataEntity.IsReworked = Convert.ToInt32(this._procedureDataEntity.IsSpecialRework); // 是否是返工 procedureDataEntity.NodeType = Convert.ToInt32(this._procedureDataEntity.NodeType); // 工序结点类型 procedureDataEntity.IsPublicBody = PublicNormal; procedureDataEntity.OrganizationID = this._procedureDataEntity.OrganizationID; // 组织机构 //procedureDataEntity.GoodsID = Convert.ToInt32(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsID.ToString()]); //procedureDataEntity.GoodsCode = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsCode.ToString()].ToString(); //procedureDataEntity.GoodsName = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_goodsName.ToString()].ToString(); procedureDataEntity.UserID = UserID; procedureDataEntity.UserCode = UserCode; procedureDataEntity.UserName = UserName; procedureDataEntity.ValueFlag = 1; procedureDataEntity.Remarks = this._procedureDataEntity.Remarks; #region 单点采集 // 添加行就可以 并保存 // 保存到数据库 DataSourceCollectTypeTable.Rows.Clear(); DataRow drCollectType = DataSourceCollectTypeTable.NewRow(); drCollectType["BarCode"] = procedureDataEntity.Barcode; drCollectType["IsPublicBody"] = PublicNormal; drCollectType["UserID"] = UserID; drCollectType["UserCode"] = UserCode; drCollectType["UserName"] = UserName; DataSourceCollectTypeTable.Rows.Add(drCollectType); DataTable returnString = (DataTable)DoAsync(new BaseAsyncMethod(() => { return PMModuleProxy.Service.AddWorkPiece(this._procedureID, DataSourceCollectTypeTable); } )); if (returnString.Rows.Count <= Constant.INT_IS_ZERO) { // 提示信息 MessageBox.Show(Messages.MSG_PM_W012, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { if (string.IsNullOrEmpty(returnString.Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString()))//成功 { this.txtBarcode.Text = ""; // 单点采集成功后不需要提示 // 提示信息 //MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "新增" + this.Text, "保存"), // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { if (returnString.Rows[0][Constant.BarCodeResultTableColumns.out_missFlag.ToString()].ToString() == "0") { // 表示有错误 MessageBox.Show(string.Format(returnString.Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString(), this.txtBarcode.Text.Trim(), "产品条码"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { S_CMN_020 frmscmn020 = new S_CMN_020(Convert.ToInt32(returnString.Rows[0][Constant.BarCodeResultTableColumns.out_missFlag.ToString()]) , returnString.Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString()); frmscmn020.ShowDialog(); } this.txtBarcode.Focus(); this.txtBarcode.SelectAll(); return; //// 提示信息 //MessageBox.Show(string.Format(returnString.Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString()), // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); //return; } } DataRow dr = this.DataSourceTable.NewRow(); dr["BarCode"] = procedureDataEntity.Barcode; dr["GoodsCode"] = returnString.Rows[0][Constant.BarCodeResultTableColumns.out_goodsCode.ToString()]; //procedureDataEntity.GoodsCode; dr["GoodsName"] = returnString.Rows[0][Constant.BarCodeResultTableColumns.out_goodsName.ToString()];// procedureDataEntity.GoodsName; dr["ProductionLineCode"] = procedureDataEntity.ProductionLineCode; dr["ProcedureModel"] = procedureDataEntity.ProcedureModel == (int)Constant.ProcedureModel.Piece ? "计数模型" : "检验模型"; dr["ModelType"] = procedureDataEntity.ModelType; dr["PieceType"] = procedureDataEntity.PieceType == (int)Constant.ProcedurePieceType.NoPiece ? "不计件" : "同工种策略"; dr["IsReworked"] = procedureDataEntity.IsReworked == (int)Constant.SpecialReworkFlag.Yes ? "是" : "否"; //dr["IsPublicBody"] = procedureDataEntity.IsPublicBody; dr["OrganizationName"] = string.Empty; dr["Remarks"] = procedureDataEntity.Remarks; if (this._procedureDataEntity.DeliverType == 1 && this._procedureDataEntity.CollectType == 2) { dr["UserCode"] = returnString.Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()]; } else { dr["UserCode"] = this.txtUserCode.Text.Trim(); } dr["BarCodeUserCode"] = returnString.Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()]; //Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserCode; dr["MouldCode"] = returnString.Rows[0][Constant.BarCodeResultTableColumns.out_mouldCode.ToString()]; dr["GroutingUserCode"] = returnString.Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()]; dr["GroutingNum"] = returnString.Rows[0][Constant.BarCodeResultTableColumns.out_groutingNum.ToString()]; dr["IsPublicBody"] = returnString.Rows[0][Constant.BarCodeResultTableColumns.out_ispublicbody.ToString()].ToString() != "1" ? 0 : 1; dr["GroutingDate"] = Convert.ToDateTime(returnString.Rows[0][Constant.BarCodeResultTableColumns.out_groutingdate.ToString()]); dr["LogoCodeName"] = returnString.Rows[0][Constant.BarCodeResultTableColumns.out_logoName.ToString()] + "[" + returnString.Rows[0][Constant.BarCodeResultTableColumns.out_logoCode.ToString()] + "]"; this.DataSourceTable.Rows.Add(dr); this.dgvProduction.CurrentCell = null; this.dgvProduction.Rows[dgvProduction.RowCount - 1].Selected = true; this.dgvProduction.CurrentCell = this.dgvProduction.Rows[dgvProduction.RowCount - 1].Cells[0]; #endregion #region 打印条码 if (this._procedureDataEntity.BarCodePrintCopies > 0) { bool result = Dongke.IBOSS.PRD.Client.Controls.F_MST_012006.PrintBarcode( procedureDataEntity.Barcode, this._procedureDataEntity.BarCodePrintCopies, this); } #endregion } } else { this.txtBarcode.Text = ""; } } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 窗体加载事件 /// /// /// private void F_PM_0402_Load(object sender, EventArgs e) { try { // 加载权限 FormPermissionManager.FormPermissionControl(this.Name, this, Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData); this.dgvProduction.AutoGenerateColumns = false; this.dgvProduction.DataSource = DataSourceTable; // 获取工序明细数据 ProcedureEntity procedureDataEntity = (ProcedureEntity)DoAsync(new BaseAsyncMethod(() => { return PMModuleProxy.Service.GetProcedureDataEntityByID(this._procedureID); })); this._procedureDataEntity = procedureDataEntity; if (this._procedureDataEntity.DeliverType == 0) { // 设置控件禁用或启用 SetControlEnable(); this.txtUserCode.Focus(); } else { this.txtCollectType.Text = this._procedureDataEntity.CollectType == (int)Constant.ProcedureCollectType.SinglePoint ? "单点采集" : "集中采集"; this.txtBarcode.Focus(); if (this._procedureDataEntity.CollectType == 1) { this.btnSave.Visible = true; } } //// 只有采集的时候读取,因为单点采集的时候读取需要在后台做 //if (this._procedureDataEntity.CollectType == (int)Constant.ProcedureCollectType.Togather) //{ // // 2016-10-10 是否启用过期未交坯限制 wangx // DataSet dsSetting = (DataSet)DoAsync(new BaseAsyncMethod(() => // { // return SystemModuleProxy.Service.GetSystemSettingDataByCode(Constant.SettingType.S_PM_002.ToString()); // })); // if (dsSetting != null && dsSetting.Tables[0].Rows.Count > 0) // { // _settingvaluedays = Convert.ToInt32(dsSetting.Tables[0].Rows[0]["SettingValue"]); // } // // end //} } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 删除按钮事件 /// /// /// private void tsbtnDelete_Click(object sender, EventArgs e) { if (this.dgvProduction.CurrentCell != null) { this.DataSourceTable.Rows[this.dgvProduction.CurrentCell.RowIndex].Delete(); } } /// /// 保存按钮事件 /// /// /// private void btnSave_Click(object sender, EventArgs e) { try { this.DataSourceTable.AcceptChanges(); this.DataSourceCollectTypeTable.Clear(); if (this.DataSourceTable.Rows.Count > Constant.INT_IS_ZERO) { foreach (DataRow drproductionData in this.DataSourceTable.Rows) { if (DataSourceCollectTypeTable.Select("BarCode='" + drproductionData["BarCode"].ToString() + "'").Length == 0) { DataRow drCollectType = DataSourceCollectTypeTable.NewRow(); drCollectType["BarCode"] = drproductionData["BarCode"]; drCollectType["IsPublicBody"] = drproductionData["IsPublicBody"]; drCollectType["UserID"] = UserID; drCollectType["UserCode"] = UserCode; drCollectType["UserName"] = UserName; drCollectType["GroutingUserCode"] = drproductionData["GroutingUserCode"]; drCollectType["LogoID"] = ""; DataSourceCollectTypeTable.Rows.Add(drCollectType); } } DataTable returnRow = (DataTable)DoAsync(new BaseAsyncMethod(() => { return PMModuleProxy.Service.AddWorkPiece(this._procedureID, DataSourceCollectTypeTable); })); // 提示信息 if (returnRow.Rows.Count <= Constant.INT_IS_ZERO) { // 提示信息 MessageBox.Show(Messages.MSG_PM_W012, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { if (string.IsNullOrEmpty(returnRow.Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString()))//成功 { // 提示信息 MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "新增" + this.Text, "保存"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { // 提示信息 MessageBox.Show(string.Format(returnRow.Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString()), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } this.txtBarcode.Text = ""; this._productionDataEntity.Clear(); this.DataSourceTable.Rows.Clear(); if (this._procedureDataEntity.CollectType == (int)Constant.ProcedureCollectType.Togather) { this.txtUserCode.Text = ""; this.txtUserCode.Focus(); this.txtUserCode.ReadOnly = false; } else { this.txtBarcode.Focus(); } #region 打印条码 if (this._procedureDataEntity.BarCodePrintCopies > 0) { foreach (DataRow item in DataSourceCollectTypeTable.Rows) { bool result = Dongke.IBOSS.PRD.Client.Controls.F_MST_012006.PrintBarcode( item["Barcode"].ToString(), this._procedureDataEntity.BarCodePrintCopies, this); } } #endregion } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 控件数据校验时发生 /// /// /// private void txtUserCode_Validating(object sender, System.ComponentModel.CancelEventArgs e) { try { if (txtUserCode.Text.Trim() == string.Empty) // 如果未添加数据,则此项获取焦点 { this.txtUserCode.IsMustInput = true; this.txtUserCode.SelectAll(); e.Cancel = true; return; } else if (!this.txtUserCode.ReadOnly) { SUserEntity userEntity = new SUserEntity(); userEntity.UserCode = this.txtUserCode.Text.Trim(); // 此工号是否能生产工序 CheckProcedureUserResult MsgCheckProcedureUser = (CheckProcedureUserResult)DoAsync(new BaseAsyncMethod(() => { return PMModuleProxy.Service.CheckProcedureUser(this._procedureID, this.txtUserCode.Text.Trim()); })); if (MsgCheckProcedureUser != null) { if (MsgCheckProcedureUser.ErrMsg != null) { MessageBox.Show(MsgCheckProcedureUser.ErrMsg, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); this.txtUserCode.SelectAll(); e.Cancel = true; return; } if (UserID != -Constant.INT_IS_ONE) { if (MsgCheckProcedureUser.UserID != UserID) { btnSave_Click(sender, e); } } UserID = Convert.ToInt32(MsgCheckProcedureUser.UserID); UserCode = MsgCheckProcedureUser.UserCode; UserName = MsgCheckProcedureUser.UserName; Ispublicbody = MsgCheckProcedureUser.Ispublicbody; this.txtUserCode.ReadOnly = true; } } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 自动适应列宽 /// /// /// private void tsbtnAdaptive_Click(object sender, EventArgs e) { this.dgvProduction.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); } /// /// 窗体关闭时事件 /// /// /// private void F_PM_0402_FormClosing(object sender, FormClosingEventArgs e) { if (this.btnSave.Visible) { try { this.DataSourceTable.AcceptChanges(); this.DataSourceCollectTypeTable.Clear(); if (this.DataSourceTable.Rows.Count > Constant.INT_IS_ZERO) { DialogResult result = MessageBox.Show(Messages.MSG_CMN_Q001, this.Text, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == DialogResult.Yes) { // 保存数据 btnSave_Click(sender, e); } else if (result == DialogResult.Cancel) { e.Cancel = true; } } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } } /// /// 鼠标单击事件 /// /// /// private void txtUserCode_MouseClick(object sender, MouseEventArgs e) { if (this.txtUserCode.Text.Trim() != string.Empty) { this.txtUserCode.SelectAll(); } } /// /// 生产工号回车事件 /// /// /// private void txtUserCode_KeyPress(object sender, KeyPressEventArgs e) { if ((int)e.KeyChar == 13) // 按了回车键 { this.txtBarcode.Focus(); } } #endregion #region 私有方法 /// /// 设置控件禁用或启用 /// private void SetControlEnable() { if (this._procedureDataEntity != null) { this.txtCollectType.Text = this._procedureDataEntity.CollectType == (int)Constant.ProcedureCollectType.SinglePoint ? "单点采集" : "集中采集"; if (this._procedureDataEntity.CollectType == (int)Constant.ProcedureCollectType.Togather) { this.txtUserCode.Enabled = true; this.tsbtnDelete.Visible = true; this.tsbtnDelete.Enabled = true; this.btnSave.Visible = true; } else { this.dgvProduction.ReadOnly = true; // 此工号是否能生产工序 CheckProcedureUserResult checkProcedureUser = (CheckProcedureUserResult)DoAsync(new BaseAsyncMethod(() => { return PMModuleProxy.Service.CheckProcedureUser(this._procedureID, Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserCode); })); if (checkProcedureUser != null) { if (!string.IsNullOrEmpty(checkProcedureUser.ErrMsg)) { // 此工号不允许生产工序 MessageBox.Show(checkProcedureUser.ErrMsg, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); this.Close(); return; } } UserID = checkProcedureUser.UserID; UserCode = checkProcedureUser.UserCode; UserName = checkProcedureUser.UserName; Ispublicbody = checkProcedureUser.Ispublicbody; } this.txtUserCode.Text = UserCode; } } /// /// 单点采集模式 /// /// private void CollectTypeTwo(ProductionDataEntity procedureDataEntity, string barCodeUserCode, DataSet dsGroutingProduct) { try { #region 单点采集 // 添加行就可以 并保存 // 保存到数据库 DataSourceCollectTypeTable.Rows.Clear(); DataRow drCollectType = DataSourceCollectTypeTable.NewRow(); drCollectType["BarCode"] = procedureDataEntity.Barcode; drCollectType["IsPublicBody"] = procedureDataEntity.IsPublicBody; drCollectType["UserID"] = UserID; drCollectType["UserCode"] = UserCode; drCollectType["UserName"] = UserName; drCollectType["GroutingUserCode"] = procedureDataEntity.GroutingUserCode; DataSourceCollectTypeTable.Rows.Add(drCollectType); DataTable returnString = (DataTable)DoAsync(new BaseAsyncMethod(() => { return PMModuleProxy.Service.AddWorkPiece(this._procedureID, DataSourceCollectTypeTable); } )); //// 由产品条码获取注浆信息 //DataSet dsGroutingProduct = (DataSet)DoAsync(new BaseAsyncMethod(() => //{ // return PMModuleProxy.Service.GetGroutingProducttByBarCode(procedureDataEntity.Barcode); //})); DataRow dr = this.DataSourceTable.NewRow(); dr["BarCode"] = procedureDataEntity.Barcode; dr["GoodsCode"] = procedureDataEntity.GoodsCode; dr["GoodsName"] = procedureDataEntity.GoodsName; dr["ProductionLineCode"] = procedureDataEntity.ProductionLineCode; dr["ProcedureModel"] = procedureDataEntity.ProcedureModel == (int)Constant.ProcedureModel.Piece ? "计数模型" : "检验模型"; dr["ModelType"] = procedureDataEntity.ModelType; dr["PieceType"] = procedureDataEntity.PieceType == (int)Constant.ProcedurePieceType.NoPiece ? "不计件" : "同工种策略"; dr["IsReworked"] = procedureDataEntity.IsReworked == (int)Constant.SpecialReworkFlag.Yes ? "是" : "否"; dr["IsPublicBody"] = procedureDataEntity.IsPublicBody; dr["OrganizationName"] = string.Empty; dr["Remarks"] = procedureDataEntity.Remarks; dr["UserCode"] = this.txtUserCode.Text.Trim(); dr["BarCodeUserCode"] = dsGroutingProduct.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()];// barCodeUserCode; dr["MouldCode"] = dsGroutingProduct.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_mouldCode.ToString()]; dr["GroutingUserCode"] = dsGroutingProduct.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()]; dr["GroutingNum"] = dsGroutingProduct.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingNum.ToString()]; dr["GroutingDate"] = Convert.ToDateTime(dsGroutingProduct.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingdate.ToString()]); this.DataSourceTable.Rows.Add(dr); this.dgvProduction.CurrentCell = null; this.dgvProduction.Rows[dgvProduction.RowCount - 1].Selected = true; this.dgvProduction.CurrentCell = this.dgvProduction.Rows[dgvProduction.RowCount - 1].Cells[0]; #endregion } catch (Exception ex) { throw ex; } } /// ///集中采集模式 /// /// private void CollectTypeOne(ProductionDataEntity procedureDataEntity, string barCodeUserCode, DataSet dsGroutingProduct) { try { #region 集中采集 DataRow[] drRows = this.DataSourceTable.Select("BarCode='" + procedureDataEntity.Barcode + "'"); if (drRows.Length > Constant.INT_IS_ZERO) { this.txtBarcode.Text = ""; return; } // 由产品条码获取注浆信息 //DataSet dsGroutingProduct = (DataSet)DoAsync(new BaseAsyncMethod(() => //{ // return PMModuleProxy.Service.GetGroutingProducttByBarCode(procedureDataEntity.Barcode); //})); DataRow dr = this.DataSourceTable.NewRow(); dr["BarCode"] = procedureDataEntity.Barcode; dr["GoodsCode"] = procedureDataEntity.GoodsCode; dr["GoodsName"] = procedureDataEntity.GoodsName; dr["ProductionLineCode"] = procedureDataEntity.ProductionLineCode; dr["ProcedureModel"] = procedureDataEntity.ProcedureModel == (int)Constant.ProcedureModel.Piece ? "计数模型" : "检验模型"; dr["ModelType"] = procedureDataEntity.ModelType; dr["PieceType"] = procedureDataEntity.PieceType == (int)Constant.ProcedurePieceType.NoPiece ? "不计件" : "同工种策略"; dr["IsReworked"] = procedureDataEntity.IsReworked == (int)Constant.SpecialReworkFlag.Yes ? "是" : "否"; dr["IsPublicBody"] = procedureDataEntity.IsPublicBody; dr["OrganizationName"] = string.Empty; dr["Remarks"] = procedureDataEntity.Remarks; dr["UserCode"] = procedureDataEntity.UserCode; dr["UserID"] = procedureDataEntity.UserID; dr["BarCodeUserCode"] = dsGroutingProduct.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()];//; dr["MouldCode"] = dsGroutingProduct.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_mouldCode.ToString()]; dr["GroutingUserCode"] = dsGroutingProduct.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()]; dr["GroutingNum"] = dsGroutingProduct.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingNum.ToString()]; dr["GroutingDate"] = Convert.ToDateTime(dsGroutingProduct.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingdate.ToString()]); dr["LogoID"] = dsGroutingProduct.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoID.ToString()]; dr["LogoCodeName"] = dsGroutingProduct.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoName.ToString()] + "[" + dsGroutingProduct.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoCode.ToString()] + "]"; this.DataSourceTable.Rows.Add(dr); this.dgvProduction.CurrentCell = null; this.dgvProduction.Rows[dgvProduction.RowCount - 1].Selected = true; this.dgvProduction.CurrentCell = this.dgvProduction.Rows[dgvProduction.RowCount - 1].Cells[0]; #endregion } catch (Exception ex) { throw ex; } } /// /// 设置GridViewCell的公坯是否可以更改 /// private void SetGridViewCellEnable() { foreach (DataGridViewRow vr in this.dgvProduction.Rows) { if (vr.Cells["OrgUserCode"].Value.ToString() != vr.Cells["BarCodeUserCode"].Value.ToString()) { vr.Cells["BarCode"].ReadOnly = true; vr.Cells["GoodsCode"].ReadOnly = true; vr.Cells["GoodsName"].ReadOnly = true; vr.Cells["ProductionLineCode"].ReadOnly = true; vr.Cells["ProcedureModel"].ReadOnly = true; vr.Cells["ModelType"].ReadOnly = true; vr.Cells["PieceType"].ReadOnly = true; vr.Cells["OrganizationName"].ReadOnly = true; vr.Cells["Remarks"].ReadOnly = true; vr.Cells["OrgUserCode"].ReadOnly = true; vr.Cells["IsPublicBody"].ReadOnly = false; } else { vr.Cells["BarCode"].ReadOnly = true; vr.Cells["GoodsCode"].ReadOnly = true; vr.Cells["GoodsName"].ReadOnly = true; vr.Cells["ProductionLineCode"].ReadOnly = true; vr.Cells["ProcedureModel"].ReadOnly = true; vr.Cells["ModelType"].ReadOnly = true; vr.Cells["PieceType"].ReadOnly = true; vr.Cells["OrganizationName"].ReadOnly = true; vr.Cells["Remarks"].ReadOnly = true; vr.Cells["OrgUserCode"].ReadOnly = true; vr.Cells["IsPublicBody"].ReadOnly = true; } } } #endregion } }