| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597 |
- /*******************************************************************************
- * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_PC_0104.cs
- * 2.功能描述:成型线管理
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 庄天威 2014/09/28 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.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.PCModuleService;
- namespace Dongke.IBOSS.PRD.Client.PCModule
- {
- /// <summary>
- /// 成型线管理
- /// </summary>
- public partial class F_PC_0104 : DockPanelBase
- {
- #region 成员变量
- // 单例模式使用
- private static F_PC_0104 _instance;
- // 成型线集合
- private List<GroutingLineEntity> _groutingLineList = new List<GroutingLineEntity>();
- //选择的成型线状态
- private int? _mouldStatus;
- #endregion
- #region 构造函数
- /// <summary>
- /// 构造函数
- /// </summary>
- public F_PC_0104()
- {
- InitializeComponent();
- // 为控件名赋值
- this.btnSearch.Text = ButtonText.BTN_SEARCH;
- this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
- this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
- this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
- this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
- this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
- this.tsbtnQueryRecord.Text = ButtonText.TSBTN_QUERYRECORD;
- this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
- this.Text = FormTitles.F_PC_0104;
- }
- #endregion
- #region 单例模式
- /// <summary>
- /// 单例模式,防止重复创建窗体
- /// </summary>
- public static F_PC_0104 Instance
- {
- get
- {
- if (_instance == null)
- {
- _instance = new F_PC_0104();
- }
- return _instance;
- }
- }
- #endregion
- #region 事件处理
- /// <summary>
- /// 页面加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void F_PC_0104_Load(object sender, System.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);
- // 为成型线绑定数据源
- this.BindMouldType();
- // 设置日期控件不可用
- this.SetBeginTimePickerEnable(false);
- this.SetEndTimePickerEnable(false);
- this.chkValueFlag.AllItemCheck();
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 自动列宽按钮按下处理
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnAdaptive_Click(object sender, EventArgs e)
- {
- this.dgvGroutingLine.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
- this.dgvGroutingLineDetail.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
- }
- /// <summary>
- /// 开始日期条件选中状态改变处理事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void cbStartTime_CheckedChanged(object sender, EventArgs e)
- {
- this.SetBeginTimePickerEnable(this.cbStartTime.Checked);
- }
- /// <summary>
- /// 结束日期条件选中状态改变处理事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void cbEndTime_CheckedChanged(object sender, EventArgs e)
- {
- this.SetEndTimePickerEnable(this.cbEndTime.Checked);
- }
- /// <summary>
- /// 查询按钮按下处理
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnSearch_Click(object sender, EventArgs e)
- {
- try
- {
- this.dgvGroutingLine.DataSource = null;
- this.dgvGroutingLineDetail.DataSource = null;
- this._mouldStatus = this.lstcbxGMouldStatus.SelectedValue == null
- ? null : (int?)Convert.ToInt32(this.lstcbxGMouldStatus.SelectedValue);
- DataSet dsGroutingLine = (DataSet)DoAsync(new Dongke.IBOSS.PRD.Basics.DockPanel.AsyncMethod(() =>
- {
- return GetGroutingLine();
- }));
- if (dsGroutingLine != null)
- {
- this.DataTableToListByLine(dsGroutingLine);
- if (dsGroutingLine.Tables.Count != Constant.INT_IS_ZERO)
- {
- this.dgvGroutingLine.DataSource = ((DataSet)dsGroutingLine).Tables[0];
- this.dgvGroutingLine.ReadOnly = true;
- if (this.dgvGroutingLine.Rows.Count == Constant.INT_IS_ZERO)
- {
- // 提示未查找到数据
- MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
- MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- }
- this.dgvGroutingLineDetail.DataSource = null;
- }
- else
- {
- // 提示未查找到数据
- 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);
- }
- }
- /// <summary>
- /// 清空查询条件处理
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnClearCondition_Click(object sender, EventArgs e)
- {
- this.txtBuildingNo.Text = "";
- this.txtFloorNo.Text = "";
- this.txtGroutingLineNo.Text = "";
- this.lstcbxGMouldStatus.Text = "";
- this.lstcbxGMouldStatus.SelectedValue = "";
- this.txtGroutingLineCode.Text = "";
- this.txtGroutingLineName.Text = "";
- this.cbStartTime.Checked = false;
- this.cbEndTime.Checked = false;
- this.txtBeginUsedDateStart.Enabled = false;
- this.txtBeginUsedDateEnd.Enabled = false;
- this.txtEndUsedDateStart.Enabled = false;
- this.txtEndUsedDateEnd.Enabled = false;
- this.txtRemarks.Text = "";
- this.txtGroutingUserCode.Text = "";
- this.chkValueFlag.AllItemCheck();
- }
- /// <summary>
- /// 窗体关闭事件处理
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnClose_Click(object sender, System.EventArgs e)
- {
- this.Close();
- }
- /// <summary>
- /// 窗体关闭后,释放单例模式
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void F_PC_0104_FormClosed(object sender, System.Windows.Forms.FormClosedEventArgs e)
- {
- _instance = null;
- }
- /// <summary>
- /// 双击某成型线进行编辑
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvGroutingLine_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
- {
- try
- {
- if (e.RowIndex == -Constant.INT_IS_ONE || e.ColumnIndex == -Constant.INT_IS_ONE)
- {
- return;
- }
- DataGridViewRow currentRow = this.dgvGroutingLine.CurrentRow;
- int GroutingLineId = Convert.ToInt32(currentRow.Cells["GroutingLineId"].Value);
- F_PC_0103 frmFPC0103 = new F_PC_0103(GroutingLineId);
- DialogResult dialogresult = frmFPC0103.ShowDialog();
- if (dialogresult.Equals(DialogResult.OK))
- {
- this.dgvGroutingLine.DataSource = null;
- object obResult = DoAsync(new Dongke.IBOSS.PRD.Basics.DockPanel.AsyncMethod(GetGroutingLine));
- if (obResult != null)
- {
- DataSet dsGroutingLine = (DataSet)obResult;
- if (dsGroutingLine.Tables.Count != Constant.INT_IS_ZERO)
- {
- this.dgvGroutingLine.DataSource = dsGroutingLine.Tables[0];
- this.dgvGroutingLine.ReadOnly = true;
- }
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 添加新成型线
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnAdd_Click(object sender, EventArgs e)
- {
- try
- {
- F_PC_0102 frmFPC0102 = new F_PC_0102();
- DialogResult dialogresult = frmFPC0102.ShowDialog();
- if (dialogresult.Equals(DialogResult.OK))
- {
- this.dgvGroutingLine.DataSource = null;
- DataSet dsGroutingLine = (DataSet)DoAsync(new Dongke.IBOSS.PRD.Basics.DockPanel.AsyncMethod(() =>
- {
- return GetGroutingLine();
- }));
- if (dsGroutingLine != null)
- {
- if (dsGroutingLine.Tables.Count != Constant.INT_IS_ZERO)
- {
- this.dgvGroutingLine.DataSource = ((DataSet)dsGroutingLine).Tables[0];
- this.dgvGroutingLine.ReadOnly = true;
- }
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 编辑选中成型线
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnEdit_Click(object sender, EventArgs e)
- {
- try
- {
- DataGridViewRow currentRow = this.dgvGroutingLine.CurrentRow;
- if (currentRow != null)
- {
- int GroutingLineId = Convert.ToInt32(currentRow.Cells["GroutingLineId"].Value);
- F_PC_0103 frmFPC0103 = new F_PC_0103(GroutingLineId);
- DialogResult dialogresult = frmFPC0103.ShowDialog();
- if (dialogresult.Equals(DialogResult.OK))
- {
- this.dgvGroutingLine.DataSource = null;
- object obResult = DoAsync(new Dongke.IBOSS.PRD.Basics.DockPanel.AsyncMethod(GetGroutingLine));
- if (obResult != null)
- {
- DataSet dsGroutingLine = (DataSet)obResult;
- if (dsGroutingLine.Tables.Count != Constant.INT_IS_ZERO)
- {
- this.dgvGroutingLine.DataSource = dsGroutingLine.Tables[0];
- this.dgvGroutingLine.ReadOnly = true;
- }
- }
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 选择某成型线查看模具明细
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvGroutingLine_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
- {
- try
- {
- if (e.RowIndex == -Constant.INT_IS_ONE || e.ColumnIndex == -Constant.INT_IS_ONE)
- {
- return;
- }
- int GroutingLineID = Convert.ToInt32(this.dgvGroutingLine.Rows[e.RowIndex].Cells["GroutingLineID"].Value);
- this.BindDetailInfo(GroutingLineID);
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 打开履历查询界面
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnQueryRecord_Click(object sender, EventArgs e)
- {
- try
- {
- F_PC_0105 frmFPC0105 = new F_PC_0105();
- DialogResult dialogresult = frmFPC0105.ShowDialog();
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 成型线列头点击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvGroutingLine_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
- {
- try
- {
- if (this.dgvGroutingLine.SelectedRows.Count != Constant.INT_IS_ZERO)
- {
- int GroutingLineID = Convert.ToInt32(this.dgvGroutingLine.SelectedRows[0].Cells["GroutingLineID"].Value);
- this.BindDetailInfo(GroutingLineID);
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- #endregion
- #region 私有方法
- /// <summary>
- /// 为页面的成型线类型绑定数据源
- /// </summary>
- private void BindMouldType()
- {
- try
- {
- DataTable dtDataSourse = new DataTable();
- dtDataSourse.Columns.Add("GMouldType", System.Type.GetType("System.String"));
- dtDataSourse.Columns.Add("GMouldTypeName", System.Type.GetType("System.String"));
- for (int i = 0; i < Constant.ConGMouldStatusCount; i++)
- {
- DataRow drRow = dtDataSourse.NewRow();
- drRow["GMouldType"] = Constant.ConGMouldStatus[i, 0];
- drRow["GMouldTypeName"] = Constant.ConGMouldStatus[i, 1];
- dtDataSourse.Rows.Add(drRow);
- }
- this.lstcbxGMouldStatus.ListBox.DisplayMember = "GMouldTypeName";
- this.lstcbxGMouldStatus.ListBox.ValueMember = "GMouldType";
- this.lstcbxGMouldStatus.ListBox.DataSource = dtDataSourse;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 设置开始使用时间可用状态
- /// </summary>
- /// <param name="isEnable">
- /// false:不可用
- /// true:可用
- /// </param>
- private void SetBeginTimePickerEnable(bool isEnable)
- {
- this.txtBeginUsedDateStart.Enabled = isEnable;
- this.txtBeginUsedDateEnd.Enabled = isEnable;
- }
- /// <summary>
- /// 设置结束使用时间可用状态
- /// </summary>
- /// <param name="isEnable">
- /// false:不可用
- /// true:可用
- /// </param>
- private void SetEndTimePickerEnable(bool isEnable)
- {
- this.txtEndUsedDateStart.Enabled = isEnable;
- this.txtEndUsedDateEnd.Enabled = isEnable;
- }
- /// <summary>
- /// 根据条件取得成型线数据
- /// </summary>
- /// <returns></returns>
- private DataSet GetGroutingLine()
- {
- try
- {
- this.dgvGroutingLine.AutoGenerateColumns = false;
- GroutingLineEntity groutingLineEntity = new GroutingLineEntity();
- groutingLineEntity.VALUEFLAG = null;
- groutingLineEntity.BUILDINGNO = this.txtBuildingNo.Text.Trim();
- groutingLineEntity.FLOORNO = this.txtFloorNo.Text.Trim();
- groutingLineEntity.GROUTINGLINENO = this.txtGroutingLineNo.Text.Trim();
- if (_mouldStatus != null)
- {
- groutingLineEntity.MouldStatus = _mouldStatus;
- }
- groutingLineEntity.GROUTINGLINECODE = this.txtGroutingLineCode.Text.Trim();
- groutingLineEntity.GROUTINGLINENAME = this.txtGroutingLineName.Text.Trim();
- if (this.cbStartTime.Checked)
- {
- groutingLineEntity.BEGINUSEDDATE = Convert.ToDateTime(this.txtBeginUsedDateStart.Text.Trim());
- groutingLineEntity.BEGINUSEDDATEEND = Convert.ToDateTime(this.txtBeginUsedDateEnd.Text.Trim()).AddHours(23)
- .AddMinutes(59).AddSeconds(59);
- }
- if (this.cbEndTime.Checked)
- {
- groutingLineEntity.ENDUSEDDATE = Convert.ToDateTime(this.txtEndUsedDateStart.Text.Trim());
- groutingLineEntity.ENDUSEDDATEEND = Convert.ToDateTime(this.txtEndUsedDateEnd.Text.Trim()).AddHours(23)
- .AddMinutes(59).AddSeconds(59);
- }
- groutingLineEntity.REMARKS = this.txtRemarks.Text.Trim();
- if (this.mtType.MouldTypeID != null)
- {
- groutingLineEntity.MOULDTYPEID = this.mtType.MouldTypeID;
- }
- object[] objListValue = chkValueFlag.SelectedValues;
- if (objListValue.Length == Constant.INT_IS_ONE)
- {
- groutingLineEntity.VALUEFLAG = (int)objListValue[0];
- }
- else if (objListValue.Length == Constant.INT_IS_ZERO)
- {
- return null;
- }
- groutingLineEntity.USERCODE = this.txtGroutingUserCode.Text.Trim();
- return PCModuleProxy.Service.GetGroutingLine(groutingLineEntity);
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 将成型线DataSet数据集转入集合中
- /// </summary>
- /// <param name="dsLine"></param>
- private void DataTableToListByLine(DataSet dsLine)
- {
- try
- {
- this._groutingLineList.Clear();
- foreach (DataRow drFor in dsLine.Tables[0].Rows)
- {
- GroutingLineEntity lineEntity = new GroutingLineEntity();
- lineEntity.GROUTINGLINEID = Convert.ToInt32(drFor["GROUTINGLINEID"]);
- lineEntity.BUILDINGNO = drFor["BUILDINGNO"].ToString();
- lineEntity.FLOORNO = drFor["FLOORNO"].ToString();
- lineEntity.GROUTINGLINENO = drFor["GROUTINGLINENO"].ToString();
- lineEntity.GROUTINGLINECODE = drFor["GROUTINGLINECODE"].ToString();
- lineEntity.GROUTINGLINENAME = drFor["GROUTINGLINENAME"].ToString();
- lineEntity.MOULDQUANTITY = Convert.ToDecimal(drFor["MOULDQUANTITY"]);
- lineEntity.MOULDTYPEID = Convert.ToInt32(drFor["GMOULDTYPEID"]);
- lineEntity.USERID = Convert.ToInt32(drFor["USERID"]);
- lineEntity.BEGINUSEDDATE = Convert.ToDateTime(drFor["BEGINUSEDDATE"]);
- if (drFor["ENDUSEDDATE"].ToString() != string.Empty)
- {
- lineEntity.ENDUSEDDATE = Convert.ToDateTime(drFor["ENDUSEDDATE"].ToString());
- }
- lineEntity.MouldStatus = Convert.ToInt32(drFor["GMouldStatus"]);
- lineEntity.REMARKS = drFor["REMARKS"].ToString();
- lineEntity.ACCOUNTID = Convert.ToInt32(drFor["ACCOUNTID"]);
- lineEntity.VALUEFLAG = Convert.ToInt32(drFor["VALUEFLAG"]);
- lineEntity.CREATETIME = Convert.ToDateTime(drFor["CREATETIME"]);
- lineEntity.CREATEUSERID = Convert.ToInt32(drFor["CREATEUSERID"]);
- lineEntity.UPDATETIME = Convert.ToDateTime(drFor["UPDATETIME"]);
- lineEntity.UPDATEUSERID = Convert.ToInt32(drFor["UPDATEUSERID"]);
- lineEntity.OPTIMESTAMP = Convert.ToDateTime(drFor["OPTIMESTAMP"]);
- lineEntity.MOULDTYPENAME = drFor["GMOULDTYPENAME"].ToString();
- this._groutingLineList.Add(lineEntity);
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 根据成型线ID获取明细信息
- /// </summary>
- private void BindDetailInfo(int GroutingLineID)
- {
- try
- {
- this.dgvGroutingLineDetail.AutoGenerateColumns = false;
- DataSet dsDetail = (DataSet)DoAsync(new Dongke.IBOSS.PRD.Basics.DockPanel.AsyncMethod(() =>
- {
- return PCModuleProxy.Service.GetGroutingLineDetailByMainId(GroutingLineID, null, 0);
- }));
- this.dgvGroutingLineDetail.DataSource = dsDetail.Tables[0];
- this.dgvGroutingLineDetail.ReadOnly = true;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- #endregion
- }
- }
|