new User(true).ShowDialog(); }
private void miModifiedPass_Click(object sender, EventArgs e) {
new User(false).ShowDialog(); }
private void miReLogin_Click(object sender, EventArgs e) {
this.DialogResult = DialogResult.Retry; this.Close(); }
private void miExit_Click(object sender, EventArgs e) {
DialogResult result = MessageBox.Show(\是否要退出?\\MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.No) {
return; }
Application.Exit();
18
}
#endregion
(五)学生信息添加设计
学生信息添加界面如图4-4所示:
图4-4 学生信息添加界面设计图
添加学生信息代码如下:
private void btSure_Click(object sender, EventArgs e) {
foreach (Control c in this.Controls) {
19
if (c is TextBox && c.Text.Trim() == \ {
MessageBox.Show(\缺少必要信息!\ return; } }
string id = tbID.Text.Trim(); string name = tbName.Text.Trim(); string sex = cbbSex.SelectedItem.ToString(); string nation=tbNation.Text.Trim();
DateTime birth = DateTime.Parse(tbBirth.Text); string jiguan = tbJiGuan.Text.Trim(); string phone = tbPhone.Text.Trim(); string address = tbAddress.Text.Trim();
int classID = Convert.ToInt32(cbbClass.SelectedValue); string sql = \T_Student set F_Name='\+ name + \+ sex + \+ nation + \+ jiguan + \\ if(!tbID.ReadOnly) {
sql = \\
20
address + \ }
if (DBHelper.ExcuteSql(sql) == 1) {
MessageBox.Show(\操作成功!\ this.DialogResult = DialogResult.Retry; this.Close(); } }
(六)学生成绩添加设计
学生成绩添加界面如图4-5所示:
图4-5 学生成绩添加界面设计图
成绩添加代码如下:
private void btSure_Click(object sender, EventArgs e) {
21
string stuID = tbStuID.Text;
int courseID = Convert.ToInt32(cbbCourse.SelectedValue); float score = float.Parse(tbScore.Text);
string sql = \count(*) from T_Score where F_StuID='\
int count = Convert.ToInt32(DBHelper.GetSingle(sql)); if (count == 0) { sql
=
\
into
T_Score
values('\ } else {
sql = \T_Score set F_Score=\+ score + \where F_StuID='\ }
if (DBHelper.ExcuteSql(sql) != -1) {
MessageBox.Show(\操作成功!\ this.DialogResult = DialogResult.Retry; this.Close(); } }
22