/******************************************************************************* * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential * 类的信息: * 1.程序名称:F_PM_1101.cs * 2.功能描述:废弃产品信息一览 * 编辑履历: * 作者 日期 版本 修改内容 * 庄天威 2014/09/25 1.00 新建 *******************************************************************************/ using System; using System.Data; using System.Windows.Forms; using Dongke.IBOSS.PRD.Basics.BaseResources; using Dongke.IBOSS.PRD.Basics.DockPanel; 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; namespace Dongke.IBOSS.PRD.Client.PMModule { /// /// 废弃产品信息一览 /// public partial class F_PM_1101 : DockPanelBase { #region 成员变量 //单例模式 private static F_PM_1101 _instance; //产品分级类别ID private int _goodsLevelTypeID = Convert.ToInt32(Constant.GoodsLevelType.Damage); //页面审核状态值 private int? _AuditStatus; #endregion #region 构造函数 /// /// 废弃一览构造 /// public F_PM_1101() { InitializeComponent(); this.Text = FormTitles.F_PM_1101; //this.cbSelectTime.Checked = false; this.cbSelectTime.Checked = true; this.txtScrapDateStart.Enabled = true; this.txtScrapDateEnd.Enabled = true; this.tsbtnAdd.Text = ButtonText.TSBTN_ADD; this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT; this.tsbtnApprover.Text = ButtonText.TSBTN_AUDIT; this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE; this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE; } #endregion #region 单例模式 /// /// 单例模式,防止重复创建窗体 /// public static F_PM_1101 Instance { get { if (_instance == null) { _instance = new F_PM_1101(); } return _instance; } } #endregion #region 事件 /// /// 打开新建窗体事件 /// /// /// private void tsbtnAdd_Click(object sender, EventArgs e) { try { F_PM_1102 frmFPM1102 = new F_PM_1102(Constant.FormMode.Add, "", 0,this.tsbtnApprover.Visible); DialogResult dialogresult = frmFPM1102.ShowDialog(); if (dialogresult.Equals(DialogResult.OK)) { this.dgvScrapProduct.DataSource = null; DataSet dsScrap = (DataSet)DoAsync(new AsyncMethod(() => { return this.GetScrapProduct(); })); if (dsScrap != null) { if (dsScrap.Tables.Count != Constant.INT_IS_ZERO) { this.dgvScrapProduct.DataSource = ((DataSet)dsScrap).Tables[Constant.INT_IS_ZERO]; this.dgvScrapProduct.ReadOnly = true; } } } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 查询事件 /// /// /// private void btnSearch_Click(object sender, EventArgs e) { try { if (this.cbAuditStatus.Text != string.Empty) { this._AuditStatus = Convert.ToInt32(this.cbAuditStatus.SelectedValue); } else { this._AuditStatus = null; } DataSet dsScrapProduct = (DataSet)DoAsync(new AsyncMethod(() => { return this.GetScrapProduct(); })); if (dsScrapProduct != null) { if (dsScrapProduct.Tables[0].Rows.Count != Constant.INT_IS_ZERO) { this.dgvScrapProduct.DataSource = ((DataSet)dsScrapProduct).Tables[Constant.INT_IS_ZERO]; this.dgvScrapProduct.ReadOnly = true; } else { this.dgvScrapProduct.DataSource = null; // 提示未查找到数据 MessageBox.Show(Messages.MSG_CMN_I002, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { this.dgvScrapProduct.DataSource = null; // 提示未查找到数据 MessageBox.Show(Messages.MSG_CMN_I002, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 时间有效性切换 /// /// /// private void cbSelectTime_CheckedChanged(object sender, EventArgs e) { this.txtScrapDateStart.Enabled = this.cbSelectTime.Checked; this.txtScrapDateEnd.Enabled = this.cbSelectTime.Checked; } /// /// 清空条件 /// /// /// private void btnClearCondition_Click(object sender, EventArgs e) { this.txtProductionLineCode.Text = ""; this.txtProductionLineName.Text = ""; this.txtResponProcedureCode.Text = ""; this.txtResponProcedureName.Text = ""; this.txtBarCode.Text = ""; //this.dkUser.UserID = null; //this.dkUser.Text = ""; this.txtUserCode.Text = ""; this.cbSelectTime.Checked = true; this.txtGoodsCode.Text = ""; this.txtGoodsName.Text = ""; this.txtRemarks.Text = ""; this.txtRreason.Text = ""; this.txtGroutingUserCode.Text = ""; } /// /// 编辑窗体打开 /// /// /// private void tsbtnEdit_Click(object sender, EventArgs e) { try { DataGridViewRow currentRow = this.dgvScrapProduct.CurrentRow; if (currentRow != null) { string barCode = currentRow.Cells["BarCode"].Value.ToString(); int SPId = Convert.ToInt32(currentRow.Cells["ScrapProductID"].Value.ToString()); F_PM_1102 frmFPM1102 = new F_PM_1102(Constant.FormMode.Edit, barCode, SPId,this.tsbtnApprover.Visible); DialogResult dialogresult = frmFPM1102.ShowDialog(); if (dialogresult.Equals(DialogResult.OK)) { this.dgvScrapProduct.DataSource = null; object obScrapResult = DoAsync(new AsyncMethod(GetScrapProduct)); if (obScrapResult != null) { DataSet dsScrap = (DataSet)obScrapResult; if (dsScrap.Tables.Count != Constant.INT_IS_ZERO) { this.dgvScrapProduct.DataSource = dsScrap.Tables[Constant.INT_IS_ZERO]; this.dgvScrapProduct.ReadOnly = true; } } } } else { MessageBox.Show(Messages.MSG_CMN_W020, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 编辑窗体打开 /// /// /// private void dgvScrapProduct_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { try { DataGridViewRow currentRow = this.dgvScrapProduct.CurrentRow; if (currentRow != null) { string barCode = currentRow.Cells["BarCode"].Value.ToString(); int SPId = Convert.ToInt32(currentRow.Cells["ScrapProductID"].Value.ToString()); F_PM_1102 frmFPM1102 = new F_PM_1102(Constant.FormMode.Edit, barCode, SPId,this.tsbtnApprover.Visible); DialogResult dialogresult = frmFPM1102.ShowDialog(); if (dialogresult.Equals(DialogResult.OK)) { this.dgvScrapProduct.DataSource = null; object obScrapResult = DoAsync(new AsyncMethod(GetScrapProduct)); if (obScrapResult != null) { DataSet dsScrap = (DataSet)obScrapResult; if (dsScrap.Tables.Count != Constant.INT_IS_ZERO) { this.dgvScrapProduct.DataSource = dsScrap.Tables[Constant.INT_IS_ZERO]; this.dgvScrapProduct.ReadOnly = true; } } } } else { MessageBox.Show(Messages.MSG_CMN_W020, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 关闭一览窗体 /// /// /// private void tsbtnClose_Click(object sender, EventArgs e) { this.Close(); } /// /// 窗体关闭事件 /// /// /// private void F_PM_1101_FormClosed(object sender, FormClosedEventArgs e) { _instance = null; } /// /// 自动列宽 /// /// /// private void tsbtnAdaptive_Click(object sender, EventArgs e) { this.dgvScrapProduct.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); } /// /// 审批按钮事件 /// /// /// private void tsbtnApprover_Click(object sender, EventArgs e) { try { DataGridViewRow currentRow = this.dgvScrapProduct.CurrentRow; if (currentRow != null) { string barCode = currentRow.Cells["BarCode"].Value.ToString(); int ScrapProductID = Convert.ToInt32(currentRow.Cells["ScrapProductID"].Value); string GoodsLevelTypeID = currentRow.Cells["GoodsLevelTypeID"].Value.ToString(); if (GoodsLevelTypeID != _goodsLevelTypeID.ToString()) { return; } F_PM_1103 frmFPM1103 = new F_PM_1103(barCode, 0, ScrapProductID); DialogResult dialogresult = frmFPM1103.ShowDialog(); if (dialogresult.Equals(DialogResult.OK)) { this.dgvScrapProduct.DataSource = null; object obScrapResult = DoAsync(new AsyncMethod(GetScrapProduct)); if (obScrapResult != null) { DataSet dsScrap = (DataSet)obScrapResult; if (dsScrap.Tables.Count != Constant.INT_IS_ZERO) { this.dgvScrapProduct.DataSource = dsScrap.Tables[Constant.INT_IS_ZERO]; this.dgvScrapProduct.ReadOnly = true; } } } } else { MessageBox.Show(Messages.MSG_CMN_W020, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 窗体加载 /// /// /// private void F_PM_1101_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); DataSet dsStatus = SystemModuleProxy.Service.GetAuditStatus(); this.cbAuditStatus.DataSource = dsStatus.Tables[0]; this.cbAuditStatus.ValueMember = "AuditStatusID"; this.cbAuditStatus.DisplayMember = "AuditStatusName"; this.cbAuditStatus.Text = ""; } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } #endregion #region 私有方法 /// /// 根据界面查询条件获取数据集 /// private DataSet GetScrapProduct() { try { this.dgvScrapProduct.AutoGenerateColumns = false; ScrapProductEntity scrapProductEntity = new ScrapProductEntity(); scrapProductEntity.ProductionLineCode = this.txtProductionLineCode.Text.Trim(); scrapProductEntity.ProductionLineName = this.txtProductionLineName.Text.Trim(); scrapProductEntity.ResponProcedureCode = this.txtResponProcedureCode.Text.Trim(); scrapProductEntity.ResponProcedureName = this.txtResponProcedureName.Text.Trim(); scrapProductEntity.GroutingUserCode = this.txtGroutingUserCode.Text.Trim(); scrapProductEntity.BarCode = this.txtBarCode.Text.Trim(); //scrapProductEntity.ResponUserID = this.dkUser.UserID; scrapProductEntity.ResponUserCode = this.txtUserCode.Text.Trim(); if (this.cbSelectTime.Checked == true) { scrapProductEntity.ScrapDate = Convert.ToDateTime(this.txtScrapDateStart.Text); scrapProductEntity.ScrapDateEnd = Convert.ToDateTime(this.txtScrapDateEnd.Text); } scrapProductEntity.GoodsCode = this.txtGoodsCode.Text.Trim(); scrapProductEntity.GoodsName = this.txtGoodsName.Text.Trim(); scrapProductEntity.Remarks = this.txtRemarks.Text.Trim(); scrapProductEntity.Rreason = this.txtRreason.Text.Trim(); if (this._AuditStatus != null) { scrapProductEntity.AuditStatus = this._AuditStatus; } return PMModuleProxy.Service.GetScrapProduct(scrapProductEntity); } catch (Exception ex) { throw ex; } } #endregion } }