| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020 |
- /*******************************************************************************
- * 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());
- //xuwei add 2019-12-12
- if(dr1[0]["SemiGoodsLevel"]!=null)
- procedureEntity.SemiGoodsLevel = dr1[0]["SemiGoodsLevel"].ToString();
- //xuwei add 2020-01-02
- procedureEntity.IsGlazeChange = Convert.ToInt32(dr1[0]["isGlazeChange"].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
- }
- }
|