📄 form4.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace StudentManage.UILevel
{
public partial class Form4 : Form
{
public Form4()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
SqlConnection sc = new SqlConnection("server=.;uid=sa;database=StudentManage");
sc.Open();
string sql = "insert into Score (Class,StudentID,Course)values('" + this.comboBox2.Text + "','" + this.textBox2.Text + "','" + this.comboBox3.Text + "')";
SqlCommand scom = new SqlCommand(sql, sc);
if (this.comboBox2.Text != "" && this.textBox2.Text != "" && this.comboBox3.Text != "")
{
scom.ExecuteNonQuery();
MessageBox.Show("添加成功!");
}
else MessageBox.Show("添加失败!");
sc.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void label3_Click(object sender, EventArgs e)
{
}
private void label2_Click(object sender, EventArgs e)
{
}
private void textBox4_TextChanged(object sender, EventArgs e)
{
}
private void button3_Click(object sender, EventArgs e)
{
this.Close();
}
private void button2_Click(object sender, EventArgs e)
{
try
{
SqlConnection sc = new SqlConnection("server=.;uid=sa;database=StudentManage");
sc.Open();
string sql = "delete from Score where Class='" + this.comboBox2.Text + "'and StudentID='" + this.textBox2.Text + "'and Course='" + this.comboBox3.Text + "'";
SqlCommand scom = new SqlCommand(sql, sc);
if (this.comboBox2.Text != "" && this.textBox2.Text != "" && this.comboBox3.Text != "")
{
scom.ExecuteNonQuery();
MessageBox.Show("删除成功!");
}
else MessageBox.Show("删除失败!");
sc.Close();
}
catch (Exception ex)
{
MessageBox.Show("ex.Message");
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -