| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480 |
- /*******************************************************************************
- * Copyright(c) 2015 dongke All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_PM_0104.cs
- * 2.功能描述:可注浆的成型线选择画面
- * 选择或填写未注浆原因都会生成注浆日报
- * 1.选择:注浆标识为注浆,未注浆原因不可用
- * 2.填未注浆原因:注浆标识为未注浆并带有原因
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 欧阳涛 2015/03/27 1.00 新建
- *******************************************************************************/
- using System;
- using System.Data;
- using System.Reflection;
- 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_0104_1 : DKFormBase
- {
- #region 成员变量
- private DataRow[] _groutinginfo; // 返回调用画面选择成型线信息,包括:成型线ID,未注浆原因
- private DataTable _notGroutingRreason; // 未注浆原因,防止再次连接数据库
- private int _groutinglineid = -1;
- private DataTable _groutinguser = null;
- private DateTime _groutingDate = DateTime.Now.Date;
- #endregion
- #region 构造函数
- /// <summary>
- /// 构造函数
- /// </summary>
- public F_PM_0104_1()
- {
- InitializeComponent();
- // 为各个控件文本赋值
- this.InitializeControls();
- }
- #endregion
- #region 属性
- /// <summary>
- /// 返回选择的数据行
- /// </summary>
- public DataRow[] GroutingInfo
- {
- get
- {
- return this._groutinginfo;
- }
- set
- {
- this._groutinginfo = value;
- }
- }
- /// <summary>
- /// 未注浆原因
- /// </summary>
- public DataTable NotGroutingRreason
- {
- get
- {
- return this._notGroutingRreason;
- }
- set
- {
- this._notGroutingRreason = value;
- }
- }
- /// <summary>
- /// 注浆日期
- /// </summary>
- public DateTime GroutingDate
- {
- get
- {
- return this._groutingDate;
- //return this.dtpGroutingDate.Value.Date;
- }
- set
- {
- this.dtpGroutingDate.Value = value.Date;
- this._groutingDate = value.Date;
- }
- }
- #endregion
- #region 控件事件
- /// <summary>
- /// 页面Load事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void F_PM_0104_Load(object sender, EventArgs e)
- {
- // 未注浆原因绑定数据
- this.NoGroutingRreason.DataSource = this._notGroutingRreason;
- this.NoGroutingRreason.ValueMember = "DictionaryID";
- this.NoGroutingRreason.DisplayMember = "DictionaryValue";
- this.dgvGroutingLine.AutoGenerateColumns = false;
- this.dgvGroutingUser.AutoGenerateColumns = false;
- }
- /// <summary>
- /// 查询按钮按下事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnSearch_Click(object sender, System.EventArgs e)
- {
- try
- {
- FPM0104_SE se = new FPM0104_SE();
- se.GroutingDate = this.dtpGroutingDate.Value.Date;
- se.GroutingLineCode = this.txtGroutingLineCode.Text;
- se.GroutingLineName = this.txtGroutingLineName.Text;
- se.GroutingUserCode = this.txtUserCode.Text;
- se.Monitorcode = this.txtMUserCode.Text;
- this.dgvGroutingLine.DataSource = null;
- this.DataSource = null;
- this.dgvGroutingLine.Columns["NoGroutingRreason"].ReadOnly = false;
- this._groutinguser = null;
- this.dgvGroutingUser.DataSource = null;
- // 根据注浆日期、成型线获取所有可注浆模具信息
- ServiceResultEntity sre = this.DoAsync<ServiceResultEntity>(() =>
- {
- return PMModuleProxyNew.Service.GetFPM0104SData(se);
- }
- );
- // 异常情况处理
- if (sre.Status == Constant.ServiceResultStatus.Success)
- {
- this._groutingDate = se.GroutingDate;
- this.DataSource = sre.Data;
- this.DataSource.Tables[0].Columns.Add("NoGroutingRreason", typeof(decimal));
- this.DataSource.Tables[0].Columns.Add("SEL", typeof(int));
- this.dgvGroutingLine.DataSource = this.DataSource.Tables[0];
- foreach (DataGridViewRow row in this.dgvGroutingLine.Rows)
- {
- string canManyTimes = row.Cells["CanManyTimes"].Value.ToString();
- // 多次注浆
- if ("1" == canManyTimes)
- {
- row.Cells["GroutingNum"].ReadOnly = false;
- }
- else
- {
- row.Cells["GroutingNum"].ReadOnly = true;
- }
- }
- this.dgvGroutingLine.IsSetInputColumnsColor = true;
- this._groutinguser = this.DataSource.Tables[1];
- this._groutinguser.DefaultView.RowFilter = "1=0";
- this.dgvGroutingUser.DataSource = this._groutinguser;
- }
- if (sre.Status == Constant.ServiceResultStatus.Other)
- {
- if (sre.OtherStatus == -1)
- {
- MessageBox.Show(sre.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- }
- }
- 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 dgvGroutingLine_CurrentCellDirtyStateChanged(object sender, EventArgs e)
- {
- try
- {
- if (this.dgvGroutingLine.CurrentRow != null && this.dgvGroutingLine.IsCurrentCellDirty)
- {
- if ("sel".Equals(this.dgvGroutingLine.Columns
- [this.dgvGroutingLine.CurrentCell.ColumnIndex].Name))
- {
- this.dgvGroutingLine.CommitEdit(DataGridViewDataErrorContexts.Commit);
- }
- }
- }
- 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 dgvGroutingLine_CellValueChanged(object sender, DataGridViewCellEventArgs e)
- {
- try
- {
- if (e.RowIndex > -1)
- {
- DataGridViewRow dataGridViewRow = this.dgvGroutingLine.Rows[e.RowIndex];
- // 如果是选择了该成型线,则对未注浆原因进行控制输入
- if ("sel".Equals(this.dgvGroutingLine.Columns[e.ColumnIndex].Name))
- {
- // 选择了成型线
- if ("1" == dataGridViewRow.Cells["sel"].Value.ToString())
- {
- dataGridViewRow.Cells["NoGroutingRreason"].ReadOnly = true;
- dataGridViewRow.Cells["NoGroutingRreason"].Value = DBNull.Value;
- }
- else
- {
- dataGridViewRow.Cells["NoGroutingRreason"].ReadOnly = false;
- }
- }
- }
- }
- 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 dgvGroutingLine_Sorted(object sender, EventArgs e)
- {
- foreach (DataGridViewRow row in this.dgvGroutingLine.Rows)
- {
- // 未注浆,可以输入未注浆原因
- if ("1" == row.Cells["sel"].Value.ToString())
- {
- row.Cells["NoGroutingRreason"].Value = DBNull.Value;
- row.Cells["NoGroutingRreason"].ReadOnly = true;
- }
- else
- {
- row.Cells["NoGroutingRreason"].ReadOnly = false;
- }
- string canManyTimes = row.Cells["CanManyTimes"].Value.ToString();
- // 多次注浆
- if ("1" == canManyTimes)
- {
- row.Cells["GroutingNum"].ReadOnly = false;
- }
- else
- {
- row.Cells["GroutingNum"].ReadOnly = true;
- }
- }
- this.dgvGroutingLine.IsSetInputColumnsColor = true;
- }
- /// <summary>
- /// 确定按钮按下事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnOK_Click(object sender, System.EventArgs e)
- {
- try
- {
- this._groutinginfo = null;
- if (this.DataSource == null || this.DataSource.Tables.Count == 0)
- {
- DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_C_001);
- return;
- }
- this.DataSource.AcceptChanges();
- DataRow[] groutinginfo = this.DataSource.Tables[0].Select("SEL = 1 OR NoGroutingRreason IS NOT NULL");
- if (groutinginfo == null || groutinginfo.Length == 0)
- {
- this.dgvGroutingLine.IsSetInputColumnsColor = true;
- DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_C_001);
- return;
- }
- foreach (DataRow item in groutinginfo)
- {
- object userid = item["GroutingUserID"];
- if (userid == null || userid == DBNull.Value)
- {
- DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_C_006,
- string.Format("成型线【{0}】没有选择成型工号。", item["GroutingLineCode"]));
- return;
- }
- object num = item["GroutingNum"];
- if (num == null || num == DBNull.Value)
- {
- DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_C_006,
- string.Format("成型线【{0}】没有输入注浆次数。", item["GroutingLineCode"]));
- return;
- }
- }
- this._groutinginfo = groutinginfo;
- this.DialogResult = DialogResult.OK;
- this.Close();
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- finally
- {
- if (this._groutinginfo == null)
- {
- this.dgvGroutingLine_Sorted(null, null);
- }
- }
- }
- /// <summary>
- /// 关闭按钮按下事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnClose_Click(object sender, System.EventArgs e)
- {
- this.DialogResult = DialogResult.Cancel;
- this.Close();
- }
- /// <summary>
- /// 全选复选框状态改变事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void cbSelectAll_CheckedChanged(object sender, EventArgs e)
- {
- foreach (DataGridViewRow dataGridViewRow in this.dgvGroutingLine.Rows)
- {
- dataGridViewRow.Cells["sel"].Value = this.cbSelectAll.Checked ? 1 : 0;
- }
- }
- #endregion
- #region 私有方法/函数
- /// <summary>
- /// 初始化控件
- /// </summary>
- private void InitializeControls()
- {
- this.Text = FormTitles.F_PM_0104;
- this.btnSearch.Text = ButtonText.BTN_SEARCH;
- this.btnOK.Text = ButtonText.BTN_OK;
- this.btnCancel.Text = ButtonText.BTN_CANCEL;
- // 取客户端当天日期
- this.dtpGroutingDate.Value = DateTime.Now.Date;
- }
- #endregion
- private void dgvGroutingLine_SelectionChanged(object sender, EventArgs e)
- {
- try
- {
- if (this._groutinguser == null || this._groutinguser.Rows.Count == 0)
- {
- return;
- }
- DataGridViewRow dgvr = this.dgvGroutingLine.CurrentRow;
- if (dgvr == null)
- {
- this._groutinguser.DefaultView.RowFilter = "1=0";
- return;
- }
- int glid = System.Convert.ToInt32(dgvr.Cells["GroutingLineID"].Value);
- if (this._groutinglineid != glid)
- {
- // 成型工个数
- int uc = System.Convert.ToInt32(dgvr.Cells["UserCount"].Value);
- if (uc > 1)
- {
- this._groutinguser.DefaultView.RowFilter = "GroutingLineID = " + glid;
- }
- else
- {
- this._groutinguser.DefaultView.RowFilter = "1=0";
- }
- this._groutinglineid = glid;
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- private void dgvGroutingUser_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
- {
- try
- {
- if (e.ColumnIndex < 0 || e.RowIndex < 0)
- {
- return;
- }
- if (this._groutinguser == null || this._groutinguser.Rows.Count == 0)
- {
- return;
- }
- DataGridViewRow dgvrGL = this.dgvGroutingLine.CurrentRow;
- if (dgvrGL == null)
- {
- return;
- }
- DataGridViewRow dgvrGU = this.dgvGroutingUser.CurrentRow;
- if (dgvrGU == null)
- {
- return;
- }
- dgvrGL.Cells["GroutingUserID"].Value = dgvrGU.Cells["GUUserID"].Value;
- dgvrGL.Cells["GroutingUserCode"].Value = dgvrGU.Cells["GUUserCode"].Value;
- //DataRowView drv = dgvrGL.DataBoundItem as DataRowView;
- //if (drv != null)
- //{
- // drv.EndEdit();
- //}
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- private void btnAdaptive_Click(object sender, EventArgs e)
- {
- this.dgvGroutingLine.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
- this.dgvGroutingUser.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
- }
- private void btnClearCondition_Click(object sender, EventArgs e)
- {
- this.txtGroutingLineCode.Clear();
- this.txtUserCode.Clear();
- this.txtGroutingLineName.Clear();
- this.dtpGroutingDate.Value = DateTime.Now.Date;
- }
- }
- }
|