sc 11 months ago
parent
commit
b4adafdc2a
  1. 32
      UserClass/AsyncTcpServer.cs
  2. 33
      View/TechnologicalProcessView.xaml.cs

32
UserClass/AsyncTcpServer.cs

@ -197,15 +197,15 @@ namespace DyeingComputer.UserClass
int d = Convert.ToInt16( dat_821.GetValue("ID"));
TechnologicalProcessView.SQLiteHelpers = new SQLiteHelper(TechnologicalProcessView.DBAddress); //数据库连接路径
TechnologicalProcessView.SQLiteHelpers.Open(); //打开数据库
/**插入行**/
string ProgramID = TechnologicalProcessView.SQLiteHelpers.ExecuteScalar("select ProgramID from RUN where Step = '1'", null).ToString();
string ProgramNAME = TechnologicalProcessView.SQLiteHelpers.ExecuteScalar("select Program from RUN where Step = '1'", null).ToString();
TechnologicalProcessView.SQLiteHelpers.Close();
// TechnologicalProcessView.SQLiteHelpers.Close();
DataRow dr = TechnologicalProcessView.sql.Tables[0].NewRow();//添加表数据
dr["ProgramID"] = ProgramID;
dr["Program"] = ProgramNAME;
TechnologicalProcessView.sql.Tables[0].Rows.InsertAt(dr, d - 1);
/**编辑行号**/
int a = TechnologicalProcessView.sql.Tables[0].Rows.Count;
for (int i = 0; i < a; i++)
{
@ -214,7 +214,7 @@ namespace DyeingComputer.UserClass
drt["Step"] = i + 1;
drt.EndEdit();
}
/**编辑行信息**/
DataRow drtt = TechnologicalProcessView.sql.Tables[0].Rows[d - 1];
drtt.BeginEdit();
drtt["StepID"] = dat_821.GetValue("STEPID").ToString();
@ -230,14 +230,12 @@ namespace DyeingComputer.UserClass
var _TechnologicalProcessView = Application.Current.Windows.Cast<UserControl>().FirstOrDefault(window => window is TechnologicalProcessView) as TechnologicalProcessView;//跨页面
_TechnologicalProcessView.Grid.ItemsSource = TechnologicalProcessView.sql.Tables[0].DefaultView;
_TechnologicalProcessView.Grid.SelectedIndex = -1;
TechnologicalProcessView.SQLiteHelpers = new SQLiteHelper(TechnologicalProcessView.DBAddress); //数据库连接路径
TechnologicalProcessView.SQLiteHelpers.Open(); //打开数据库
/**存入信息**/
TechnologicalProcessView.SQLiteHelpers.Delete("RUN", null, null);
DataTable data_t = new DataTable();
data_t.Columns.Add("DYELOT", typeof(string)); //添加列
data_t = TechnologicalProcessView.sql.Tables[0].Clone();
int a = TechnologicalProcessView.sql.Tables[0].Rows.Count;
a = TechnologicalProcessView.sql.Tables[0].Rows.Count;
for (int i = 0; i < a; i++)
{
data_t.Clear();//清空
@ -246,19 +244,18 @@ namespace DyeingComputer.UserClass
DataRow drT = data_t.NewRow();
drT.ItemArray = dt.ItemArray;
data_t.Rows.InsertAt(drT, 0);
dr.BeginEdit(); //添加订单号
dr["DYELOT"] = MainWindowViewModel.WorkNumder;
dr.EndEdit();
drT.BeginEdit(); //添加订单号
drT["DYELOT"] = MainWindowViewModel.WorkNumder;
drT.EndEdit();
TechnologicalProcessView.SQLiteHelpers.InsertData("RUN", TechnologicalProcessView.SQLiteHelpers.DataTableToDictionary(data_t));//行插入
}
TechnologicalProcessView.SQLiteHelpers.Close(); //关闭连接
}//插入
else if (dat_821.GetValue("INSTRUCTION").ToString() == "EDIT")
{
int n = Convert.ToInt16(dat_821.GetValue("ID").ToString());
/**编辑行信息**/
DataRow dr = TechnologicalProcessView.sql.Tables[0].Rows[n - 1];
dr.BeginEdit();
dr["StepID"] = dat_821.GetValue("STEPID").ToString();
@ -274,7 +271,7 @@ namespace DyeingComputer.UserClass
var _TechnologicalProcessView = Application.Current.Windows.Cast<UserControl>().FirstOrDefault(window => window is TechnologicalProcessView) as TechnologicalProcessView;//跨页面
_TechnologicalProcessView.Grid.ItemsSource = TechnologicalProcessView.sql.Tables[0].DefaultView;
_TechnologicalProcessView.Grid.SelectedIndex = -1;
/**存入信息**/
TechnologicalProcessView.SQLiteHelpers = new SQLiteHelper(TechnologicalProcessView.DBAddress); //数据库连接路径
TechnologicalProcessView.SQLiteHelpers.Open(); //打开数据库
TechnologicalProcessView.SQLiteHelpers.Delete("RUN", null, null);
@ -290,13 +287,12 @@ namespace DyeingComputer.UserClass
DataRow drT = data_t.NewRow();
drT.ItemArray = dt.ItemArray;
data_t.Rows.InsertAt(drT, 0);
dr.BeginEdit(); //添加订单号
dr["DYELOT"] = MainWindowViewModel.WorkNumder;
dr.EndEdit();
drT.BeginEdit(); //添加订单号
drT["DYELOT"] = MainWindowViewModel.WorkNumder;
drT.EndEdit();
TechnologicalProcessView.SQLiteHelpers.InsertData("RUN", TechnologicalProcessView.SQLiteHelpers.DataTableToDictionary(data_t));//行插入
}
TechnologicalProcessView.SQLiteHelpers.Close(); //关闭连接
}//编辑
else if (dat_821.GetValue("INSTRUCTION").ToString() == "DELETE")

33
View/TechnologicalProcessView.xaml.cs

@ -177,9 +177,9 @@ namespace DyeingComputer.View
DataRow drT = data_t.NewRow();
drT.ItemArray = dt.ItemArray;
data_t.Rows.InsertAt(drT, 0);
dr.BeginEdit(); //添加订单号
dr["DYELOT"] = MainWindowViewModel.WorkNumder;
dr.EndEdit();
drT.BeginEdit(); //添加订单号
drT["DYELOT"] = MainWindowViewModel.WorkNumder;
drT.EndEdit();
SQLiteHelpers.InsertData("RUN", SQLiteHelpers.DataTableToDictionary(data_t));//行插入
}
@ -202,12 +202,37 @@ namespace DyeingComputer.View
int d = 0;
int a = sql.Tables[0].Rows.Count;
if (ID != null) { d = StrToInt.To16Convert10(ID); } else { return; }
if (ID != null) { d = Convert.ToInt16(ID); } else { return; }
if (a != d)//如果删除不是最后一行执行
{
sql.Tables[0].Rows.RemoveAt(d - 1);
Dat();
Grid.SelectedIndex = -1;
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
SQLiteHelpers.Open(); //打开数据库
SQLiteHelpers.Delete("RUN", null, null);
DataTable data_t = new DataTable();
data_t.Columns.Add("DYELOT", typeof(string)); //添加列
data_t = sql.Tables[0].Clone();
a = sql.Tables[0].Rows.Count;
for (int i = 0; i < a; i++)
{
data_t.Clear();//清空
DataRow dt = sql.Tables[0].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(); //关闭连接
Grid.ItemsSource = sql.Tables[0].DefaultView; //转换显示计划表
}
}

Loading…
Cancel
Save