数据库连接修改

This commit is contained in:
sc committed 2025-08-28 18:30:42 +08:00
commit ad64084638
14 files changed
+306 -305

No files matched your search

+60 -59
View File
@@ -69,8 +69,8 @@ namespace DyeingComputer.UserClass
public static string[] Prohibit = new string[10] { "S01", "S02", "S03", "S05", "S06", "S07", "SL1", "SL2", "SL3", ""};//禁止操作的指令
public static SQLiteHelper SQLiteHelpers = null; //定义数据库
public static readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\800COMPUTER.db"; //数据库路径
// public static SQLiteHelper SQLiteHelpers = null; //定义数据库
// public static readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\800COMPUTER.db"; //数据库路径
public static async Task Main()
{
NetFwManger.AllowPort(7790,"TCP");//开放7790端口
@@ -263,11 +263,11 @@ namespace DyeingComputer.UserClass
else if (dat_821.GetValue("INSTRUCTION").ToString() == "INSERT")
{
int d = Convert.ToInt16(dat_821.GetValue("ID"));
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
SQLiteHelpers.Open(); //打开数据库
//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();
string ProgramID = MainWindow.SQLiteHelpers.ExecuteScalar("select ProgramID from RUN where Step = '1'", null).ToString();
string ProgramNAME = MainWindow.SQLiteHelpers.ExecuteScalar("select Program from RUN where Step = '1'", null).ToString();
// TechnologicalProcessView.SQLiteHelpers.Close();
DataRow dr = MainWindowViewModel.dt_TP.NewRow();//添加表数据
dr["ProgramID"] = ProgramID;
@@ -298,7 +298,7 @@ namespace DyeingComputer.UserClass
/**存入信息**/
// SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
// SQLiteHelpers.Open(); //打开数据库
SQLiteHelpers.Delete("RUN", null, null);
MainWindow.SQLiteHelpers.Delete("RUN", null, null);
DataTable data_t = MainWindowViewModel.dt_TP.Clone();
for (int i = 0; i < MainWindowViewModel.dt_TP.Rows.Count; i++)
{
@@ -312,9 +312,9 @@ namespace DyeingComputer.UserClass
drT["DYELOT"] = MainWindowViewModel.WorkNumder;
drT.EndEdit();
SQLiteHelpers.InsertData("RUN", SQLiteHelpers.DataTableToDictionary(data_t));//行插入
MainWindow.SQLiteHelpers.InsertData("RUN", MainWindow.SQLiteHelpers.DataTableToDictionary(data_t));//行插入
}
SQLiteHelpers.Close(); //关闭连接
//SQLiteHelpers.Close(); //关闭连接
client.SendAsync("SC831" + "[" + MainWindowViewModel.S01 + "]" + MainWindowViewModel.dt_TP.ToJsonString());
MainWindowViewModel.TX++;
@@ -339,9 +339,9 @@ namespace DyeingComputer.UserClass
// _TechnologicalProcessView.Grid.ItemsSource = TechnologicalProcessView.sql.Tables[0].DefaultView;
_TechnologicalProcessView.GridSTEP.SelectedIndex = -1;
/**存入信息**/
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
SQLiteHelpers.Open(); //打开数据库
SQLiteHelpers.Delete("RUN", null, null);
//SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
//SQLiteHelpers.Open(); //打开数据库
MainWindow.SQLiteHelpers.Delete("RUN", null, null);
DataTable data_t = MainWindowViewModel.dt_TP.Clone();
for (int i = 0; i < MainWindowViewModel.dt_TP.Rows.Count; i++)
{
@@ -355,9 +355,9 @@ namespace DyeingComputer.UserClass
drT["DYELOT"] = MainWindowViewModel.WorkNumder;
drT.EndEdit();
SQLiteHelpers.InsertData("RUN", SQLiteHelpers.DataTableToDictionary(data_t));//行插入
MainWindow.SQLiteHelpers.InsertData("RUN", MainWindow.SQLiteHelpers.DataTableToDictionary(data_t));//行插入
}
SQLiteHelpers.Close(); //关闭连接
//SQLiteHelpers.Close(); //关闭连接
client.SendAsync("SC831" + "[" + MainWindowViewModel.S01 + "]" + MainWindowViewModel.dt_TP.ToJsonString());
MainWindowViewModel.TX++;
@@ -368,9 +368,9 @@ namespace DyeingComputer.UserClass
MainWindowViewModel.dt_TP.Rows.RemoveAt(d - 1);
TechnologicalProcessView.Dat();
/**存入信息**/
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
SQLiteHelpers.Open(); //打开数据库
SQLiteHelpers.Delete("RUN", null, null);
//SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
//SQLiteHelpers.Open(); //打开数据库
MainWindow.SQLiteHelpers.Delete("RUN", null, null);
DataTable data_t = MainWindowViewModel.dt_TP.Clone();
for (int i = 0; i < MainWindowViewModel.dt_TP.Rows.Count; i++)
{
@@ -384,9 +384,9 @@ namespace DyeingComputer.UserClass
drT["DYELOT"] = MainWindowViewModel.WorkNumder;
drT.EndEdit();
SQLiteHelpers.InsertData("RUN", SQLiteHelpers.DataTableToDictionary(data_t));//行插入
MainWindow.SQLiteHelpers.InsertData("RUN", MainWindow.SQLiteHelpers.DataTableToDictionary(data_t));//行插入
}
SQLiteHelpers.Close(); //关闭连接
//SQLiteHelpers.Close(); //关闭连接
client.SendAsync("SC831" + "[" + MainWindowViewModel.S01 + "]" + MainWindowViewModel.dt_TP.ToJsonString());
MainWindowViewModel.TX++;
@@ -407,12 +407,12 @@ namespace DyeingComputer.UserClass
{
try
{
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
SQLiteHelpers.Open(); //打开数据库
// SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
// SQLiteHelpers.Open(); //打开数据库
string sql_script = "select * from Dyelot where State = '201' AND WorkOrder = '" +
MainWindowViewModel.WorkNumder + "'";
DataTable dt = SQLiteHelpers.ExecuteDataSet(sql_script, null).Tables[0]; //转换
SQLiteHelpers.Close(); //关闭连接
DataTable dt = MainWindow.SQLiteHelpers.ExecuteDataSet(sql_script, null).Tables[0]; //转换
//SQLiteHelpers.Close(); //关闭连接
client.SendAsync("SC827" + "[" + MainWindowViewModel.S01 + "]" + dt.ToJsonString());
MainWindowViewModel.TX++;
@@ -430,8 +430,8 @@ namespace DyeingComputer.UserClass
Dictionary<string, object> Dyelot_dat;
Dyelot_dat = SerializeConvert.JsonDeserializeFromString<Dictionary<string, object>>(SYSDAT);
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
SQLiteHelpers.Open(); //打开数据库
// SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
// SQLiteHelpers.Open(); //打开数据库
Dictionary<string, object> Product_data = new Dictionary<string, object>();//缓存函数
Product_data.Add("State", Dyelot_dat.GetValue("State"));
@@ -440,17 +440,17 @@ namespace DyeingComputer.UserClass
Product_data.Add("Amount", Dyelot_dat.GetValue("Amount"));
Product_data.Add("DispenseEndTime", Dyelot_dat.GetValue("DispenseEndTime"));
}
SQLiteHelpers.Update("Dyelot", Product_data, "Dyelot ='" + Dyelot_dat.GetValue("Dyelot")
MainWindow.SQLiteHelpers.Update("Dyelot", Product_data, "Dyelot ='" + Dyelot_dat.GetValue("Dyelot")
+ "' AND Step ='" + Dyelot_dat.GetValue("Step") + "' AND ProductCode='" +
Dyelot_dat.GetValue("ProductCode") + "'", null);
MainWindowViewModel.Dyelot_dat = SQLiteHelpers.ExecuteDataSet(
MainWindowViewModel.Dyelot_dat = MainWindow.SQLiteHelpers.ExecuteDataSet(
"select * from Dyelot where WorkOrder = '" +
MainWindowViewModel.WorkNumder + "'", null).Tables[0];
int dt = SQLiteHelpers.ExecuteDataSet("select * from Dyelot where Dyelot='" +
int dt = MainWindow.SQLiteHelpers.ExecuteDataSet("select * from Dyelot where Dyelot='" +
Dyelot_dat.GetValue("Dyelot") + "' AND State ='201'", null).Tables[0].Rows.Count;
if (dt == 0) MainWindowViewModel.CALL_FR = false;
SQLiteHelpers.Close(); //关闭连接
//SQLiteHelpers.Close(); //关闭连接
client.SendAsync("SC828" + SYSKEY + SYSDAT);
MainWindowViewModel.TX++;
@@ -574,11 +574,11 @@ namespace DyeingComputer.UserClass
{
try
{
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
SQLiteHelpers.Open(); //打开数据库
//SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
//SQLiteHelpers.Open(); //打开数据库
string sql_script = "select * from Dyelot where WorkOrder = '" + MainWindowViewModel.WorkNumder + "'";
DataTable dt = SQLiteHelpers.ExecuteDataSet(sql_script, null).Tables[0]; //转换
SQLiteHelpers.Close(); //关闭连接
DataTable dt = MainWindow.SQLiteHelpers.ExecuteDataSet(sql_script, null).Tables[0]; //转换
// SQLiteHelpers.Close(); //关闭连接
client.SendAsync("SC833" + "[" + MainWindowViewModel.S01 + "]" + dt.ToJsonString());
MainWindowViewModel.TX++;
@@ -656,17 +656,18 @@ namespace DyeingComputer.UserClass
{
try
{
SQLiteHelper SQLiteHelpersLOG = new SQLiteHelper("\\DataBase\\LOG.db"); //数据库连接路径
Dictionary<string, object> dat_859;
dat_859 = SerializeConvert.JsonDeserializeFromString<Dictionary<string, object>>(SYSDAT);
if (dat_859.GetValue("INSTRUCTION").ToString() == "SERVER")
{
SQLiteHelpers = new SQLiteHelper("\\DataBase\\LOG.db"); //数据库连接路径
SQLiteHelpers.Open(); //打开数据库
DataTable dt_ = SQLiteHelpers.ExecuteDataSet("select * from SERVER where TIME >"+
//SQLiteHelper SQLiteHelpersLOG = new SQLiteHelper("\\DataBase\\LOG.db"); //数据库连接路径
SQLiteHelpersLOG.Open(); //打开数据库
DataTable dt_ = SQLiteHelpersLOG.ExecuteDataSet("select * from SERVER where TIME >"+
DateTime.Parse(dat_859.GetValue("TIME_S").ToString()).ToString("yyyy/MM/dd HH:mm:ss") + "TIME <"+
DateTime.Parse(dat_859.GetValue("TIME_E").ToString()).ToString("yyyy/MM/dd HH:mm:ss"), null).Tables[0];
SQLiteHelpers.Close();//关闭数据库
SQLiteHelpersLOG.Close();//关闭数据库
client.SendAsync("SC859" + "[" + MainWindowViewModel.S01 + "]" + dt_.ToJsonString());//缓存信息
@@ -674,12 +675,12 @@ namespace DyeingComputer.UserClass
}
else if (dat_859.GetValue("INSTRUCTION").ToString() == "OperationLog")
{
SQLiteHelpers = new SQLiteHelper("\\DataBase\\LOG.db"); //数据库连接路径
SQLiteHelpers.Open(); //打开数据库
DataTable dt_ = SQLiteHelpers.ExecuteDataSet("select * from OperationLog where TIME >" +
//SQLiteHelpers = new SQLiteHelper("\\DataBase\\LOG.db"); //数据库连接路径
SQLiteHelpersLOG.Open(); //打开数据库
DataTable dt_ = SQLiteHelpersLOG.ExecuteDataSet("select * from OperationLog where TIME >" +
DateTime.Parse(dat_859.GetValue("TIME_S").ToString()).ToString("yyyy/MM/dd HH:mm:ss") + "TIME <" +
DateTime.Parse(dat_859.GetValue("TIME_E").ToString()).ToString("yyyy/MM/dd HH:mm:ss"), null).Tables[0];
SQLiteHelpers.Close();//关闭数据库
SQLiteHelpersLOG.Close();//关闭数据库
client.SendAsync("SC859" + "[" + MainWindowViewModel.S01 + "]" + dt_.ToJsonString());//缓存信息
@@ -687,12 +688,12 @@ namespace DyeingComputer.UserClass
}
else if (dat_859.GetValue("INSTRUCTION").ToString() == "IOLog")
{
SQLiteHelpers = new SQLiteHelper("\\DataBase\\LOG.db"); //数据库连接路径
SQLiteHelpers.Open(); //打开数据库
DataTable dt_ = SQLiteHelpers.ExecuteDataSet("select * from IOLog where TIME >" +
//SQLiteHelpers = new SQLiteHelper("\\DataBase\\LOG.db"); //数据库连接路径
SQLiteHelpersLOG.Open(); //打开数据库
DataTable dt_ = SQLiteHelpersLOG.ExecuteDataSet("select * from IOLog where TIME >" +
DateTime.Parse(dat_859.GetValue("TIME_S").ToString()).ToString("yyyy/MM/dd HH:mm:ss") + "TIME <" +
DateTime.Parse(dat_859.GetValue("TIME_E").ToString()).ToString("yyyy/MM/dd HH:mm:ss"), null).Tables[0];
SQLiteHelpers.Close();//关闭数据库
SQLiteHelpersLOG.Close();//关闭数据库
client.SendAsync("SC859" + "[" + MainWindowViewModel.S01 + "]" + dt_.ToJsonString());//缓存信息
@@ -700,12 +701,12 @@ namespace DyeingComputer.UserClass
}
else if (dat_859.GetValue("INSTRUCTION").ToString() == "ERRLog")
{
SQLiteHelpers = new SQLiteHelper("\\DataBase\\LOG.db"); //数据库连接路径
SQLiteHelpers.Open(); //打开数据库
DataTable dt_ = SQLiteHelpers.ExecuteDataSet("select * from ERRLog where TIME >" +
//SQLiteHelpers = new SQLiteHelper("\\DataBase\\LOG.db"); //数据库连接路径
SQLiteHelpersLOG.Open(); //打开数据库
DataTable dt_ = SQLiteHelpersLOG.ExecuteDataSet("select * from ERRLog where TIME >" +
DateTime.Parse(dat_859.GetValue("TIME_S").ToString()).ToString("yyyy/MM/dd HH:mm:ss") + "TIME <" +
DateTime.Parse(dat_859.GetValue("TIME_E").ToString()).ToString("yyyy/MM/dd HH:mm:ss"), null).Tables[0];
SQLiteHelpers.Close();//关闭数据库
SQLiteHelpersLOG.Close();//关闭数据库
client.SendAsync("SC859" + "[" + MainWindowViewModel.S01 + "]" + dt_.ToJsonString());//缓存信息
@@ -731,11 +732,11 @@ namespace DyeingComputer.UserClass
Dictionary<string, object> datagrid_v = new Dictionary<string, object>();//缓存函数
datagrid_v.Add("Value", dat_861.GetValue("Value"));
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
SQLiteHelpers.Open(); //打开数据库
SQLiteHelpers.Update("Parameters", datagrid_v, "ParameterID ='" + dat_861.GetValue("ID") + "'", null);//更新
MainWindowViewModel.dt_ParameterSet = SQLiteHelpers.ExecuteDataSet("select * from Parameters order by ParameterID asc", null).Tables[0];
SQLiteHelpers.Close();//关闭数据库
// SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
// SQLiteHelpers.Open(); //打开数据库
MainWindow.SQLiteHelpers.Update("Parameters", datagrid_v, "ParameterID ='" + dat_861.GetValue("ID") + "'", null);//更新
MainWindowViewModel.dt_ParameterSet = MainWindow.SQLiteHelpers.ExecuteDataSet("select * from Parameters order by ParameterID asc", null).Tables[0];
//SQLiteHelpers.Close();//关闭数据库
client.SendAsync("SC854" + "[" + MainWindowViewModel.S01 + "]" + MainWindowViewModel.dt_ParameterSet.ToJsonString());//缓存信息
@@ -766,11 +767,11 @@ namespace DyeingComputer.UserClass
Dictionary<string, object> datagrid_v = new Dictionary<string, object>();//缓存函数
datagrid_v.Add("Value", dat_862.GetValue("Value"));
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
SQLiteHelpers.Open(); //打开数据库
SQLiteHelpers.Update("System", datagrid_v, "ParameterID ='" + dat_862.GetValue("ID") + "'", null);//更新
MainWindowViewModel.dt_SysSet = SQLiteHelpers.ExecuteDataSet("select * from System order by ParameterID asc", null).Tables[0];
SQLiteHelpers.Close();//关闭数据库
// SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
// SQLiteHelpers.Open(); //打开数据库
MainWindow.SQLiteHelpers.Update("System", datagrid_v, "ParameterID ='" + dat_862.GetValue("ID") + "'", null);//更新
MainWindowViewModel.dt_SysSet = MainWindow.SQLiteHelpers.ExecuteDataSet("select * from System order by ParameterID asc", null).Tables[0];
//SQLiteHelpers.Close();//关闭数据库
client.SendAsync("SC855" + "[" + MainWindowViewModel.S01 + "]" + MainWindowViewModel.dt_SysSet.ToJsonString());//缓存信息
+6 -6
View File
@@ -10,8 +10,8 @@ namespace DyeingComputer.UserClass
{
public class LogGing
{
private static SQLiteHelper SQLiteHelpers = null; //定义数据库
private readonly static string DBAddress = Environment.CurrentDirectory + "\\DataBase\\800COMPUTER.db"; //数据库路径
// private static SQLiteHelper SQLiteHelpers = null; //定义数据库
// private readonly static string DBAddress = Environment.CurrentDirectory + "\\DataBase\\800COMPUTER.db"; //数据库路径
public static bool sqld=false;
public static void LogGingDATA(string dat)
{
@@ -52,7 +52,7 @@ namespace DyeingComputer.UserClass
if (!sqld)
{
sqld = true;
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
//SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
string Log_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
Dictionary<string, object> logsql = new Dictionary<string, object>();
// 添加元素
@@ -60,9 +60,9 @@ namespace DyeingComputer.UserClass
logsql.Add("API", api);
logsql.Add("MESSAGE", dat);
logsql.Add("TIME", Log_time);
SQLiteHelpers.Open(); //打开数据库
SQLiteHelpers.InsertData("SERVER", logsql);//行插入
SQLiteHelpers.Close(); //关闭连接
// SQLiteHelpers.Open(); //打开数据库
MainWindow.SQLiteHelpers.InsertData("SERVER", logsql);//行插入
//SQLiteHelpers.Close(); //关闭连接
sqld = false;
}
}
+30 -30
View File
@@ -14,18 +14,18 @@ namespace DyeingComputer.UserClass
{
public class SQLDATA
{
private static SQLiteHelper SQLiteHelpers = null; //定义数据库
private readonly static string DBAddress = Environment.CurrentDirectory + "\\DataBase\\800COMPUTER.db"; //数据库路径
// private static SQLiteHelper SQLiteHelpers = null; //定义数据库
// private readonly static string DBAddress = Environment.CurrentDirectory + "\\DataBase\\800COMPUTER.db"; //数据库路径
//WorkOrder表检查写入
public static bool WorkOrder(string WorkOrder, string ProgramName, string StartTime, string EndTime, string Time, string Remark,string lock_,string state,string ProgramID, string color,string dyelot)
{
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
SQLiteHelpers.Open(); //打开数据库
object i = SQLiteHelpers.ExecuteScalar("select * from WorkOrder where WorkOrder = "+ WorkOrder,null);
// SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
// SQLiteHelpers.Open(); //打开数据库
object i = MainWindow.SQLiteHelpers.ExecuteScalar("select * from WorkOrder where WorkOrder = "+ WorkOrder,null);
if (i!=null)
{
SQLiteHelpers.Close();
//SQLiteHelpers.Close();
return false;
}
Dictionary<string, object> WorkOrder_new = new Dictionary<string, object>();//缓存函数
@@ -40,59 +40,59 @@ namespace DyeingComputer.UserClass
WorkOrder_new.Add("ProgramID", ProgramID);
WorkOrder_new.Add("color", color);
WorkOrder_new.Add("Dyelot", dyelot);
SQLiteHelpers.InsertData("WorkOrder", WorkOrder_new);
SQLiteHelpers.Close();
MainWindow.SQLiteHelpers.InsertData("WorkOrder", WorkOrder_new);
//SQLiteHelpers.Close();
return true;
}
public static bool WorkOderStep(DataTable WorkOrderStep_)
{
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
SQLiteHelpers.Open(); //打开数据库
// SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
// SQLiteHelpers.Open(); //打开数据库
int a = WorkOrderStep_.Rows.Count;
if (a < 1)
{
SQLiteHelpers.Close();
MainWindow.SQLiteHelpers.Close();
return false;
}
string Program = WorkOrderStep_.Rows[0][0].ToString();
object n = SQLiteHelpers.ExecuteScalar("select * from WorkorderSteps where Program = " + Program, null);
object n = MainWindow.SQLiteHelpers.ExecuteScalar("select * from WorkorderSteps where Program = " + Program, null);
if (n != null)//如id存在着返回错误状态
{
SQLiteHelpers.Close();
//SQLiteHelpers.Close();
return false;
}
for (int i = 0; i < a; i++)
{
SQLiteHelpers.InsertData("WorkorderSteps", SQLiteHelpers.ToDictionary(WorkOrderStep_.Rows[i]));//行插入
{
MainWindow.SQLiteHelpers.InsertData("WorkorderSteps", MainWindow.SQLiteHelpers.ToDictionary(WorkOrderStep_.Rows[i]));//行插入
}
SQLiteHelpers.Close(); //关闭连接
//SQLiteHelpers.Close(); //关闭连接
return true;
}
public static void TechnologicalProcess_START(string workName)
{
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
SQLiteHelpers.Open(); //打开数据库
// SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
// SQLiteHelpers.Open(); //打开数据库
int r = 0;
string sql_script = "select * from WorkorderSteps where ProgramID = '" + workName + "'";
// if (TechnologicalProcessView.sql != null) TechnologicalProcessView.sql.Clear(); //清空缓存
MainWindowViewModel.dt_TP = SQLiteHelpers.ExecuteDataSet(sql_script, null).Tables[0]; //读取表写入缓存
MainWindowViewModel.ProgramName = SQLiteHelpers.ExecuteScalar("select ProgramName from Workorder where ProgramID = '" + workName + "'", null).ToString();
MainWindowViewModel.dt_TP = MainWindow.SQLiteHelpers.ExecuteDataSet(sql_script, null).Tables[0]; //读取表写入缓存
MainWindowViewModel.ProgramName = MainWindow.SQLiteHelpers.ExecuteScalar("select ProgramName from Workorder where ProgramID = '" + workName + "'", null).ToString();
SQLiteHelpers.Delete("RUN", null, null); //删除run信息
MainWindow.SQLiteHelpers.Delete("RUN", null, null); //删除run信息
int a = MainWindowViewModel.dt_TP.Rows.Count;
for (int i = 0; i < a; i++)
{
SQLiteHelpers.InsertData("RUN", SQLiteHelpers.ToDictionary(MainWindowViewModel.dt_TP.Rows[i]));//行插入
MainWindow.SQLiteHelpers.InsertData("RUN", MainWindow.SQLiteHelpers.ToDictionary(MainWindowViewModel.dt_TP.Rows[i]));//行插入
}
//数据插入
MainWindowViewModel.WorkNumder = SQLiteHelpers.ExecuteDataSet("select WorkOrder from Workorder where ProgramID = '" + workName + "'", null);;
MainWindowViewModel.WorkNumder = MainWindow.SQLiteHelpers.ExecuteDataSet("select WorkOrder from Workorder where ProgramID = '" + workName + "'", null);;
TechnologicalProcessView.workName = workName;
MainWindowViewModel.SYS_REDYE = 0;
MainWindowViewModel.ViewID = 1;
SQLiteHelpers.Close(); //关闭连接
//SQLiteHelpers.Close(); //关闭连接
}
public static bool Dyelot(DataTable Dyelot_)//领料单
@@ -127,19 +127,19 @@ namespace DyeingComputer.UserClass
int a = DyelotTable.Rows.Count;
if (a < 1) return false;
string Dyelot = DyelotTable.Rows[0][0].ToString();
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
SQLiteHelpers.Open(); //打开数据库
object n = SQLiteHelpers.ExecuteScalar("select * from Dyelot where Dyelot = " + Dyelot, null);
//SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
//SQLiteHelpers.Open(); //打开数据库
object n = MainWindow.SQLiteHelpers.ExecuteScalar("select * from Dyelot where Dyelot = " + Dyelot, null);
if (n != null)//如id存在着返回错误状态
{
SQLiteHelpers.Close();
//SQLiteHelpers.Close();
return false;
}
for (int i = 0; i < a; i++)
{
SQLiteHelpers.InsertData("Dyelot", SQLiteHelpers.ToDictionary(DyelotTable.Rows[i]));//行插入
MainWindow.SQLiteHelpers.InsertData("Dyelot", MainWindow.SQLiteHelpers.ToDictionary(DyelotTable.Rows[i]));//行插入
}
SQLiteHelpers.Close(); //关闭连接
//SQLiteHelpers.Close(); //关闭连接
return true;
}