修改工艺步骤编辑逻辑
This commit is contained in:
commit
d4918cd419
5 files changed
+111
-117
No files matched your search
@@ -15,14 +15,14 @@
|
||||
<ConvertMoels:StatenConvert x:Key="StatenConvert"/>
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
<DataGrid x:Name="GridSTEP" AlternationCount="2" IsReadOnly="True" SelectionChanged="Grid_SelectionChanged"
|
||||
Margin="630,40,0,0" d:ItemsSource="{d:SampleData ItemCount=90}" AutoGenerateColumns="False" MinColumnWidth="30"
|
||||
ItemsSource="{Binding Path=TechnologicalProcess_View,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
|
||||
HorizontalGridLinesBrush="#FFC9C9C9" VerticalGridLinesBrush="#FFC9C9C9" GridLinesVisibility="All" BorderBrush="{x:Null}"
|
||||
BorderThickness="1,1,1,1" ColumnHeaderHeight="40" HorizontalContentAlignment="Right" Grid.ColumnSpan="2" AllowDrop="False"
|
||||
CanUserReorderColumns="False" CanUserSortColumns="False" CanUserResizeRows="False" CanUserResizeColumns="False"
|
||||
CanUserAddRows="True" CanUserDeleteRows="False" HeadersVisibility ="Column"
|
||||
Background="White" SelectionMode="Single" FontSize="15" MinHeight="632" TabIndex="1" Focusable="True" >
|
||||
<DataGrid x:Name="GridSTEP" AlternationCount="2" IsReadOnly="True" SelectionChanged="Grid_SelectionChanged"
|
||||
Margin="630,40,0,0" d:ItemsSource="{d:SampleData ItemCount=90}" AutoGenerateColumns="False" MinColumnWidth="30"
|
||||
ItemsSource="{Binding Path=TechnologicalProcess_View,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
|
||||
HorizontalGridLinesBrush="#FFC9C9C9" VerticalGridLinesBrush="#FFC9C9C9" GridLinesVisibility="All" BorderBrush="{x:Null}"
|
||||
BorderThickness="1,1,1,1" ColumnHeaderHeight="40" HorizontalContentAlignment="Right" Grid.ColumnSpan="2" AllowDrop="False"
|
||||
CanUserReorderColumns="False" CanUserSortColumns="False" CanUserResizeRows="False" CanUserResizeColumns="False"
|
||||
CanUserAddRows="True" CanUserDeleteRows="False" HeadersVisibility ="Column"
|
||||
Background="White" SelectionMode="Single" FontSize="15" MinHeight="632" TabIndex="1" Focusable="True" >
|
||||
<DataGrid.Resources>
|
||||
<Style TargetType="ScrollViewer">
|
||||
<Setter Property="PanningMode" Value="VerticalOnly"/>
|
||||
|
||||
@@ -23,9 +23,7 @@ using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using System.Windows.Threading;
|
||||
using static DyeingComputer.UserClass.SqliteHelper;
|
||||
using static DyeingComputer.ViewModel.MainWindowViewModel;
|
||||
using static DyeingComputer.Windows.ViewStep;
|
||||
using static System.Net.WebRequestMethods;
|
||||
|
||||
namespace DyeingComputer.View
|
||||
{
|
||||
@@ -251,6 +249,9 @@ namespace DyeingComputer.View
|
||||
public static SQLiteHelper SQLiteHelpers = null; //定义数据库
|
||||
public static readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\800COMPUTER.db"; //数据库路径
|
||||
public static DataSet sql; //内存数据缓存
|
||||
string Numder = null;
|
||||
string ID = null;
|
||||
string P1 = "0", P2 = "0", P3 = "0", P4 = "0", P5 = "0";
|
||||
private void TechnologicalProcess_Import()
|
||||
{
|
||||
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
||||
@@ -260,7 +261,7 @@ namespace DyeingComputer.View
|
||||
if (sql != null) sql.Clear(); //清空缓存
|
||||
sql = SQLiteHelpers.ExecuteDataSet(sql_script, null); //读取表写入缓存
|
||||
MainWindowViewModel.ProgramName = SQLiteHelpers.ExecuteScalar("select ProgramName from WorkOrder where ProgramID = '" + workName + "'", null).ToString();
|
||||
if (sql != null) dt_TP = sql.Tables[0]; //转换显示计划表
|
||||
if (sql != null) MainWindowViewModel.dt_TP = sql.Tables[0]; //转换显示计划表
|
||||
|
||||
SQLiteHelpers.Delete("RUN", null, null); //删除run信息
|
||||
DataTable data_t = new DataTable();
|
||||
@@ -296,11 +297,9 @@ namespace DyeingComputer.View
|
||||
}
|
||||
catch (Exception) { }
|
||||
SQLiteHelpers.Close(); //关闭连接
|
||||
|
||||
// if (sql != null)
|
||||
MainWindowViewModel.dt_TP = sql.Tables[0]; //转换显示计划表
|
||||
}
|
||||
|
||||
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// FocusManager.SetFocusedElement(Grid, Grid);
|
||||
@@ -308,7 +307,7 @@ namespace DyeingComputer.View
|
||||
}
|
||||
private void UserControl_KeyDown(object sender, KeyEventArgs e) //键盘监控
|
||||
{
|
||||
if (errTabler.Rows.Count == 0)//无错误信息
|
||||
if (MainWindowViewModel.errTabler.Rows.Count == 0)//无错误信息
|
||||
{
|
||||
if ((MainWindowViewModel.WORK_RUN == 1) || (MainWindowViewModel.WORK_RUN == 0))//停止暂停时可以启用开始
|
||||
{
|
||||
@@ -328,7 +327,6 @@ namespace DyeingComputer.View
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ProgramgroupView_edit_Click(object sender, RoutedEventArgs e)//编辑按钮
|
||||
{
|
||||
if (string.IsNullOrEmpty(Numder)) { Numder = null; P1 = "0"; P2 = "0"; P3 = "0"; P4 = "0"; P5 = "0"; }
|
||||
@@ -343,51 +341,57 @@ namespace DyeingComputer.View
|
||||
{
|
||||
int n = Convert.ToInt16(ID);
|
||||
ID = null;
|
||||
DataRow dr = sql.Tables[0].Rows[n - 1];
|
||||
dr.BeginEdit();
|
||||
dr["StepID"] = e.StepID;
|
||||
dr["StepName"] = e.StepNAME;
|
||||
dr["ParameterName"] = e.PNAME;
|
||||
dr["Parameter1"] = e.P1;
|
||||
dr["Parameter2"] = e.P2;
|
||||
dr["Parameter3"] = e.P3;
|
||||
dr["Parameter4"] = e.P4;
|
||||
dr["Parameter5"] = e.P5;
|
||||
dr.EndEdit();
|
||||
|
||||
dt_TP = sql.Tables[0];
|
||||
GridSTEP.SelectedIndex = -1;
|
||||
if (e.PNAME != "")
|
||||
{
|
||||
DataRow dr = sql.Tables[0].Rows[n - 1];
|
||||
dr.BeginEdit();
|
||||
dr["StepID"] = e.StepID;
|
||||
dr["StepName"] = e.StepNAME;
|
||||
dr["ParameterName"] = e.PNAME;
|
||||
dr["Parameter1"] = e.P1;
|
||||
dr["Parameter2"] = e.P2;
|
||||
dr["Parameter3"] = e.P3;
|
||||
dr["Parameter4"] = e.P4;
|
||||
dr["Parameter5"] = e.P5;
|
||||
dr.EndEdit();
|
||||
|
||||
MainWindowViewModel.dt_TP = sql.Tables[0];
|
||||
GridSTEP.SelectedIndex = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
MainWindowViewModel.dt_TP.Rows.RemoveAt(n - 1);
|
||||
Dat();
|
||||
GridSTEP.SelectedIndex = -1;
|
||||
}
|
||||
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
||||
SQLiteHelpers.Open(); //打开数据库
|
||||
SQLiteHelpers.Delete("RUN", null, null);
|
||||
DataTable data_t = dt_TP.Clone();
|
||||
for (int i = 0; i < dt_TP.Rows.Count; i++)
|
||||
DataTable data_t = MainWindowViewModel.dt_TP.Clone();
|
||||
for (int i = 0; i < MainWindowViewModel.dt_TP.Rows.Count; i++)
|
||||
{
|
||||
data_t.Clear();//清空
|
||||
|
||||
DataRow dt = dt_TP.Rows[i];//行转换
|
||||
DataRow dt = MainWindowViewModel.dt_TP.Rows[i];//行转换
|
||||
DataRow drT = data_t.NewRow();
|
||||
drT.ItemArray = dt.ItemArray;
|
||||
data_t.Rows.InsertAt(drT, 0);
|
||||
drT.BeginEdit(); //添加订单号
|
||||
drT["DYELOT"] = MainWindowViewModel.WorkNumder;
|
||||
drT.EndEdit();
|
||||
|
||||
SQLiteHelpers.InsertData("RUN", SQLiteHelpers.DataTableToDictionary(data_t));//行插入
|
||||
}
|
||||
SQLiteHelpers.Close(); //关闭连接
|
||||
APILog.LOGlog(MainWindowViewModel.WorkNumder.ToString(), "UserActions", "STEP = " + n,
|
||||
"StepID="+ e.StepID + ";StepName="+ e.StepNAME+";P1="+ e.P1+
|
||||
";P2="+ e.P2+";P3="+ e.P3+";P4="+ e.P4+";P5="+ e.P5);
|
||||
User_Button = true;
|
||||
"StepID=" + e.StepID + ";StepName=" + e.StepNAME + ";P1=" + e.P1 +
|
||||
";P2=" + e.P2 + ";P3=" + e.P3 + ";P4=" + e.P4 + ";P5=" + e.P5);
|
||||
MainWindowViewModel.User_Button = true;
|
||||
}
|
||||
public static void Dat()//行号刷新
|
||||
{
|
||||
int a = dt_TP.Rows.Count;
|
||||
int a = MainWindowViewModel.dt_TP.Rows.Count;
|
||||
for (int i = 0; i < a; i++)
|
||||
{
|
||||
DataRow dr = dt_TP.Rows[i];
|
||||
DataRow dr = MainWindowViewModel.dt_TP.Rows[i];
|
||||
dr.BeginEdit();
|
||||
dr["Step"] = i + 1;
|
||||
dr.EndEdit();
|
||||
@@ -396,55 +400,47 @@ namespace DyeingComputer.View
|
||||
private void ProgramgroupView_del_Click(object sender, RoutedEventArgs e)//删除
|
||||
{
|
||||
int d = 0;
|
||||
int a = dt_TP.Rows.Count;
|
||||
int a = MainWindowViewModel.dt_TP.Rows.Count;
|
||||
|
||||
if (ID != null) { d = Convert.ToInt16(ID); } else { return; }
|
||||
dt_TP.Rows.RemoveAt(d - 1);
|
||||
|
||||
MainWindowViewModel.dt_TP.Rows.RemoveAt(d - 1);
|
||||
Dat();
|
||||
GridSTEP.SelectedIndex = -1;
|
||||
|
||||
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
||||
SQLiteHelpers.Open(); //打开数据库
|
||||
SQLiteHelpers.Delete("RUN", null, null);
|
||||
DataTable data_t = dt_TP.Clone();
|
||||
a = dt_TP.Rows.Count;
|
||||
DataTable data_t = MainWindowViewModel.dt_TP.Clone();
|
||||
a = MainWindowViewModel.dt_TP.Rows.Count;
|
||||
for (int i = 0; i < a; i++)
|
||||
{
|
||||
data_t.Clear();//清空
|
||||
|
||||
DataRow dt = dt_TP.Rows[i];//行转换
|
||||
DataRow dt = MainWindowViewModel.dt_TP.Rows[i];//行转换
|
||||
DataRow drT = data_t.NewRow();
|
||||
drT.ItemArray = dt.ItemArray;
|
||||
data_t.Rows.InsertAt(drT, 0);
|
||||
drT.BeginEdit(); //添加订单号
|
||||
drT["DYELOT"] = MainWindowViewModel.WorkNumder;
|
||||
drT.EndEdit();
|
||||
|
||||
SQLiteHelpers.InsertData("RUN", SQLiteHelpers.DataTableToDictionary(data_t));//行插入
|
||||
}
|
||||
|
||||
SQLiteHelpers.Close(); //关闭连接
|
||||
APILog.LOGlog(MainWindowViewModel.WorkNumder.ToString(), "UserActions", "Delete", "STEP = " + ID);
|
||||
User_Button = true;
|
||||
MainWindowViewModel.User_Button = true;
|
||||
}
|
||||
|
||||
private void ProgramgroupView_Insert_Click(object sender, RoutedEventArgs e)//插入
|
||||
{
|
||||
int d = 0;
|
||||
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
||||
SQLiteHelpers.Open(); //打开数据库
|
||||
|
||||
string ProgramID = SQLiteHelpers.ExecuteScalar("select ProgramID from RUN where Step = '1'", null).ToString();
|
||||
string ProgramNAME = SQLiteHelpers.ExecuteScalar("select Program from RUN where Step = '1'", null).ToString();
|
||||
|
||||
SQLiteHelpers.Close();
|
||||
|
||||
if (ID != null) { d = Convert.ToInt16(ID); } else { return; }
|
||||
DataRow dr = MainWindowViewModel.dt_TP.NewRow();//添加表数据
|
||||
dr["ProgramID"] = ProgramID;
|
||||
dr["Program"] = ProgramNAME;
|
||||
|
||||
MainWindowViewModel.dt_TP.Rows.InsertAt(dr, d - 1);
|
||||
// ID = null;
|
||||
Dat();
|
||||
@@ -459,7 +455,6 @@ namespace DyeingComputer.View
|
||||
}
|
||||
private void ProgramgroupView_Jump_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
MainWindowViewModel.RUN_STEPID = Convert.ToInt16(ID);//插入步骤号
|
||||
MainWindowViewModel.STEP_START(Numder, Convert.ToDouble(P1), Convert.ToDouble(P2), Convert.ToDouble(P3),
|
||||
Convert.ToDouble(P4), Convert.ToDouble(P5));
|
||||
@@ -467,11 +462,6 @@ namespace DyeingComputer.View
|
||||
";StepID=" + Numder + ";P1=" + P1 + ";P2=" + P2 + ";P3=" + P3 + ";P4=" + P4 + ";P5=" + P5);
|
||||
|
||||
}//跳步
|
||||
|
||||
string Numder = null;
|
||||
string ID = null;
|
||||
string P1 = "0", P2 = "0", P3 = "0", P4 = "0", P5 = "0";
|
||||
|
||||
private void DyeingMachine_Click(object sender, RoutedEventArgs e)//染色剂
|
||||
{
|
||||
Receip.Visibility = Visibility.Collapsed;
|
||||
@@ -491,8 +481,7 @@ namespace DyeingComputer.View
|
||||
{
|
||||
Parameter_set.Visibility = Visibility.Visible;
|
||||
Receip.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
}
|
||||
private void Grid_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
// if (MainWindowViewModel.WORK_RUN == 2) GridSTEP.SelectedIndex = MainWindowViewModel.RUN_STEPID - 1;//设定图表显示
|
||||
|
||||
Reference in new issue
Block a user