using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using System.Windows.Forms;
namespace WStest
{
public class MySqlServer
{
SqlConnection mysqlCon;
//配方信息结构体
public struct recipeNode
{
public int Tnnum;
public int Tnclass;
public int TnclassPrepar;
public float Tntime;
public float TntimePrepar;
public float Tntp;
public float TntpPrepar;
public float Allowtpdif;
public float AllowtpdifPrepar;
public float Prhigh;
public float PrhighPrepar;
public float Prlow;
public float PrlowPrepar;
public float Arflow;
public float ArflowPrepar;
public float Highpr_MPa;
public float Highpr_MPaPrepar;
public float Fucnum;
public float FucnumPrepar;
}
//配方信息结构体
public struct recipeInformNode
{
public int RecipeNum;
public string Name;
public string Marks;
public DateTime DataTime;
}
public MySqlServer(string server, string integrated_Security, string initial_Catalog)
{
//server=可以写计算机名称 ip地址、Localhost或.都可以
//integrated security=SSPI 安全声明
//Intitial Catalog=csharpzx 初始化数据库
string constr = "Server=" + server + "; integrated security=" + integrated_Security + "; Initial Catalog=" + initial_Catalog;
constr = "Server=DESKTOP-HMBL0P9\\SQLEXPRESS; integrated security=SSPI; Initial Catalog=wsdbtest01";
mysqlCon = new SqlConnection(constr);
}
public MySqlServer(string Server, string user, string pwd, string database)
{
//server=可以写计算机名称 ip地址、Localhost或.都可以
//user = sa 管理员名
//pwd=darly 安全声明
//database=csharpzx 初始化数据库
string constr = "Server=" + Server + "; user=sa" + user + "; pwd=" + pwd + ";database=" + database;
constr = "Server=DESKTOP-HMBL0P9\\SQLEXPRESS; user=sa; pwd=AWSXCsqlws; database=wsdbtest01";
mysqlCon = new SqlConnection(constr);
}
public void openSqlServer()
{
string _msg = "";
try
{
//打开链接
mysqlCon.Open();
}
catch (Exception ex)
{
_msg = ex.Message;
//关闭链接
mysqlCon.Close();
}
finally
{
if (_msg != "")
{
MessageBox.Show(_msg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
public void closeSqlServer()
{
mysqlCon.Close();
}
//读单条记录
public void readOne()
{
string sql = "select * from Table_ChartDate";
SqlCommand mycom = new SqlCommand(sql, mysqlCon);
//声明dataReader对象
SqlDataReader mydr = mycom.ExecuteReader();
if (mydr.Read())
{
/*******/
}
else
{
MessageBox.Show("无数据");
}
mydr.Close();
}
//读取整表
public SqlDataReader readAll(string table)
{
string sql = "select * from " + table;
SqlCommand mycom = new SqlCommand(sql, mysqlCon);
//声明dataReader对象
SqlDataReader mydr = mycom.ExecuteReader();
return mydr;
}
//读单条记录
public SqlDataReader readOne_int(string table, string colName, string value)
{
string sql = "select * from " + table + " WHERE " + colName + "=" + value;
SqlCommand mycom = new SqlCommand(sql, mysqlCon);
//声明dataReader对象
SqlDataReader mydr = mycom.ExecuteReader();
return mydr;
}
//读单条记录
public SqlDataReader readOne_string(string table, string colName, string value)
{
string sql = "select * from " + table + " WHERE " + colName + "= " + "'" + value + "'";
SqlCommand mycom = new SqlCommand(sql, mysqlCon);
//声明dataReader对象
SqlDataReader mydr = mycom.ExecuteReader();
return mydr;
}
//读第一条记录
public SqlDataReader readOneTop(string table)
{
string sql = "SELECT TOP 1 * FROM " + table + " ORDER BY id ASC";
SqlCommand mycom = new SqlCommand(sql, mysqlCon);
//声明dataReader对象
SqlDataReader mydr = mycom.ExecuteReader();
return mydr;
}
//读最后一条记录
public SqlDataReader readOneBount(string table)
{
string sql = "SELECT TOP 1 * FROM " + table + " ORDER BY id DESC";
SqlCommand mycom = new SqlCommand(sql, mysqlCon);
//声明dataReader对象
SqlDataReader mydr = mycom.ExecuteReader();
return mydr;
}
//批量读
public SqlDataReader readBufferDataRead(string table, string colName, string start, string end)
{
string sql = "select * from " + table + " WHERE " + colName + ">=" + "'" + start + "'" + " AND " + colName + "<=" + "'" + end + "'";
//sql = "select * from Table_AlarmInfo WHERE datatime>='2024-09-09 18:00:00.000' AND datatime<='2024-09-09 18:00:00.000'";
SqlCommand mycom = new SqlCommand(sql, mysqlCon);
//声明dataReader对象
SqlDataReader mydr = mycom.ExecuteReader();
return mydr;
}
//单条写入报警数据
public void writeOne_AlarmInfo(string table, string code, string alarm_class, string alarm_info, string reason, string solution, string dataTime)
{
string sql = "INSERT INTO " + table + "(code, alarm_class, alarm_info, reason, solution, dataTime) VALUES(" +
code +
", '" + alarm_class + "'" +
", '" + alarm_info + "'" +
", '" + reason + "'" +
", '" + solution + "'" +
", '" + dataTime + "'" + ")";
//string sql = "INSERT INTO Table_AlarmInfo(code, alarm_class, alarm_info, reason, solution, dataTime) VALUES(12, 'A', 'asfcve', 'wwww', 'gghhhg', '2024-09-11 09:22:00.000')";
SqlCommand mycom = new SqlCommand(sql, mysqlCon);
mycom.ExecuteNonQuery();
}
//单条写入测试曲线数据
public void writeOne_ChartDate(string table, string dataTime, double[] writeBuffer)
{
string sql = "INSERT INTO " + table + "(" +
"datatime, " +
"[加热区目标温度_℃], " +
"[S1区-TT温度_℃], " +
"[S1区-IP温度_℃], " +
"[B区-TT温度_℃], " +
"[B区-IP温度_℃], " +
"[S2区-TT温度_℃], " +
"[S2区-IP温度_℃], " +
"[炉内相压_PT6.12_KPa], " +
"[炉内绝压_PT6.13_KPa], " +
"[炉内极限真空_PT6.13_Pa], " +
"[脱蜡罐相压_PT9.12_KPa], " +
"[脱蜡管绝压_PT9.13_KPa], " +
"[炉内--脱蜡管压差_KPa], " +
"炉内高压目标压力_MPa, " +
"[炉内高压_PT11.6_MPa], " +
"[脱蜡管气体温度_℃], " +
"[脱蜡热水实际温度_℃], " +
"[脱蜡热水设定温度_℃], " +
"[前保温门温度_℃], " +
"[后保温门温度_℃], " +
"[冷却水_进水_℃], " +
"[冷却水_出水_℃], " +
"[S1区电极温度_℃], " +
"[B区电极温度_℃], " +
"[S2区电极温度_℃], " +
"[炉前顶部温度_℃], " +
"[炉前底部温度_℃], " +
"[炉后顶部温度_℃], " +
"[炉后底部温度_℃], " +
"[预留1_℃], " +
"[预留2_℃], " +
"[冷却分离前端温度_℃], " +
"[冷却分离后端温度_℃], " +
"[N2目标流量_L/min], " +
"[N2实际流量_L/min], " +
"[S1区输出功率比_%], " +
"[B区输出功率比_%], " +
"[S2区输出功率比_%], " +
"S1区输出功率_KW, " +
"B区输出功率_KW, " +
"S2区输出功率_KW, " +
"S1区单炉累计能耗_KWH, " +
"B区单炉累计能耗_KWH, " +
"S2区单炉累计能耗_KWH, " +
"单炉累计总能耗_KWH, " +
"S1区漏电电流_A, " +
"B区漏电电流_A, " +
"S2区漏电电流_A, " +
"S1区一次电压_V, " +
"B区一次电压_V, " +
"S2区一次电压_V, " +
"S1区一次电流_A, " +
"B区一次电流_A, " +
"S2区一次电流_A, " +
"[FIC11.26_L/min], " +
"[FIC11.27_L/min], " +
"[FIC11.28_L/min], " +
"[FIC11.48_L/min], " +
"[FIC11.47_L/min], " +
"[FIC11.46_L/min], " +
"[PT11.42_MPa], " +
"[PT11.22_MPa], " +
"[V8.4开度_%], " +
"[V11.21开度_%]" +
") VALUES(" +
"'" +
dataTime + "'" +
", " + writeBuffer[0] +
", " + writeBuffer[1] +
", " + writeBuffer[2] +
", " + writeBuffer[3] +
", " + writeBuffer[4] +
", " + writeBuffer[5] +
", " + writeBuffer[6] +
", " + writeBuffer[7] +
", " + writeBuffer[8] +
", " + writeBuffer[9] +
", " + writeBuffer[10] +
", " + writeBuffer[11] +
", " + writeBuffer[12] +
", " + writeBuffer[13] +
", " + writeBuffer[14] +
", " + writeBuffer[15] +
", " + writeBuffer[16] +
", " + writeBuffer[17] +
", " + writeBuffer[18] +
", " + writeBuffer[19] +
", " + writeBuffer[20] +
", " + writeBuffer[21] +
", " + writeBuffer[22] +
", " + writeBuffer[23] +
", " + writeBuffer[24] +
", " + writeBuffer[25] +
", " + writeBuffer[26] +
", " + writeBuffer[27] +
", " + writeBuffer[28] +
", " + writeBuffer[29] +
", " + writeBuffer[30] +
", " + writeBuffer[31] +
", " + writeBuffer[32] +
", " + writeBuffer[33] +
", " + writeBuffer[34] +
", " + writeBuffer[35] +
", " + writeBuffer[36] +
", " + writeBuffer[37] +
", " + writeBuffer[38] +
", " + writeBuffer[39] +
", " + writeBuffer[40] +
", " + writeBuffer[41] +
", " + writeBuffer[42] +
", " + writeBuffer[43] +
", " + writeBuffer[44] +
", " + writeBuffer[45] +
", " + writeBuffer[46] +
", " + writeBuffer[47] +
", " + writeBuffer[48] +
", " + writeBuffer[49] +
", " + writeBuffer[50] +
", " + writeBuffer[51] +
", " + writeBuffer[52] +
", " + writeBuffer[53] +
", " + writeBuffer[54] +
", " + writeBuffer[55] +
", " + writeBuffer[56] +
", " + writeBuffer[57] +
", " + writeBuffer[58] +
", " + writeBuffer[59] +
", " + writeBuffer[60] +
", " + writeBuffer[61] +
", " + writeBuffer[62] +
", " + writeBuffer[63] + ")";
//string sql = "INSERT INTO Table_AlarmInfo(code, alarm_class, alarm_info, reason, solution, dataTime) VALUES(12, 'A', 'asfcve', 'wwww', 'gghhhg', '2024-09-11 09:22:00.000')";
SqlCommand mycom = new SqlCommand(sql, mysqlCon);
mycom.ExecuteNonQuery();
}
//单条写入测试曲线数据
public void writeOne_ChartDate02(string table, string dataTime, double[] writeBuffer)
{
string sql = "INSERT INTO " + table + "(" +
"datatime, " +
"设置温度, " +
"底部热电偶温度, " +
"顶部热电偶温度, " +
"底部红外温度, " +
"顶部红外温度, " +
"保温桶温度, " +
"循环水出口温度, " +
"高压压力_KPaG, " +
"绝压压力_KPa, " +
"相压压力_KPaG, " +
"真空度_Pa, " +
"[N2质里流里计设置流里_L/Min], " +
"[N2质量流量计反馈流里_L/Min], " +
"[底部红外吹扫流里_L/Min], " +
"[顶部红外吹扫流里_L/Min], " +
"加热总功率_KWH, " +
"底部调功器输出电流_A, " +
"底部调功器输出电压_V, " +
"[底部调功器PID输出值_%], " +
"底部调功器输出功率_KW, " +
"底部调功器用电量_KWH, " +
"顶部调功器输出电流_A, " +
"顶部调功器输出电压_v, " +
"[顶部调功器PID输出值_%], " +
"顶部调功器输出功率_KW, " +
"顶部调功器用电量_KWH" +
") VALUES(" +
"'" +
dataTime + "'" +
", " + writeBuffer[0] +
", " + writeBuffer[1] +
", " + writeBuffer[2] +
", " + writeBuffer[3] +
", " + writeBuffer[4] +
", " + writeBuffer[5] +
", " + writeBuffer[6] +
", " + writeBuffer[7] +
", " + writeBuffer[8] +
", " + writeBuffer[9] +
", " + writeBuffer[10] +
", " + writeBuffer[11] +
", " + writeBuffer[12] +
", " + writeBuffer[13] +
", " + writeBuffer[14] +
", " + writeBuffer[15] +
", " + writeBuffer[16] +
", " + writeBuffer[17] +
", " + writeBuffer[18] +
", " + writeBuffer[19] +
", " + writeBuffer[20] +
", " + writeBuffer[21] +
", " + writeBuffer[22] +
", " + writeBuffer[23] +
", " + writeBuffer[24] +
", " + writeBuffer[25] + ")";
//string sql = "INSERT INTO Table_AlarmInfo(code, alarm_class, alarm_info, reason, solution, dataTime) VALUES(12, 'A', 'asfcve', 'wwww', 'gghhhg', '2024-09-11 09:22:00.000')";
SqlCommand mycom = new SqlCommand(sql, mysqlCon);
mycom.ExecuteNonQuery();
}
//单条写入测试数据
public void writeOneTest01(string table, string dataTime)
{
double test = 1;
string sql = "INSERT INTO " + table + "(" +
"datetime, " +
"[加热区目标温度_℃], " +
"[S1区-TT温度_℃], "+
"[S1区-IP温度_℃], "+
"[B区-TT温度_℃], "+
"[B区-IP温度_℃], "+
"[S2区-TT温度_℃], "+
"[S2区-IP温度_℃], "+
"[炉内相压_PT6.12_KPa], "+
"[炉内绝压_PT6.13_KPa], "+
"[炉内极限真空_PT6.13_Pa], "+
"[脱蜡罐相压_PT9.12_KPa], "+
"[脱蜡管绝压_PT9.13_KPa], "+
"[炉内--脱蜡管压差_KPa], "+
"炉内高压目标压力_MPa, "+
"[炉内高压_PT11.6_MPa], " +
"[脱蜡管气体温度_℃], "+
"[脱蜡热水实际温度_℃], "+
"[脱蜡热水设定温度_℃], "+
"[前保温门温度_℃], "+
"[后保温门温度_℃], "+
"[冷却水_进水_℃], "+
"[冷却水_出水_℃], "+
"[S1区电极温度_℃], "+
"[B区电极温度_℃], "+
"[S2区电极温度_℃], "+
"[炉前顶部温度_℃], "+
"[炉前底部温度_℃], "+
"[炉后顶部温度_℃], "+
"[炉后底部温度_℃], " +
"[预留1_℃], "+
"[预留2_℃], "+
"[冷却分离前端温度_℃], "+
"[冷却分离后端温度_℃], "+
"[N2目标流量_L/min], "+
"[N2实际流量_L/min], "+
"[S1区输出功率比_%], "+
"[B区输出功率比_%], "+
"[S2区输出功率比_%], " +
"S1区输出功率_KW, "+
"B区输出功率_KW, "+
"S2区输出功率_KW, "+
"S1区单炉累计能耗_KWH, "+
"B区单炉累计能耗_KWH, "+
"S2区单炉累计能耗_KWH, "+
"单炉累计总能耗_KWH, "+
"S1区漏电电流_A, "+
"B区漏电电流_A, "+
"S2区漏电电流_A, "+
"S1区一次电压_V, "+
"B区一次电压_V, "+
"S2区一次电压_V, "+
"S1区一次电流_A, "+
"B区一次电流_A, "+
"S2区一次电流_A, "+
"[FIC11.26_L/min], "+
"[FIC11.27_L/min], "+
"[FIC11.28_L/min], "+
"[FIC11.48_L/min], "+
"[FIC11.47_L/min], "+
"[FIC11.46_L/min], "+
"[PT11.42_MPa], "+
"[PT11.22_MPa], "+
"[V8.4开度_%], "+
"[V11.21开度_%]" +
") VALUES(" +
"'" +
dataTime + "'" +
", " + test +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) +
", " + (test + 0.1) + ")";
//string sql = "INSERT INTO Table_AlarmInfo(code, alarm_class, alarm_info, reason, solution, dataTime) VALUES(12, 'A', 'asfcve', 'wwww', 'gghhhg', '2024-09-11 09:22:00.000')";
SqlCommand mycom = new SqlCommand(sql, mysqlCon);
mycom.ExecuteNonQuery();
}
//单条写入配方信息
public void writeOne_RecipeInform(string table, recipeInformNode recipeInformNode)
{
string sql = "INSERT INTO " + table + "(" +
"recipeNum, " +
"name, " +
"marks, " +
"dataTime" +
") VALUES(" +
"'" +
recipeInformNode.RecipeNum + "'" +
", " + recipeInformNode.Name +
", " + recipeInformNode.Marks +
", " + recipeInformNode.DataTime +
")";
//string sql = "INSERT INTO Table_AlarmInfo(code, alarm_class, alarm_info, reason, solution, dataTime) VALUES(12, 'A', 'asfcve', 'wwww', 'gghhhg', '2024-09-11 09:22:00.000')";
SqlCommand mycom = new SqlCommand(sql, mysqlCon);
mycom.ExecuteNonQuery();
}
//单条写入配方工艺
public void writeOne_Tnnum(string table, int recipeNum, string dataTime, recipeNode recipeNode)
{
string sql = "INSERT INTO " + table + "(" +
"recipeNum, " +
"dataTime, " +
"tnNum, " +
"tnclass, " +
"tntime, " +
"tntp, " +
"allowtpdif, " +
"prHigh, " +
"PrLow, " +
"arFlow, " +
"highpr_MPa, " +
"Fucnum" +
") VALUES(" +
"'" +
recipeNum + "'" +
", " + dataTime +
", " + recipeNode.Tnnum +
", " + recipeNode.Tnclass +
", " + recipeNode.Tntime +
", " + recipeNode.Tntp +
", " + recipeNode.Allowtpdif +
", " + recipeNode.Prhigh +
", " + recipeNode.Prlow +
", " + recipeNode.Arflow +
", " + recipeNode.Highpr_MPa +
", " + recipeNode.Fucnum
+ ")";
//string sql = "INSERT INTO Table_AlarmInfo(code, alarm_class, alarm_info, reason, solution, dataTime) VALUES(12, 'A', 'asfcve', 'wwww', 'gghhhg', '2024-09-11 09:22:00.000')";
SqlCommand mycom = new SqlCommand(sql, mysqlCon);
mycom.ExecuteNonQuery();
}
//单条写入配方信息
public void writeOne_RecipeInformTest(string table, string dataTime, string[] recipeInform)
{
string sql = "INSERT INTO " + table + "(" +
"recipeNum, " +
"name, " +
"marks, " +
"dataTime" +
") VALUES(" +
recipeInform[0] +
", " + "'" + recipeInform[1] + "'" +
", " + "'" + recipeInform[2] + "'" +
", " +
"'" + dataTime + "'" +
")";
//string sql = "INSERT INTO Table_AlarmInfo(code, alarm_class, alarm_info, reason, solution, dataTime) VALUES(12, 'A', 'asfcve', 'wwww', 'gghhhg', '2024-09-11 09:22:00.000')";
SqlCommand mycom = new SqlCommand(sql, mysqlCon);
mycom.ExecuteNonQuery();
}
//单条更新配方信息
public void updateOne_RecipeInform(string table, string dataTime, string colName, string value, string[] recipeInform)
{
string sql = "UPDATE " + table + " SET " +
"name = " + "'" + recipeInform[0] + "'" + ", " +
"marks = " + "'" + recipeInform[1] + "'" + ", " +
"dataTime = " + "'" + dataTime + "'" +
" WHERE " + colName + " = " + value;
//string sql = "INSERT INTO Table_AlarmInfo(code, alarm_class, alarm_info, reason, solution, dataTime) VALUES(12, 'A', 'asfcve', 'wwww', 'gghhhg', '2024-09-11 09:22:00.000')";
//UPDATE Persons SET ID_P = 6, city = 'London' WHERE LastName = 'Wilson';
SqlCommand mycom = new SqlCommand(sql, mysqlCon);
mycom.ExecuteNonQuery();
}
//单条写入配方工艺
public void writeOne_TnnumTest(string table, int recipeNum, string dataTime, string[] recipe)
{
string sql = "INSERT INTO " + table + "(" +
"recipeNum, " +
"dataTime, " +
"tnNum, " +
"tnclass, " +
"tntime, " +
"tntp, " +
"allowtpdif, " +
"prHigh, " +
"PrLow, " +
"arFlow, " +
"highpr_MPa, " +
"Fucnum" +
") VALUES(" +
recipeNum +
", " + "'" + dataTime + "'" +
", " + recipe[0] +
", " + recipe[1] +
", " + recipe[2] +
", " + recipe[3] +
", " + recipe[4] +
", " + recipe[5] +
", " + recipe[6] +
", " + recipe[7] +
", " + recipe[8] +
", " + recipe[9]
+ ")";
//string sql = "INSERT INTO Table_AlarmInfo(code, alarm_class, alarm_info, reason, solution, dataTime) VALUES(12, 'A', 'asfcve', 'wwww', 'gghhhg', '2024-09-11 09:22:00.000')";
SqlCommand mycom = new SqlCommand(sql, mysqlCon);
mycom.ExecuteNonQuery();
}
//更新单条配方工艺
public void updateOne_TnnumTest(string table, string dataTime, string colName, string value, string[] recipe)
{
string sql = "UPDATE " + table + " SET " +
"dataTime = " + "'" + dataTime + "'" + ", " +
"tnNum = " + recipe[0] + ", " +
"tnclass = " + recipe[1] + ", " +
"tntime = " + recipe[2] + ", " +
"tntp = " + recipe[3] + ", " +
"allowtpdif = " + recipe[4] + ", " +
"prHigh = " + recipe[5] + ", " +
"PrLow = " + recipe[6] + ", " +
"arFlow = " + recipe[7] + ", " +
"highpr_MPa = " + recipe[8] + ", " +
"Fucnum = " + recipe[9] +
" WHERE " + colName + " = " + value;
//string sql = "INSERT INTO Table_AlarmInfo(code, alarm_class, alarm_info, reason, solution, dataTime) VALUES(12, 'A', 'asfcve', 'wwww', 'gghhhg', '2024-09-11 09:22:00.000')";
SqlCommand mycom = new SqlCommand(sql, mysqlCon);
mycom.ExecuteNonQuery();
}
//删除单条配方信息
public void deleteOne_RecipeInform(string table, string colName, string value)
{
string sql = "DELETE " + "FROM " + table + " WHERE " + colName + " = " + value;
//string sql = "INSERT INTO Table_AlarmInfo(code, alarm_class, alarm_info, reason, solution, dataTime) VALUES(12, 'A', 'asfcve', 'wwww', 'gghhhg', '2024-09-11 09:22:00.000')";
SqlCommand mycom = new SqlCommand(sql, mysqlCon);
mycom.ExecuteNonQuery();
}
//删除配方工艺
public void delete_Tnnum(string table, string colName, string value)
{
string sql = "DELETE " + "FROM " + table + " WHERE " + colName + " = " + value;
//string sql = "INSERT INTO Table_AlarmInfo(code, alarm_class, alarm_info, reason, solution, dataTime) VALUES(12, 'A', 'asfcve', 'wwww', 'gghhhg', '2024-09-11 09:22:00.000')";
SqlCommand mycom = new SqlCommand(sql, mysqlCon);
mycom.ExecuteNonQuery();
}
//添加报警
public void add_AlrmInfo(string table, string dataTime, int alarm_code, int alarm_class)
{
string sql = "INSERT INTO " + table + "(" +
"dataTime, " +
"alarm_code, " +
"alarm_class" +
") VALUES(" +
"'" + dataTime + "'" +
", " + alarm_code +
", " + alarm_class
+ ")";
//string sql = "INSERT INTO Table_AlarmInfo(code, alarm_class, alarm_info, reason, solution, dataTime) VALUES(12, 'A', 'asfcve', 'wwww', 'gghhhg', '2024-09-11 09:22:00.000')";
SqlCommand mycom = new SqlCommand(sql, mysqlCon);
mycom.ExecuteNonQuery();
}
}
}
这是所有的MySqlServer类实现,请帮我实现IDisposable接口
最新发布