winform
![](https://images2017.cnblogs.com/blog/1119140/201711/1119140-20171118153352296-1334830966.png)
保存按钮
#region 保存
private void button1_Click(object sender, EventArgs e)
{
//温湿度采录记录表--新增
Coldstoragerecord cik = new Coldstoragerecord();
//部门
//db.BindDataToComboBox("select * from Coldstoragerecord", comboBox2, "BMID", "BMname");
cik.BMID1 =int.Parse(this.comboBox1.Text.ToString());
//监控区域
cik.AreaID1 = this.comboBox2.Text;
//采样时间
cik.DecordDate1 = this.dateTimePicker1.Value.ToString("yyyy-MM-dd");
//温度
cik.Temperature = this.textBox1.Text;
//湿度
cik.Humidity = this.textBox2.Text;
//处理措施
cik.Treatmentmeasures1 = this.comboBox3.Text;
//记录员
cik.Recordkeeper1 = this.comboBox4.Text;
cik.BMname1 = this.textBox1.Text;
//添加冷库温湿度记录
Mangar.AddColdstoragerecord(cik);
MessageBox.Show("保存成功!");
}
#endregion
BLL层
#region 冷库温湿度记录
public static bool AddColdstoragerecord(Coldstoragerecord cik)
{
return servise.AddColdstoragerecord(cik);
}
#endregion
DAL层
#region 冷库温湿度记录
public static bool AddColdstoragerecord(Coldstoragerecord cik)
{
//Com c = new Com();
//int smID = c.getMax("Coldstoragerecord", "1");
string sql = string.Format(@"Insert into Coldstoragerecord (kingID,BMID, AreaID, DecordDate, temperature, humidity, Treatmentmeasures, Recordkeeper, Operator,BMname)values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}')"
,cik.KingID ,cik.BMID1, cik.AreaID1, cik.DecordDate1, cik.Temperature, cik.Humidity, cik.Treatmentmeasures1, cik.Recordkeeper1, cik.Operator1, cik.BMname1);
return db.Exect(sql);
}
#endregion
DBHelper
#region 增删改
public bool Exect(string sql)
{
Init();
SqlCommand com = new SqlCommand(sql, con);
int i = com.ExecuteNonQuery();
con.Close();
return i > 0;
}
#endregion
Model层
namespace Model
{
public class Coldstoragerecord
{
public Coldstoragerecord()
{ }
//冷库温湿度记录
//ID
private string kingID;
public string KingID
{
get { return kingID; }
set { kingID = value; }
}
//部门
private int BMID;
public int BMID1
{
get { return BMID; }
set { BMID = value; }
}
//监控区域
private string AreaID;
public string AreaID1
{
get { return AreaID; }
set { AreaID = value; }
}
//采样时间
private string DecordDate;
public string DecordDate1
{
get { return DecordDate; }
set { DecordDate = value; }
}
//温度
private string temperature;
public string Temperature
{
get { return temperature; }
set { temperature = value; }
}
//湿度
private string humidity;
public string Humidity
{
get { return humidity; }
set { humidity = value; }
}
//处理措施
private string Treatmentmeasures;
public string Treatmentmeasures1
{
get { return Treatmentmeasures; }
set { Treatmentmeasures = value; }
}
//记录员
private string Recordkeeper;
public string Recordkeeper1
{
get { return Recordkeeper; }
set { Recordkeeper = value; }
}
//操作员
private string Operator;
public string Operator1
{
get { return Operator; }
set { Operator = value; }
}
//部门名称
private string BMname;
public string BMname1
{
get { return BMname; }
set { BMname = value; }
}
}
}