form1 登录界面
form2 功能选择界面
form3 增加信息界面
form4 删除信息界面
form5 修改信息界面
form6 查询信息界面
从之前的登录界面登录成功后进入功能选择界面
代码
private void button2_Click(object sender, EventArgs e)
{
Form4 form4 = new Form4();
form4.Show();
this.Hide();
}
private void button1_Click(object sender, EventArgs e)
{
Form3 form3 = new Form3();
form3.Show();
this.Hide();
}
private void guanbi_Click(object sender, FormClosedEventArgs e)
{
Application.Exit();
}
private void button3_Click(object sender, EventArgs e)
{
Form5 form5 = new Form5();
form5.Show();
this.Hide();
}
private void button4_Click(object sender, EventArgs e)
{
Form6 form6 = new Form6();
form6.Show();
this.Hide();
}
增加信息界面
代码
private void button1_Click(object sender, EventArgs e)
{
String StuID = textBox1.Text.Trim();
String StuName = textBox2.Text.Trim();
String StuSex = textBox3.Text.Trim();
String StuAge = textBox4.Text.Trim();
String StuSdept = textBox5.Text.Trim(); //读取需要插入的值
SqlConnection con = new SqlConnection(“Data Source=LAPTOP-93V8OVPD\MSSQLSERVER01;Initial Catalog=Fwork;User ID=sa;Password=155872”);
try
{
con.Open();
string insertStr = "INSERT INTO Student (Sno,Sname,Ssex,Sage,Sdept) " + //拼接字符串
“VALUES (’” + StuID + “’,’” + StuName + “’,’” + StuSex + “’,” + StuAge + “,’” + StuSdept + “’)”;
SqlCommand cmd = new SqlCommand(insertStr, con);
cmd.ExecuteNonQuery();
}
catch
{
MessageBox.Show(“输入数据违反要求!”);
}
finally
{
con.Close();
}
this.studentTableAdapter.Fill(this.fworkDataSet5.Student);
}
private void button2_Click(object sender, EventArgs e)
{
Form2 form2 = new Form2();
form2.Show();
this.Hide();
}
private void button2_Click(object sender, FormClosingEventArgs e)
{
Application.Exit();
}
private void Form3_Load_1(object sender, EventArgs e)
{
// TODO: 这行代码将数据加载到表“fworkDataSet5.Student”中。您可以根据需要移动或删除它。
this.studentTableAdapter.Fill(this.fworkDataSet5.Student);
}
没写完
实验三
最新推荐文章于 2023-07-12 19:34:39 发布