数据读写逻辑修改
This commit is contained in:
commit
fb1b024944
6 files changed
+38
-53
No files matched your search
+3
-25
@@ -49,7 +49,6 @@ namespace DyeingComputer.UserClass
|
|||||||
{
|
{
|
||||||
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
||||||
SQLiteHelpers.Open(); //打开数据库
|
SQLiteHelpers.Open(); //打开数据库
|
||||||
DataTable data_t = WorkOrderStep_.Clone();
|
|
||||||
int a = WorkOrderStep_.Rows.Count;
|
int a = WorkOrderStep_.Rows.Count;
|
||||||
if (a < 1)
|
if (a < 1)
|
||||||
{
|
{
|
||||||
@@ -65,11 +64,7 @@ namespace DyeingComputer.UserClass
|
|||||||
}
|
}
|
||||||
for (int i = 0; i < a; i++)
|
for (int i = 0; i < a; i++)
|
||||||
{
|
{
|
||||||
data_t.Clear();//清空
|
SQLiteHelpers.InsertData("WorkorderSteps", SQLiteHelpers.ToDictionary(WorkOrderStep_.Rows[i]));//行插入
|
||||||
DataRow dr = data_t.NewRow();
|
|
||||||
dr.ItemArray = WorkOrderStep_.Rows[i].ItemArray;
|
|
||||||
data_t.Rows.InsertAt(dr, 0);
|
|
||||||
SQLiteHelpers.InsertData("WorkorderSteps", SQLiteHelpers.DataTableToDictionary(data_t));//行插入
|
|
||||||
}
|
}
|
||||||
SQLiteHelpers.Close(); //关闭连接
|
SQLiteHelpers.Close(); //关闭连接
|
||||||
return true;
|
return true;
|
||||||
@@ -86,22 +81,10 @@ namespace DyeingComputer.UserClass
|
|||||||
MainWindowViewModel.ProgramName = SQLiteHelpers.ExecuteScalar("select ProgramName from Workorder where ProgramID = '" + workName + "'", null).ToString();
|
MainWindowViewModel.ProgramName = SQLiteHelpers.ExecuteScalar("select ProgramName from Workorder where ProgramID = '" + workName + "'", null).ToString();
|
||||||
|
|
||||||
SQLiteHelpers.Delete("RUN", null, null); //删除run信息
|
SQLiteHelpers.Delete("RUN", null, null); //删除run信息
|
||||||
DataTable data_t = new DataTable();
|
|
||||||
data_t = MainWindowViewModel.dt_TP.Clone();
|
|
||||||
data_t.Columns.Add("DYELOT", typeof(string)); //添加列
|
|
||||||
int a = MainWindowViewModel.dt_TP.Rows.Count;
|
int a = MainWindowViewModel.dt_TP.Rows.Count;
|
||||||
for (int i = 0; i < a; i++)
|
for (int i = 0; i < a; i++)
|
||||||
{
|
{
|
||||||
data_t.Clear();//清空
|
SQLiteHelpers.InsertData("RUN", SQLiteHelpers.ToDictionary(MainWindowViewModel.dt_TP.Rows[i]));//行插入
|
||||||
DataRow dt = MainWindowViewModel.dt_TP.Rows[i];//行转
|
|
||||||
DataRow dr = data_t.NewRow();
|
|
||||||
dr.ItemArray = dt.ItemArray;
|
|
||||||
dr.BeginEdit(); //添加订单号
|
|
||||||
dr["DYELOT"] = MainWindowViewModel.WorkNumder;
|
|
||||||
dr.EndEdit();
|
|
||||||
data_t.Rows.InsertAt(dr, 0); //行转换
|
|
||||||
|
|
||||||
r = SQLiteHelpers.InsertData("RUN", SQLiteHelpers.DataTableToDictionary(data_t));//行插入
|
|
||||||
}
|
}
|
||||||
//数据插入
|
//数据插入
|
||||||
MainWindowViewModel.WorkNumder = SQLiteHelpers.ExecuteDataSet("select WorkOrder from Workorder where ProgramID = '" + workName + "'", null);;
|
MainWindowViewModel.WorkNumder = SQLiteHelpers.ExecuteDataSet("select WorkOrder from Workorder where ProgramID = '" + workName + "'", null);;
|
||||||
@@ -141,7 +124,6 @@ namespace DyeingComputer.UserClass
|
|||||||
}
|
}
|
||||||
DyelotTable.Rows.Add(newRow);
|
DyelotTable.Rows.Add(newRow);
|
||||||
}
|
}
|
||||||
DataTable data_t = DyelotTable.Clone();
|
|
||||||
int a = DyelotTable.Rows.Count;
|
int a = DyelotTable.Rows.Count;
|
||||||
if (a < 1) return false;
|
if (a < 1) return false;
|
||||||
string Dyelot = DyelotTable.Rows[0][0].ToString();
|
string Dyelot = DyelotTable.Rows[0][0].ToString();
|
||||||
@@ -155,11 +137,7 @@ namespace DyeingComputer.UserClass
|
|||||||
}
|
}
|
||||||
for (int i = 0; i < a; i++)
|
for (int i = 0; i < a; i++)
|
||||||
{
|
{
|
||||||
data_t.Clear();//清空
|
SQLiteHelpers.InsertData("Dyelot", SQLiteHelpers.ToDictionary(DyelotTable.Rows[i]));//行插入
|
||||||
DataRow dr = data_t.NewRow();
|
|
||||||
dr.ItemArray = DyelotTable.Rows[i].ItemArray;
|
|
||||||
data_t.Rows.InsertAt(dr, 0);
|
|
||||||
SQLiteHelpers.InsertData("Dyelot", SQLiteHelpers.DataTableToDictionary(data_t));//行插入
|
|
||||||
}
|
}
|
||||||
SQLiteHelpers.Close(); //关闭连接
|
SQLiteHelpers.Close(); //关闭连接
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -680,6 +680,23 @@ namespace DyeingComputer.UserClass
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 将DataRow转换为Dictionary<string, object>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="row">DataRow实例</param>
|
||||||
|
/// <returns>键为列名、值为对应数据的字典</returns>
|
||||||
|
public Dictionary<string, object> ToDictionary(DataRow row)
|
||||||
|
{
|
||||||
|
var dictionary = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
if (row == null) return dictionary;
|
||||||
|
|
||||||
|
foreach (DataColumn column in row.Table.Columns)
|
||||||
|
{
|
||||||
|
object value = row[column] == DBNull.Value ? null : row[column];
|
||||||
|
dictionary[column.ColumnName] = value;
|
||||||
|
}
|
||||||
|
return dictionary;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -384,18 +384,13 @@ namespace DyeingComputer.View
|
|||||||
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
||||||
SQLiteHelpers.Open(); //打开数据库
|
SQLiteHelpers.Open(); //打开数据库
|
||||||
SQLiteHelpers.Delete("RUN", null, null);
|
SQLiteHelpers.Delete("RUN", null, null);
|
||||||
DataTable data_t = MainWindowViewModel.dt_TP.Clone();
|
|
||||||
for (int i = 0; i < MainWindowViewModel.dt_TP.Rows.Count; i++)
|
for (int i = 0; i < MainWindowViewModel.dt_TP.Rows.Count; i++)
|
||||||
{
|
{
|
||||||
data_t.Clear();//清空
|
|
||||||
DataRow dt = MainWindowViewModel.dt_TP.Rows[i];//行转换
|
DataRow dt = MainWindowViewModel.dt_TP.Rows[i];//行转换
|
||||||
DataRow drT = data_t.NewRow();
|
dt.BeginEdit(); //添加订单号
|
||||||
drT.ItemArray = dt.ItemArray;
|
dt["DYELOT"] = MainWindowViewModel.Dyelot;
|
||||||
data_t.Rows.InsertAt(drT, 0);
|
dt.EndEdit();
|
||||||
drT.BeginEdit(); //添加订单号
|
SQLiteHelpers.InsertData("RUN", SQLiteHelpers.ToDictionary(dt));//行插入
|
||||||
drT["DYELOT"] = MainWindowViewModel.WorkNumder;
|
|
||||||
drT.EndEdit();
|
|
||||||
SQLiteHelpers.InsertData("RUN", SQLiteHelpers.DataTableToDictionary(data_t));//行插入
|
|
||||||
}
|
}
|
||||||
SQLiteHelpers.Close(); //关闭连接
|
SQLiteHelpers.Close(); //关闭连接
|
||||||
APILog.LOGlog(MainWindowViewModel.WorkNumder.ToString(), "UserActions", "EDIT STEP = " + n,
|
APILog.LOGlog(MainWindowViewModel.WorkNumder.ToString(), "UserActions", "EDIT STEP = " + n,
|
||||||
@@ -553,18 +548,13 @@ namespace DyeingComputer.View
|
|||||||
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
||||||
SQLiteHelpers.Open(); //打开数据库
|
SQLiteHelpers.Open(); //打开数据库
|
||||||
SQLiteHelpers.Delete("RUN", null, null);
|
SQLiteHelpers.Delete("RUN", null, null);
|
||||||
DataTable data_t = MainWindowViewModel.dt_TP.Clone();
|
|
||||||
for (int i = 0; i < MainWindowViewModel.dt_TP.Rows.Count; i++)
|
for (int i = 0; i < MainWindowViewModel.dt_TP.Rows.Count; i++)
|
||||||
{
|
{
|
||||||
data_t.Clear();//清空
|
|
||||||
DataRow dt = MainWindowViewModel.dt_TP.Rows[i];//行转换
|
DataRow dt = MainWindowViewModel.dt_TP.Rows[i];//行转换
|
||||||
DataRow drT = data_t.NewRow();
|
dt.BeginEdit(); //添加订单号
|
||||||
drT.ItemArray = dt.ItemArray;
|
dt["DYELOT"] = MainWindowViewModel.Dyelot;
|
||||||
data_t.Rows.InsertAt(drT, 0);
|
dt.EndEdit();
|
||||||
drT.BeginEdit(); //添加订单号
|
SQLiteHelpers.InsertData("RUN", SQLiteHelpers.ToDictionary(dt));//行插入
|
||||||
drT["DYELOT"] = MainWindowViewModel.WorkNumder;
|
|
||||||
drT.EndEdit();
|
|
||||||
SQLiteHelpers.InsertData("RUN", SQLiteHelpers.DataTableToDictionary(data_t));//行插入
|
|
||||||
}
|
}
|
||||||
SQLiteHelpers.Close(); //关闭连接
|
SQLiteHelpers.Close(); //关闭连接
|
||||||
APILog.LOGlog(MainWindowViewModel.WorkNumder.ToString(), "UserActions", "Insert STEP = " + n,
|
APILog.LOGlog(MainWindowViewModel.WorkNumder.ToString(), "UserActions", "Insert STEP = " + n,
|
||||||
|
|||||||
@@ -91,6 +91,7 @@
|
|||||||
<DataGridTextColumn Header="{x:Static lang:Resources.ProcessName}" Width="350" Binding="{Binding ProgramName}" IsReadOnly="True"/>
|
<DataGridTextColumn Header="{x:Static lang:Resources.ProcessName}" Width="350" Binding="{Binding ProgramName}" IsReadOnly="True"/>
|
||||||
<DataGridTextColumn Header="ProcessID" Binding="{Binding ProgramID}" Width="0" MinWidth="0" MaxWidth="0"/>
|
<DataGridTextColumn Header="ProcessID" Binding="{Binding ProgramID}" Width="0" MinWidth="0" MaxWidth="0"/>
|
||||||
<DataGridTextColumn Header="lock" Binding="{Binding lock}" Width="0" MinWidth="0" MaxWidth="0"/>
|
<DataGridTextColumn Header="lock" Binding="{Binding lock}" Width="0" MinWidth="0" MaxWidth="0"/>
|
||||||
|
<DataGridTextColumn Header="DYELOT" Binding="{Binding Dyelot}" Width="0" MinWidth="0" MaxWidth="0"/>
|
||||||
<DataGridTextColumn Header="{x:Static lang:Resources.State}" Width="120" IsReadOnly="True">
|
<DataGridTextColumn Header="{x:Static lang:Resources.State}" Width="120" IsReadOnly="True">
|
||||||
<DataGridTextColumn.ElementStyle>
|
<DataGridTextColumn.ElementStyle>
|
||||||
<Style TargetType="{x:Type TextBlock}">
|
<Style TargetType="{x:Type TextBlock}">
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ namespace DyeingComputer.View
|
|||||||
string Process_Name;
|
string Process_Name;
|
||||||
string Process_id;
|
string Process_id;
|
||||||
string _lock;
|
string _lock;
|
||||||
|
string Dyelot;
|
||||||
bool SQL_UPDATE = false;
|
bool SQL_UPDATE = false;
|
||||||
int inf_cont = 0;
|
int inf_cont = 0;
|
||||||
|
|
||||||
@@ -225,6 +226,7 @@ namespace DyeingComputer.View
|
|||||||
Process_Name = (Grid.Columns[1].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第1列,
|
Process_Name = (Grid.Columns[1].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第1列,
|
||||||
Process_id = (Grid.Columns[2].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第0列,
|
Process_id = (Grid.Columns[2].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第0列,
|
||||||
_lock = (Grid.Columns[3].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第1列,
|
_lock = (Grid.Columns[3].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第1列,
|
||||||
|
Dyelot = (Grid.Columns[4].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第1列,
|
||||||
|
|
||||||
SQL_UPDATE = true;
|
SQL_UPDATE = true;
|
||||||
|
|
||||||
@@ -339,7 +341,6 @@ namespace DyeingComputer.View
|
|||||||
}
|
}
|
||||||
|
|
||||||
DataTable WorkorderSteps = new DataTable();
|
DataTable WorkorderSteps = new DataTable();
|
||||||
DataTable data_t = new DataTable();
|
|
||||||
int a;
|
int a;
|
||||||
|
|
||||||
/*检查并写入run信息*/
|
/*检查并写入run信息*/
|
||||||
@@ -369,27 +370,23 @@ namespace DyeingComputer.View
|
|||||||
updata_temp.Clear(); //使用前清缓存
|
updata_temp.Clear(); //使用前清缓存
|
||||||
updata_temp.Add("State", 205);
|
updata_temp.Add("State", 205);
|
||||||
SQLiteHelpers.Update("WorkOrder", updata_temp, "WorkOrder='" + WorkOrder_Numder + "'", null);
|
SQLiteHelpers.Update("WorkOrder", updata_temp, "WorkOrder='" + WorkOrder_Numder + "'", null);
|
||||||
MainWindowViewModel.Dyelot_dat = SQLiteHelpers.ExecuteDataSet("select * from Dyelot where WorkOrder = '" +
|
MainWindowViewModel.Dyelot_dat = SQLiteHelpers.ExecuteDataSet("select * from Dyelot where Dyelot = '" +
|
||||||
WorkOrder_Numder + "'", null).Tables[0];
|
Dyelot + "'", null).Tables[0];
|
||||||
WorkorderSteps = SQLiteHelpers.ExecuteDataSet(
|
WorkorderSteps = SQLiteHelpers.ExecuteDataSet(
|
||||||
"select * from WorkorderSteps where WorkOrder='" + WorkOrder_Numder + "'", null).Tables[0]; //读取表写入缓存
|
"select * from WorkorderSteps where WorkOrder='" + WorkOrder_Numder + "'", null).Tables[0]; //读取表写入缓存
|
||||||
MainWindowViewModel.ProgramName = Process_Name;
|
MainWindowViewModel.ProgramName = Process_Name;
|
||||||
|
MainWindowViewModel.Dyelot = Dyelot;
|
||||||
SQLiteHelpers.Delete("RUN", null, null); //删除run信息
|
SQLiteHelpers.Delete("RUN", null, null); //删除run信息
|
||||||
data_t = WorkorderSteps.Clone();
|
|
||||||
a = WorkorderSteps.Rows.Count;
|
a = WorkorderSteps.Rows.Count;
|
||||||
for (int i = 0; i < a; i++)
|
for (int i = 0; i < a; i++)
|
||||||
{
|
{
|
||||||
data_t.Clear();//清空
|
DataRow dr = WorkorderSteps.Rows[i];//行转
|
||||||
DataRow dt = WorkorderSteps.Rows[i];//行转
|
|
||||||
DataRow dr = data_t.NewRow();
|
|
||||||
dr.ItemArray = dt.ItemArray;
|
|
||||||
dr.BeginEdit(); //添加订单号
|
dr.BeginEdit(); //添加订单号
|
||||||
dr["ProgramID"] = Process_id;
|
dr["ProgramID"] = Process_id;
|
||||||
dr["Program"] = MainWindowViewModel.ProgramName;
|
dr["Program"] = MainWindowViewModel.ProgramName;
|
||||||
dr.EndEdit();
|
dr.EndEdit();
|
||||||
data_t.Rows.InsertAt(dr, 0); //行转换
|
|
||||||
|
|
||||||
SQLiteHelpers.InsertData("RUN", SQLiteHelpers.DataTableToDictionary(data_t));//行插入
|
SQLiteHelpers.InsertData("RUN", SQLiteHelpers.ToDictionary(dr));//行插入
|
||||||
}
|
}
|
||||||
updata_temp.Clear(); //使用前清缓存
|
updata_temp.Clear(); //使用前清缓存
|
||||||
updata_temp.Add("RUN", 1);
|
updata_temp.Add("RUN", 1);
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ namespace DyeingComputer.ViewModel
|
|||||||
public static DataTable errTabler = new DataTable();//错误表
|
public static DataTable errTabler = new DataTable();//错误表
|
||||||
public static DataTable RUN_DATATABLE = new DataTable();//缓存工作表
|
public static DataTable RUN_DATATABLE = new DataTable();//缓存工作表
|
||||||
public static DataTable Dyelot_dat = new DataTable();//物料表
|
public static DataTable Dyelot_dat = new DataTable();//物料表
|
||||||
|
public static string Dyelot; //领料单号
|
||||||
public static int RUN_STEPID;//当前步骤
|
public static int RUN_STEPID;//当前步骤
|
||||||
public static int SYS_REDYE=0;//当前重燃步
|
public static int SYS_REDYE=0;//当前重燃步
|
||||||
public static string SYSKEY;
|
public static string SYSKEY;
|
||||||
@@ -2843,6 +2844,7 @@ namespace DyeingComputer.ViewModel
|
|||||||
dat_FR.Add("State", "201");
|
dat_FR.Add("State", "201");
|
||||||
dat_FR.Add("Tank", TANK.ToString());
|
dat_FR.Add("Tank", TANK.ToString());
|
||||||
dat_FR.Add("Machine", S01);
|
dat_FR.Add("Machine", S01);
|
||||||
|
dat_FR.Add("Type", Type);
|
||||||
dat_FR.Add("CALL_TIME", sys_Time);
|
dat_FR.Add("CALL_TIME", sys_Time);
|
||||||
|
|
||||||
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
||||||
|
|||||||
Reference in new issue
Block a user