private void InitInformation(STUDENT student) { // Khởi tạo các giá trị ban đầu lbDOB.Text = ((DateTime)student.DOB).ToString("dd/MM/yyyy"); if (student.GENDER == 1) { lbGender.Text = "Nam"; } else { lbGender.Text = "Nữ"; } lbStudentId.Text = student.STUDENTID; lbStudentName.Text = student.STUDENTNAME.ToUpper(); lbAddress.Text = student.ADDRESSS; lbCMND.Text = student.CMND; lbDepartment.Text = student.DEPARTMENT; lbFolk.Text = student.FOLK; lbIssuedBy.Text = student.ISSUEDBY; lbNation.Text = student.NATION; lbPhoneNumber.Text = student.PHONENUMBER; lbReligion.Text = student.RELIGION; lbStudyAt.Text = student.STUDYAT; lbStudyYear.Text = student.STUDENTYEAR.ToString(); lbEmail.Text = student.EMAIL; lbDateCMND.Text = ((DateTime)student.DATECMND).ToString("dd/MM/yyyy"); if (student.PHOTO != "") { avatarBox.Image = new Bitmap(CommonUsing.ImagePath() + student.PHOTO); } }
private void InitInformation(STUDENT student) { // Khởi tạo các giá trị ban đầu txtStudentId.Text = student.STUDENTID; txtFullName.Text = student.STUDENTNAME; txtAddress.Text = student.ADDRESSS; txtCMND.Text = student.CMND; txtDepartment.Text = student.DEPARTMENT; txtFolk.Text = student.FOLK; txtIssuedBy.Text = student.ISSUEDBY; txtNation.Text = student.NATION; txtPhoneNumber.Text = student.PHONENUMBER; txtReligion.Text = student.RELIGION; txtSchool.Text = student.STUDYAT; txtYear.Text = student.STUDENTYEAR.ToString(); txtEmail.Text = student.EMAIL; if (student.GENDER == 1) { cbbGender.SelectedItem = "Nam"; } else { cbbGender.SelectedItem = "Nữ"; } dob.Value = (DateTime)student.DOB; dateCMND.Value = (DateTime)student.DATECMND; if (student.PHOTO != "") { avatarBox.Image = new Bitmap(CommonUsing.ImagePath() + student.PHOTO); } lbImageName.Text = student.PHOTO; lbInformation.Text = ""; }
private void btnSave_Click(object sender, EventArgs e) { try { // Xác thực thông tin nhập vào if (txtStudentId.Text == "") { lbInformation.Text = "Thông báo lỗi: " + MessageDefine.StudentIdNull; return; } // thêm thông tin sinh viên sau chỉnh sửa vào csdl STUDENT student = new STUDENT(); student.STUDENTID = txtStudentId.Text; student.STUDENTNAME = txtFullName.Text; student.DOB = dob.Value; if (cbbGender.SelectedItem.ToString().Equals("Nam")) { student.GENDER = 1; } else { student.GENDER = 2; } student.RELIGION = txtReligion.Text; student.FOLK = txtFolk.Text; student.ADDRESSS = txtAddress.Text; student.CMND = txtCMND.Text; student.DATECMND = dateCMND.Value; student.ISSUEDBY = txtIssuedBy.Text; student.NATION = txtNation.Text; student.PHONENUMBER = txtPhoneNumber.Text; student.STUDYAT = txtSchool.Text; student.STUDENTYEAR = int.Parse(txtYear.Text); student.DEPARTMENT = txtDepartment.Text; student.PHOTO = lbImageName.Text; student.STATUSS = 1; student.EMAIL = txtEmail.Text; db.Entry(student).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); // Upload file ảnh avatar vào hệ thống if (avatarPath != "") { File.Copy(avatarPath, CommonUsing.ImagePath() + Path.GetFileName(avatarPath), true); } MessageBox.Show("Chỉnh sửa thông tin sinh viên thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); StudentManage studentManage = new StudentManage(); studentManage.Show(); } catch (Exception ex) { lbInformation.Text = ex.Message; } }