/******************************************************************************* * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential * 类的信息: * 1.程序名称:F_MST_0503.cs * 2.功能描述:配置或撤销产品工序配置 * 编辑履历: * 作者 日期 版本 修改内容 * 陈晓野 2017/07/11 1.00 新建 *******************************************************************************/ using System; using System.Collections.Generic; using System.Data; using System.Windows.Forms; using Dongke.IBOSS.PRD.Basics.BaseResources; using Dongke.IBOSS.PRD.Client.CommonModule; using Dongke.IBOSS.PRD.WCF.DataModels; using Dongke.IBOSS.PRD.WCF.Proxys; using Dongke.WinForm.Controls; namespace Dongke.IBOSS.PRD.Client.SystemModule { /// /// 配置或撤销产品工序配置 /// public partial class F_MST_0503 : FormBase { #region 成员变量 // 1:配置到工序;2:从工序撤销 private int _formStatus; #endregion #region 构造函数 /// /// 配置或撤销产品工序配置 /// /// 1:配置到工序;2:从工序撤销 /// 产品列表 public F_MST_0503(int formStatus, DataTable goods) { InitializeComponent(); this.dgvGoods.AutoGenerateColumns = false; if (goods.Columns.Contains("Sel")) { goods.Columns.Remove("Sel"); } goods.Columns.Add("Sel", typeof(int)); this.dgvGoods.DataSource = goods; this._formStatus = formStatus; this.Text = (_formStatus == 1 ? "配置" : "撤销") + "产品工序"; } #endregion #region 事件 /// /// 关闭 /// /// /// private void tsbtnClose_Click(object sender, System.EventArgs e) { this.Close(); } /// /// 自适应列宽 /// /// /// private void tsbtnAdaptive_Click(object sender, System.EventArgs e) { this.dgvGoods.AutoResizeColumns(); } /// /// 画面加载 /// /// /// private void F_MST_0503_Load(object sender, System.EventArgs e) { try { foreach (DataGridViewColumn item in this.dgvGoods.Columns) { if ("Sel" != item.Name) { item.ReadOnly = true; } } this.dgvGoods.IsSetInputColumnsColor = true; } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 全选 /// /// /// private void tsbtnAllCheck_Click(object sender, System.EventArgs e) { try { this.dgvGoods.CommitEdit(DataGridViewDataErrorContexts.Commit); foreach (DataGridViewRow item in dgvGoods.Rows) { DataRowView row = item.DataBoundItem as DataRowView; if (row != null) { row["Sel"] = 1; row.EndEdit(); } } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 反选 /// /// /// private void tsbtnUnCheck_Click(object sender, System.EventArgs e) { try { this.dgvGoods.CommitEdit(DataGridViewDataErrorContexts.Commit); foreach (DataGridViewRow item in dgvGoods.Rows) { DataRowView row = item.DataBoundItem as DataRowView; if (row != null) { int c = int.Parse(row["Sel"].ToString()); row["Sel"] = (c == 1 ? 0 : 1); row.EndEdit(); } } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 全不选 /// /// /// private void tsbtnNoCheck_Click(object sender, System.EventArgs e) { try { this.dgvGoods.CommitEdit(DataGridViewDataErrorContexts.Commit); foreach (DataGridViewRow item in dgvGoods.Rows) { DataRowView row = item.DataBoundItem as DataRowView; if (row != null) { row["Sel"] = 0; row.EndEdit(); } } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 保存 /// /// /// private void tsbtnSave_Click(object sender, EventArgs e) { try { this.dgvGoods.CommitEdit(DataGridViewDataErrorContexts.Commit); this.dgvGoods.EndEdit(); DataTable goods = this.dgvGoods.DataSource as DataTable; List goodsIDList = new List(); foreach (DataRow item in goods.Rows) { item.EndEdit(); if ("1" == item["Sel"].ToString()) { goodsIDList.Add(item["GoodsID"].ToString()); } } if (goodsIDList.Count == 0) { MessageBox.Show("没有选择任何产品", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (dkproductionLineSearchBox.ProductionLineID== null || string.IsNullOrWhiteSpace(this.dkProcedureSearchBox.ProcedureIDS)) { DialogResult dr = MessageBox.Show("确定设置全部生产线或工序?", this.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dr != DialogResult.OK) { return; } } ClientRequestEntity cre = new ClientRequestEntity(); cre.NameSpace = "MST05"; cre.Name = "SetGoodsToProcedure"; cre.Properties["Type"] = _formStatus; cre.Properties["GoodsIDs"] = string.Join(",", goodsIDList); cre.Properties["ProductionLineID"] = this.dkproductionLineSearchBox.ProductionLineID; cre.Properties["ProcedureIDs"] = this.dkProcedureSearchBox.ProcedureIDS; ServiceResultEntity sre = CommonModuleProxy.Service.DoRequest(cre); if (sre.Status == Basics.BaseResources.Constant.ServiceResultStatus.Success) { MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "产品工序", (_formStatus == 1 ? "配置" : "撤销")), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "产品工序", (_formStatus == 1 ? "配置" : "撤销")), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } #endregion #region 私有方法 #endregion } }