📄 form3.cs
字号:
this.sqlDataAdapter4.SelectCommand = this.sqlSelectCommand4;
this.sqlDataAdapter4.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "设备种类表", new System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("种类编号", "种类编号"),
new System.Data.Common.DataColumnMapping("种类名", "种类名"),
new System.Data.Common.DataColumnMapping("设备数量", "设备数量")})});
this.sqlDataAdapter4.UpdateCommand = this.sqlUpdateCommand4;
//
// sqlSelectCommand4
//
this.sqlSelectCommand4.CommandText = "SELECT 种类编号, 种类名, 设备数量 FROM 设备种类表";
this.sqlSelectCommand4.Connection = this.sqlConnection1;
//
// sqlInsertCommand4
//
this.sqlInsertCommand4.CommandText = "INSERT INTO 设备种类表(种类编号, 种类名, 设备数量) VALUES (@种类编号, @种类名, @设备数量); SELECT 种类编号, 种类名," +
" 设备数量 FROM 设备种类表 WHERE (种类编号 = @种类编号)";
this.sqlInsertCommand4.Connection = this.sqlConnection1;
this.sqlInsertCommand4.Parameters.Add(new System.Data.SqlClient.SqlParameter("@种类编号", System.Data.SqlDbType.VarChar, 10, "种类编号"));
this.sqlInsertCommand4.Parameters.Add(new System.Data.SqlClient.SqlParameter("@种类名", System.Data.SqlDbType.VarChar, 20, "种类名"));
this.sqlInsertCommand4.Parameters.Add(new System.Data.SqlClient.SqlParameter("@设备数量", System.Data.SqlDbType.Int, 4, "设备数量"));
//
// sqlUpdateCommand4
//
this.sqlUpdateCommand4.CommandText = "UPDATE 设备种类表 SET 种类编号 = @种类编号, 种类名 = @种类名, 设备数量 = @设备数量 WHERE (种类编号 = @Original_种" +
"类编号) AND (种类名 = @Original_种类名) AND (设备数量 = @Original_设备数量); SELECT 种类编号, 种类名, 设备" +
"数量 FROM 设备种类表 WHERE (种类编号 = @种类编号)";
this.sqlUpdateCommand4.Connection = this.sqlConnection1;
this.sqlUpdateCommand4.Parameters.Add(new System.Data.SqlClient.SqlParameter("@种类编号", System.Data.SqlDbType.VarChar, 10, "种类编号"));
this.sqlUpdateCommand4.Parameters.Add(new System.Data.SqlClient.SqlParameter("@种类名", System.Data.SqlDbType.VarChar, 20, "种类名"));
this.sqlUpdateCommand4.Parameters.Add(new System.Data.SqlClient.SqlParameter("@设备数量", System.Data.SqlDbType.Int, 4, "设备数量"));
this.sqlUpdateCommand4.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_种类编号", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "种类编号", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand4.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_种类名", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "种类名", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand4.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_设备数量", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "设备数量", System.Data.DataRowVersion.Original, null));
//
// sqlDeleteCommand4
//
this.sqlDeleteCommand4.CommandText = "DELETE FROM 设备种类表 WHERE (种类编号 = @Original_种类编号) AND (种类名 = @Original_种类名) AND (设备" +
"数量 = @Original_设备数量)";
this.sqlDeleteCommand4.Connection = this.sqlConnection1;
this.sqlDeleteCommand4.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_种类编号", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "种类编号", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand4.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_种类名", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "种类名", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand4.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_设备数量", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "设备数量", System.Data.DataRowVersion.Original, null));
//
// ddd1
//
this.ddd1.DataSetName = "ddd";
this.ddd1.Locale = new System.Globalization.CultureInfo("zh-CN");
//
// Form3
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(368, 517);
this.Controls.Add(this.tabControl1);
this.Name = "Form3";
this.Text = "Form3";
this.tabControl1.ResumeLayout(false);
this.tabPage1.ResumeLayout(false);
this.tabPage2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.aaa1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.bbb1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.ccc1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.ddd1)).EndInit();
this.ResumeLayout(false);
}
#endregion
private void groupBox1_Enter(object sender, System.EventArgs e)
{
}
private void button1_Click(object sender, System.EventArgs e)
{
SqlConnection con=new SqlConnection(" workstation id=S0184;packet size=4096;user id=sa;initial catalog=设备管理系统;persist security info=False");
con.Open();
//string state = "空";
string temp = "insert into 使用表(设备名,设备号,部门号,管理人编号,申请日期,使用结束日期) values('"+this.textBox1.Text+"','"+this.textBox2.Text+"','"+this.textBox3.Text+"','"+this.textBox4.Text+"','"+this.textBox6.Text+"','"+this.textBox7.Text+"')";
SqlCommand cmd=new SqlCommand(temp,con);
SqlDataReader sqlreader=cmd.ExecuteReader();
MessageBox.Show("您已成功添加此记录");
textBox1.Text="";
textBox2.Text="";
textBox3.Text="";
textBox4.Text="";
textBox6.Text="";
textBox7.Text="";
}
private void button4_Click(object sender, System.EventArgs e)
{
if(t==1)
{
string constr= "workstation id=s0184;packet size=4096;integrated security=SSPI;data source=s0184;pe" +
"rsist security info=False;initial catalog=设备管理系统";
string sq1="select * from 设备表 where (状态='"+textBox5.Text+"')";
SqlConnection cn1=new SqlConnection(constr);
SqlDataAdapter sqlDataAdapter1=new SqlDataAdapter(sq1,cn1);
sqlDataAdapter1.Fill(aaa1,"设备表");
dataGrid1.SetDataBinding(aaa1,"设备表");
}
else if(t==2)
{
string constr= "workstation id=s0184;packet size=4096;integrated security=SSPI;data source=s0184;pe" +
"rsist security info=False;initial catalog=设备管理系统";
string sq1="select * from 设备表 where (设备名='"+textBox5.Text+"')";
SqlConnection cn1=new SqlConnection(constr);
SqlDataAdapter sqlDataAdapter1=new SqlDataAdapter(sq1,cn1);
sqlDataAdapter1.Fill(aaa1,"设备表");
dataGrid1.SetDataBinding(aaa1,"设备表");
}
else if(t==3)
{
string constr= "workstation id=s0184;packet size=4096;integrated security=SSPI;data source=s0184;pe" +
"rsist security info=False;initial catalog=设备管理系统";
string sq1="select * from 设备表 where (设备号='"+textBox5.Text+"')";
SqlConnection cn1=new SqlConnection(constr);
SqlDataAdapter sqlDataAdapter3=new SqlDataAdapter(sq1,cn1);
sqlDataAdapter3.Fill(ccc1,"设备表");
dataGrid1.SetDataBinding(ccc1,"设备表");
}
else if(t==4)
{
string constr= "workstation id=s0184;packet size=4096;integrated security=SSPI;data source=s0184;pe" +
"rsist security info=False;initial catalog=设备管理系统";
string sq1="select * from 设备种类表 where (种类名='"+textBox5.Text+"')";
SqlConnection cn1=new SqlConnection(constr);
SqlDataAdapter sqlDataAdapter4=new SqlDataAdapter(sq1,cn1);
sqlDataAdapter4.Fill(ddd1,"设备种类表");
dataGrid1.SetDataBinding(ddd1,"设备种类表");
}
else
MessageBox.Show("请输入查询条件! ","查询",MessageBoxButtons.OK);
}
private void tabPage2_Click(object sender, System.EventArgs e)
{
}
private void tabControl1_SelectedIndexChanged(object sender, System.EventArgs e)
{
}
private void button5_Click(object sender, System.EventArgs e)
{
Form form2 =new Form2();
form2.ShowDialog();
this.Close();
}
private void button3_Click(object sender, System.EventArgs e)
{
Form form2 =new Form2();
form2.ShowDialog();
this.Close();
}
public int t;
private void radioButton1_CheckedChanged(object sender, System.EventArgs e)
{
t=1;
}
private void radioButton2_CheckedChanged(object sender, System.EventArgs e)
{
t=2;
}
private void radioButton3_CheckedChanged(object sender, System.EventArgs e)
{
t=3;
}
private void radioButton4_CheckedChanged(object sender, System.EventArgs e)
{
t=4;
}
private void textBox5_TextChanged(object sender, System.EventArgs e)
{
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -