public void initializeDataService(string IP, string ServerUser, string ServerPwd, string dbFilePath) { SqlServerHelp.SetConncetionString(IP, dbFilePath, ServerUser, ServerPwd); ServerIP = IP; this.ServerUser = ServerUser; this.ServerPWD = ServerPwd; }
/// <summary> /// 查询连接状态 例如plc /// </summary> private void PlctConnect() { toolStripStatusLabel1.Text = "欢迎使用高温静置系统" + " "; toolStripStatusLabel2.Text = "欢迎您:" + SySetHeip.LoginInfo + " " + DateTime.Now.ToString(); DeleteInfo++; if (DeleteInfo >= 36000)//删除温度数据 { string SqlError = string.Format(@"delete [dbo.tb_Error] where [ErrorTime] <= '{0} '", DateTime.Now.AddDays(-30).ToString("yyyy-MM-dd HH:mm:ss ")); SqlServerHelp.ExecuteSql(SqlError);//删除一个月外的报警记录 string SqlStatus = string.Format(@"delete [dbo.tb_MachineStatus] where [WriteTime] <= '{0} '", DateTime.Now.AddDays(-30).ToString("yyyy-MM-dd HH:mm:ss ")); SqlServerHelp.ExecuteSql(SqlStatus);//删除一个月外的温度记录 DeleteInfo = 0; } if (PLCSocket.PlcQueryHelp.BreakThread_one) //plc连接状态 { Plc.Image = ND.Properties.Resources.greenlight; //显示绿色灯 lblWranInfo.Text = "PLC通信正常"; } else { Plc.Image = ND.Properties.Resources.redlight;//显示红色灯 lblWranInfo.Text = " PLC通信失败"; } }
private void buttonX1_Click(object sender, EventArgs e) { try { //textName.Text = "ADMIN"; //textPassword.Text = "ADMIN"; string sql = string.Format("select * from tb_Login where Name='{0}' and password='******' and Authority='{2}'", textName.Text.Trim(), textPassword.Text.Trim(), Authority.Text.Trim()); DataTable dt = SqlServerHelp.Query(sql).Tables[0]; if (dt.Rows.Count > 0 && dt != null) { SySetHeip.LoginInfo = Authority.SelectedItem.ToString(); if (dt.Rows[0]["Authority"].ToString().Trim() == "操作员") { SySetHeip.Operate = true; } else if (dt.Rows[0]["Authority"].ToString().Trim() == "管理员") { SySetHeip.Admin = true; } else if (dt.Rows[0]["Authority"].ToString().Trim() == "工程师") { SySetHeip.Engineer = true; } frm_Authoring f = new frm_Authoring(); this.Hide(); f.Show(); } else { Common.Msg.ShowError("未找到登录的相关信息"); } } catch {} }
private void OutInfo() { string sql = string.Format(@"SELECT OutTem,OutTime FROM [dbo.tb_RnuInfo] "); DataTable dt = SqlServerHelp.DtQuery(sql).Tables[0]; string[] timeList = new string[] { OutAndInInfoHelp.time1, OutAndInInfoHelp.time2, OutAndInInfoHelp.time3, OutAndInInfoHelp.time4, OutAndInInfoHelp.time5, OutAndInInfoHelp.time6, OutAndInInfoHelp.time7, OutAndInInfoHelp.time8, }; for (int i = 0; i < timeList.Length; i++) { timeList[i] = dt.Rows[i]["OutTem"].ToString(); } while (true) { OutAndInInfoHelp.StopTimeAddress();//完成时,调用接口 Thread.Sleep(5000); } }
/// <summary> /// 查询数据库已经出站第几个小车 /// </summary> /// <param name="Door"></param> /// <returns></returns> //10=已经入站,15=已经出站一个小车,20=已经全部出站完 public static string RunOutInfo(string Door) { string Sql = string.Format(@"SELECT * FROM [db_ND10L].[dbo].[dbo.tb_RnuInfo] WHERE Door ='{0}'", Door); DataTable dt = SqlServerHelp.Query(Sql).Tables[0]; return(dt.Rows[0]["OutAndInInfo"].ToString().Trim()); }
public frm_TimeQuery() { InitializeComponent(); try { string sql = string.Format(@"SELECT * FROM [db_ND10L].[dbo].[dbo.tb_RnuInfo]"); dgvmain.DataSource = SqlServerHelp.Query(sql).Tables[0]; } catch { } }
public static int SolitaryHandbarrow2(string HandbarrowBarCode2) { DateTime beginTime = DateTime.Now; DateTime endTime = DateTime.Now; TimeSpan timeS = new TimeSpan(); try { getCell = Interface.ChargeNumberAddess(HandbarrowBarCode2, Number, DoorInfo); //调用接口 Meg = [email protected]; //返回信息 Code = [email protected]; //code } catch (Exception ex) { Meg = ex.Message; Code = 1001; } finally { if (string.IsNullOrEmpty(Meg) && [email protected] == 0) { BarcodeList2 = ""; endTime = DateTime.Now; timeS = endTime - beginTime; ControlHelp.ControlHelp.listBoxInfo("MES返回:" + [email protected] + "信息:" + [email protected] + " 耗时:" + timeS.Milliseconds.ToString());//返回信息 List <string> list = strToNull([email protected]); for (int i = 0; i < list.Count; i++) { BarcodeList2 += list[i] + ","; } if (!string.IsNullOrEmpty(BarcodeList2)) { BarcodeList2 = InterceptStringHelp.Delectlast(BarcodeList2); //写CSV文件 ConfigureHelp.SaveInfoToCSVFileAtLog(beginTime.ToString("yyyy-MM-dd hh:mm:ss"), endTime.ToString("yyyy-MM-dd hh:mm:ss"), timeS.TotalMilliseconds.ToString(), string.Format("开始时间代码Error [BeginTime]({0}、{1})", HandbarrowBarCode2, Number), Code + "", Meg, 1); } } else { ControlHelp.ControlHelp.listBoxInfo("MES返回:" + [email protected] + "信息:" + [email protected] + " 耗时:" + timeS.Milliseconds.ToString());//返回信息 //写CSV文件 ConfigureHelp.SaveInfoToCSVFileAtLog(beginTime.ToString("yyyy-MM-dd hh:mm:ss"), endTime.ToString("yyyy-MM-dd hh:mm:ss"), timeS.TotalMilliseconds.ToString(), string.Format("开始时间代码Error [BeginTime]({0}、{1})", HandbarrowBarCode2, Number), Code + "", Meg, 1); Common.Msg.Warning("条码号:" + HandbarrowBarCode2 + "获取小车内的托盘失败,请重新两个绑定小车"); } //扫到的条形码写入数据库 string Sql = string.Format(@"UPDATE [db_ND10L].[dbo].[dbo.tb_RnuInfo] SET Barcode2 ='{0}',BarcodeInclude2='{1}' WHERE Door='{2}'", HandbarrowBarCode2, BarcodeList2, DoorInfo); SqlServerHelp.ExecuteSql(Sql); } return(Code); }
private void button2_Click(object sender, EventArgs e) { string sql = string.Format("DELETE FROM[db_ND10L].[dbo].[tb_Login] WHERE ID ='{0}'", Order.Text.Trim()); SqlServerHelp.ExecuteSql(sql); //删除用户 ControlHelp.ControlHelp.SqlErrorInfo("删除用户" + SetName.Text.Trim() + " " + "权限:" + Authority.Text.Trim() + " " + "序列号:" + Order.Text.Trim()); string sql1 = string.Format("select * from tb_Login "); dgvmain.DataSource = SqlServerHelp.Query(sql1).Tables[0]; }
private void Revise_Click(object sender, EventArgs e) { string sql = string.Format(@"UPDATE [db_ND10L].[dbo].[tb_Login] set Name='{0}' ,password='******',Authority='{2}' where ID='{3}'", SetName.Text.Trim(), SetPwodr.Text.Trim(), Authority.Text.Trim(), Order.Text.Trim()); SqlServerHelp.ExecuteSql(sql); //修改用户 ControlHelp.ControlHelp.SqlErrorInfo("修改用户" + SetName.Text.Trim() + " " + "权限:" + Authority.Text.Trim()); string sql1 = string.Format("select * from tb_Login "); dgvmain.DataSource = SqlServerHelp.Query(sql1).Tables[0]; }
public static void WriteSqlAddress(string door, double[] list, double RunTime, double SetTime) { string sql = string.Format(@"INSERT INTO [db_ND10L].[dbo].[dbo.tb_MachineStatus] ([WriteTime] ,[Door] ,[UpperLimitOfTemperature] ,[LowerTemperatureLimit] ,[MonitoringTemperature] ,[SetValueMonitoringTemperature] ,[RunTime],SetTime) values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), door, list[0], list[1], list[2], list[3], RunTime, SetTime); SqlServerHelp.ExecuteSql(sql); }
public DataSet Query(string tableNameSQL, string orderSQL, string conditionSQL) { DataSet ds = new DataSet(); string[] names = tableNameSQL.Split(_separator); string[] orders = null; string[] conditions = null; if (orderSQL != null) { orders = orderSQL.Split(_separator); } if (conditionSQL != null) { conditions = conditionSQL.Split(_separator); } for (int i = 0; i < names.Count(); ++i) { string tableName = TableNamePrex + names[i]; string strCmd = ""; if (conditions != null && i < conditions.Count()) { string cond = conditions[i]; strCmd = getSelectCmd(tableName, cond); } else { strCmd = "SELECT * FROM " + tableName + ""; } if (orders != null && i < orders.Count()) { strCmd += OrderSQL(orders[i]); } DataSet _ds = SqlServerHelp.Query(strCmd); if (_ds.Tables.Count > 0) { DataTable dt = _ds.Tables[0]; _ds.Tables.RemoveAt(0); dt.TableName = tableName; ds.Tables.Add(dt); } } return(ds); }
private void button1_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(SetName.Text.Trim()) && !string.IsNullOrEmpty(SetPwodr.Text.Trim()) && !string.IsNullOrEmpty(Authority.Text.Trim())) { string sql = string.Format(@"INSERT INTO [db_ND10L].[dbo].[tb_Login](Name,[password],Authority ) VALUES('{0}','{1}','{2}')", SetName.Text.Trim(), SetPwodr.Text.Trim(), Authority.Text.Trim()); SqlServerHelp.ExecuteSql(sql); //增加用户 ControlHelp.ControlHelp.SqlErrorInfo("增加用户" + SetName.Text.Trim() + " " + "权限:" + Authority.Text.Trim()); string sql1 = string.Format("select * from tb_Login "); dgvmain.DataSource = SqlServerHelp.Query(sql1).Tables[0]; } else { Common.Msg.Warning("增加的用户,密码,权限,三者之间不能有一个为空"); } }
/// <summary> /// 查询第二个的条形码 /// </summary> /// <param name="door">炉门条件</param> /// <returns></returns> public static List <string> QueryBarcodeInfo2(string door) { string Sql = string.Format(@"SELECT * FROM[db_ND10L].[dbo].[dbo.tb_RnuInfo] WHERE Door = '{0}'", door); DataTable bt = SqlServerHelp.Query(Sql).Tables[0]; Barcode2 = bt.Rows[0]["Barcode2"].ToString(); string[] list = InterceptStringHelp.SingleCharacter(bt.Rows[0]["BarcodeInclude2"].ToString().Trim()); List <string> listTemp = new List <string>(); foreach (string s in list) { if (string.IsNullOrEmpty(s)) { continue; } listTemp.Add(s); } return(listTemp); }
/// <summary> /// 调用出站接口,更改出站小车状态 /// </summary> /// <param name="Info"></param> /// <param name="door"></param> public static void PlcEndTime(string Info, string door) { string Sql = string.Format(@"UPDATE [db_ND10L].[dbo].[dbo.tb_RnuInfo] SET OutAndInInfo='{0}' WHERE Door='{1}'", Info, door); SqlServerHelp.ExecuteSql(Sql); }
/// <summary> /// 炉门开始/停止时间写入数据库(运行完成时,调接口出站) /// </summary> //dt.Rows[0]["OutAndInInfo"].ToString().Trim()=20为已经出完两个小车 public static void StopTimeAddress() { List <string> List = new List <string>(); List <string> List2 = new List <string>(); try { if (PlcQueryHelp.BreakThread_one) { if (PlcQueryHelp.BitStatus1[0]) //联机 { if (PlcQueryHelp.BitStatus1[2]) //启动时写入时间 { if (RunOutInfo("1") != "10") { PlcBeginTime("1");//该炉子已经入站运行 } } if (PlcQueryHelp.BitStatus1[4]) { if (string.IsNullOrEmpty(time1) && string.IsNullOrEmpty(temperature1)) //运行完成 { time1 = PlcQueryHelp.SetTime1.ToString(); //时间 temperature1 = PlcQueryHelp.listAddressTime1[2].ToString(); //温度 string sql = string.Format(@"UPDATE [dbo.tb_RnuInfo] SET OutTem={0}, OutTime={1} WHERE Door={2}", time1, temperature1, 1); SqlServerHelp.ExecuteSql(sql); } if (RunOutInfo("1") == "10" || string.IsNullOrEmpty(RunOutInfo("1"))) //运行完成,开始出第一个小车 { List = QueryBarcodeInfo("1"); //小车1内的所有托盘信息 InterfaceHelp.Interface.ReceiveNumber(List, Barcode, "1", "15", SySetHeip.ResourceNumberOne, time1, temperature1); } if (RunOutInfo("1") == "15") //已经出完第一个小车,开始出第二个小车 { List2 = QueryBarcodeInfo2("1"); //小车2内的所有托盘信息 InterfaceHelp.Interface.ReceiveNumber(List2, Barcode2, "1", "20", SySetHeip.ResourceNumberOne, time1, temperature1); } if (RunOutInfo("1") == "20")//已经出完两个小车, { time1 = ""; temperature1 = ""; string Sql = string.Format(@"UPDATE [db_ND10L].[dbo].[dbo.tb_RnuInfo] SET OutAndInInfo='{0}' WHERE Door='{1}'", "两个小车出站完成", 1); SqlServerHelp.ExecuteSql(Sql); } } } else { string Sql = string.Format(@"UPDATE [db_ND10L].[dbo].[dbo.tb_RnuInfo] SET Barcode='{0}',BarcodeInclude ='{0}', Barcode2='{0}',BarcodeInclude2 ='{0}' , OutAndInInfo='{0}' WHERE Door='{1}'", "", 1); SqlServerHelp.ExecuteSql(Sql); } //2 if (PlcQueryHelp.BitStatus2[0]) { if (PlcQueryHelp.BitStatus2[2])//启动时写入时间 { if (RunOutInfo("2") != "10") { PlcBeginTime("2");//该炉子已经入站运行 } } if (PlcQueryHelp.BitStatus2[4]) { if (string.IsNullOrEmpty(time2) && string.IsNullOrEmpty(temperature2)) //运行完成 { time2 = PlcQueryHelp.SetTime2.ToString(); //时间 temperature2 = PlcQueryHelp.listAddressTime2[2].ToString(); //温度 string sql = string.Format(@"UPDATE [dbo.tb_RnuInfo] SET OutTem={0}, OutTime={1} WHERE Door={2}", time2, temperature2, 2); SqlServerHelp.ExecuteSql(sql); } if (RunOutInfo("2") == "10" || string.IsNullOrEmpty(RunOutInfo("2")))//运行完成,开始出第一个小车 { List = QueryBarcodeInfo("2"); InterfaceHelp.Interface.ReceiveNumber(List, Barcode, "2", "15", SySetHeip.ResourceNumberTwo, time2, temperature2); } if (RunOutInfo("2") == "15")//已经出完第一个小车,开始出第二个小车 { List2 = QueryBarcodeInfo2("2"); InterfaceHelp.Interface.ReceiveNumber(List2, Barcode2, "2", "20", SySetHeip.ResourceNumberTwo, time2, temperature2); } if (RunOutInfo("2") == "20")//已经出完两个小车, { time2 = ""; temperature2 = ""; string Sql = string.Format(@"UPDATE [db_ND10L].[dbo].[dbo.tb_RnuInfo] SET OutAndInInfo='{0}' WHERE Door='{1}'", "两个小车出站完成", 2); SqlServerHelp.ExecuteSql(Sql); } } } else { string Sql = string.Format(@"UPDATE [db_ND10L].[dbo].[dbo.tb_RnuInfo] SET Barcode='{0}',BarcodeInclude ='{0}', Barcode2='{0}',BarcodeInclude2 ='{0}' , OutAndInInfo='{0}' WHERE Door='{1}'", "", 2); SqlServerHelp.ExecuteSql(Sql); } //3 if (PlcQueryHelp.BitStatus3[0]) { if (PlcQueryHelp.BitStatus3[2])//启动时写入时间 { if (RunOutInfo("3") != "10") { PlcBeginTime("3");//该炉子已经入站运行 } } if (PlcQueryHelp.BitStatus3[4]) { if (string.IsNullOrEmpty(time3) && string.IsNullOrEmpty(temperature3)) //运行完成 { time3 = PlcQueryHelp.SetTime3.ToString(); //时间 temperature3 = PlcQueryHelp.listAddressTime3[2].ToString(); //温度 string sql = string.Format(@"UPDATE [dbo.tb_RnuInfo] SET OutTem={0}, OutTime={1} WHERE Door={2}", time3, temperature3, 3); SqlServerHelp.ExecuteSql(sql); } if (RunOutInfo("3") == "10" || string.IsNullOrEmpty(RunOutInfo("3")))//运行完成,开始出第一个小车 { List = QueryBarcodeInfo("3"); InterfaceHelp.Interface.ReceiveNumber(List, Barcode, "3", "15", SySetHeip.ResourceNumberThree, time3, temperature3); } if (RunOutInfo("3") == "15")//已经出完第一个小车,开始出第二个小车 { List2 = QueryBarcodeInfo2("3"); InterfaceHelp.Interface.ReceiveNumber(List2, Barcode2, "3", "20", SySetHeip.ResourceNumberThree, time3, temperature3); } if (RunOutInfo("3") == "20")//已经出完两个小车 { time3 = ""; temperature3 = ""; string Sql = string.Format(@"UPDATE [db_ND10L].[dbo].[dbo.tb_RnuInfo] SET OutAndInInfo='{0}' WHERE Door='{1}'", "两个小车出站完成", 3); SqlServerHelp.ExecuteSql(Sql); } } } else { string Sql = string.Format(@"UPDATE [db_ND10L].[dbo].[dbo.tb_RnuInfo] SET Barcode='{0}',BarcodeInclude ='{0}', Barcode2='{0}',BarcodeInclude2 ='{0}' , OutAndInInfo='{0}' WHERE Door='{1}'", "", 3); SqlServerHelp.ExecuteSql(Sql); } //4 if (PlcQueryHelp.BitStatus4[0]) { if (PlcQueryHelp.BitStatus4[2])//启动时写入时间 { if (RunOutInfo("4") != "10") { PlcBeginTime("4");//该炉子已经入站运行 } } if (PlcQueryHelp.BitStatus4[4]) { if (string.IsNullOrEmpty(time4) && string.IsNullOrEmpty(temperature4)) //运行完成 { time4 = PlcQueryHelp.SetTime4.ToString(); //时间 temperature4 = PlcQueryHelp.listAddressTime4[2].ToString(); //温度 string sql = string.Format(@"UPDATE [dbo.tb_RnuInfo] SET OutTem={0}, OutTime={1} WHERE Door={2}", time4, temperature4, 4); SqlServerHelp.ExecuteSql(sql); } if (RunOutInfo("4") == "10" || string.IsNullOrEmpty(RunOutInfo("4")))//运行完成,开始出第一个小车 { List = QueryBarcodeInfo("4"); InterfaceHelp.Interface.ReceiveNumber(List, Barcode, "4", "15", SySetHeip.ResourceNumberFour, time4, temperature4); } if (RunOutInfo("4") == "15")//运行完成,开始出第二个小车 { List2 = QueryBarcodeInfo2("4"); InterfaceHelp.Interface.ReceiveNumber(List2, Barcode2, "4", "20", SySetHeip.ResourceNumberFour, time4, temperature4); } if (RunOutInfo("4") == "20") { time4 = ""; temperature4 = ""; string Sql = string.Format(@"UPDATE [db_ND10L].[dbo].[dbo.tb_RnuInfo] SET OutAndInInfo='{0}' WHERE Door='{1}'", "两个小车出站完成", 4); SqlServerHelp.ExecuteSql(Sql); } } } else { string Sql = string.Format(@"UPDATE [db_ND10L].[dbo].[dbo.tb_RnuInfo] SET Barcode='{0}',BarcodeInclude ='{0}', Barcode2='{0}',BarcodeInclude2 ='{0}' , OutAndInInfo='{0}' WHERE Door='{1}'", "", 4); SqlServerHelp.ExecuteSql(Sql); } //5 if (PlcQueryHelp.BitStatus5[0]) { if (PlcQueryHelp.BitStatus5[2])//启动时写入时间 { if (RunOutInfo("5") != "10") { PlcBeginTime("5");//该炉子已经入站运行 } } if (PlcQueryHelp.BitStatus5[4]) { if (string.IsNullOrEmpty(time5) && string.IsNullOrEmpty(temperature5)) //运行完成 { time5 = PlcQueryHelp.SetTime5.ToString(); //时间 temperature5 = PlcQueryHelp.listAddressTime5[2].ToString(); //温度 string sql = string.Format(@"UPDATE [dbo.tb_RnuInfo] SET OutTem={0}, OutTime={1} WHERE Door={2}", time5, temperature5, 5); SqlServerHelp.ExecuteSql(sql); } if (RunOutInfo("5") == "10" || string.IsNullOrEmpty(RunOutInfo("5")))//运行完成,开始出第一个小车 { List = QueryBarcodeInfo("5"); InterfaceHelp.Interface.ReceiveNumber(List, Barcode, "5", "15", SySetHeip.ResourceNumberFive, time5, temperature5); } if (RunOutInfo("5") == "15")//运行完成,开始出第二个小车 { List2 = QueryBarcodeInfo2("5"); InterfaceHelp.Interface.ReceiveNumber(List2, Barcode2, "5", "20", SySetHeip.ResourceNumberFive, time5, temperature5); } if (RunOutInfo("5") == "20") { time5 = ""; temperature5 = ""; string Sql = string.Format(@"UPDATE [db_ND10L].[dbo].[dbo.tb_RnuInfo] SET OutAndInInfo='{0}' WHERE Door='{1}'", "两个小车出站完成", 5); SqlServerHelp.ExecuteSql(Sql); } } } else { string Sql = string.Format(@"UPDATE [db_ND10L].[dbo].[dbo.tb_RnuInfo] SET Barcode='{0}',BarcodeInclude ='{0}', Barcode2='{0}',BarcodeInclude2 ='{0}' , OutAndInInfo='{0}' WHERE Door='{1}'", "", 5); SqlServerHelp.ExecuteSql(Sql); } //6 if (PlcQueryHelp.BitStatus6[0]) { if (PlcQueryHelp.BitStatus6[2])//启动时写入时间 { if (RunOutInfo("6") != "10") { PlcBeginTime("6");//该炉子已经入站运行 } } else { if (PlcQueryHelp.BitStatus6[4]) { if (string.IsNullOrEmpty(time6) && string.IsNullOrEmpty(temperature6)) //运行完成 { time6 = PlcQueryHelp.SetTime6.ToString(); //时间 temperature6 = PlcQueryHelp.listAddressTime6[2].ToString(); //温度 string sql = string.Format(@"UPDATE [dbo.tb_RnuInfo] SET OutTem={0}, OutTime={1} WHERE Door={2}", time6, temperature6, 6); SqlServerHelp.ExecuteSql(sql); } if (RunOutInfo("6") == "10" || string.IsNullOrEmpty(RunOutInfo("6")))//运行完成,开始出第一个小车 { List = QueryBarcodeInfo("6"); InterfaceHelp.Interface.ReceiveNumber(List, Barcode, "6", "15", SySetHeip.ResourceNumberSix, time6, temperature6); } if (RunOutInfo("6") == "15")//运行完成,开始出第二个小车 { List2 = QueryBarcodeInfo2("6"); InterfaceHelp.Interface.ReceiveNumber(List2, Barcode2, "6", "20", SySetHeip.ResourceNumberSix, time6, temperature6); } if (RunOutInfo("6") == "20") { time6 = ""; temperature6 = ""; string Sql = string.Format(@"UPDATE [db_ND10L].[dbo].[dbo.tb_RnuInfo] SET OutAndInInfo='{0}' WHERE Door='{1}'", "两个小车出站完成", 6); SqlServerHelp.ExecuteSql(Sql); } } } } else { string Sql = string.Format(@"UPDATE [db_ND10L].[dbo].[dbo.tb_RnuInfo] SET Barcode='{0}',BarcodeInclude ='{0}', Barcode2='{0}',BarcodeInclude2 ='{0}' , OutAndInInfo='{0}' WHERE Door='{1}'", "", 6); SqlServerHelp.ExecuteSql(Sql); } //7 if (PlcQueryHelp.BitStatus7[0]) { if (PlcQueryHelp.BitStatus7[2])//启动时写入时间 { if (RunOutInfo("7") != "10") { PlcBeginTime("7");//该炉子已经入站运行 } } if (PlcQueryHelp.BitStatus7[4]) { if (string.IsNullOrEmpty(time7) && string.IsNullOrEmpty(temperature7)) //运行完成 { time7 = PlcQueryHelp.SetTime7.ToString(); //时间 temperature7 = PlcQueryHelp.listAddressTime7[2].ToString(); //温度 string sql = string.Format(@"UPDATE [dbo.tb_RnuInfo] SET OutTem={0}, OutTime={1} WHERE Door={2}", time7, temperature7, 7); SqlServerHelp.ExecuteSql(sql); } if (RunOutInfo("7") == "10" || string.IsNullOrEmpty(RunOutInfo("7")))//运行完成,开始出第一个小车 { List = QueryBarcodeInfo("7"); InterfaceHelp.Interface.ReceiveNumber(List, Barcode, "7", "15", SySetHeip.ResourceNumberSeven, time7, temperature7); } if (RunOutInfo("7") == "15")//运行完成,开始出第二个小车 { List2 = QueryBarcodeInfo2("7"); InterfaceHelp.Interface.ReceiveNumber(List2, Barcode2, "7", "20", SySetHeip.ResourceNumberSeven, time7, temperature7); } if (RunOutInfo("7") == "20") { time7 = ""; temperature7 = ""; string Sql = string.Format(@"UPDATE [db_ND10L].[dbo].[dbo.tb_RnuInfo] SET OutAndInInfo='{0}' WHERE Door='{1}'", "两个小车出站完成", 7); SqlServerHelp.ExecuteSql(Sql); } } } else { string Sql = string.Format(@"UPDATE [db_ND10L].[dbo].[dbo.tb_RnuInfo] SET Barcode='{0}',BarcodeInclude ='{0}', Barcode2='{0}',BarcodeInclude2 ='{0}' , OutAndInInfo='{0}' WHERE Door='{1}'", "", 7); SqlServerHelp.ExecuteSql(Sql); } //8 if (PlcQueryHelp.BitStatus8[0]) { if (PlcQueryHelp.BitStatus8[2])//启动时写入时间 { if (RunOutInfo("8") != "10") { PlcBeginTime("8");//该炉子已经入站运行 } } if (PlcQueryHelp.BitStatus8[4]) { if (string.IsNullOrEmpty(time8) && string.IsNullOrEmpty(temperature8)) //运行完成 { time8 = PlcQueryHelp.SetTime8.ToString(); //时间 temperature8 = PlcQueryHelp.listAddressTime8[2].ToString(); //温度 string sql = string.Format(@"UPDATE [dbo.tb_RnuInfo] SET OutTem={0}, OutTime={1} WHERE Door={2}", time8, temperature8, 8); SqlServerHelp.ExecuteSql(sql); } if (RunOutInfo("8") == "10" || string.IsNullOrEmpty(RunOutInfo("8")))//运行完成,开始出第一个小车 { List = QueryBarcodeInfo("8"); InterfaceHelp.Interface.ReceiveNumber(List, Barcode, "8", "15", SySetHeip.ResourceNumberEight, time8, temperature8); } if (RunOutInfo("8") == "15")//运行完成,开始出第二个小车 { List2 = QueryBarcodeInfo2("8"); InterfaceHelp.Interface.ReceiveNumber(List2, Barcode2, "8", "20", SySetHeip.ResourceNumberEight, time8, temperature8); } if (RunOutInfo("8") == "20") { time8 = ""; temperature8 = ""; string Sql = string.Format(@"UPDATE [db_ND10L].[dbo].[dbo.tb_RnuInfo] SET OutAndInInfo='{0}' WHERE Door='{1}'", "两个小车出站完成", 8); SqlServerHelp.ExecuteSql(Sql); } } } else { string Sql = string.Format(@"UPDATE [db_ND10L].[dbo].[dbo.tb_RnuInfo] SET Barcode='{0}',BarcodeInclude ='{0}', Barcode2='{0}',BarcodeInclude2 ='{0}' , OutAndInInfo='{0}' WHERE Door='{1}'", "", 8); SqlServerHelp.ExecuteSql(Sql); } } } catch { } }
/// <summary> /// 将报警记录写入数据库 /// </summary> /// <param name="ValueAddress"></param> public static void SqlErrorInfo(string ValueAddress) { string Sql = string.Format(@"INSERT INTO [dbo.tb_Error](ErrorTime,ErrorContent) VALUES ( '{0}','{1}')", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), ValueAddress.Trim()); SqlServerHelp.ExecuteSql(Sql); }
private void Query_Click(object sender, EventArgs e) { string sql = string.Format("select * from tb_Login "); dgvmain.DataSource = SqlServerHelp.Query(sql).Tables[0]; }
// Get record count of a table int getRecordCount(string tableNameSQL) { return(SqlServerHelp.GetRecordCount(tableNameSQL)); }
public void initializeDataService(string dbFilePath) { SqlServerHelp.SetConncetionString(dbFilePath); }