| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835 |
- /*******************************************************************************
- * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_PM_0102.cs
- * 2.功能描述:注浆登记
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 陈晓野 2015/03/25 1.00 新建
- *******************************************************************************/
- using System;
- 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_0102 : DKFormBase
- {
- #region 成员变量
- // 窗体模式ID
- private Constant.FormMode _formMode = Constant.FormMode.Add;
- // 未注浆原因,传给选择页面
- private DataTable _dtNotGroutingRreason;
- // 注浆日报ID
- private int _dailyId;
- // 注浆日期
- private DateTime _groutingDate = DateTime.Now.Date;
- // 账务日期
- private DateTime _accountDate = DateTime.Now.Date;
- //private decimal? _logoid = null;
- private bool _canEdit = true;
- #endregion
- #region 构造函数
- /// <summary>
- /// 构造函数
- /// </summary>
- public F_PM_0102()
- :this(0)
- {
- }
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="dailyID">注浆日报ID:新建时为0</param>
- public F_PM_0102(int dailyID)
- {
- this.InitializeComponent();
- this._dailyId = dailyID;
- this.InitializeControls();
- }
- #endregion
- #region 属性
- /// <summary>
- /// 注浆登记的ID(多个用【,】隔开)
- /// </summary>
- public string GroutingDailyIDs
- {
- get;
- private set;
- }
- #endregion
- #region 事件
- /// <summary>
- /// 窗体加载
- /// </summary>
- private void F_PM_0102_Load(object sender, EventArgs e)
- {
- try
- {
- this.lblGroutingDateValue.Text = string.Empty;
- DataSet logoInfo = SystemModuleProxy.Service.GetLogoInfo();
- if (logoInfo != null && logoInfo.Tables.Count > 0)
- {
- this.cmbLogo.DataSource = logoInfo.Tables[0];
- this.cmbLogo.DisplayMember = "LogoNameCode";
- this.cmbLogo.ValueMember = "LogoID";
- this.colLogo.DataSource = logoInfo.Tables[0].Copy();
- this.colLogo.DisplayMember = "LogoNameCode";
- this.colLogo.ValueMember = "LogoID";
- //if(logoInfo.Tables[0].Rows.Count > 0)
- //{
- // _logoid = Convert.ToDecimal(logoInfo.Tables[0].Rows[0]["LogoID"]);
- //}
- }
- // 设置列表未注浆原因选项数据源
- 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 tsbtnAllGrouting_Click(object sender, EventArgs e)
- {
- try
- {
- // 获取登录用户所有的注浆信息,并绑定
- this.txtGrouting.Clear();
- this.dgvDetail.DataSource = null;
- this.DataSource = null;
- this.DataSource = this.GetGroutingDailyInfo(null, null);
- if (this.DataSource != null && this.DataSource.Tables.Count == 2)
- {
- StringBuilder groutingLines = new StringBuilder();
- foreach (DataRow row in this.DataSource.Tables[0].Rows)
- {
- if (groutingLines.Length > 0)
- {
- groutingLines.Append(", ");
- }
- groutingLines.Append(string.Format("{0}({1})", row["GroutingLineCode"], row["MouldQuantity"]));
- }
- this.DataSource.Tables[1].Columns.Add("NoGroutingRreason", typeof(decimal));
- this.DataSource.Tables[1].Columns.Add("Remarks", typeof(string));
- //DataColumn dc = new DataColumn("LogoID", typeof(decimal));
- //if (_logoid.HasValue)
- //{
- // dc.DefaultValue = _logoid.Value;
- //}
- //this.DataSource.Tables[1].Columns.Add(dc);
- this.txtGrouting.Text = groutingLines.ToString();
- this.dgvDetail.DataSource = this.DataSource.Tables[1];
- this.dgvDetail.IsSetInputColumnsColor = true;
- // 按钮状态
- this.tsbtnAllGrouting.Enabled = false;
- this.tsbtnGrouting.Enabled = false;
- this.tsbtnClearDetail.Enabled = true;
- this.tsbtnChangeGroutingUser.Enabled = true;
- this.btnSave.Enabled = true;
- }
- }
- 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_0104_1 frmPM0104 = new F_PM_0104_1();
- frmPM0104.NotGroutingRreason = this._dtNotGroutingRreason;
- DialogResult dialogResult = frmPM0104.ShowDialog();
- if (DialogResult.OK == dialogResult && frmPM0104.GroutingInfo.Length > 0)
- {
- // 根据选择成型线页面返回成型线,取得注浆明细数据
- string groutingLineIDs = string.Empty;
- foreach (DataRow dataRow in frmPM0104.GroutingInfo)
- {
- if (groutingLineIDs.Length > 0)
- {
- groutingLineIDs += ",";
- }
- groutingLineIDs += dataRow["GroutingLineID"].ToString();
- }
- this.txtGrouting.Clear();
- this.dgvDetail.DataSource = null;
- this.DataSource = null;
- this.DataSource = this.GetGroutingDailyInfo(frmPM0104.GroutingDate, groutingLineIDs);
- // 组成页面的注浆日期、注浆成型线显示信息,并且绑定注浆信息的数据源
- if (this.DataSource != null && this.DataSource.Tables.Count == 2)
- {
- StringBuilder groutingLines = new StringBuilder();
- // 根据成型线选择注浆原因,控制注浆列表的未注浆选择列
- this.DataSource.Tables[1].Columns.Add("NoGroutingRreason", typeof(decimal));
- this.DataSource.Tables[1].Columns.Add("Remarks", typeof(string));
- //DataColumn dc = new DataColumn("LogoID", typeof(decimal));
- //if (_logoid.HasValue)
- //{
- // dc.DefaultValue = _logoid.Value;
- //}
- //this.DataSource.Tables[1].Columns.Add(dc);
- foreach (DataRow dataRow in frmPM0104.GroutingInfo)
- {
- string sqlWhere = "GroutingLineID = " + dataRow["GroutingLineID"].ToString();
- DataRow[] drLines = this.DataSource.Tables[0].Select(sqlWhere);
- if (drLines == null || drLines.Length == 0)
- {
- continue;
- }
- DataRow[] drs = this.DataSource.Tables[1].Select("GroutingLineID = " + dataRow["GroutingLineID"].ToString());
- if (drs == null || drs.Length == 0)
- {
- drLines[0].Delete();
- continue;
- }
- if (groutingLines.Length > 0)
- {
- groutingLines.Append(", ");
- }
- groutingLines.Append(string.Format("{0}({1})[{2}]", drLines[0]["GroutingLineCode"], drLines[0]["MouldQuantity"], drLines[0]["monitorcode"]));
- drLines[0]["UserID"] = dataRow["GroutingUserID"];
- drLines[0]["UserCode"] = dataRow["GroutingUserCode"];
- string canManyTimes = drLines[0]["CanManyTimes"].ToString();
- int num = System.Convert.ToInt32(dataRow["GroutingNum"]);
- int batchNo = System.Convert.ToInt32(drLines[0]["GroutingBatchNo"]);
- if (num > 1 && "1" == canManyTimes)
- {
- for (int i = 1; i < num; i++)
- {
- DataRow newRow = this.DataSource.Tables[0].Rows.Add(drLines[0].ItemArray);
- newRow["GroutingBatchNo"] = batchNo + i;
- }
- }
- foreach (DataRow detailDataRow in drs)
- {
- detailDataRow["GroutingUserID"] = dataRow["GroutingUserID"];
- detailDataRow["GroutingUserCode"] = dataRow["GroutingUserCode"];
- object NoGroutingRreason = dataRow["NoGroutingRreason"];
- if (NoGroutingRreason != null && NoGroutingRreason != DBNull.Value)
- {
- detailDataRow["GroutingFlag"] = (int)Constant.GroutingFlag.No;
- detailDataRow["NoGroutingRreason"] = dataRow["NoGroutingRreason"];
- }
- if (num > 1 && "1" == canManyTimes)
- {
- for (int i = 1; i < num; i++)
- {
- DataRow newRow = this.DataSource.Tables[1].Rows.Add(detailDataRow.ItemArray);
- newRow["GroutingBatchNo"] = batchNo + i;
- }
- }
- }
- }
- this.DataSource.AcceptChanges();
- this.DataSource.Tables[1].DefaultView.Sort = "GroutingLineCode, GroutingBatchNo, GroutingMouldCode";
- this.txtGrouting.Text = groutingLines.ToString();
- this.dgvDetail.DataSource = this.DataSource.Tables[1];
- this.dgvDetail.IsSetInputColumnsColor = true;
- // 按钮状态
- this.tsbtnAllGrouting.Enabled = false;
- this.tsbtnGrouting.Enabled = false;
- this.tsbtnClearDetail.Enabled = true;
- this.tsbtnChangeGroutingUser.Enabled = true;
- this.btnSave.Enabled = true;
- }
- }
- }
- 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 tsbtnChangeGroutingUser_Click(object sender, EventArgs e)
- {
- try
- {
- }
- 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 tsbtnClearDetail_Click(object sender, EventArgs e)
- {
- this.txtGrouting.Clear();
- this.dgvDetail.DataSource = null;
- this.DataSource = null;
- this.lblGroutingDateValue.Text = this._accountDate.Date.ToString(Constant.S_DATE_YYYY_MM_DD);
- // 清空注浆信息后,清空明细、更换成型工按钮不可用
- this.tsbtnAllGrouting.Enabled = true;
- this.tsbtnGrouting.Enabled = true;
- this.tsbtnClearDetail.Enabled = false;
- this.tsbtnChangeGroutingUser.Enabled = false;
- this.btnSave.Enabled = false;
- }
- /// <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 ("GroutingFlag".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)
- {
- try
- {
- if (e.RowIndex != Constant.INT_IS_NEGATIE_ONE && this._canEdit)
- {
- DataGridViewRow dataGridViewRow = this.dgvDetail.Rows[e.RowIndex];
- // 如果是改变了注浆标识,则对未注浆原因进行控制输入
- if ( "GroutingFlag".Equals(this.dgvDetail.Columns[e.ColumnIndex].Name))
- {
- // 选择了未注浆
- if (((int)Constant.GroutingFlag.Yes).ToString() != dataGridViewRow.Cells["GroutingFlag"].Value.ToString())
- {
- dataGridViewRow.Cells["NoGroutingRreason"].ReadOnly = false;
- }
- else
- {
- dataGridViewRow.Cells["NoGroutingRreason"].ReadOnly = true;
- this.dgvDetail.Rows[e.RowIndex].Cells["NoGroutingRreason"].Value = DBNull.Value;
- }
- }
- }
- }
- 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();
- this.dgvDetail.IsSetInputColumnsColor = true;
- }
- /// <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>
- private void btnSave_Click(object sender, EventArgs e)
- {
- // 没有注浆数据
- if (this.DataSource == null || this.DataSource.Tables.Count != 2)
- {
- return;
- }
- try
- {
- DataRow[] noGroutingDataRow = this.DataSource.Tables[1].Select("GroutingFlag = 0 AND NoGroutingRreason IS NULL");
- if (noGroutingDataRow != null && noGroutingDataRow.Length > 0)
- {
- string mc = null;
- foreach (DataRow dataRow in noGroutingDataRow)
- {
- if (mc != null)
- {
- mc += ",";
- }
- mc += dataRow["GroutingMouldCode"].ToString();
- }
- DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_C_006,
- "以下模具编号既没有注浆也没有未注浆原因" + Environment.NewLine + mc);
- return;
- }
- DateTime? date = null;
- if (this._formMode == Constant.FormMode.Add)
- {
- date = this._groutingDate;
- }
- ServiceResultEntity sre = this.DoAsync<ServiceResultEntity>(() =>
- {
- return PMModuleProxyNew.Service.SetFPM0102Data(date, this.DataSource);
- }
- );
- if (sre.Status == Constant.ServiceResultStatus.Success)
- {
- DKMessageBox.ShowDialog(this, DKMessageCode.I_CMN_S_002);
- if (sre.Result != null)
- {
- this.GroutingDailyIDs = sre.Result.ToString();
- }
- this.DialogResult = DialogResult.OK;
- this.Close();
- return;
- }
- if (sre.Status == Constant.ServiceResultStatus.Other)
- {
- 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();
- }
- /// <summary>
- /// 设置注浆状态和未注浆原因
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnNGRSetting_Click(object sender, EventArgs e)
- {
- if (this.cboNoGroutingRreason.SelectedIndex < 0 || !this._canEdit)
- {
- return;
- }
- try
- {
- object noGroutingRreason = null;
- // 未注浆原因
- if (Constant.CBO_SELECT_ALL_VALUE.ToString() != this.cboNoGroutingRreason.SelectedValue.ToString())
- {
- noGroutingRreason = this.cboNoGroutingRreason.SelectedValue;
- }
- foreach (DataGridViewRow row in this.dgvDetail.Rows)
- {
- if (!row.Cells["GroutingFlag"].ReadOnly)
- {
- if (noGroutingRreason == null)
- {
- row.Cells["NoGroutingRreason"].Value = DBNull.Value;
- row.Cells["GroutingFlag"].Value = (int)Constant.GroutingFlag.Yes;
- }
- else
- {
- row.Cells["NoGroutingRreason"].Value = noGroutingRreason;
- row.Cells["GroutingFlag"].Value = (int)Constant.GroutingFlag.No;
- }
- DataRowView dataRow = row.DataBoundItem as DataRowView;
- if (dataRow != null)
- {
- dataRow.EndEdit();
- }
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- #endregion
- #region 私有方法
- /// <summary>
- /// 初始化控件
- /// </summary>
- private void InitializeControls()
- {
- // 窗体名称赋值
- if (this._dailyId > 0)
- {
- this._formMode = Constant.FormMode.Edit;
- this.Text = FormTitles.F_PM_0102_EDIT;
- this.tsbtnAllGrouting.Enabled = false;
- this.tsbtnGrouting.Enabled = false;
- this.BarCode.Visible = true;
- this.ScrapFlag.Visible = true;
- }
- else
- {
- this._formMode = Constant.FormMode.Add;
- this.Text = FormTitles.F_PM_0102_ADD;
- this.BarCode.Visible = false;
- this.ScrapFlag.Visible = false;
- }
- // 功能按钮文本赋值
- this.tsbtnAllGrouting.Text = ButtonText.TSBTN_ALLGROUTING;
- this.tsbtnGrouting.Text = ButtonText.TSBTN_GROUTING;
- this.tsbtnClearDetail.Text = ButtonText.TSBTN_CLEARDETAIL;
- this.tsbtnChangeGroutingUser.Text = ButtonText.TSBTN_CHANGEGROUTINGUSER;
- 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;
- }
- /// <summary>
- /// 设置列表中未注浆原因的数据源
- /// </summary>
- private void InitializeData()
- {
- try
- {
- // 获取成型线类型数据并绑定到控件上
- ServiceResultEntity sre = this.DoAsync<ServiceResultEntity>(() =>
- {
- return PMModuleProxyNew.Service.GetFPM0102IData(this._dailyId);
- }
- );
- if (sre.Status == Constant.ServiceResultStatus.Other)
- {
- DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_S_004, sre.Message);
- this.DialogResult = DialogResult.Cancel;
- this.Close();
- return;
- }
- if (sre.Status != Constant.ServiceResultStatus.Success)
- {
- return;
- }
- if (sre.Data != null && sre.Data.Tables.Count > 0)
- {
- // 设置全部注浆选项
- DataTable ngrDataTable = sre.Data.Tables[0].Copy();
- DataRow ngrDataRow = ngrDataTable.NewRow();
- ngrDataRow["DictionaryID"] = Constant.CBO_SELECT_ALL_VALUE;
- ngrDataRow["DictionaryValue"] = "全部注浆";
- ngrDataRow["DisplayNo"] = 0;
- ngrDataTable.Rows.InsertAt(ngrDataRow, 0);
- this.cboNoGroutingRreason.ValueMember = "DictionaryID";
- this.cboNoGroutingRreason.DisplayMember = "DictionaryValue";
- this.cboNoGroutingRreason.DataSource = ngrDataTable;
- this._dtNotGroutingRreason = sre.Data.Tables[0];
- // 设置空选项
- DataRow dataRow = this._dtNotGroutingRreason.NewRow();
- dataRow["DictionaryID"] = DBNull.Value;
- dataRow["DictionaryValue"] = Constant.CBO_SELECT_EMPTY_NAME;
- dataRow["DisplayNo"] = 0;
- this._dtNotGroutingRreason.Rows.InsertAt(dataRow, 0);
- }
- this.NoGroutingRreason.ValueMember = "DictionaryID";
- this.NoGroutingRreason.DisplayMember = "DictionaryValue";
- this.NoGroutingRreason.DataSource = this._dtNotGroutingRreason;
- if (this._formMode == Constant.FormMode.Edit)
- {
- _canEdit = ((int)sre.Result == 1);
- // 编辑时,修改未注浆原因
- if (_canEdit)
- {
- this.lblNoGroutingRreason.Visible = true;
- this.cboNoGroutingRreason.Visible = true;
- this.btnNGRSetting.Visible = true;
- }
- else
- {
- this.txtGrouting1.Visible = true;
- this.txtGrouting.Visible = false;
- this.gbxInfo.Height -= 30;// 67;
- this.dgvDetail.Top -= 30;
- this.dgvDetail.Height += 30;
- }
- sre.Data.Tables.RemoveAt(0);
- this.DataSource = sre.Data;
- if (this.DataSource != null && this.DataSource.Tables.Count == 2)
- {
- DataRow gdDataRow = this.DataSource.Tables[0].Rows[0];
- this.txtGrouting.Text = string.Format("{0}({1})", gdDataRow["GroutingLineCode"], gdDataRow["MouldQuantity"]);
- this.txtGrouting1.Text = this.txtGrouting.Text;
- this._groutingDate = Convert.ToDateTime(gdDataRow["GroutingDate"]);
- //this._accountDate = this._groutingDate;
- this.dgvDetail.DataSource = this.DataSource.Tables[1];
- this.SetEditGrid();
- this.dgvDetail.IsSetInputColumnsColor = true;
- // 按钮状态
- this.btnSave.Enabled = true;
- }
- // 编辑时,修改未注浆原因
- if (!_canEdit)
- {
- this.txtGrouting1.Text += System.Environment.NewLine + System.Environment.NewLine + sre.Message;
- this.txtGrouting1.ForeColor = System.Drawing.Color.Red;
- }
- this.dgvDetail.Focus();
- }
- else
- {
- if (sre.Result != null)
- {
- this._accountDate = Convert.ToDateTime(sre.Result);
- this._groutingDate = this._accountDate;
- }
- }
- this.lblGroutingDateValue.Text = this._groutingDate.ToString(Constant.S_DATE_YYYY_MM_DD);
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 取得可注浆信息
- /// </summary>
- /// <param name="groutingDate">注浆日期</param>
- /// <param name="groutingIDs">成型线ID(多个用【,】隔开)</param>
- /// <returns>可注浆信息</returns>
- private DataSet GetGroutingDailyInfo(DateTime? groutingDate, string groutingLineIDs)
- {
- try
- {
- // 根据注浆日期、成型线获取所有可注浆模具信息
- ServiceResultEntity sre = this.DoAsync<ServiceResultEntity>(() =>
- {
- return PMModuleProxyNew.Service.GetFPM0102_GroutingLine(groutingDate, groutingLineIDs);
- }
- );
- // 取注浆日期
- if (sre.Result != null)
- {
- this._groutingDate = Convert.ToDateTime(sre.Result);
- }
- else if (groutingDate.HasValue)
- {
- this._groutingDate = groutingDate.Value.Date;
- }
- else
- {
- this._groutingDate = DateTime.Now.Date;
- }
- this.lblGroutingDateValue.Text = this._groutingDate.ToString(Constant.S_DATE_YYYY_MM_DD);
- // 异常情况处理
- if (sre.Status > Constant.ServiceResultStatus.Success)
- {
- DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_S_004, sre.Message);
- return null;
- }
- return sre.Data;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 编辑模式下设置Grid编辑状态
- /// </summary>
- private void SetEditGrid()
- {
- if(this._formMode != Constant.FormMode.Edit)
- {
- return;
- }
- foreach (DataGridViewRow row in this.dgvDetail.Rows)
- {
- // 交坯后,不能编辑
- object deliverFlag = (row.DataBoundItem as DataRowView)["DeliverFlag"];
- if (deliverFlag != null && "1" == deliverFlag.ToString())
- {
- row.Cells["colLogo"].ReadOnly = true;
- row.Cells["GroutingFlag"].ReadOnly = true;
- row.Cells["NoGroutingRreason"].ReadOnly = true;
- }
- // 绑定条码后,不能编辑
- object barCode = row.Cells["BarCode"].Value;
- object scrapFlag = row.Cells["ScrapFlag"].Value;
- if ((barCode != null && !string.IsNullOrWhiteSpace(barCode.ToString())) ||
- (scrapFlag != null && ((int)Constant.GroutingScrapFlag.Yes).ToString() == scrapFlag.ToString()))
- {
- row.Cells["GroutingFlag"].ReadOnly = true;
- row.Cells["NoGroutingRreason"].ReadOnly = true;
- row.Cells["NoGroutingRreason"].Value = DBNull.Value;
- //row.Cells["Remarks"].ReadOnly = false;
- continue;
- }
- // 未注浆,可以输入未注浆原因
- if (((int)Constant.GroutingFlag.No).ToString() == row.Cells["GroutingFlag"].Value.ToString())
- {
- row.Cells["NoGroutingRreason"].ReadOnly = false;
- }
- else
- {
- row.Cells["NoGroutingRreason"].Value = DBNull.Value;
- row.Cells["NoGroutingRreason"].ReadOnly = true;
- }
- }
- if (!this._canEdit)
- {
- dgvDetail.Columns["GroutingFlag"].ReadOnly = true;
- dgvDetail.Columns["NoGroutingRreason"].ReadOnly = true;
- }
- }
- #endregion
- private void c_Button1_Click(object sender, EventArgs e)
- {
- if (this.cmbLogo.SelectedIndex < 0)
- {
- return;
- }
- try
- {
- foreach (DataGridViewRow row in this.dgvDetail.Rows)
- {
- if (!row.Cells["colLogo"].ReadOnly)
- {
- row.Cells["colLogo"].Value = this.cmbLogo.SelectedValue;
- DataRowView dataRow = row.DataBoundItem as DataRowView;
- if (dataRow != null)
- {
- dataRow.EndEdit();
- }
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- }
- }
|