Exemple #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            StudentInfo studentinfo = StudentInfoBLL.GetStudentInfo(studentid_edit);

            if (studentinfo != null)
            {
                txt_studengid.Text = studentinfo.StudentId.ToString();
                txt_name.Text      = studentinfo.Name;
                if (studentinfo.Sex == "男")
                {
                    rb_man.Checked   = true;
                    rb_woman.Checked = false;
                }
                else
                {
                    rb_man.Checked   = false;
                    rb_woman.Checked = true;
                }
                txt_age.Text         = studentinfo.Age.ToString();
                dt_birthdate.Text    = studentinfo.BirthDate.ToString();
                txt_phone.Text       = studentinfo.Phone;
                txt_email.Text       = studentinfo.Email;
                txt_homeaddress.Text = studentinfo.HomeAddress;
                txt_profession.Text  = studentinfo.Profession;
            }
        }
Exemple #2
0
        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("修改学生信息成功!");
            }
        }
Exemple #3
0
        public void initControl()
        {
            //查询信息并显示编辑前信息
            StudentInfo studentinfo = StudentInfoBLL.GetStudentInfo(studentid_edit);

            if (studentinfo != null)
            {
                txt_studentid.Text = studentinfo.StudentId;
                txt_name.Text      = studentinfo.Name;
                if (studentinfo.Sex == "男")
                {
                    rb_man.Checked   = true;
                    rb_woman.Checked = false;
                }
                else
                {
                    rb_man.Checked   = false;
                    rb_woman.Checked = true;
                }
                txt_age.Text         = studentinfo.Age.ToString();
                dt_birthdate.Text    = studentinfo.BirthDate.ToString();
                txt_phone.Text       = studentinfo.Phone;
                txt_email.Text       = studentinfo.Email;
                txt_homeaddress.Text = studentinfo.HomeAddress;
                txt_profession.Text  = studentinfo.Profession;
            }
        }
Exemple #4
0
        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("修改学生信息成功!");
            }
        }
Exemple #5
0
 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);
         }
     }
 }