| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015 |
- /*******************************************************************************
- * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_PC_0201.cs
- * 2.功能描述:生产线配置一览界面
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 王鑫 2015/03/27 1.00 新建
- *******************************************************************************/
- using System;
- using System.Data;
- using System.Drawing;
- using System.Windows.Forms;
- using Dongke.IBOSS.Basics.FlowSetting;
- using Dongke.IBOSS.PRD.Basics.BaseResources;
- using Dongke.IBOSS.PRD.Basics.DockPanel;
- using Dongke.IBOSS.PRD.Basics.Library;
- using Dongke.IBOSS.PRD.Client.CommonModule;
- using Dongke.IBOSS.PRD.Client.DataModels;
- 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_0205 : DockPanelBase
- {
- #region 成员变量
- // 窗体的单例模式
- private static F_PC_0205 _instance;
- // 当前选择的行
- private int _selectedRowIndex;
- #endregion
- #region 构造
- /// <summary>
- /// 单例模式,防止重复创建窗体
- /// </summary>
- public static F_PC_0205 Instance
- {
- get
- {
- if (_instance == null)
- {
- _instance = new F_PC_0205();
- }
- return _instance;
- }
- }
- /// <summary>
- /// 构造
- /// </summary>
- public F_PC_0205()
- {
- InitializeComponent();
- // 设置控件显示名称
- this.SetFromTitleInfo();
- }
- #endregion
- #region 事件
- /// <summary>
- /// 关闭窗体
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void F_PC_0201_FormClosed(object sender, FormClosedEventArgs e)
- {
- _instance = null;
- }
- /// <summary>
- /// 页面加载
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void F_PC_0201_Load(object sender, EventArgs e)
- {
- try
- {
- // 绑定权限
- FormPermissionManager.FormPermissionControl(this.Name, this,
- LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
- this.dgvLine.AutoGenerateColumns = false;
- this.dgvProcedure.AutoGenerateColumns = false;
- // 绑定数据源
- this.SelValueFlag.DataSource = CreateDataSource.GetValueFlagTable();
- // 默认选中有效数据
- object[] checkValueFlags = new object[] { Constant.INT_IS_ONE };
- this.SelValueFlag.SelectedValues = checkValueFlags;
- }
- 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_0204 frmPC0204 = new F_PC_0204(Constant.FormMode.Add, 0, "", "", "", 1);
- DialogResult dialogResult = frmPC0204.ShowDialog();
- if (dialogResult.Equals(DialogResult.OK))
- {
- frmPC0204.Close();
- F_PC_0203 frmPC0203 = new F_PC_0203(Constant.FormMode.Edit, frmPC0204.LineID, frmPC0204.LineCode, frmPC0204.LineName, frmPC0204.Remarks, frmPC0204.ValueFlag);
- DialogResult dialogResult0203 = frmPC0203.ShowDialog();
- if (dialogResult0203.Equals(DialogResult.OK))
- {
- // 查询时先清空数据源
- this.dgvLine.DataSource = null;
- if (frmPC0203.IDList.Count == Constant.INT_IS_ZERO)
- {
- return;
- }
- int id = frmPC0203.IDList[0];
- DataSet resultData = (DataSet)DoAsync(() =>
- {
- return PCModuleProxy.Service.SearchProductionLine(
- new ProductionLineEntity() { ProductionLineID = id });
- });
- if (resultData != null && resultData.Tables.Count > Constant.INT_IS_ZERO)
- {
- this.dgvLine.DataSource = resultData.Tables[0];
- // 设置选中第一行
- if (this.dgvLine.RowCount > 0)
- {
- this._selectedRowIndex = Constant.INT_IS_ZERO;
- this.dgvLine.Rows[this._selectedRowIndex].Selected = 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
- {
- if (this.dgvLine.CurrentCell == null)
- {
- return;
- }
- int id = int.Parse(this.dgvLine.Rows[this.dgvLine.CurrentCell.RowIndex].Cells["ProductionLineID"].Value.ToString());
- string lineCode = this.dgvLine.Rows[this.dgvLine.CurrentCell.RowIndex].Cells["ProductionLineCode"].Value.ToString();
- string lineName = this.dgvLine.Rows[this.dgvLine.CurrentCell.RowIndex].Cells["ProductionLineName"].Value.ToString();
- string remarks = this.dgvLine.Rows[this.dgvLine.CurrentCell.RowIndex].Cells["Remarks"].Value.ToString();
- int valueflag = int.Parse(this.dgvLine.Rows[this.dgvLine.CurrentCell.RowIndex].Cells["ValueFlag"].Value.ToString());
- F_PC_0204 frmPC0204 = new F_PC_0204(Constant.FormMode.Edit, id, lineCode, lineName, remarks, valueflag);
- DialogResult dialogResult = frmPC0204.ShowDialog();
- if (dialogResult.Equals(DialogResult.OK))
- {
- frmPC0204.Close();
- // 查询时先清空数据源
- this.dgvLine.DataSource = null;
- ProductionLineEntity line = new ProductionLineEntity();
- line.ProductionLineID = id;
- DataSet result = (DataSet)DoAsync(() =>
- {
- return PCModuleProxy.Service.SearchProductionLine(line);
- });
- if (result != null && result.Tables.Count > Constant.INT_IS_ZERO)
- {
- this.dgvLine.DataSource = result.Tables[0];
- if (result.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
- {
- // 定位当前行
- if (this.dgvLine.Rows.Count > this._selectedRowIndex)
- {
- this.dgvLine.Rows[this._selectedRowIndex].Selected = true;
- this.dgvLine.CurrentCell =
- this.dgvLine.Rows[this._selectedRowIndex].Cells["ProductionLineCode"];
- }
- else if (this.dgvLine.Rows.Count <= this._selectedRowIndex)
- {
- this._selectedRowIndex = dgvLine.Rows.Count - 1;
- this.dgvLine.CurrentCell =
- this.dgvLine.Rows[this.dgvLine.Rows.Count - 1].Cells["ProductionLineCode"];
- this.dgvLine.Rows[dgvLine.Rows.Count - 1].Selected = true;
- }
- }
- else
- {
- // 清空明细中的数据
- this.dgvProcedure.DataSource = null;
- // 提示未查找到数据
- 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 btnSearch_Click(object sender, EventArgs e)
- {
- try
- {
- #region 没有选择正常标示
- if (this.SelValueFlag.SelectedValues.Length == Constant.INT_IS_ZERO)
- {
- // 清空数据
- this.dgvLine.DataSource = null;
- this.dgvProcedure.DataSource = null;
- // 设置按钮可用状态
- this.SetButtonStatus();
- // 提示未查找到数据
- MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
- MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- #endregion
- ProductionLineEntity line = new ProductionLineEntity();
- #region 赋值
- if (!string.IsNullOrEmpty(this.txtLineCode.Text.Trim()))
- {
- line.ProductionLineCode = this.txtLineCode.Text.Trim();
- }
- if (!string.IsNullOrEmpty(this.txtLineName.Text.Trim()))
- {
- line.ProductionLineName = this.txtLineName.Text.Trim();
- }
- if (!string.IsNullOrEmpty(this.txtRemarks.Text.Trim()))
- {
- line.Remarks = this.txtRemarks.Text;
- }
- line.ValueFlags = this.SelValueFlag.SelectedValues;
- #endregion
- DataSet result = (DataSet)DoAsync(() =>
- {
- return PCModuleProxy.Service.SearchProductionLine(line);
- });
- if (result != null && result.Tables.Count > Constant.INT_IS_ZERO)
- {
- // 控制明细不查询
- this.Tag = false;
- this.dgvLine.DataSource = result.Tables[0];
- if (result.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
- {
- // 定位当前行
- if (this.dgvLine.Rows.Count > this._selectedRowIndex)
- {
- this.dgvLine.Rows[this._selectedRowIndex].Selected = true;
- this.dgvLine.CurrentCell =
- this.dgvLine.Rows[this._selectedRowIndex].Cells["ProductionLineCode"];
- }
- else if (this.dgvLine.Rows.Count <= this._selectedRowIndex)
- {
- this._selectedRowIndex = dgvLine.Rows.Count - 1;
- this.dgvLine.CurrentCell =
- this.dgvLine.Rows[this.dgvLine.Rows.Count - 1].Cells["ProductionLineCode"];
- this.dgvLine.Rows[dgvLine.Rows.Count - 1].Selected = true;
- }
- this.Tag = true;
- // 查明细
- this.dgvLine_SelectionChanged(null, null);
- }
- else
- {
- // 清空明细中的数据
- this.dgvProcedure.DataSource = null;
- // 提示未查找到数据
- MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
- MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- }
- // 设置按钮可用状态
- this.SetButtonStatus();
- }
- 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 dgvLine_SelectionChanged(object sender, EventArgs e)
- {
- try
- {
- // 在绑定总表时 不查询明细
- if (!Convert.ToBoolean(this.Tag)
- || this.dgvLine.CurrentCell == null)
- {
- return;
- }
- // 选中行时查询明细
- else
- {
- if (this.txtLineCode.ReadOnly)
- {
- return;
- }
- ProductionLineEntity line = new ProductionLineEntity();
- line.ProductionLineID = Convert.ToInt32(
- this.dgvLine.Rows[_selectedRowIndex].Cells["ProductionLineID"].Value);
- DataSet result = (DataSet)DoAsync(() =>
- {
- return PCModuleProxy.Service.SearchProductionLine(line);
- });
-
- // 绑定明细数据
- if (result != null && result.Tables.Count >= Constant.INT_IS_TWO)
- {
- this.dgvProcedure.DataSource = result.Tables[1];
- this.dgvProcedure.CurrentCell = null;
- }
- }
- }
- 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 dgvLine_CellEnter(object sender, DataGridViewCellEventArgs e)
- {
- try
- {
- if (this.dgvLine.CurrentCell != null)
- {
- // 记录最后选择行
- this._selectedRowIndex = this.dgvLine.CurrentCell.RowIndex;
- // 设置工具条按钮可用状态
- this.SetButtonStatus();
- }
- }
- 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 tsbtnClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- /// <summary>
- /// 自适应列宽
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnAdaptive_Click(object sender, EventArgs e)
- {
- this.dgvLine.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
- this.dgvProcedure.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
- }
- /// <summary>
- /// 双击单元格编辑
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvLine_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
- {
- try
- {
- //if (this.dgvLine.CurrentCell != null)
- //{
- // if (this.tsbtnEdit.Enabled)
- // {
- // this.tsbtnEdit_Click(sender, e);
- // }
- //}
- }
- 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 tsbtnDisable_Click(object sender, EventArgs e)
- {
- try
- {
- if (this.dgvLine.CurrentCell != null)
- {
- DialogResult dialogResult
- = MessageBox.Show(string.Format(Messages.MSG_CMN_Q002, "生产线配置", "停用"),
- this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
- if (dialogResult.Equals(DialogResult.No))
- {
- return;
- }
- int id = Convert.ToInt32(
- this.dgvLine.Rows[this._selectedRowIndex].Cells["ProductionLineID"].Value);
- // 停用
- int result = (int)DoAsync(() =>
- {
- return PCModuleProxy.Service.StopProductionLine(id, 0);
- });
- if (result > Constant.INT_IS_ZERO)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "生产线配置", "停用"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
- // 刷新窗口数据
- this.btnSearch_Click(sender, e);
- }
- else if (result == (int)Constant.RETURN_IS_DATACHANGED)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W007, "执行操作的数据不是最新的,请关闭当前窗体,重新操作"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- else
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "生产线配置", "停用"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- }
- }
- 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 tsbtnBegin_Click(object sender, EventArgs e)
- {
- try
- {
- if (this.dgvLine.CurrentCell != null)
- {
- DialogResult dialogResult
- = MessageBox.Show(string.Format(Messages.MSG_CMN_Q002, "生产线配置", "启用"),
- this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
- if (dialogResult.Equals(DialogResult.No))
- {
- return;
- }
- int id = Convert.ToInt32(
- this.dgvLine.Rows[this._selectedRowIndex].Cells["ProductionLineID"].Value);
- // 启用
- int result = (int)DoAsync(() =>
- {
- return PCModuleProxy.Service.StopProductionLine(id, 1);
- });
- if (result > Constant.INT_IS_ZERO)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "生产线配置", "启用"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
- // 刷新窗口数据
- this.btnSearch_Click(sender, e);
- }
- else if (result == (int)Constant.RETURN_IS_DATACHANGED)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W007, "执行操作的数据不是最新的,请关闭当前窗体,重新操作"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- else
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "生产线配置", "启用"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- }
- }
- 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 tsbtnCopyAndNew_Click(object sender, EventArgs e)
- {
- if (this.dgvLine.CurrentCell == null)
- {
- return;
- }
- int id = int.Parse(this.dgvLine
- .Rows[this.dgvLine.CurrentCell.RowIndex].Cells["ProductionLineID"].Value.ToString());
- string lineCode = this.dgvLine.Rows[this.dgvLine.CurrentCell.RowIndex].Cells["ProductionLineCode"].Value.ToString();
- string lineName = this.dgvLine.Rows[this.dgvLine.CurrentCell.RowIndex].Cells["ProductionLineName"].Value.ToString();
- string remarks = this.dgvLine.Rows[this.dgvLine.CurrentCell.RowIndex].Cells["Remarks"].Value.ToString();
- int valueflag = int.Parse(this.dgvLine.Rows[this.dgvLine.CurrentCell.RowIndex].Cells["ValueFlag"].Value.ToString());
- F_PC_0204 frmPC0204 = new F_PC_0204(Constant.FormMode.CopyAndAdd, id, lineCode, lineName, remarks, valueflag);
- DialogResult dialogResult = frmPC0204.ShowDialog();
- if (dialogResult.Equals(DialogResult.OK))
- {
- frmPC0204.Close();
- F_PC_0203 frmPC0203 = new F_PC_0203(Constant.FormMode.CopyAndAdd, frmPC0204.LineID, frmPC0204.LineCode, frmPC0204.LineName, frmPC0204.Remarks, frmPC0204.ValueFlag);
- DialogResult dialogResult0203 = frmPC0203.ShowDialog();
- if (dialogResult0203.Equals(DialogResult.OK))
- {
- // 查询时先清空数据源
- this.dgvLine.DataSource = null;
- ProductionLineEntity line = new ProductionLineEntity();
- if (frmPC0203.IDList.Count > 0)
- {
- line.ProductionLineCode = frmPC0203.ProductionlineCode;
- }
- else
- {
- line.ProductionLineID = id;
- }
- DataSet result = (DataSet)DoAsync(() =>
- {
- return PCModuleProxy.Service.SearchProductionLine(line);
- });
- if (result != null && result.Tables.Count > Constant.INT_IS_ZERO)
- {
- this.dgvLine.DataSource = result.Tables[0];
- if (result.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
- {
- // 定位当前行
- if (this.dgvLine.Rows.Count > this._selectedRowIndex)
- {
- this.dgvLine.Rows[this._selectedRowIndex].Selected = true;
- this.dgvLine.CurrentCell =
- this.dgvLine.Rows[this._selectedRowIndex].Cells["ProductionLineCode"];
- }
- else if (this.dgvLine.Rows.Count <= this._selectedRowIndex)
- {
- this._selectedRowIndex = dgvLine.Rows.Count - 1;
- this.dgvLine.CurrentCell =
- this.dgvLine.Rows[this.dgvLine.Rows.Count - 1].Cells["ProductionLineCode"];
- this.dgvLine.Rows[dgvLine.Rows.Count - 1].Selected = true;
- }
- }
- else
- {
- // 清空明细中的数据
- this.dgvProcedure.DataSource = null;
- // 提示未查找到数据
- MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
- MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- }
- }
- }
- }
- /// <summary>
- /// 清空条件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnClearCondition_Click(object sender, EventArgs e)
- {
- this.txtLineCode.Text = "";
- this.txtRemarks.Text = "";
- this.txtLineName.Text = "";
- this.SelValueFlag.SelectedValues = new object[] { Constant.INT_IS_ONE };
- }
- /// <summary>
- /// 流程按钮事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnFlowSetting_Click(object sender, EventArgs e)
- {
- if (this.dgvLine.CurrentCell == null)
- {
- return;
- }
- int id = int.Parse(this.dgvLine
- .Rows[this.dgvLine.CurrentCell.RowIndex].Cells["ProductionLineID"].Value.ToString());
- int? nodeno = null;
- int? procedureid = null;
- if (this.dgvProcedure.CurrentCell != null)
- {
- nodeno = int.Parse(this.dgvProcedure
- .Rows[this.dgvProcedure.CurrentCell.RowIndex].Cells["nodeno"].Value.ToString());
- procedureid = int.Parse(this.dgvProcedure
- .Rows[this.dgvProcedure.CurrentCell.RowIndex].Cells["procedureid"].Value.ToString());
- }
- string lineCode = this.dgvLine.Rows[this.dgvLine.CurrentCell.RowIndex].Cells["ProductionLineCode"].Value.ToString();
- string lineName = this.dgvLine.Rows[this.dgvLine.CurrentCell.RowIndex].Cells["ProductionLineName"].Value.ToString();
- string remarks = this.dgvLine.Rows[this.dgvLine.CurrentCell.RowIndex].Cells["Remarks"].Value.ToString();
- int valueflag = int.Parse(this.dgvLine.Rows[this.dgvLine.CurrentCell.RowIndex].Cells["ValueFlag"].Value.ToString());
- //if (nodeno != null)
- //{
- // EditProcedure(Convert.ToInt32(nodeno), Convert.ToInt32(id), Convert.ToInt32(procedureid));
- //}
- //else
- //{
- F_PC_0203 frmPC0203 = new F_PC_0203(Constant.FormMode.Edit, id, lineCode, lineName, remarks, valueflag);
- DialogResult dialogResult0203 = frmPC0203.ShowDialog();
- if (dialogResult0203.Equals(DialogResult.OK))
- {
- // 查询时先清空数据源
- this.dgvLine.DataSource = null;
- ProductionLineEntity line = new ProductionLineEntity();
- line.ProductionLineID = id;
- DataSet result = (DataSet)DoAsync(() =>
- {
- return PCModuleProxy.Service.SearchProductionLine(line);
- });
- if (result != null && result.Tables.Count > Constant.INT_IS_ZERO)
- {
- this.dgvLine.DataSource = result.Tables[0];
- if (result.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
- {
- // 定位当前行
- if (this.dgvLine.Rows.Count > this._selectedRowIndex)
- {
- this.dgvLine.Rows[this._selectedRowIndex].Selected = true;
- this.dgvLine.CurrentCell =
- this.dgvLine.Rows[this._selectedRowIndex].Cells["ProductionLineCode"];
- }
- else if (this.dgvLine.Rows.Count <= this._selectedRowIndex)
- {
- this._selectedRowIndex = dgvLine.Rows.Count - 1;
- this.dgvLine.CurrentCell =
- this.dgvLine.Rows[this.dgvLine.Rows.Count - 1].Cells["ProductionLineCode"];
- this.dgvLine.Rows[dgvLine.Rows.Count - 1].Selected = true;
- }
- }
- else
- {
- // 清空明细中的数据
- this.dgvProcedure.DataSource = null;
- // 提示未查找到数据
- MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
- MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- }
- // }
- }
- }
- /// <summary>
- /// 工序单元格双击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvProcedure_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
- {
- try
- {
- int ProductionLineID = int.Parse(this.dgvLine
- .Rows[this.dgvLine.CurrentCell.RowIndex].Cells["ProductionLineID"].Value.ToString());
- int? nodeno = null;
- int? procedureid = null;
- int? productionlineid = null;
- if (this.dgvProcedure.CurrentCell != null)
- {
- nodeno = int.Parse(this.dgvProcedure
- .Rows[this.dgvProcedure.CurrentCell.RowIndex].Cells["nodeno"].Value.ToString());
- procedureid = int.Parse(this.dgvProcedure
- .Rows[this.dgvProcedure.CurrentCell.RowIndex].Cells["procedureid"].Value.ToString());
- productionlineid = int.Parse(this.dgvProcedure
- .Rows[this.dgvProcedure.CurrentCell.RowIndex].Cells["procedurelineid"].Value.ToString());
- }
- EditProcedure(Convert.ToInt32(nodeno), Convert.ToInt32(productionlineid), Convert.ToInt32(procedureid));
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- #endregion
- #region 私有方法
- /// <summary>
- /// 设置按钮可用状态
- /// </summary>
- private void SetButtonStatus()
- {
- if (this.dgvLine.CurrentCell != null)
- {
- int valueFlag = Convert.ToInt32(
- this.dgvLine.Rows[this._selectedRowIndex].Cells["ValueFlag"].Value);
- this.tsbtnCopyAndNew.Enabled = true;
- this.tsbtnFlowSetting.Enabled = true;
- if (valueFlag == Constant.INT_IS_ZERO)
- {
- this.tsbtnEdit.Enabled = false;
- this.tsbtnDisable.Enabled = false;
- this.tsbtnBegin.Enabled = !this.tsbtnDisable.Enabled;
- this.tsbtnFlowSetting.Enabled = false;
- }
- else
- {
- this.tsbtnEdit.Enabled = true;
- this.tsbtnDisable.Enabled = true;
- this.tsbtnBegin.Enabled = !this.tsbtnDisable.Enabled;
- this.tsbtnFlowSetting.Enabled = true;
- }
- }
- else
- {
- this.tsbtnCopyAndNew.Enabled = false;
- this.tsbtnFlowSetting.Enabled = false;
- }
- }
- /// <summary>
- /// 设置窗体按钮的文本信息
- /// </summary>
- private void SetFromTitleInfo()
- {
- // 窗体标题
- this.Text = FormTitles.F_PC_0201;
- // 按钮名称
- this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
- this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
- this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
- this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
- this.tsbtnDisable.Text = ButtonText.TSBTN_DISABLE;
- this.btnSearch.Text = ButtonText.BTN_SEARCH;
- this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
- }
- /// <summary>
- /// 编辑单个工序方法
- /// </summary>
- /// <param name="nodeno"></param>
- /// <param name="procedurelineid"></param>
- /// <param name="procedureid"></param>
- private void EditProcedure(int nodeno, int procedurelineid, int procedureid)
- {
- IBOSS.Basics.FlowSetting.FlowBox flowBox = new FlowBox();
- DataSet dsProductionDataSet = PCModuleProxy.Service.GetProductionLineDetail(procedurelineid);
- // 加载生产线信息
- DataTable lineTable = dsProductionDataSet.Tables["lineTable"];
- // 画图
- if (lineTable != null && lineTable.Rows.Count > 0)
- {
- flowBox.LoadFlow((byte[])(lineTable.Rows[0]["FlowXML"]));
- //this.OPTimeStamp = Convert.ToDateTime(lineTable.Rows[0]["OPTimeStamp"]);
- }
- // 加载工序信息
- DataRow[] dr1 = dsProductionDataSet.Tables["procedureTable"].Select("nodeno=" + nodeno);
- FlowNode node = null;
- foreach (FlowNode n in flowBox.AllNodes)
- {
- if (n.ItemID == nodeno)
- {
- node = n;
- break;
- }
- }
- if (dr1.Length > 0)
- {
- node.NodeImageType = Convert.ToInt32(dr1[0]["ProcedureModel"]);//工序模型为了给双击事件弹出对应的窗体
- //this.OPTimeStamp = Convert.ToDateTime(dr1[0]["OPTimeStamp"]);
- }
- if (dr1.Length > 0)
- {
- node.NodeImageType = Convert.ToInt32(dr1[0]["ProcedureModel"]);//工序模型为了给双击事件弹出对应的窗体
- }
- if (node.NodeImageType == 1)
- {
- if (Convert.ToInt32(dr1[0]["modeltype"]) == Constant.ProcedureModelType.IntoKiln.GetHashCode())
- {
- node.NodeImage = new Bitmap(this.GetType(), "images.入窑64-01.png");
- }
- else if (Convert.ToInt32(dr1[0]["modeltype"]) == Constant.ProcedureModelType.LoadCar.GetHashCode())
- {
- node.NodeImage = new Bitmap(this.GetType(), "images.装车64-01.png");
- }
- else if (Convert.ToInt32(dr1[0]["modeltype"]) == Constant.ProcedureModelType.UnloadCar.GetHashCode())
- {
- node.NodeImage = new Bitmap(this.GetType(), "images.卸车64-01.png");
- }
- else
- {
- node.NodeImage = new Bitmap(this.GetType(), "images.newflow.png");
- }
- }
- else
- {
- node.NodeImage = new Bitmap(this.GetType(), "images.newflowcheck.png");
- }
- if (Convert.ToInt32(dr1[0]["MustFlag"].ToString()) == 1)
- {
- node.CanSkip = true;
- }
- else
- {
- node.CanSkip = false;
- }
- node.Code = dr1[0]["ProcedureCode"].ToString();
- node.Name = dr1[0]["ProcedureName"].ToString();
- node.Remark = dr1[0]["Remarks"].ToString();
- ProcedureEntity procedureEntity = new ProcedureEntity();//工序
- procedureEntity.ProcedureID = Convert.ToInt32(dr1[0]["ProcedureID"].ToString());
- procedureEntity.ProcedureCode = dr1[0]["ProcedureCode"].ToString();
- procedureEntity.ProcedureName = dr1[0]["ProcedureName"].ToString();
- procedureEntity.ProcedureModel = Convert.ToInt32(dr1[0]["ProcedureModel"].ToString());
- procedureEntity.ModelType = Convert.ToInt32(dr1[0]["modeltype"].ToString());
- procedureEntity.NodeType = Convert.ToInt32(dr1[0]["nodetype"].ToString());
- procedureEntity.MustFlag = Convert.ToInt32(dr1[0]["MustFlag"].ToString());
- procedureEntity.CollectType = Convert.ToInt32(dr1[0]["CollectType"].ToString());
- procedureEntity.PieceType = Convert.ToInt32(dr1[0]["PieceType"].ToString());
- procedureEntity.IsSpecialRework = Convert.ToInt32(dr1[0]["isspecialrework"].ToString());
- //xuwei add 2019-10-14
- procedureEntity.IsSemireWork = Convert.ToInt32(dr1[0]["isSemireWork"].ToString());
- procedureEntity.OrganizationID = Convert.ToInt32(dr1[0]["OrganizationID"].ToString());
- procedureEntity.Remarks = dr1[0]["Remarks"].ToString();
- procedureEntity.NodeNo = Convert.ToInt32(dr1[0]["NodeNo"]);
- procedureEntity.ProductionLineID = Convert.ToInt32(dr1[0]["ProductionLineID"]);
- procedureEntity.OPTimeStamp = Convert.ToDateTime(dr1[0]["OPTimeStamp"]);
- procedureEntity.MissPriority = Convert.ToInt32(dr1[0]["misspriority"]);
- procedureEntity.DisplayNo = Convert.ToInt32(dr1[0]["DisplayNo"]);
- procedureEntity.UnDo = Convert.ToInt32(dr1[0]["UnDoFlag"]);
- procedureEntity.DeliverType = Convert.ToInt32(dr1[0]["DeliverType"]);
- procedureEntity.BarCodePrintCopies = Convert.ToInt32(dr1[0]["BarCodePrintCopies"]);
- procedureEntity.BarCodeFlag = Convert.ToInt32(dr1[0]["BarCodeFlag"]);
- //if (dr1[0]["LogoID"] != DBNull.Value)
- //{
- // procedureEntity.LogoID = Convert.ToInt32(dr1[0]["LogoID"]);
- //}
- // 对应产品信息
- DataRow[] goodsRows = dsProductionDataSet.Tables["procedureGoodsTable"].Select("NodeNo =" + nodeno);
- if (goodsRows != null && goodsRows.Length > 0)
- {
- procedureEntity.ProcedureGoodsTable = goodsRows.CopyToDataTable();
- procedureEntity.ProcedureGoodsTable.TableName = "procedureGoodsTable";
- }
- else
- {
- procedureEntity.ProcedureGoodsTable = dsProductionDataSet.Tables["procedureGoodsTable"].Clone();
- }
- // 工序对应工号表
- DataRow[] userRows = dsProductionDataSet.Tables["procedureUserTable"].Select("NodeNo =" + nodeno);
- if (userRows != null && userRows.Length > 0)
- {
- procedureEntity.ProcedureUserTable = userRows.CopyToDataTable();
- procedureEntity.ProcedureUserTable.TableName = "procedureUserTable";
- }
- else
- {
- procedureEntity.ProcedureUserTable = dsProductionDataSet.Tables["procedureUserTable"].Clone();
- }
- // 工序对应缺陷表(在检验工序中能检验出来的缺陷。)
- DataRow[] defectRows = dsProductionDataSet.Tables["procedureDefectTable"].Select("NodeNo =" + nodeno);
- if (defectRows != null && defectRows.Length > 0)
- {
- procedureEntity.ProcedureDefectTable = defectRows.CopyToDataTable();
- procedureEntity.ProcedureDefectTable.TableName = "procedureDefectTable";
- }
- else
- {
- procedureEntity.ProcedureDefectTable = dsProductionDataSet.Tables["procedureDefectTable"].Clone();
- }
- // 生产工序对应缺陷表
- DataRow[] defectProcedureJobsRows = dsProductionDataSet.Tables["defectProcedureJobsTable"].Select("NodeNo =" + nodeno);
- if (defectProcedureJobsRows != null && defectProcedureJobsRows.Length > 0)
- {
- procedureEntity.DefectProcedureJobsTable = defectProcedureJobsRows.CopyToDataTable();
- procedureEntity.DefectProcedureJobsTable.TableName = "defectProcedureJobsTable";
- }
- else
- {
- procedureEntity.DefectProcedureJobsTable = dsProductionDataSet.Tables["defectProcedureJobsTable"].Clone();
- }
- // 工序对应窑炉
- DataRow[] kilnRows = dsProductionDataSet.Tables["procedureKilnTable"].Select("NodeNo =" + nodeno);
- if (kilnRows != null && kilnRows.Length > 0)
- {
- procedureEntity.ProcedureKilnTable = kilnRows.CopyToDataTable();
- procedureEntity.ProcedureKilnTable.TableName = "procedureKilnTable";
- }
- else
- {
- procedureEntity.ProcedureKilnTable = dsProductionDataSet.Tables["procedureKilnTable"].Clone();
- }
- node.TagNonSerialized = procedureEntity;
- ProductionLineEntity line = new ProductionLineEntity();
- line.ProductionLineID = procedureEntity.ProductionLineID;
- if (node.NodeImageType == 2)
- {
- F_PC_0206 frm0206 = new F_PC_0206(node, flowBox, true);
- frm0206.ShowDialog();
- if (frm0206.DialogResult == DialogResult.OK)
- {
- flowBox.SaveFlow();
- DataSet result = (DataSet)DoAsync(() =>
- {
- return PCModuleProxy.Service.SearchProductionLine(line);
- });
- // 绑定明细数据
- if (result != null && result.Tables.Count >= Constant.INT_IS_TWO)
- {
- this.dgvProcedure.DataSource = result.Tables[1];
- this.dgvProcedure.CurrentCell = null;
- }
- }
- }
- else
- {
- F_PC_0207 frm0207 = new F_PC_0207(node, flowBox, true);
- frm0207.ShowDialog();
- if (frm0207.DialogResult == DialogResult.OK)
- {
- flowBox.SaveFlow();
- DataSet result = (DataSet)DoAsync(() =>
- {
- return PCModuleProxy.Service.SearchProductionLine(line);
- });
- // 绑定明细数据
- if (result != null && result.Tables.Count >= Constant.INT_IS_TWO)
- {
- this.dgvProcedure.DataSource = result.Tables[1];
- this.dgvProcedure.CurrentCell = null;
- }
- }
- }
- }
- #endregion
- }
- }
|