实验三

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);
}
没写完

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值