private void btn_update_Click(object sender, EventArgs e) { StudentInfo studentinfo = StudentInfoBLL.GetStudentInfo(studentid_edit); studentinfo.StudentId = txt_studengid.Text; studentinfo.Name = txt_name.Text; if (rb_man.Checked) { studentinfo.Sex = "男"; } else if (rb_woman.Checked) { studentinfo.Sex = "女"; } studentinfo.Age = Int32.Parse(txt_age.Text); studentinfo.BirthDate = DateTime.Parse(dt_birthdate.Text); studentinfo.Phone = txt_phone.Text; studentinfo.Email = txt_email.Text; studentinfo.HomeAddress = txt_homeaddress.Text; studentinfo.Profession = txt_profession.Text; if (StudentInfoBLL.UpdateStudentInfo(studentinfo)) { MessageBox.Show("修改学生信息成功!"); } }
private void btn_edit_Click(object sender, EventArgs e) { StudentInfo studentinfo = StudentInfoBLL.GetStudentInfo(studentid_edit); Regex r = new Regex("^([a-zA-Z]|[0-9])(\\w|\\-)+@[a-zA-Z0-9]+\\.([a-zA-Z]{2,4})$"); if (!r.IsMatch(txt_email.Text.ToString())) { MessageBox.Show(txt_email.Text.ToString() + " 不是个正确的邮箱"); return; } Regex id = new Regex("^\\+?[1-9][0-9]*$"); if (!id.IsMatch(txt_studengid.Text)) { MessageBox.Show("编号" + txt_studengid.Text + "不是个正整数"); return; } studentinfo.StudentId = Int32.Parse(txt_studengid.Text); studentinfo.Name = txt_name.Text; if (rb_man.Checked) { studentinfo.Sex = "男"; } else if (rb_woman.Checked) { studentinfo.Sex = "女"; } studentinfo.Age = Int32.Parse(txt_age.Text); studentinfo.BirthDate = DateTime.Parse(dt_birthday.Text); studentinfo.Phone = txt_phone.Text; studentinfo.Email = txt_email.Text; studentinfo.HomeAddress = txt_homeaddress.Text; studentinfo.Profession = txt_profession.Text; if (StudentInfoBLL.UpdateStudentInfo(studentinfo)) { MessageBox.Show("修改学生信息成功!"); } }
private void btn_update_Click(object sender, EventArgs e) { try { //更新学生编辑信息 StudentInfo studentinfo = StudentInfoBLL.GetStudentInfo(studentid_edit); //studentinfo.StudentId = Int32.Parse(txt_studengid.Text); studentinfo.Name = txt_name.Text; if (rb_man.Checked) { studentinfo.Sex = "男"; } else if (rb_woman.Checked) { studentinfo.Sex = "女"; } studentinfo.Age = Int32.Parse(txt_age.Text); studentinfo.BirthDate = DateTime.Parse(dt_birthdate.Text); studentinfo.Phone = txt_phone.Text; studentinfo.Email = txt_email.Text; studentinfo.HomeAddress = txt_homeaddress.Text; studentinfo.Profession = txt_profession.Text; if (StudentInfoBLL.UpdateStudentInfo(studentinfo)) { MessageBox.Show("修改学生信息成功!"); } }catch (Exception) { if (String.IsNullOrEmpty(txt_age.Text)) { MessageBox.Show("年龄输入不能为空!"); } else { MessageBox.Show("请不要修改学生编号!", "错误", MessageBoxButtons.OK); } } }