|
|
using Newtonsoft.Json;
|
|
|
using RS.BLL;
|
|
|
using RS.Common;
|
|
|
using RS.Model;
|
|
|
using Sunny.UI;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.ComponentModel;
|
|
|
using System.Data;
|
|
|
using System.Drawing;
|
|
|
using System.IO;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
using System.Windows.Forms;
|
|
|
using MorClient.UserControls;
|
|
|
using MorClient.UserFrmFrame;
|
|
|
using Module.Plc.ModbusTcp.Tool;
|
|
|
using RS.Module.Common;
|
|
|
|
|
|
namespace MorClient
|
|
|
{
|
|
|
public partial class FormulaUnit : UserControl
|
|
|
{
|
|
|
DataTable dtResult = null;
|
|
|
DataGridViewHandle gridHdl = new DataGridViewHandle();
|
|
|
BRecipeWoekManage bRecipeWoekManage = new BRecipeWoekManage();
|
|
|
|
|
|
//当前实例化对象
|
|
|
private static FormulaUnit formula = new FormulaUnit();
|
|
|
/// <summary>
|
|
|
/// 当前选中配方名
|
|
|
/// </summary>
|
|
|
static string scrNowRecipeName = "Demo";
|
|
|
/// <summary>
|
|
|
/// 只使用一个Formula_Unit_Insert
|
|
|
/// </summary>
|
|
|
Formula_Unit_Insert unit_Insert_Now = new Formula_Unit_Insert();
|
|
|
/// <summary>
|
|
|
/// 当前 DataGridView:当外层选项卡改变时;给dataGridViewNow 赋值 左侧
|
|
|
/// </summary>
|
|
|
static DataGridView dataGridViewNow = new DataGridView();
|
|
|
|
|
|
/// <summary>
|
|
|
/// 当前机台名称
|
|
|
/// </summary>
|
|
|
public static string nowMachineName = "SCR1";
|
|
|
// 当前配方上面相同信息
|
|
|
static List<string> RecipeSameInfoNow = new List<string> { "", "", "", "", "", "", "" };
|
|
|
/// <summary>
|
|
|
/// 1新增保存,2修改保存
|
|
|
/// </summary>
|
|
|
int function = 0;
|
|
|
|
|
|
public FormulaUnit()
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
LocateMachineLocation();
|
|
|
SetNowPageUnUse();
|
|
|
}
|
|
|
#region 获取实例化对象
|
|
|
public void GetFormulaUnit(FormulaUnit formulaUnitObject)
|
|
|
{
|
|
|
formula = formulaUnitObject;
|
|
|
}
|
|
|
#endregion 获取实例化对象
|
|
|
|
|
|
#region 页面初始化 调用方法
|
|
|
/// <summary>
|
|
|
/// 初始化时-最内层配方 页面展示
|
|
|
/// </summary>
|
|
|
/// <param name="fmlaUnitObject"></param>
|
|
|
public void ShowUintInsert(FormulaUnit fmlaUnitObject)
|
|
|
{
|
|
|
unit_Insert_Now.dataGridView.ReadOnly = true;
|
|
|
ShowRecipeLeftData(dGVSCR1, "SCR1");
|
|
|
scrNowRecipeName = bRecipeWoekManage.GetMachineOneRecipeScrInfo("SCR1");
|
|
|
//现在默认展示“SCR1默认展示配方”:SCR1
|
|
|
ShowRecipeRightData(scrNowRecipeName, 1);
|
|
|
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 设置 默认选项卡
|
|
|
/// </summary>
|
|
|
public void SetSelectTab()
|
|
|
{
|
|
|
uiTabControlMenu4.SelectedTab = uiTabControlMenu4.TabPages["tabPage_scr1"];
|
|
|
}
|
|
|
public void SelectdataGridView()
|
|
|
{
|
|
|
dataGridViewNow = dGVSCR1;
|
|
|
unit_Insert_Now.dataGridView.ReadOnly = true;
|
|
|
}
|
|
|
#endregion 页面初始化 调用方法
|
|
|
// 键的类型为机台名称:SCR1 SCR2 SCR3 SCR4
|
|
|
// 值的类型为整数 1 2 3 4
|
|
|
Dictionary<string, int> dictionaryMachine = new Dictionary<string, int>();
|
|
|
/// <summary>
|
|
|
/// 判断当前机台是那个位置
|
|
|
/// </summary>
|
|
|
public void LocateMachineLocation()
|
|
|
{
|
|
|
// 向字典中添加键值对
|
|
|
dictionaryMachine.Add("SCR1", 1);
|
|
|
dictionaryMachine.Add("SCR2", 2);
|
|
|
dictionaryMachine.Add("SCR3", 3);
|
|
|
dictionaryMachine.Add("SCR4", 4);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 外层选项卡 改变时
|
|
|
/// </summary>
|
|
|
/// <param name="sender"></param>
|
|
|
/// <param name="e"></param>
|
|
|
private void uiTabControlMenu3_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
{
|
|
|
function = 0;
|
|
|
switch (uiTabControlMenu4.SelectedTab.Text)
|
|
|
{
|
|
|
case "SCR1":
|
|
|
SetNowPageUnUse();
|
|
|
unit_Insert_Now.SetRowLocate();
|
|
|
//展示左侧数据
|
|
|
ShowRecipeLeftData(dGVSCR1, "SCR1");
|
|
|
dataGridViewNow = dGVSCR1;
|
|
|
nowMachineName = "SCR1";
|
|
|
string str1 = bRecipeWoekManage.GetMachineOneRecipeScrInfo("SCR1");
|
|
|
if (str1 != "")
|
|
|
{
|
|
|
scrNowRecipeName = str1;
|
|
|
ShowRecipeRightData(scrNowRecipeName, 1);
|
|
|
}
|
|
|
else
|
|
|
ShowRecipeRightData("", 1);
|
|
|
break;
|
|
|
case "SCR2":
|
|
|
SetNowPageUnUse();
|
|
|
unit_Insert_Now.SetRowLocate();
|
|
|
ShowRecipeLeftData(dGVSCR2, "SCR2");
|
|
|
dataGridViewNow = dGVSCR2;
|
|
|
nowMachineName = "SCR2";
|
|
|
string str2 = bRecipeWoekManage.GetMachineOneRecipeScrInfo("SCR2");
|
|
|
//现在默认展示“SCR1默认展示配方”:SCR1
|
|
|
if (str2 != "")
|
|
|
{
|
|
|
scrNowRecipeName = str2;
|
|
|
ShowRecipeRightData(scrNowRecipeName, 2);
|
|
|
}
|
|
|
else
|
|
|
ShowRecipeRightData("", 2);
|
|
|
break;
|
|
|
case "SCR3":
|
|
|
SetNowPageUnUse();
|
|
|
unit_Insert_Now.SetRowLocate();
|
|
|
ShowRecipeLeftData(dGVSCR3, "SCR3");
|
|
|
dataGridViewNow = dGVSCR3;
|
|
|
nowMachineName = "SCR3";
|
|
|
string str3 = bRecipeWoekManage.GetMachineOneRecipeScrInfo("SCR3");
|
|
|
//现在默认展示“SCR1默认展示配方”:SCR1
|
|
|
if (str3 != "")
|
|
|
{
|
|
|
scrNowRecipeName = str3;
|
|
|
ShowRecipeRightData(scrNowRecipeName, 3);
|
|
|
}
|
|
|
else
|
|
|
ShowRecipeRightData("", 3);
|
|
|
break;
|
|
|
|
|
|
case "SCR4":
|
|
|
SetNowPageUnUse();
|
|
|
unit_Insert_Now.SetRowLocate();
|
|
|
ShowRecipeLeftData(dGVSCR4, "SCR4");
|
|
|
dataGridViewNow = dGVSCR4;
|
|
|
nowMachineName = "SCR4";
|
|
|
string str4 = bRecipeWoekManage.GetMachineOneRecipeScrInfo("SCR4");
|
|
|
//现在默认展示“SCR1默认展示配方”:SCR1
|
|
|
if (str4 != "")
|
|
|
{
|
|
|
scrNowRecipeName = str4;
|
|
|
ShowRecipeRightData(scrNowRecipeName, 4);
|
|
|
}
|
|
|
else
|
|
|
ShowRecipeRightData("", 4);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#region 点击单元格内容时发生 给当前选中的配方赋值 并展示配方详细步骤
|
|
|
/// <summary>
|
|
|
/// 获取 当前选中配方名
|
|
|
/// </summary>
|
|
|
/// <param name="dataGridView"></param>
|
|
|
/// <returns></returns>
|
|
|
public void GetScrRecipeName(DataGridView dataGridView)
|
|
|
{
|
|
|
// 假设dataGridView1是你的DataGridView控件
|
|
|
// 获取当前选中单元格的行和列索引
|
|
|
int selectedRowIndex = dataGridView.SelectedCells[0].OwningRow.Index;
|
|
|
int selectedColumnIndex = dataGridView.SelectedCells[0].OwningColumn.Index;
|
|
|
// 获取选中单元格的值
|
|
|
scrNowRecipeName = dataGridView.Rows[selectedRowIndex].Cells[selectedColumnIndex].Value.ToString();
|
|
|
if (dictionaryMachine.ContainsKey(nowMachineName))
|
|
|
{
|
|
|
function = 0;
|
|
|
ShowRecipeRightData(scrNowRecipeName, dictionaryMachine[nowMachineName]);
|
|
|
}
|
|
|
//new UIPage().ShowSuccessTip("已选择" + scrNowRecipeName);
|
|
|
}
|
|
|
|
|
|
#endregion 点击单元格内容时发生 给当前选中的配方赋值
|
|
|
|
|
|
#region 机台下配方 左侧 页面展示
|
|
|
|
|
|
/// <summary>
|
|
|
/// 展示当前机台下 存在那些配方
|
|
|
/// </summary>
|
|
|
/// <param name="dataGridView"></param>
|
|
|
/// <param name="scrName">机台名</param>
|
|
|
public void ShowRecipeLeftData(DataGridView dataGridView, string scrName)
|
|
|
{
|
|
|
LoadDataNewSCR(dataGridView, scrName);
|
|
|
GenerateDataGridViewColumnsSCR(dataGridView);
|
|
|
}
|
|
|
|
|
|
// 生成DataGridView列
|
|
|
private void GenerateDataGridViewColumnsSCR(DataGridView dataGridView)
|
|
|
{
|
|
|
if (dataGridView.DataSource != null)
|
|
|
{
|
|
|
if (dataGridView.Columns.Count > 0)
|
|
|
{
|
|
|
dataGridView.Columns[0].HeaderText = "配方名称";
|
|
|
//dataGridView1.RowHeadersVisible = false;
|
|
|
gridHdl._dbgrid = dataGridView;
|
|
|
gridHdl.GenerateBaseDataGridView();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 加载当前机台下的配方
|
|
|
/// </summary>
|
|
|
/// <param name="dataGridView"></param>
|
|
|
/// <param name="scrName">机台名</param>
|
|
|
private void LoadDataNewSCR(DataGridView dataGridView, string scrName)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
dtResult = bRecipeWoekManage.GetMachineRecipeScrInfo(scrName);
|
|
|
if (dtResult != null)
|
|
|
{
|
|
|
dataGridView.DataSource = dtResult;
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
ex.ToString();
|
|
|
}
|
|
|
}
|
|
|
#endregion 机台下配方 左侧 页面展示
|
|
|
|
|
|
#region 机台下配方 右侧 页面展示
|
|
|
/// <summary>
|
|
|
/// 设置右侧展示数据:Formula_Unit_Insert中
|
|
|
/// </summary>
|
|
|
/// <param name="recipeName">配方名称</param>
|
|
|
/// <param name="localtion">需要加载数据所在位置:1初始化时(默认)、 1 SCR1机台...4 SCR4机台</param>
|
|
|
public void ShowRecipeRightData(string recipeName, int localtion)
|
|
|
{
|
|
|
unit_Insert_Now.CreateNewRecipe(localtion);
|
|
|
|
|
|
unit_Insert_Now.Dock = DockStyle.Fill;
|
|
|
|
|
|
//展示右侧 下方数据
|
|
|
unit_Insert_Now.GetDataSource(recipeName, nowMachineName);
|
|
|
//获取右侧 上方数据List<string>
|
|
|
// 点击SCR1 时 默认展示scrNowRecipeName
|
|
|
scrNowRecipeName = recipeName;
|
|
|
//查询配方中相同的数据
|
|
|
RecipeSameInfoNow = bRecipeWoekManage.GetRecipeSameInfo(scrNowRecipeName);
|
|
|
//展示右侧 上方数据
|
|
|
unit_Insert_Now.SetSameData(RecipeSameInfoNow);
|
|
|
|
|
|
switch (uiTabControlMenu4.SelectedTab.Text)
|
|
|
{
|
|
|
case "SCR1":
|
|
|
formula.panelSCR1.Controls.Clear();
|
|
|
formula.panelSCR1.Controls.Add(unit_Insert_Now);
|
|
|
formula.panelSCR1.Show();
|
|
|
break;
|
|
|
case "SCR2":
|
|
|
formula.panelSCR2.Controls.Clear();
|
|
|
formula.panelSCR2.Controls.Add(unit_Insert_Now);
|
|
|
formula.panelSCR2.Show();
|
|
|
break;
|
|
|
case "SCR3":
|
|
|
formula.panelSCR3.Controls.Clear();
|
|
|
formula.panelSCR3.Controls.Add(unit_Insert_Now);
|
|
|
formula.panelSCR3.Show();
|
|
|
break;
|
|
|
case "SCR4":
|
|
|
formula.panelSCR4.Controls.Clear();
|
|
|
formula.panelSCR4.Controls.Add(unit_Insert_Now);
|
|
|
formula.panelSCR4.Show();
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
public void ShowDemoRecipeRightData(string recipeName, int localtion)
|
|
|
{
|
|
|
unit_Insert_Now.CreateNewRecipe(localtion);
|
|
|
|
|
|
unit_Insert_Now.Dock = DockStyle.Fill;
|
|
|
|
|
|
//展示右侧 下方数据
|
|
|
unit_Insert_Now.GetDomeDataSource(recipeName);
|
|
|
//获取右侧 上方数据List<string>
|
|
|
// 点击SCR1 时 默认展示scrNowRecipeName
|
|
|
scrNowRecipeName = recipeName;
|
|
|
|
|
|
|
|
|
//string str = JsonConvert.SerializeObject(bRecipeWoekManage.GetRecipeSameInfoAdd(scrNowRecipeName));
|
|
|
//查询配方中相同的数据
|
|
|
RecipeSameInfoNow = JsonConvert.DeserializeObject<List<string>>("[null,\"默认\",\"2024/2/24 18:42:40\",\"0.00f\",\"0.00f\",\"0\"]");
|
|
|
//展示右侧 上方数据
|
|
|
unit_Insert_Now.SetSameData(RecipeSameInfoNow);
|
|
|
|
|
|
switch (uiTabControlMenu4.SelectedTab.Text)
|
|
|
{
|
|
|
case "SCR1":
|
|
|
formula.panelSCR1.Controls.Clear();
|
|
|
formula.panelSCR1.Controls.Add(unit_Insert_Now);
|
|
|
formula.panelSCR1.Show();
|
|
|
break;
|
|
|
case "SCR2":
|
|
|
formula.panelSCR2.Controls.Clear();
|
|
|
formula.panelSCR2.Controls.Add(unit_Insert_Now);
|
|
|
formula.panelSCR2.Show();
|
|
|
break;
|
|
|
case "SCR3":
|
|
|
formula.panelSCR3.Controls.Clear();
|
|
|
formula.panelSCR3.Controls.Add(unit_Insert_Now);
|
|
|
formula.panelSCR3.Show();
|
|
|
break;
|
|
|
case "SCR4":
|
|
|
formula.panelSCR4.Controls.Clear();
|
|
|
formula.panelSCR4.Controls.Add(unit_Insert_Now);
|
|
|
formula.panelSCR4.Show();
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion 机台下配方 右侧 页面展示
|
|
|
|
|
|
#region 左侧机台配方名功能按钮管理
|
|
|
|
|
|
/// <summary>
|
|
|
/// 新增-显示模板Demo
|
|
|
/// </summary>
|
|
|
/// <param name="sender"></param>
|
|
|
/// <param name="e"></param>
|
|
|
private void uiButton20_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
if (PublicParams.currUserInfo.userGroup == "Operator")
|
|
|
{
|
|
|
MessageBox.Show("权限不足");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
function = 1;
|
|
|
SetControlenUse();
|
|
|
unit_Insert_Now.SetControlUse();
|
|
|
unit_Insert_Now.Enabled = true;
|
|
|
|
|
|
|
|
|
//新增 DEMO
|
|
|
|
|
|
if (dictionaryMachine.ContainsKey(nowMachineName))
|
|
|
{
|
|
|
//ShowDemoRecipeRightData
|
|
|
ShowDemoRecipeRightData("Demo", dictionaryMachine[nowMachineName]);
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 设置当前界面控件不可用
|
|
|
/// </summary>
|
|
|
public void SetNowPageUnUse()
|
|
|
{
|
|
|
SetControlUnUse();
|
|
|
unit_Insert_Now.SetControlUnUse();
|
|
|
unit_Insert_Now.dataGridView.ReadOnly = true;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 取消
|
|
|
/// </summary>
|
|
|
/// <param name="sender"></param>
|
|
|
/// <param name="e"></param>
|
|
|
private void uiButton22_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
if (PublicParams.currUserInfo.userGroup == "Operator")
|
|
|
{
|
|
|
MessageBox.Show("权限不足");
|
|
|
return;
|
|
|
}
|
|
|
SetNowPageUnUse();
|
|
|
|
|
|
string currentValue1 = "";
|
|
|
switch (uiTabControlMenu4.SelectedTab.Text)
|
|
|
{
|
|
|
case "SCR1":
|
|
|
//if (dGVSCR1.CurrentCell.Value != null)
|
|
|
if (dGVSCR1.CurrentCell != null)
|
|
|
{
|
|
|
currentValue1 = dGVSCR1.CurrentCell.Value.ToString();
|
|
|
}
|
|
|
break;
|
|
|
case "SCR2":
|
|
|
if (dGVSCR2.CurrentCell != null)
|
|
|
{
|
|
|
currentValue1 = dGVSCR2.CurrentCell.Value.ToString();
|
|
|
}
|
|
|
break;
|
|
|
case "SCR3":
|
|
|
if (dGVSCR3.CurrentCell != null)
|
|
|
{
|
|
|
currentValue1 = dGVSCR3.CurrentCell.Value.ToString();
|
|
|
}
|
|
|
break;
|
|
|
case "SCR4":
|
|
|
if (dGVSCR4.CurrentCell != null)
|
|
|
{
|
|
|
currentValue1 = dGVSCR4.CurrentCell.Value.ToString();
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
if (dictionaryMachine.ContainsKey(nowMachineName))
|
|
|
{
|
|
|
ShowRecipeRightData(currentValue1, dictionaryMachine[nowMachineName]);
|
|
|
}
|
|
|
scrNowRecipeName = currentValue1;
|
|
|
}
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 保存:保存机台配方 保存详细配方
|
|
|
/// </summary>
|
|
|
/// <param name="sender"></param>
|
|
|
/// <param name="e"></param>
|
|
|
private void uiButton23_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
if (PublicParams.currUserInfo.userGroup == "Operator")
|
|
|
{
|
|
|
MessageBox.Show("权限不足");
|
|
|
return;
|
|
|
}
|
|
|
if (!string.IsNullOrEmpty(unit_Insert_Now.ReturnAddRecipe()))
|
|
|
{
|
|
|
SetControlUnUse();
|
|
|
unit_Insert_Now.SetControlUnUse();
|
|
|
unit_Insert_Now.dataGridView.ReadOnly = true;
|
|
|
|
|
|
#region
|
|
|
if (function == 1)
|
|
|
{
|
|
|
if (!bRecipeWoekManage.SelRecipeNameInRecipeInfo(unit_Insert_Now.ReturnAddRecipe(), nowMachineName))
|
|
|
{
|
|
|
//dataGridView
|
|
|
//保存当前机台下的配方
|
|
|
RecipeMachine recipeMachine = new RecipeMachine();
|
|
|
recipeMachine.scrRecipeName = unit_Insert_Now.ReturnAddRecipe();
|
|
|
scrNowRecipeName = unit_Insert_Now.ReturnAddRecipe();
|
|
|
//判断配方,判断配方里面的数据
|
|
|
//判断配方是否重复step
|
|
|
if (!unit_Insert_Now.IsControlUnUse())
|
|
|
{
|
|
|
MessageBox.Show("数据重复");
|
|
|
return;
|
|
|
}
|
|
|
//新增-保存
|
|
|
bool result = bRecipeWoekManage.SelRecipeNameInfo(recipeMachine.scrRecipeName, nowMachineName);
|
|
|
if (!result)
|
|
|
{
|
|
|
recipeMachine.scrMachineName = nowMachineName;
|
|
|
recipeMachine.founderId = unit_Insert_Now.ReturnCreatUser(out string machineRecipeCreatTime);
|
|
|
recipeMachine.foundTime = machineRecipeCreatTime;
|
|
|
//保存机台配方绑定关系
|
|
|
bRecipeWoekManage.SaveRecipeMachine(recipeMachine);
|
|
|
//保存 详细配方步骤
|
|
|
bRecipeWoekManage.SaveRecipeScrInfo(unit_Insert_Now.ReturnRecipeInfo(), nowMachineName);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
MessageBox.Show("重名配方");
|
|
|
}
|
|
|
}
|
|
|
else//就是修改
|
|
|
{
|
|
|
if (!bRecipeWoekManage.SelRecipeNameInRecipeInfo(unit_Insert_Now.ReturnAddRecipe(), nowMachineName) || scrNowRecipeName == unit_Insert_Now.ReturnAddRecipe())
|
|
|
{
|
|
|
//1更新详细内容
|
|
|
|
|
|
//2更改绑定关系
|
|
|
//3更改作业配方
|
|
|
|
|
|
RecipeMachine recipeMachine = new RecipeMachine();
|
|
|
recipeMachine.scrRecipeName = unit_Insert_Now.ReturnAddRecipe();
|
|
|
recipeMachine.scrMachineName = nowMachineName;
|
|
|
recipeMachine.founderId = unit_Insert_Now.ReturnCreatUser(out string machineRecipeCreatTime);
|
|
|
recipeMachine.foundTime = machineRecipeCreatTime;
|
|
|
|
|
|
bRecipeWoekManage.UpdateRecipeScr(unit_Insert_Now.ReturnRecipeInfo(), scrNowRecipeName);
|
|
|
bRecipeWoekManage.UpdateRecipeMachineInfo(recipeMachine, scrNowRecipeName);
|
|
|
if (scrNowRecipeName != unit_Insert_Now.ReturnAddRecipe())
|
|
|
{
|
|
|
bRecipeWoekManage.Updatetb_work_recipe(scrNowRecipeName, recipeMachine.scrRecipeName, nowMachineName);
|
|
|
}
|
|
|
scrNowRecipeName = unit_Insert_Now.ReturnAddRecipe();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
MessageBox.Show("重名配方");
|
|
|
}
|
|
|
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
//重新加载左侧配方信息
|
|
|
ShowRecipeLeftData(dataGridViewNow, nowMachineName);
|
|
|
//重新加载右侧配方信息
|
|
|
if (dictionaryMachine.ContainsKey(nowMachineName))
|
|
|
{
|
|
|
ShowRecipeRightData(scrNowRecipeName, dictionaryMachine[nowMachineName]);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
MessageBox.Show("配方名称为空 不允许保存");
|
|
|
}
|
|
|
|
|
|
switch (uiTabControlMenu4.SelectedTab.Text)
|
|
|
{
|
|
|
case "SCR1":
|
|
|
{
|
|
|
string newName = unit_Insert_Now.ReturnAddRecipe();
|
|
|
for (int i = 0; i < dGVSCR1.Rows.Count; i++)
|
|
|
{
|
|
|
if (dGVSCR1.Rows[i].Cells[0].Value.ToString() == newName)
|
|
|
dGVSCR1.CurrentCell = dGVSCR1.Rows[i].Cells[0];
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
case "SCR2":
|
|
|
{
|
|
|
string newName = unit_Insert_Now.ReturnAddRecipe();
|
|
|
for (int i = 0; i < dGVSCR2.Rows.Count; i++)
|
|
|
{
|
|
|
if (dGVSCR2.Rows[i].Cells[0].Value.ToString() == newName)
|
|
|
dGVSCR2.CurrentCell = dGVSCR2.Rows[i].Cells[0];
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
case "SCR3":
|
|
|
{
|
|
|
string newName = unit_Insert_Now.ReturnAddRecipe();
|
|
|
for (int i = 0; i < dGVSCR3.Rows.Count; i++)
|
|
|
{
|
|
|
if (dGVSCR3.Rows[i].Cells[0].Value.ToString() == newName)
|
|
|
dGVSCR3.CurrentCell = dGVSCR3.Rows[i].Cells[0];
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
case "SCR4":
|
|
|
{
|
|
|
string newName = unit_Insert_Now.ReturnAddRecipe();
|
|
|
for (int i = 0; i < dGVSCR4.Rows.Count; i++)
|
|
|
{
|
|
|
if (dGVSCR4.Rows[i].Cells[0].Value.ToString() == newName)
|
|
|
dGVSCR4.CurrentCell = dGVSCR4.Rows[i].Cells[0];
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 另存
|
|
|
/// </summary>
|
|
|
/// <param name="sender"></param>
|
|
|
/// <param name="e"></param>
|
|
|
private void uiButton24_Click_1(object sender, EventArgs e)
|
|
|
{
|
|
|
if (PublicParams.currUserInfo.userGroup == "Operator")
|
|
|
{
|
|
|
MessageBox.Show("权限不足");
|
|
|
return;
|
|
|
}
|
|
|
if (dtResult != null && dtResult.Rows.Count > 0)
|
|
|
{
|
|
|
SetControlUnUse();
|
|
|
unit_Insert_Now.SetControlUnUse();
|
|
|
unit_Insert_Now.dataGridView.ReadOnly = true;
|
|
|
FrmFormulaSaveAs frmFormulaSaveAs = new FrmFormulaSaveAs();
|
|
|
frmFormulaSaveAs.ShowDialog();
|
|
|
string recipeName = frmFormulaSaveAs.SaveAsRecipeName();
|
|
|
if (FrmFormulaSaveAs.ifDetermine)
|
|
|
{
|
|
|
DateTime dateTime = DateTime.Now;
|
|
|
string formattedDateTime = dateTime.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
//dataGridView
|
|
|
//保存当前机台下的配方
|
|
|
RecipeMachine recipeMachine = new RecipeMachine();
|
|
|
recipeMachine.scrRecipeName = recipeName;
|
|
|
|
|
|
recipeMachine.scrMachineName = nowMachineName;//FrmFormulaSaveAs.scr;
|
|
|
recipeMachine.founderId = unit_Insert_Now.ReturnCreatUser();
|
|
|
recipeMachine.foundTime = formattedDateTime;
|
|
|
|
|
|
bRecipeWoekManage.SaveRecipeMachine(recipeMachine);
|
|
|
//保存 详细配方步骤
|
|
|
bRecipeWoekManage.SaveRecipeScrInfo(unit_Insert_Now.ReturnRecipeSaveAsInfo(recipeName), nowMachineName/* FrmFormulaSaveAs.scr*/);
|
|
|
|
|
|
//重新加载左侧配方信息
|
|
|
ShowRecipeLeftData(dataGridViewNow, nowMachineName);
|
|
|
//重新加载右侧配方信息
|
|
|
if (dictionaryMachine.ContainsKey(nowMachineName))
|
|
|
{
|
|
|
ShowRecipeRightData(scrNowRecipeName, dictionaryMachine[nowMachineName]);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
MessageBox.Show("配方不存在");
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 编辑
|
|
|
/// </summary>
|
|
|
/// <param name="sender"></param>
|
|
|
/// <param name="e"></param>
|
|
|
private void uiButton21_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
if (PublicParams.currUserInfo.userGroup == "Operator")
|
|
|
{
|
|
|
MessageBox.Show("权限不足");
|
|
|
return;
|
|
|
}
|
|
|
if (dtResult != null)
|
|
|
{
|
|
|
SetControlenUse();
|
|
|
unit_Insert_Now.SetControlUse();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
MessageBox.Show("当前配方为空,请先添加配方!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 鼠标点击 所在行数
|
|
|
/// </summary>
|
|
|
static int rowLocateMachine = 0;
|
|
|
/// <summary>
|
|
|
/// 删除
|
|
|
/// </summary>
|
|
|
/// <param name="sender"></param>
|
|
|
/// <param name="e"></param>
|
|
|
private void uiButton25_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
if (PublicParams.currUserInfo.userGroup == "Operator")
|
|
|
{
|
|
|
MessageBox.Show("权限不足");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (dtResult != null && dtResult.Rows.Count > 0)
|
|
|
{
|
|
|
DataGridView dataGridViewObj = new DataGridView();
|
|
|
DataGridViewRow dataGridViewRow;
|
|
|
|
|
|
switch (uiTabControlMenu4.SelectedTab.Text)
|
|
|
{
|
|
|
|
|
|
case "SCR1":
|
|
|
DialogResult dgRstScr1 = MessageBox.Show(this, "您确认要删除吗?", "警告", MessageBoxButtons.OKCancel);
|
|
|
if (dgRstScr1 == DialogResult.OK)
|
|
|
{
|
|
|
dataGridViewObj = dGVSCR1;
|
|
|
if (publicProgram.scrA1 == scrNowRecipeName || publicProgram.scrB1 == scrNowRecipeName)
|
|
|
{
|
|
|
MessageBox.Show("当前配方已选择");
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
case "SCR2":
|
|
|
DialogResult dgRstScr2 = MessageBox.Show(this, "您确认要删除吗?", "警告", MessageBoxButtons.OKCancel);
|
|
|
if (dgRstScr2 == DialogResult.OK)
|
|
|
{
|
|
|
dataGridViewObj = dGVSCR2;
|
|
|
if (publicProgram.scrA2 == scrNowRecipeName || publicProgram.scrB2 == scrNowRecipeName)
|
|
|
{
|
|
|
MessageBox.Show("当前配方已选择");
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
case "SCR3":
|
|
|
DialogResult dgRstScr3 = MessageBox.Show(this, "您确认要删除吗?", "警告", MessageBoxButtons.OKCancel);
|
|
|
if (dgRstScr3 == DialogResult.OK)
|
|
|
{
|
|
|
dataGridViewObj = dGVSCR3;
|
|
|
if (publicProgram.scrA3 == scrNowRecipeName || publicProgram.scrB3 == scrNowRecipeName)
|
|
|
{
|
|
|
MessageBox.Show("当前配方已选择");
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
case "SCR4":
|
|
|
DialogResult dgRstScr4 = MessageBox.Show(this, "您确认要删除吗?", "警告", MessageBoxButtons.OKCancel);
|
|
|
if (dgRstScr4 == DialogResult.OK)
|
|
|
{
|
|
|
dataGridViewObj = dGVSCR4;
|
|
|
if (publicProgram.scrA4 == scrNowRecipeName || publicProgram.scrB4 == scrNowRecipeName)
|
|
|
{
|
|
|
MessageBox.Show("当前配方已选择");
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
if (rowLocateMachine != -1)
|
|
|
{
|
|
|
dataGridViewRow = dataGridViewObj.Rows[rowLocateMachine] as DataGridViewRow;
|
|
|
|
|
|
string recipeName = dataGridViewRow.Cells[0].Value.ToString();
|
|
|
|
|
|
if (bRecipeWoekManage.chooseUnitRecipe(uiTabControlMenu4.SelectedTab.Text, recipeName))
|
|
|
{
|
|
|
MessageBox.Show("当前配方已被选择");
|
|
|
return;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//DialogResult dgRst = MessageBox.Show(this, "您确认要删除吗?", "警告", MessageBoxButtons.OKCancel);
|
|
|
//if (dgRst == DialogResult.OK)
|
|
|
//{
|
|
|
|
|
|
|
|
|
|
|
|
if (rowLocateMachine >= 0 && rowLocateMachine < dataGridViewObj.RowCount)
|
|
|
{
|
|
|
|
|
|
//数据库删除该配方
|
|
|
bRecipeWoekManage.DelMachineRecipeInfo(recipeName, nowMachineName);
|
|
|
bRecipeWoekManage.DelRecipeScrInfo(recipeName, nowMachineName);
|
|
|
//页面删除
|
|
|
dataGridViewObj.Rows.RemoveAt(rowLocateMachine);
|
|
|
|
|
|
//已选择的 单元配方 ,当单元配方被删除 ,作业配方中 置为null
|
|
|
//bRecipeWoekManage.Updatetb_work_recipe(scrNowRecipeName, null, nowMachineName);
|
|
|
|
|
|
switch (uiTabControlMenu4.SelectedTab.Text)
|
|
|
{
|
|
|
case "SCR1":
|
|
|
scrNowRecipeName = bRecipeWoekManage.GetMachineOneRecipeScrInfo("SCR1");
|
|
|
//现在默认展示“SCR1默认展示配方”:SCR1
|
|
|
ShowRecipeRightData(scrNowRecipeName, 1);
|
|
|
break;
|
|
|
case "SCR2":
|
|
|
scrNowRecipeName = bRecipeWoekManage.GetMachineOneRecipeScrInfo("SCR2");
|
|
|
//现在默认展示“SCR1默认展示配方”:SCR1
|
|
|
ShowRecipeRightData(scrNowRecipeName, 2);
|
|
|
break;
|
|
|
case "SCR3":
|
|
|
scrNowRecipeName = bRecipeWoekManage.GetMachineOneRecipeScrInfo("SCR3");
|
|
|
//现在默认展示“SCR1默认展示配方”:SCR1
|
|
|
ShowRecipeRightData(scrNowRecipeName, 3);
|
|
|
break;
|
|
|
case "SCR4":
|
|
|
scrNowRecipeName = bRecipeWoekManage.GetMachineOneRecipeScrInfo("SCR4");
|
|
|
//现在默认展示“SCR1默认展示配方”:SCR1
|
|
|
ShowRecipeRightData(scrNowRecipeName, 4);
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
//删除之后 默认显示(Demo)
|
|
|
//ShowRecipeRightData("Demo");
|
|
|
//设置选择行
|
|
|
rowLocateMachine = 0;
|
|
|
if (dataGridViewObj.RowCount > 1)
|
|
|
{
|
|
|
dataGridViewObj.Rows[0].Cells[0].Selected = true;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
MessageBox.Show("请选择要删除的行");
|
|
|
}
|
|
|
//}
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
MessageBox.Show("请重新选择删除配方");
|
|
|
}
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
MessageBox.Show("配方为空请先选择配方!");
|
|
|
}
|
|
|
}
|
|
|
#endregion 左侧机台配方名功能按钮管理
|
|
|
/// <summary>
|
|
|
/// 让按钮 控件不可用
|
|
|
/// </summary>
|
|
|
public void SetControlUnUse()
|
|
|
{
|
|
|
uiButton19.Enabled = false;
|
|
|
uiButton22.Enabled = false;
|
|
|
uiButton23.Enabled = false;
|
|
|
uiButton26.Enabled = false;
|
|
|
uiButton27.Enabled = false;
|
|
|
uiButton28.Enabled = false;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 让当前步骤 功能控件可用
|
|
|
/// </summary>
|
|
|
public void SetControlenUse()
|
|
|
{
|
|
|
uiButton19.Enabled = true;
|
|
|
uiButton22.Enabled = true;
|
|
|
uiButton23.Enabled = true;
|
|
|
uiButton26.Enabled = true;
|
|
|
uiButton27.Enabled = true;
|
|
|
uiButton28.Enabled = true;
|
|
|
|
|
|
unit_Insert_Now.dataGridView.ReadOnly = false;
|
|
|
}
|
|
|
|
|
|
|
|
|
#region 配方-步骤-功能按钮
|
|
|
/// <summary>
|
|
|
/// 插入步骤
|
|
|
/// </summary>
|
|
|
/// <param name="sender"></param>
|
|
|
/// <param name="e"></param>
|
|
|
private void uiButton26_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
if (PublicParams.currUserInfo.userGroup == "Operator")
|
|
|
{
|
|
|
MessageBox.Show("权限不足");
|
|
|
return;
|
|
|
}
|
|
|
if (unit_Insert_Now.whetherAdd())
|
|
|
unit_Insert_Now.RecipeStepInsert();
|
|
|
else
|
|
|
MessageBox.Show("最大为30条");
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 添加步骤
|
|
|
/// </summary>
|
|
|
/// <param name="sender"></param>
|
|
|
/// <param name="e"></param>
|
|
|
private void uiButton19_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
if (PublicParams.currUserInfo.userGroup == "Operator")
|
|
|
{
|
|
|
MessageBox.Show("权限不足");
|
|
|
return;
|
|
|
}
|
|
|
if (unit_Insert_Now.whetherAdd())
|
|
|
unit_Insert_Now.RecipeStepAdd();
|
|
|
else
|
|
|
MessageBox.Show("最大为30条");
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 删除步骤
|
|
|
/// </summary>
|
|
|
/// <param name="sender"></param>
|
|
|
/// <param name="e"></param>
|
|
|
private void uiButton27_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
if (PublicParams.currUserInfo.userGroup == "Operator")
|
|
|
{
|
|
|
MessageBox.Show("权限不足");
|
|
|
return;
|
|
|
}
|
|
|
if (unit_Insert_Now.whetherAdd())
|
|
|
unit_Insert_Now.RecipeStepDelete();
|
|
|
else
|
|
|
MessageBox.Show("最大为30条");
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 复制步骤
|
|
|
/// </summary>
|
|
|
/// <param name="sender"></param>
|
|
|
/// <param name="e"></param>
|
|
|
private void uiButton28_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
if (PublicParams.currUserInfo.userGroup == "Operator")
|
|
|
{
|
|
|
MessageBox.Show("权限不足");
|
|
|
return;
|
|
|
}
|
|
|
if (unit_Insert_Now.whetherAdd())
|
|
|
unit_Insert_Now.RecipeStepCopy();
|
|
|
else
|
|
|
MessageBox.Show("最大为30条");
|
|
|
}
|
|
|
#endregion 配方-步骤-功能按钮
|
|
|
|
|
|
private void dGVSCR1_CellClick(object sender, DataGridViewCellEventArgs e)
|
|
|
{
|
|
|
GetScrRecipeName(dGVSCR1);
|
|
|
rowLocateMachine = e.RowIndex;
|
|
|
foreach (DataGridViewColumn column in dGVSCR1.Columns)
|
|
|
{
|
|
|
column.SortMode = DataGridViewColumnSortMode.NotSortable;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void dGVSCR2_CellClick(object sender, DataGridViewCellEventArgs e)
|
|
|
{
|
|
|
GetScrRecipeName(dGVSCR2);
|
|
|
rowLocateMachine = e.RowIndex;
|
|
|
foreach (DataGridViewColumn column in dGVSCR2.Columns)
|
|
|
{
|
|
|
column.SortMode = DataGridViewColumnSortMode.NotSortable;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void dGVSCR3_CellClick(object sender, DataGridViewCellEventArgs e)
|
|
|
{
|
|
|
GetScrRecipeName(dGVSCR3);
|
|
|
rowLocateMachine = e.RowIndex;
|
|
|
foreach (DataGridViewColumn column in dGVSCR3.Columns)
|
|
|
{
|
|
|
column.SortMode = DataGridViewColumnSortMode.NotSortable;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void dGVSCR4_CellClick(object sender, DataGridViewCellEventArgs e)
|
|
|
{
|
|
|
GetScrRecipeName(dGVSCR4);
|
|
|
rowLocateMachine = e.RowIndex;
|
|
|
foreach (DataGridViewColumn column in dGVSCR4.Columns)
|
|
|
{
|
|
|
column.SortMode = DataGridViewColumnSortMode.NotSortable;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|