| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526 |
- /*******************************************************************************
- * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_PM_2901.cs
- * 2.功能描述:开模报损
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 周兴 2018/04/02 1.00 新建
- *******************************************************************************/
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Reflection;
- using System.Text;
- 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;
- using Dongke.IBOSS.PRD.WCF.DataModels;
- using Dongke.IBOSS.PRD.WCF.Proxys;
- namespace Dongke.IBOSS.PRD.Client.PMModule
- {
- /// <summary>
- /// 注浆明细条码绑定
- /// </summary>
- public partial class F_PM_2901 : DKFormBase
- {
- #region 成员变量
- // 注浆日报ID
- private int _dailyId;
- // 注浆日期
- private DateTime _groutingDate = DateTime.Now.Date;
- #endregion
- #region 构造函数
- /// <summary>
- /// 构造函数
- /// </summary>
- public F_PM_2901()
- : this(0)
- {
- }
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="dailyID">注浆日报ID</param>
- public F_PM_2901(int dailyID)
- {
- this.InitializeComponent();
- this._dailyId = dailyID;
- this.InitializeControls();
- }
- #endregion
- #region 属性
- /// <summary>
- /// 注浆登记ID
- /// </summary>
- public List<int> GroutingDailyIDs
- {
- get;
- private set;
- }
- #endregion
- #region 事件
- /// <summary>
- /// 窗体加载
- /// </summary>
- private void F_PM_2901_Load(object sender, EventArgs e)
- {
- try
- {
- this.lblGroutingDateValue.Text = string.Empty;
- // 设置列表
- this.InitializeData();
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 全线注浆按钮按下,生成该成型班长的所有注浆信息
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnGrouting_Click(object sender, EventArgs e)
- {
- try
- {
- F_PM_0105 frmPM0105 = new F_PM_0105();
- frmPM0105.IsBarCodeScrapReasonUseFlag = true;
- DialogResult dialogResult = frmPM0105.ShowDialog();
- if (dialogResult != DialogResult.OK)
- {
- return;
- }
- this._dailyId = frmPM0105.GroutingDailyID;
- this.InitializeData();
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 提交选择列内容的修改
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvDetail_CurrentCellDirtyStateChanged(object sender, EventArgs e)
- {
- try
- {
- if (this.dgvDetail.CurrentRow != null && this.dgvDetail.IsCurrentCellDirty)
- {
- if ("ScrapFlag".Equals(this.dgvDetail.Columns
- [this.dgvDetail.CurrentCell.ColumnIndex].Name))
- {
- this.dgvDetail.CommitEdit(DataGridViewDataErrorContexts.Commit);
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 损坯时,不能绑定条码
- /// </summary>
- private void dgvDetail_CellValueChanged(object sender, DataGridViewCellEventArgs e)
- {
- if (e.RowIndex < 0)
- {
- return;
- }
- try
- {
- DataGridViewRow dataGridViewRow = this.dgvDetail.Rows[e.RowIndex];
- if ("ScrapFlag".Equals(this.dgvDetail.Columns[e.ColumnIndex].Name))
- {
- // 未绑定时,如果是改变了损坯标识,则对绑定条码进行控制输入
- if (string.IsNullOrWhiteSpace(dataGridViewRow.Cells["colOBarCode"].Value + ""))
- {
- if (Convert.ToBoolean(dataGridViewRow.Cells["ScrapFlag"].EditedFormattedValue))
- {
- dataGridViewRow.Cells["SReasonID"].ReadOnly = false;
- }
- else
- {
- dataGridViewRow.Cells["SReasonID"].ReadOnly = true;
- dataGridViewRow.Cells["SReasonID"].Value = DBNull.Value;
- }
- this.dgvDetail.IsSetInputColumnsColor = true;
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 排序后设置Grid状态
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvDetail_Sorted(object sender, EventArgs e)
- {
- this.SetEditGrid();
- }
- /// <summary>
- /// 自动列宽
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnAdaptive_Click(object sender, EventArgs e)
- {
- this.dgvDetail.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
- }
- /// <summary>
- /// 页面关闭
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnClose_Click(object sender, EventArgs e)
- {
- this.DialogResult = DialogResult.Cancel;
- this.Close();
- }
- /// <summary>
- /// 绑定条码
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void txtBarCodeStart_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (e.KeyChar == Constant.SYSTEM_KEYBOARD_ENTER_VALUE)
- {
- this.btnBindBarCode_Click(sender, e);
- }
- }
- /// <summary>
- /// 绑定报损原因
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnBindBarCode_Click(object sender, EventArgs e)
- {
- try
- {
- if (!string.IsNullOrWhiteSpace(this.cboSReason.SelectedValue + ""))
- {
- int sReasonID = Convert.ToInt32(this.cboSReason.SelectedValue);
- for (int i = 0; i < this.dgvDetail.Rows.Count; i++)
- {
- if (Convert.ToBoolean(this.dgvDetail.Rows[i].Cells["ScrapFlag"].EditedFormattedValue))
- {
- this.dgvDetail.Rows[i].Cells["SReasonID"].Value = sReasonID;
- }
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 清空条码
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnClearBarCode_Click(object sender, EventArgs e)
- {
- try
- {
- foreach (DataGridViewRow row in this.dgvDetail.Rows)
- {
- row.Cells["SReasonID"].Value = DBNull.Value;
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 保存数据
- /// </summary>
- private void btnSave_Click(object sender, EventArgs e)
- {
- // 没有注浆数据
- if (this.DataSource == null || this._dailyId <= 0)
- {
- return;
- }
- try
- {
- // 校验数据
- if (!IsValidData())
- {
- return;
- }
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "GroutingScrapProduct";
- cre.Name = "SaveScrapKm";
- cre.Data = this.DataSource;
- ServiceResultEntity sre = this.DoAsync<ServiceResultEntity>(() =>
- {
- return PMModuleProxyNew.Service.HandleRequest(cre);
- }
- );
- if (sre.Status == Constant.ServiceResultStatus.Success)
- {
- if (string.IsNullOrWhiteSpace(sre.Message))
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "开模报损", "保存"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- else
- {
- MessageBox.Show("开模报损保存成功,但有部分商品未成功;具体信息如下【" + sre.Message + "】。",
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- if (this.GroutingDailyIDs == null)
- {
- this.GroutingDailyIDs = new List<int>();
- }
- this.GroutingDailyIDs.Add(this._dailyId);
- //this.DialogResult = DialogResult.OK;
- //this.Close();
- this._dailyId = 0;
- this.lblGroutingDateValue.Text = string.Empty;
- this.txtGrouting.Clear();
- this.dgvDetail.DataSource = null;
- this.btnSave.Enabled = false;
- return;
- }
- else if (sre.Status == Constant.ServiceResultStatus.Other)
- {
- int resultRow = (int)sre.Result;
- if (resultRow == -99)
- {
- MessageBox.Show(string.Format(Messages.W_CMN_C_006, "未查询到该产品信息,请确认该产品是否已经进行注浆"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- else
- {
- DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_S_004, sre.Message);
- }
- }
- this.SetEditGrid();
- }
- catch (Exception ex)
- {
- this.SetEditGrid();
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 关闭窗体
- /// </summary>
- private void btnCancel_Click(object sender, EventArgs e)
- {
- this.DialogResult = DialogResult.Cancel;
- this.Close();
- }
- #endregion
- #region 私有方法
- /// <summary>
- /// 初始化控件
- /// </summary>
- private void InitializeControls()
- {
- this.Text = FormTitles.F_PM_2901;
- // 功能按钮文本赋值
- this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
- this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
- this.btnSave.Text = ButtonText.BTN_SAVE;
- this.btnClose.Text = ButtonText.BTN_CLOSE;
- this.dgvDetail.AutoGenerateColumns = false;
- this.lblGroutingDateValue.Text = string.Empty;
- this.btnBindBarCode.Text = ButtonText.BTN_BINDSCRAPREASON;
- this.btnClearBarCode.Text = ButtonText.BTN_CLEARSCRAPREASON;
- this.btnBindBarCode.Enabled = false;
- this.btnClearBarCode.Enabled = false;
- }
- /// <summary>
- /// 取得注浆日报信息
- /// </summary>
- private void InitializeData()
- {
- try
- {
- if (this._dailyId > 0)
- {
- this.DataSource = null;
- this.dgvDetail.DataSource = null;
- this.txtGrouting.Clear();
- // 获取成型线类型数据并绑定到控件上
- ServiceResultEntity sre = this.DoAsync<ServiceResultEntity>(() =>
- {
- return PMModuleProxyNew.Service.GetFPM0103Data(this._dailyId);
- }
- );
- if (sre.Status == Constant.ServiceResultStatus.Other)
- {
- DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_S_004, sre.Message);
- return;
- }
- if (sre.Status != Constant.ServiceResultStatus.Success)
- {
- return;
- }
- this.DataSource = sre.Data;
- DataRow lineDataRow = sre.Data.Tables[0].Rows[0];
- this._groutingDate = Convert.ToDateTime(lineDataRow["GroutingDate"]);
- this.lblGroutingDateValue.Text = this._groutingDate.ToString(Constant.S_DATE_YYYY_MM_DD);
- this.txtGrouting.Text = string.Format("{0}({1})", lineDataRow["GroutingLineCode"], lineDataRow["MouldQuantity"]);
- this.dgvDetail.DataSource = sre.Data.Tables[1];
- // 获取成型报损原因
- if (sre.Data.Tables.Count > 2)
- {
- SReasonID.DisplayMember = "ScrapReason";
- SReasonID.ValueMember = "ScrapReasonID";
- SReasonID.DataSource = sre.Data.Tables[2];
- this.cboSReason.DisplayMember = "ScrapReason";
- this.cboSReason.ValueMember = "ScrapReasonID";
- this.cboSReason.DataSource = sre.Data.Tables[2];
- }
- this.SetEditGrid();
- this.btnBindBarCode.Enabled = true;
- this.btnClearBarCode.Enabled = true;
- this.btnSave.Enabled = true;
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 编辑模式下设置Grid编辑状态
- /// </summary>
- private void SetEditGrid()
- {
- foreach (DataGridViewRow row in this.dgvDetail.Rows)
- {
- // 报损标识勾上才可以编辑报损原因
- if (!Convert.ToBoolean(row.Cells["ScrapFlag"].EditedFormattedValue))
- {
- row.Cells["SReasonID"].ReadOnly = true;
- }
- //// 交坯后,不能编辑
- //object deliverFlag = row.Cells["DeliverFlag"].Value;
- //if (deliverFlag != null && "1" == deliverFlag.ToString())
- //{
- // row.Cells["BarCode"].ReadOnly = true;
- // row.Cells["ScrapFlag"].ReadOnly = true;
- // row.Cells["Remarks"].ReadOnly = true;
- // row.Cells["colLogo"].ReadOnly = true;
- // continue;
- //}
- //// 绑定条码后,不能编辑条码
- //object obarCode = row.Cells["colOBarCode"].Value;
- //if (obarCode != null && !string.IsNullOrWhiteSpace(obarCode.ToString()))
- //{
- // row.Cells["BarCode"].ReadOnly = true;
- // continue;
- //}
- //// 损坯后,不能编辑
- //if (((int)Constant.GroutingScrapFlag.No).ToString() == row.Cells["ScrapFlag"].Value.ToString())
- //{
- // row.Cells["BarCode"].ReadOnly = false;
- //}
- //else
- //{
- // row.Cells["BarCode"].Value = DBNull.Value;
- // row.Cells["BarCode"].ReadOnly = true;
- //}
- }
- this.dgvDetail.IsSetInputColumnsColor = true;
- }
- /// <summary>
- /// 校验数据
- /// </summary>
- /// <returns></returns>
- private bool IsValidData()
- {
- try
- {
- for (int j = 0; j < this.dgvDetail.Rows.Count; j++)
- {
- // 判断如果勾选上报损标识,那么报损原因必须输入
- if (Convert.ToBoolean(this.dgvDetail.Rows[j].Cells["ScrapFlag"].EditedFormattedValue)
- && string.IsNullOrWhiteSpace(this.dgvDetail.Rows[j].Cells["SReasonID"].EditedFormattedValue + ""))
- {
- dgvDetail.CurrentCell = dgvDetail.Rows[j].Cells["ScrapFlag"];
- // 增加单元格的错误消息
- dgvDetail.Rows[j].ErrorText = string.Format(Messages.W_CMN_S_004, "报损原因为空");
- return false;
- }
- }
- return true;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- #endregion
- }
- }
|