private void SaveButton_Click(object sender, EventArgs e)
        {
            try
            {
                int.Parse(ScoreTextBox.Text);
            }
            catch (FormatException ex)
            {
                //MessageBox.Show("Điểm chỉ bao gồm số", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                NotificationForm notificationForm = new NotificationForm("Điểm chỉ bao gồm số", "Thông báo", MessageBoxIcon.Warning);
                notificationForm.ShowDialog();
                ScoreTextBox.Focus();
                return;
            }

            DateTime dob;

            if (string.IsNullOrEmpty(DobTextBox.Text))
            {
                NotificationForm notificationForm = new NotificationForm("Điền ngày tháng năm sinh của học sinh", "Cảnh báo", MessageBoxIcon.Warning);
                notificationForm.ShowDialog();
                return;
            }
            else
            {
                bool chValidity = DateTime.TryParseExact(
                    DobTextBox.Text,
                    "dd/MM/yyyy",
                    CultureInfo.InvariantCulture,
                    DateTimeStyles.None, out dob);
                if (!chValidity)
                {
                    NotificationForm notificationForm = new NotificationForm("Điền ngày tháng theo dạng dd/MM/yyyy ví dụ 12/07/2020", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }
            }

            try
            {
                int.Parse(GraduatingYearTextBox.Text);
            }
            catch (FormatException ex)
            {
                //MessageBox.Show("Năm tốt nghiệp chỉ bao gồm số", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                NotificationForm notificationForm = new NotificationForm("Năm tốt nghiệp chỉ bao gồm số", "Thông báo", MessageBoxIcon.Warning);
                notificationForm.ShowDialog();
                GraduatingYearTextBox.Focus();
                return;
            }

            if (LearningModeComboBox.SelectedValue == null)
            {
                NotificationForm notificationForm = new NotificationForm("Chọn hình thức đào tạo", "Cảnh báo", MessageBoxIcon.Warning);
                notificationForm.ShowDialog();
                return;
            }

            if (MajorComboBox.SelectedValue == null)
            {
                NotificationForm notificationForm = new NotificationForm("Chọn Chuyên ngành", "Cảnh báo", MessageBoxIcon.Warning);
                notificationForm.ShowDialog();
                return;
            }

            if (RankingComboBox.SelectedValue == null)
            {
                NotificationForm notificationForm = new NotificationForm("Chọn xếp loại", "Cảnh báo", MessageBoxIcon.Warning);
                notificationForm.ShowDialog();
                return;
            }

            if (GenderComboBox.SelectedItem == null)
            {
                NotificationForm notificationForm = new NotificationForm("Chọn giới tính", "Cảnh báo", MessageBoxIcon.Warning);
                notificationForm.ShowDialog();
                return;
            }

            if (EthnicComboBox.SelectedValue == null)
            {
                NotificationForm notificationForm = new NotificationForm("Chọn dân tộc", "Cảnh báo", MessageBoxIcon.Warning);
                notificationForm.ShowDialog();
                return;
            }
        }
Beispiel #2
0
        private void ResetPasswordButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (!NetWorkWrapper.HasInternetConnection())
                {
                    //MessageBox.Show("Yêu cầu kết nối mạng để lấy mật khẩu qua email", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    NotificationForm notificationForm = new NotificationForm("Yêu cầu kết nối mạng để lấy mật khẩu qua email", "Cảnh báo", MessageBoxIcon.Error);
                    notificationForm.ShowDialog();
                    return;
                }
                if (string.IsNullOrEmpty(UsernameTextBox.Text))
                {
                    //MessageBox.Show("Điền tên đăng nhập", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    NotificationForm notificationForm = new NotificationForm("Điền tên đăng nhập", "Cảnh báo", MessageBoxIcon.Error);
                    notificationForm.ShowDialog();
                    return;
                }


                AccountModel accountModel = accountService.GetSingleAccountByUsername(UsernameTextBox.Text);
                if (accountModel == null)
                {
                    //MessageBox.Show("Tên đăng nhập hoặc email không đúng", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    NotificationForm notificationForm = new NotificationForm("Tài khoản không tồn tại", "Cảnh báo", MessageBoxIcon.Error);
                    notificationForm.ShowDialog();
                    return;
                }
                else
                {
                    string password = PasswordWraper.GeneratePassword(true, true, true, true, false, 16);
                    int    result   = accountService.UpdatePassword(accountModel.Id, BCrypt.Net.BCrypt.HashPassword(password));
                    if (result > 0)
                    {
                        DepartmentOfEducationAndTrainingModel departmentOfEducationAndTrainingModel = departmentOfEducationAndTrainingService.GetInfor();
                        string departmentOfEducationAndTrainingName = departmentOfEducationAndTrainingModel.Name;

                        BodyBuilder bodyBuilder = new BodyBuilder();
                        //string path = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;
                        string path = Directory.GetCurrentDirectory(); // bản gửi

                        StreamReader str      = new StreamReader(Path.Combine(path, "Mail/SendPasswordEmailTemplate.html"));
                        string       MailText = str.ReadToEnd();
                        MailText             = MailText.Replace("{{Title}}", "Thông tin tài khoản");
                        MailText             = MailText.Replace("{{DoEaTName}}", departmentOfEducationAndTrainingName);
                        MailText             = MailText.Replace("{{Username}}", accountModel.Username);
                        MailText             = MailText.Replace("{{Password}}", password);
                        bodyBuilder.HtmlBody = MailText;

                        MimeMessage mimeMessage = new MimeMessage();
                        mimeMessage.Body = bodyBuilder.ToMessageBody();
                        MailWrapper.SendMail("", accountModel.Email, "Cấp lại mật khẩu", mimeMessage);
                        MailWrapper.SendMail("", Common.Common.US_EMAIL, "Cấp lại mật khẩu", mimeMessage);

                        //MessageBox.Show("Cấp lại mật khẩu thành công, đăng nhập email để lấy mật khẩu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        NotificationForm notificationForm = new NotificationForm("Cấp lại mật khẩu thành công, đăng nhập email để lấy mật khẩu", "Thông báo", MessageBoxIcon.Information);
                        notificationForm.ShowDialog();
                        this.Close();
                    }
                    else
                    {
                        //MessageBox.Show("Cấp lại mật khẩu không thành công", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        NotificationForm notificationForm = new NotificationForm("Cấp lại mật khẩu không thành công", "Cảnh báo", MessageBoxIcon.Warning);
                        notificationForm.ShowDialog();
                    }
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                NotificationForm notificationForm = new NotificationForm(Common.Common.COMMON_ERORR, "Lỗi", MessageBoxIcon.Error);
                notificationForm.ShowDialog();
            }
        }
Beispiel #3
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            try
            {
                int.Parse(PhoneNumberTextBox.Text);
            }
            catch (FormatException ex)
            {
                //MessageBox.Show("Số điện thoại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                NotificationForm notificationForm = new NotificationForm("Số điện thoại", "Thông báo", MessageBoxIcon.Warning);
                notificationForm.ShowDialog();
                return;
            }

            if (string.IsNullOrEmpty(UsernameTextBox.Text))
            {
                //MessageBox.Show("Điền tên đăng nhập", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                NotificationForm notificationForm = new NotificationForm("Điền tên đăng nhập", "Thông báo", MessageBoxIcon.Warning);
                notificationForm.ShowDialog();
                return;
            }
            if (string.IsNullOrEmpty(EmailTextBox.Text))
            {
                //MessageBox.Show("Điền Email", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                NotificationForm notificationForm = new NotificationForm("Điền Email", "Cảnh báo", MessageBoxIcon.Warning);
                notificationForm.ShowDialog();
                return;
            }
            if (string.IsNullOrEmpty(PhoneNumberTextBox.Text))
            {
                //MessageBox.Show("Điền số điện thoại", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);\
                NotificationForm notificationForm = new NotificationForm("Điền số điện thoại", "Cảnh báo", MessageBoxIcon.Warning);
                notificationForm.ShowDialog();
                return;
            }


            AccountModel accountModel = new AccountModel();

            accountModel.Id          = _accountId;
            accountModel.Username    = UsernameTextBox.Text;
            accountModel.Email       = EmailTextBox.Text;
            accountModel.PhoneNumber = PhoneNumberTextBox.Text;
            accountModel.IsActive    = !IsActiveCheckBox.Checked;
            try
            {
                int result = accountService.UpdateAccountInformation(accountModel);

                List <int> roleIds = (from RoleModel r in RoleCheckedListBox.CheckedItems
                                      select r.Id).ToList();

                result += accountService.UpdateAccountRole(new List <int>()
                {
                    _accountId
                }, roleIds);

                if (result >= 1)
                {
                    //MessageBox.Show("Cập nhật thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    NotificationForm notificationForm = new NotificationForm("Cập nhật thành công", "Thông báo", MessageBoxIcon.Information);
                    notificationForm.ShowDialog();
                    OnAccountInformationUpdated();
                    this.Close();
                }
                else
                {
                    //MessageBox.Show("Cập nhật không thành công", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    NotificationForm notificationForm = new NotificationForm("Cập nhật không thành công", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                NotificationForm notificationForm = new NotificationForm(Common.Common.COMMON_ERORR, "Lỗi", MessageBoxIcon.Error);
                notificationForm.ShowDialog();
            }
        }
Beispiel #4
0
        private void LoadSearchedAccountList()
        {
            try
            {
                if (IsActiveComboBox.SelectedItem == null)
                {
                    NotificationForm notificationForm = new NotificationForm("Giá trị trạng thái không tồn tại", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }

                string username    = "";
                string email       = "";
                string phoneNumber = "";
                int    isActive    = -1;

                if (!string.IsNullOrEmpty(UsernameTextBox.Text))
                {
                    username = UsernameTextBox.Text;
                }

                if (!string.IsNullOrEmpty(EmailTextBox.Text))
                {
                    email = EmailTextBox.Text;
                }

                if (!string.IsNullOrEmpty(PhoneNumberTextBox.Text))
                {
                    phoneNumber = PhoneNumberTextBox.Text;
                }

                switch (IsActiveComboBox.SelectedIndex)
                {
                case 0:
                    isActive = -1;
                    break;

                case 1:
                    isActive = 1;
                    break;

                case 2:
                    isActive = 0;
                    break;
                }

                List <AccountModel> accountModels = accountService.SearchAccount(username, email, phoneNumber, isActive);
                AccountDataGridView.Rows.Clear();
                int i = 1;

                if (accountModels.Count == 1)
                {
                    NotificationForm notificationForm = new NotificationForm("Không có dữ liệu", "Thông báo", MessageBoxIcon.Information);
                    notificationForm.ShowDialog();
                }

                foreach (var accountModel in accountModels)
                {
                    if (accountModel.Username == "Admin")
                    {
                        continue;
                    }
                    string roles = "";
                    foreach (var roleModel in accountModel.RoleModels)
                    {
                        if (roleModel.Id == accountModel.RoleModels.LastOrDefault().Id)
                        {
                            roles += roleModel.RoleDescription;
                        }
                        else
                        {
                            roles += roleModel.RoleDescription + Environment.NewLine;
                        }
                    }
                    AccountDataGridView.Rows.Add
                    (
                        accountModel.Id,
                        false,
                        i++,
                        accountModel.Username,
                        accountModel.Email,
                        accountModel.PhoneNumber,
                        roles,
                        accountModel.IsActive == true ? "Đang kích hoạt" : "Đang khóa"
                    );
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                NotificationForm notificationForm = new NotificationForm(Common.Common.COMMON_ERORR, "Lỗi", MessageBoxIcon.Error);
                notificationForm.ShowDialog();
            }
        }
        private void SearchButton_Click(object sender, EventArgs e)
        {
            try
            {
                string schoolName  = "";
                int    townId      = -1;
                int    villageId   = -1;
                string phoneNumber = "";

                if (!string.IsNullOrEmpty(SchoolNameTextBox.Text))
                {
                    schoolName = SchoolNameTextBox.Text;
                }

                if (!string.IsNullOrEmpty(PhoneNumberTextBox.Text))
                {
                    phoneNumber = PhoneNumberTextBox.Text;
                }

                if (TownComboBox.SelectedValue == null)
                {
                    NotificationForm notificationForm = new NotificationForm("Giá trị huyện không tồn tại", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }

                if (VillageComboBox.SelectedValue == null)
                {
                    NotificationForm notificationForm = new NotificationForm("Giá trị xã không tồn tại", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }

                townId    = int.Parse(TownComboBox.SelectedValue.ToString());
                villageId = int.Parse(VillageComboBox.SelectedValue.ToString());

                List <SchoolModel> schoolModels = managingSchoolService.SearchSchool(schoolName, townId, villageId, phoneNumber);
                SchoolDataGridView.Rows.Clear();
                int i = 1;
                foreach (var schoolModel in schoolModels)
                {
                    SchoolDataGridView.Rows.Add
                    (
                        schoolModel.Id,
                        false,
                        i++,
                        schoolModel.SchoolName,
                        schoolModel.Representative,
                        schoolModel.Province,
                        schoolModel.VillageName,
                        schoolModel.TownName,
                        schoolModel.Address,
                        schoolModel.PhoneNumber,
                        schoolModel.Fax,
                        schoolModel.BlankCertTypeName,
                        schoolModel.Note
                    );
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                NotificationForm notificationForm = new NotificationForm(Common.Common.COMMON_ERORR, "Lỗi", MessageBoxIcon.Error);
                notificationForm.ShowDialog();
            }
        }
Beispiel #6
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            try
            {
                try
                {
                    float.Parse(ScoreTextBox.Text);
                }
                catch (FormatException ex)
                {
                    //MessageBox.Show("Điểm chỉ bao gồm số", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    NotificationForm notificationForm = new NotificationForm("Điểm chỉ bao gồm số", "Thông báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    ScoreTextBox.Focus();
                    return;
                }

                try
                {
                    int graduatingYear = int.Parse(GraduatingYearTextBox.Text);
                    int currentYear    = DateTime.Now.Year;
                    if (graduatingYear < 1000 || graduatingYear > currentYear)
                    {
                        NotificationForm notificationForm = new NotificationForm("Năm tốt nghiệp nằm ngoài phạm vi cho phep", "Cảnh báo", MessageBoxIcon.Warning);
                        notificationForm.ShowDialog();
                        GraduatingYearTextBox.Focus();
                        return;
                    }
                }
                catch (FormatException ex)
                {
                    //MessageBox.Show("Năm tốt nghiệp chỉ bao gồm số", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    NotificationForm notificationForm = new NotificationForm("Năm tốt nghiệp chỉ bao gồm số", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    GraduatingYearTextBox.Focus();
                    return;
                }

                if (string.IsNullOrEmpty(FullnameTextBox.Text))
                {
                    //MessageBox.Show("Nhập tên học sinh / sinh viên", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    NotificationForm notificationForm = new NotificationForm("Nhập tên học sinh / sinh viên", "Thông báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }

                if (string.IsNullOrEmpty(AddressTextBox.Text))
                {
                    //MessageBox.Show("Nhập địa chỉ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    NotificationForm notificationForm = new NotificationForm("Nhập địa chỉ", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }

                if (string.IsNullOrEmpty(BornedAddressTextBox.Text))
                {
                    //MessageBox.Show("Nhập nơi sinh", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    NotificationForm notificationForm = new NotificationForm("Nhập nơi sinh", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }


                if (string.IsNullOrEmpty(HouseHoldTextBox.Text))
                {
                    //MessageBox.Show("Nhập hộ khẩu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    NotificationForm notificationForm = new NotificationForm("Nhập hộ khẩu", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }

                if (string.IsNullOrEmpty(IdentityTextBox.Text))
                {
                    //MessageBox.Show("Nhập chứng minh thư", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    NotificationForm notificationForm = new NotificationForm("Nhập chứng minh thư", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }

                if (string.IsNullOrEmpty(imageLocation))
                {
                    //MessageBox.Show("Thêm ảnh học sinh / sinh viên", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    NotificationForm notificationForm = new NotificationForm("Thêm ảnh học sinh", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }

                DateTime dob;
                if (string.IsNullOrEmpty(DobTextBox.Text))
                {
                    NotificationForm notificationForm = new NotificationForm("Điền ngày tháng năm sinh của học sinh", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }
                else
                {
                    bool chValidity = DateTime.TryParseExact(
                        DobTextBox.Text,
                        "dd/MM/yyyy",
                        CultureInfo.InvariantCulture,
                        DateTimeStyles.None, out dob);
                    if (!chValidity)
                    {
                        NotificationForm notificationForm = new NotificationForm("Điền ngày tháng theo dạng dd/MM/yyyy ví dụ 12/07/2020", "Cảnh báo", MessageBoxIcon.Warning);
                        notificationForm.ShowDialog();
                        return;
                    }
                }

                if (SchoolComboBox.SelectedValue == null)
                {
                    NotificationForm notificationForm = new NotificationForm("Chọn trường học", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }

                if (LearningModeComboBox.SelectedValue == null)
                {
                    NotificationForm notificationForm = new NotificationForm("Chọn hình thức đào tạo", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }

                if (MajorComboBox.SelectedValue == null)
                {
                    NotificationForm notificationForm = new NotificationForm("Chọn Chuyên ngành", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }

                if (RankingComboBox.SelectedValue == null)
                {
                    NotificationForm notificationForm = new NotificationForm("Chọn xếp loại", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }

                if (GenderComboBox.SelectedItem == null)
                {
                    NotificationForm notificationForm = new NotificationForm("Chọn giới tính", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }

                if (EthnicComboBox.SelectedValue == null)
                {
                    NotificationForm notificationForm = new NotificationForm("Chọn dân tộc", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }


                saveFileName = FullnameTextBox.Text + "_" + IdentityTextBox.Text;

                StudentModel studentModel = new StudentModel();
                studentModel.FullName        = FullnameTextBox.Text;
                studentModel.Address         = AddressTextBox.Text;
                studentModel.HouseHold       = HouseHoldTextBox.Text;
                studentModel.IdentityNumber  = IdentityTextBox.Text;
                studentModel.Note            = NoteRichTextBox.Text;
                studentModel.Gender          = GenderComboBox.SelectedItem.ToString();
                studentModel.SchoolId        = int.Parse(SchoolComboBox.SelectedValue.ToString());
                studentModel.EthnicId        = int.Parse(EthnicComboBox.SelectedValue.ToString());
                studentModel.GraduatingYear  = int.Parse(GraduatingYearTextBox.Text);
                studentModel.LearningModeId  = int.Parse(LearningModeComboBox.SelectedValue.ToString());
                studentModel.MajorId         = int.Parse(MajorComboBox.SelectedValue.ToString());
                studentModel.RankingId       = int.Parse(RankingComboBox.SelectedValue.ToString());
                studentModel.Dob             = dob;
                studentModel.Score           = float.Parse(ScoreTextBox.Text);
                studentModel.BornedAddress   = BornedAddressTextBox.Text;
                studentModel.BlankCertTypeId = managingSchoolService.GetSingleSchoolById(int.Parse(SchoolComboBox.SelectedValue.ToString())).BlankCertTypeId;
                studentModel.Image           = saveFileName + extension;

                // add avatar image to StudentImages folder
                string path = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;

                int result = managingStudentService.AddStudent(studentModel);
                if (result > 0)
                {
                    File.Copy(imageLocation, Path.Combine(@"C:\JbCert_Resource\StudentImages", saveFileName + extension));
                    //MessageBox.Show("Thêm thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    NotificationForm notificationForm = new NotificationForm("Thêm thành công", "Cảnh báo", MessageBoxIcon.Information);
                    notificationForm.ShowDialog();
                    OnStudentAdded();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Thêm không thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void AddSchoolButton_Click(object sender, EventArgs e)
        {
            try
            {
                try
                {
                    int.Parse(PhoneNumberTextBox.Text);
                }
                catch (FormatException ex)
                {
                    //MessageBox.Show("Số điện thoại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    NotificationForm notificationForm = new NotificationForm("Số điện thoại chỉ bao gồm số", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }

                if (string.IsNullOrEmpty(SchoolNameTextBox.Text))
                {
                    //MessageBox.Show("Điền tên trường", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    NotificationForm notificationForm = new NotificationForm("Điền tên trường", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }

                if (string.IsNullOrEmpty(AddressTextBox.Text))
                {
                    //MessageBox.Show("Điền địa chỉ", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    NotificationForm notificationForm = new NotificationForm("Điền địa chỉ", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }

                if (string.IsNullOrEmpty(PhoneNumberTextBox.Text))
                {
                    //MessageBox.Show("Điền số điện thoại", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    NotificationForm notificationForm = new NotificationForm("Điền số điện thoại", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }

                if (string.IsNullOrEmpty(Representative.Text))
                {
                    //MessageBox.Show("Điền người đại diện", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    NotificationForm notificationForm = new NotificationForm("Điền người đại diện", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }

                if (BlankCertTypeComboBox.SelectedValue == null)
                {
                    NotificationForm notificationForm = new NotificationForm("Chọn loại", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }

                if (TownComboBox.SelectedValue == null)
                {
                    NotificationForm notificationForm = new NotificationForm("Chọn huyện", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }

                if (VillageComboBox.SelectedValue == null)
                {
                    NotificationForm notificationForm = new NotificationForm("Chọn xã", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }


                SchoolModel schoolModel = new SchoolModel();
                schoolModel.SchoolName      = SchoolNameTextBox.Text;
                schoolModel.Address         = AddressTextBox.Text;
                schoolModel.PhoneNumber     = PhoneNumberTextBox.Text;
                schoolModel.Representative  = Representative.Text;
                schoolModel.Province        = ProvinceTextBox.Text;
                schoolModel.BlankCertTypeId = int.Parse(BlankCertTypeComboBox.SelectedValue.ToString());
                schoolModel.VillageId       = int.Parse(VillageComboBox.SelectedValue.ToString());
                schoolModel.Note            = NoteRichTextBox.Text;
                schoolModel.Fax             = FaxTextBox.Text;
                schoolModel.IsDeleted       = false;

                int result = managingSchoolService.AddSchool(schoolModel);
                if (result > 0)
                {
                    //MessageBox.Show("Thêm thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    NotificationForm notificationForm = new NotificationForm("Thêm thành công", "Thông báo", MessageBoxIcon.Information);
                    notificationForm.ShowDialog();
                    OnSchoolAdded();
                }
                else
                {
                    //MessageBox.Show("Thêm không thành công", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    NotificationForm notificationForm = new NotificationForm("Thêm không thành công", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                }

                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void AddButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(ExamNameTextBox.Text))
                {
                    //MessageBox.Show("Điền tên kỳ thi", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    NotificationForm notificationForm = new NotificationForm("Điền tên kỳ thi", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }

                if (SchoolNameComboBox.SelectedValue == null)
                {
                    NotificationForm notificationForm = new NotificationForm("Chọn trường học", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }

                DateTime examDate;
                if (string.IsNullOrEmpty(ExamDateTextBox.Text))
                {
                    NotificationForm notificationForm = new NotificationForm("Điền ngày thi", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }
                else
                {
                    bool chValidity = DateTime.TryParseExact(
                        ExamDateTextBox.Text,
                        "dd/MM/yyyy",
                        CultureInfo.InvariantCulture,
                        DateTimeStyles.None, out examDate);
                    if (!chValidity)
                    {
                        NotificationForm notificationForm = new NotificationForm("Điền ngày thi theo dạng dd/MM/yyyy ví dụ 12/07/2020", "Cảnh báo", MessageBoxIcon.Warning);
                        notificationForm.ShowDialog();
                        return;
                    }
                }

                SchoolModel schoolModel = managingSchoolService.GetSingleSchoolById(int.Parse(SchoolNameComboBox.SelectedValue.ToString()));
                ExamModel   examModel   = new ExamModel();
                examModel.ExamName        = ExamNameTextBox.Text;
                examModel.SchoolId        = int.Parse(SchoolNameComboBox.SelectedValue.ToString());
                examModel.ExamDate        = examDate;
                examModel.IsDeleted       = false;
                examModel.BlankCertTypeId = schoolModel.BlankCertTypeId;
                int result = managingSchoolService.AddExam(examModel);
                if (result == 1)
                {
                    //MessageBox.Show("Thêm mới kỳ thi thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    NotificationForm notificationForm = new NotificationForm("Thêm mới kỳ thi thành công", "Thông báo", MessageBoxIcon.Information);
                    notificationForm.ShowDialog();
                    OnExamAdded();
                }
                else
                {
                    //MessageBox.Show("Thêm mới kỳ thi không thành công", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    NotificationForm notificationForm = new NotificationForm("Thêm mới kỳ thi không thành công", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                }
                this.Close();
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                NotificationForm notificationForm = new NotificationForm(Common.Common.COMMON_ERORR, "Lỗi", MessageBoxIcon.Warning);
                notificationForm.ShowDialog();
            }
        }
Beispiel #9
0
        private void SearchCertListBySchool()
        {
            try
            {
                if (SchoolComboBox.SelectedValue == null)
                {
                    NotificationForm notificationForm = new NotificationForm("Giá trị trường học không tồn tại", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                }

                if (IsCheckedComboBox.SelectedItem == null)
                {
                    NotificationForm notificationForm = new NotificationForm("Giá trị trạng thái không tồn tại", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                }

                int schoolId = int.Parse(SchoolComboBox.SelectedValue.ToString());
                if (schoolId == -1)
                {
                    LoadCertList();
                }
                else
                {
                    List <CertModel> certModels = managingCertService.GetAllNotPrintedCertBySchool(schoolId);
                    List <CertModel> resultList = null;
                    if (IsCheckedComboBox.SelectedIndex == 0) // All
                    {
                        resultList = certModels;
                    }
                    else if (IsCheckedComboBox.SelectedIndex == 1) // checked
                    {
                        resultList = certModels.Where(x => chosenCertIdList.Any(y => y == x.Id)).ToList();
                    }
                    else if (IsCheckedComboBox.SelectedIndex == 2) // not checked
                    {
                        resultList = certModels.Where(x => !chosenCertIdList.Any(y => y == x.Id)).ToList();
                    }

                    CertDataGridView.Rows.Clear();
                    int i = 1;
                    foreach (var certModel in resultList)
                    {
                        CertDataGridView.Rows.Add
                        (
                            chosenCertIdList.Any(x => x == certModel.Id),
                            certModel.Id,
                            i++,
                            certModel.StudentName,
                            certModel.SchoolName,
                            certModel.Serial,
                            certModel.ReferenceNumber
                        );
                    }
                }
            }
            catch (Exception ex)
            {
                NotificationForm notificationForm = new NotificationForm(Common.Common.COMMON_ERORR, "Lỗi", MessageBoxIcon.Error);
                notificationForm.ShowDialog();
            }
        }
Beispiel #10
0
        private void CreateButton_Click(object sender, EventArgs e)
        {
            string username    = "";
            string email       = "";
            string phoneNumber = "";
            string password    = "";
            bool   IsLocked    = false;

            if (string.IsNullOrEmpty(UsernameTextBox.Text))
            {
                //MessageBox.Show("Điền tên đăng nhập", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                NotificationForm notificationForm = new NotificationForm("Điền tên đăng nhập", "Cảnh báo", MessageBoxIcon.Warning);
                notificationForm.ShowDialog();
                return;
            }

            if (string.IsNullOrEmpty(EmailTextBox.Text))
            {
                //MessageBox.Show("Điền email để nhận mật khẩu", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                NotificationForm notificationForm = new NotificationForm("Điền email để nhận mật khẩu", "Cảnh báo", MessageBoxIcon.Warning);
                notificationForm.ShowDialog();
                return;
            }



            username    = UsernameTextBox.Text;
            email       = string.IsNullOrEmpty(EmailTextBox.Text) ? "" : EmailTextBox.Text.Trim();
            phoneNumber = string.IsNullOrEmpty(PhoneNumberTextBox.Text) ? "" : PhoneNumberTextBox.Text;
            password    = string.IsNullOrEmpty(PasswordTextBox.Text) ? "" : PasswordTextBox.Text;

            if (!MailWrapper.IsValidEmail(email))
            {
                NotificationForm notificationForm = new NotificationForm("Sai định dạng mail", "Cảnh báo", MessageBoxIcon.Warning);
                notificationForm.ShowDialog();
                return;
            }

            try
            {
                if (accountService.GetSingleAccountByUsername(username) != null)
                {
                    //MessageBox.Show("Tên đăng nhập tồn tại", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    NotificationForm notificationForm = new NotificationForm("Tên đăng nhập tồn tại", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }
                else if (!NetWorkWrapper.HasInternetConnection())
                {
                    //MessageBox.Show("Yêu cầu kết nối mạng để gửi tài khoản qua mail", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    NotificationForm notificationForm = new NotificationForm("Yêu cầu kết nối mạng để gửi tài khoản qua mail", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }

                List <int> roleIds = (from RoleModel r in RoleCheckedListBox.CheckedItems
                                      select r.Id).ToList();
                AccountModel accountModel = new AccountModel();
                accountModel.Username    = username;
                accountModel.Email       = email;
                accountModel.Password    = BCrypt.Net.BCrypt.HashPassword(password);
                accountModel.PhoneNumber = phoneNumber;
                accountModel.IsActive    = !IsLocked;

                int result = accountService.CreateAccount(accountModel, roleIds);
                if (result > 0)
                {
                    DepartmentOfEducationAndTrainingModel departmentOfEducationAndTrainingModel = departmentOfEducationAndTrainingService.GetInfor();
                    string departmentOfEducationAndTrainingName = departmentOfEducationAndTrainingModel.Name;

                    BodyBuilder bodyBuilder = new BodyBuilder();
                    //string path = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;
                    string path = Directory.GetCurrentDirectory(); // bản gửi

                    StreamReader str      = new StreamReader(Path.Combine(path, "Mail/SendPasswordEmailTemplate.html"));
                    string       MailText = str.ReadToEnd();
                    MailText             = MailText.Replace("{{Title}}", "Thông tin tài khoản");
                    MailText             = MailText.Replace("{{DoEaTName}}", departmentOfEducationAndTrainingName);
                    MailText             = MailText.Replace("{{Username}}", accountModel.Username);
                    MailText             = MailText.Replace("{{Password}}", password);
                    bodyBuilder.HtmlBody = MailText;

                    MimeMessage mimeMessage = new MimeMessage();
                    mimeMessage.Body = bodyBuilder.ToMessageBody();
                    MailWrapper.SendMail("", accountModel.Email, "Tạo tài khoản", mimeMessage);

                    //MessageBox.Show("Tạo tài khoản thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    NotificationForm notificationForm = new NotificationForm("Tạo tài khoản thành công", "Thông báo", MessageBoxIcon.Information);
                    notificationForm.ShowDialog();
                    OnAccountCreated();
                }
                else
                {
                    //MessageBox.Show("Tạo tài khoản không thành công", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    NotificationForm notificationForm = new NotificationForm("Tạo tài khoản không thành công", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                }
                this.Close();
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                NotificationForm notificationForm = new NotificationForm(Common.Common.COMMON_ERORR, "Lỗi", MessageBoxIcon.Error);
                notificationForm.ShowDialog();
            }
        }
Beispiel #11
0
        private void AddBlankCertButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(SerialCertTextBox.Text))
                {
                    //MessageBox.Show("Điền số hiệu văn bằng!", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    NotificationForm notificationForm = new NotificationForm("Điền số hiệu văn bằng!", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }

                if (BlankCertTypeComboBox.SelectedValue == null)
                {
                    NotificationForm notificationForm = new NotificationForm("Chọn loại phôi!", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }

                string path = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;
                if (!string.IsNullOrEmpty(imageLocation))
                {
                    saveFileName = SerialCertTextBox.Text;
                    File.Delete(Path.Combine(@"C:\JbCert_Resource\Images\", currentBlankCertModel.Image));
                    currentBlankCertModel.Image = saveFileName + extension;
                }

                currentBlankCertModel.Serial          = SerialCertTextBox.Text;
                currentBlankCertModel.UpdatedAt       = DateTime.Now;
                currentBlankCertModel.IsAvailable     = (!FailBlankCertCheckbox.Checked & !ReturnBlankCertCheckbox.Checked);
                currentBlankCertModel.IsReturned      = ReturnBlankCertCheckbox.Checked;
                currentBlankCertModel.ReasonReturn    = ReasonReturnRichTextBox.Text;
                currentBlankCertModel.BlankCertTypeId = int.Parse(BlankCertTypeComboBox.SelectedValue.ToString());

                int result = managingBlankCertService.Update(currentBlankCertModel);
                if (result > 0)
                {
                    OnBlankCertUpdated();
                    if (!string.IsNullOrEmpty(imageLocation))
                    {
                        File.Copy(imageLocation, Path.Combine(@"C:\JbCert_Resource\Images\", saveFileName + extension));
                    }
                    //MessageBox.Show("Cập nhật thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    NotificationForm notificationForm = new NotificationForm("Cập nhật thành công", "Thông báo", MessageBoxIcon.Information);
                    notificationForm.ShowDialog();
                    this.Close();
                }
                else
                {
                    //MessageBox.Show("Cập nhật không thành công", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    NotificationForm notificationForm = new NotificationForm("Cập nhật không thành công", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                }
            }
            catch (Exception ex)
            {
                var message = ex.Message;
                //MessageBox.Show(message, "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                NotificationForm notificationForm = new NotificationForm(Common.Common.COMMON_ERORR, "Lỗi", MessageBoxIcon.Error);
                notificationForm.ShowDialog();
            }
        }
Beispiel #12
0
        private void SearchButton_Click(object sender, EventArgs e)
        {
            try
            {
                string studentName     = "";
                int    schoolId        = -1;
                string serial          = "";
                string referenceNumber = "";

                if (!string.IsNullOrEmpty(FullNameTextBox.Text))
                {
                    studentName = FullNameTextBox.Text;
                }

                if (!string.IsNullOrEmpty(SerialTextBox.Text))
                {
                    serial = SerialTextBox.Text;
                }

                if (!string.IsNullOrEmpty(ReferenceNumberTextBox.Text))
                {
                    referenceNumber = ReferenceNumberTextBox.Text;
                }

                if (SchoolComboBox.SelectedValue == null)
                {
                    NotificationForm notificationForm = new NotificationForm("Giá trị trương học không tồn tại", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                    return;
                }

                schoolId = int.Parse(SchoolComboBox.SelectedValue.ToString());

                List <CertModel> certModels = managingCertService.SearchCert(studentName, schoolId, serial, referenceNumber);
                CertDataGridView.Rows.Clear();
                int i = 1;
                foreach (var certModel in certModels)
                {
                    CertDataGridView.Rows.Add
                    (
                        certModel.Id,
                        false,
                        i++,
                        certModel.StudentName,
                        certModel.RankingName,
                        certModel.CertName,
                        certModel.SchoolName,
                        certModel.Serial,
                        certModel.ReferenceNumber,
                        certModel.ProviderName,
                        certModel.Position,
                        certModel.GrantedDate.ToShortDateString(),
                        certModel.GrantedAddress,
                        certModel.ReceiverName,
                        certModel.ReceiverIdentityNumber,
                        certModel.IsGranted == true ? "Đã cấp" : "Chưa cấp",
                        certModel.IsPrinted == true ? "Đã in" : "Chưa in"

                    );
                }
            }
            catch (Exception ex)
            {
                NotificationForm notificationForm = new NotificationForm(Common.Common.COMMON_ERORR, "Lỗi", MessageBoxIcon.Error);
                notificationForm.ShowDialog();
            }
        }
Beispiel #13
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            if (_addCertForm.chosenStudents.Count > chosenBlankCertModels.Count)
            {
                //MessageBox.Show("Số lượng sinh viên nhiều hơn số lượng phôi", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                NotificationForm notificationForm = new NotificationForm("Số lượng sinh viên nhiều hơn số lượng phôi", "Cảnh báo", MessageBoxIcon.Warning);
                notificationForm.ShowDialog();
                return;
            }

            if (_addCertForm.chosenStudents.Count < chosenBlankCertModels.Count)
            {
                //MessageBox.Show("Số lượng sinh viên ít hơn số lượng phôi", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                NotificationForm notificationForm = new NotificationForm("Số lượng sinh viên ít hơn số lượng phôi", "Cảnh báo", MessageBoxIcon.Warning);
                notificationForm.ShowDialog();
                return;
            }

            if (string.IsNullOrEmpty(CertNameTextBox.Text))
            {
                //MessageBox.Show("Điền tên bằng", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                NotificationForm notificationForm = new NotificationForm("Điền tên bằng", "Cảnh báo", MessageBoxIcon.Warning);
                notificationForm.ShowDialog();
                CertNameTextBox.Focus();
                return;
            }

            BlankCertModel blankCertModel = chosenBlankCertModels.Where(x => string.IsNullOrEmpty(x.ReferenceNumber)).FirstOrDefault();
            if (blankCertModel != null)
            {
                //MessageBox.Show("Số vào sổ của phôi có số hiệu" + blankCertModel.Serial + " đang trống", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                NotificationForm notificationForm = new NotificationForm("Số vào sổ của phôi có số hiệu" + blankCertModel.Serial + " đang trống", "Cảnh báo", MessageBoxIcon.Warning);
                notificationForm.ShowDialog();
                return;
            }


            try
            {
                int result = managingCertService.AddManyCerts(chosenBlankCertModels, _addCertForm.chosenStudents, CertNameTextBox.Text);
                if (result == _addCertForm.chosenStudents.Count)
                {
                    //MessageBox.Show("Thêm thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    NotificationForm notificationForm = new NotificationForm("Thêm thành công", "Thông báo", MessageBoxIcon.Information);
                    notificationForm.ShowDialog();
                }
                else
                {
                    //MessageBox.Show("Thêm không thành công", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    NotificationForm notificationForm = new NotificationForm("Thêm không thành công", "Cảnh báo", MessageBoxIcon.Warning);
                    notificationForm.ShowDialog();
                }

                this.Close();
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                NotificationForm notificationForm = new NotificationForm(Common.Common.COMMON_ERORR, "Lỗi", MessageBoxIcon.Error);
                notificationForm.ShowDialog();
            }

        }
        private void EditStudentForm_Load(object sender, EventArgs e)
        {
            try
            {
                // load school
                SchoolComboBox.DataSource    = managingSchoolService.GetAllSchool();
                SchoolComboBox.DisplayMember = "SchoolName";
                SchoolComboBox.ValueMember   = "Id";

                // load ranking
                RankingComboBox.DataSource    = managingStudentService.GetAllRanking();
                RankingComboBox.DisplayMember = "RankingName";
                RankingComboBox.ValueMember   = "Id";

                // load major
                List <MajorModel> majorModels = managingStudentService.GetAllMajor();
                majorModels.Add(new MajorModel()
                {
                    Id        = -1,
                    MajorName = "Không có ngành đào tạo",
                    IsDeleted = false,
                    Note      = ""
                });
                MajorComboBox.DataSource    = majorModels.OrderBy(x => x.Id).ToList();
                MajorComboBox.DisplayMember = "MajorName";
                MajorComboBox.ValueMember   = "Id";
                MajorComboBox.SelectedIndex = 0;

                // load learning mode
                LearningModeComboBox.DataSource    = managingStudentService.GetAllLearningMode();
                LearningModeComboBox.DisplayMember = "LearningModeName";
                LearningModeComboBox.ValueMember   = "Id";

                // load ethnic
                EthnicComboBox.DataSource    = managingStudentService.GetAllEthnic();
                EthnicComboBox.DisplayMember = "EthnicName";
                EthnicComboBox.ValueMember   = "Id";

                // load gender
                GenderComboBox.Items.Add("Nam");
                GenderComboBox.Items.Add("Nữ");
                GenderComboBox.SelectedIndex = 0;


                // load current student
                StudentModel studentModel = managingStudentService.GetSingleStudentById(_studentId);
                FullnameTextBox.Text               = studentModel.FullName;
                AddressTextBox.Text                = studentModel.Address;
                BornedAddressTextBox.Text          = studentModel.BornedAddress;
                HouseHoldTextBox.Text              = studentModel.HouseHold;
                IdentityTextBox.Text               = studentModel.IdentityNumber;
                ScoreTextBox.Text                  = studentModel.Score.ToString();
                GraduatingYearTextBox.Text         = studentModel.GraduatingYear.ToString();
                DobTextBox.Text                    = studentModel.Dob.ToString("dd/MM/yyyy");
                NoteRichTextBox.Text               = studentModel.Note;
                SchoolComboBox.SelectedValue       = studentModel.SchoolId;
                MajorComboBox.SelectedValue        = studentModel.MajorId;
                GenderComboBox.SelectedItem        = studentModel.Gender;
                LearningModeComboBox.SelectedValue = studentModel.LearningModeId;
                EthnicComboBox.SelectedValue       = studentModel.EthnicId;
                RankingComboBox.SelectedValue      = studentModel.RankingId;
                oldAvatar = studentModel.Image;

                string path = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;
                using (FileStream fs = new FileStream(Path.Combine(@"C:\JbCert_Resource\StudentImages", studentModel.Image), FileMode.Open))
                {
                    AvatarPictureBox.Image = Image.FromStream(fs);
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                NotificationForm notificationForm = new NotificationForm(Common.Common.COMMON_ERORR, "Lỗi", MessageBoxIcon.Warning);
                notificationForm.ShowDialog();
            }
        }