Example #1
0
        private void AddStudentForm_Load(object sender, EventArgs e)
        {
            // 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;
        }
Example #2
0
        private void EditCertForm_Load(object sender, EventArgs e)
        {
            try
            {
                // load school
                SchoolComboBox.DataSource    = managingSchoolService.GetAllSchool();
                SchoolComboBox.DisplayMember = "SchoolName";
                SchoolComboBox.ValueMember   = "Id";

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

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

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

                // load major
                List <MajorModel> majorModels = managingStudentService.GetAllMajor();
                majorModels.Add(new MajorModel()
                {
                    Id        = -1,
                    MajorName = "Không có chuyên ngành"
                });
                MajorComboBox.DataSource    = majorModels;
                MajorComboBox.DisplayMember = "MajorName";
                MajorComboBox.ValueMember   = "Id";

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


                certModel    = managingCertService.GetSingleCertById(_certId);
                studentModel = managingStudentService.GetSingleStudentById(certModel.StudentId);

                FullnameTextBox.Text         = studentModel.FullName;
                SchoolComboBox.SelectedValue = studentModel.SchoolId;
                BornedAddressTextBox.Text    = studentModel.BornedAddress;
                AddressTextBox.Text          = studentModel.Address;
                DobTextBox.Text                    = studentModel.Dob.ToString("dd/MM/yyyy");
                HouseHoldTextBox.Text              = studentModel.HouseHold;
                ScoreTextBox.Text                  = studentModel.Score.ToString();
                GraduatingYearTextBox.Text         = studentModel.GraduatingYear.ToString();
                RankingComboBox.SelectedValue      = studentModel.RankingId;
                MajorComboBox.SelectedValue        = studentModel.MajorId;
                LearningModeComboBox.SelectedValue = studentModel.LearningModeId;
                EthnicComboBox.SelectedValue       = studentModel.EthnicId;
                GenderComboBox.SelectedItem        = studentModel.Gender;

                SerialTextBox.Text          = certModel.Serial;
                ReferenceNumberTextBox.Text = certModel.ReferenceNumber;

                // load student image
                string imageName = managingStudentService.GetStudentImage(certModel.StudentId);
                if (string.IsNullOrEmpty(imageName))
                {
                    //MessageBox.Show("Không tìm thấy ảnh", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    NotificationForm notificationForm = new NotificationForm("Không tìm thấy ảnh", "Lỗi", MessageBoxIcon.Error);
                    notificationForm.ShowDialog();
                    return;
                }
                string path = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;
                using (FileStream fs = new FileStream(Path.Combine(@"C:\JbCert_Resource\StudentImages\", imageName), FileMode.Open))
                {
                    StudentImagePictureBox.Image = Image.FromStream(fs);
                }

                // load blankcert image
                imageName = managingBlankCertService.GetBlankCertImage(certModel.BlankCertId);
                if (string.IsNullOrEmpty(imageName))
                {
                    //MessageBox.Show("Không tìm thấy ảnh", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    NotificationForm notificationForm = new NotificationForm("Không tìm thấy ảnh", "Lỗi", MessageBoxIcon.Error);
                    notificationForm.ShowDialog();
                    return;
                }
                path = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;
                using (FileStream fs = new FileStream(Path.Combine(@"C:\JbCert_Resource\Images\", imageName), FileMode.Open))
                {
                    BlankCertImagePictureBox.Image = Image.FromStream(fs);
                }
            }
            catch (FileNotFoundException FileNotFoundEx)
            {
                NotificationForm notificationForm = new NotificationForm("Không tìm thấy ảnh, vui lòng cập nhật lại ảnh", "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();
            }
        }
        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();
            }
        }