/*******************************************************************************
* 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
{
///
/// 生产线配置一览界面
///
public partial class F_PC_0205 : DockPanelBase
{
#region 成员变量
// 窗体的单例模式
private static F_PC_0205 _instance;
// 当前选择的行
private int _selectedRowIndex;
#endregion
#region 构造
///
/// 单例模式,防止重复创建窗体
///
public static F_PC_0205 Instance
{
get
{
if (_instance == null)
{
_instance = new F_PC_0205();
}
return _instance;
}
}
///
/// 构造
///
public F_PC_0205()
{
InitializeComponent();
// 设置控件显示名称
this.SetFromTitleInfo();
}
#endregion
#region 事件
///
/// 关闭窗体
///
///
///
private void F_PC_0201_FormClosed(object sender, FormClosedEventArgs e)
{
_instance = null;
}
///
/// 页面加载
///
///
///
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);
}
}
///
/// 新建
///
///
///
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);
}
}
/*注释掉编辑,原因:变更流程的属性修改不能在工序编辑画面直接修改,要打开流程图。20210302
///
/// 编辑
///
///
///
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);
}
}
*/
///
/// 查询
///
///
///
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);
}
}
///
/// 行选中事件
///
///
///
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);
}
}
///
/// 单元格选中
///
///
///
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);
}
}
///
/// 关闭窗体
///
///
///
private void tsbtnClose_Click(object sender, EventArgs e)
{
this.Close();
}
///
/// 自适应列宽
///
///
///
private void tsbtnAdaptive_Click(object sender, EventArgs e)
{
this.dgvLine.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
this.dgvProcedure.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
}
///
/// 双击单元格编辑
///
///
///
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);
}
}
///
/// 停用
///
///
///
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);
}
}
///
/// 启用
///
///
///
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);
}
}
///
/// 复制并新建
///
///
///
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);
}
}
}
}
}
///
/// 清空条件
///
///
///
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 };
}
///
/// 流程按钮事件
///
///
///
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);
}
}
// }
}
}
///
/// 工序单元格双击事件
///
///
///
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 私有方法
///
/// 设置按钮可用状态
///
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;
}
}
///
/// 设置窗体按钮的文本信息
///
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;
}
///
/// 编辑单个工序方法
///
///
///
///
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.ShortName = dr1[0]["P_Name"].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.PName = dr1[0]["P_Name"].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"]);
procedureEntity.PrintType = Convert.ToInt32(dr1[0]["PrintType"]);
//成检工序 add xiacm 2022-10-12
if(!string.IsNullOrEmpty(dr1[0]["FinishedCheckProcedureID"] + ""))
{
procedureEntity.FinishedCheckProcedureID = Convert.ToInt32(dr1[0]["FinishedCheckProcedureID"]);
}
else
{
procedureEntity.FinishedCheckProcedureID = -1;
}
//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();
}
// 成检工序 add xiacm 2022-10-12
DataRow[] drfin = dsProductionDataSet.Tables["procedureTable"].Select("PROCEDUREID IN(12, 59, 105)");
procedureEntity.FinishedCheckProcedureTable = drfin.CopyToDataTable();
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
}
}