Exemple #1
0
        private void ThemHocSinh()
        {
            if (txtStudentCode.Text != "" &&
                txtFirstName.Text != "" &&
                txtLastName.Text != "" &&
                dtBirthday.Text != "" &&
                txtAddressDetail.Text != "" &&
                txtClassName.Text != "" &&
                txtClassID.Text != "" &&
                dtDateStudy.Text != "")
            {
                DataConnect.Student       entity  = new DataConnect.Student();
                DataConnect.StudentParent entity2 = new DataConnect.StudentParent();
                DataConnect.Student_Class entity3 = new DataConnect.Student_Class();

                entity.StudentCode = txtStudentCode.Text;
                entity.FirstName   = txtFirstName.Text;
                entity.LastName    = txtLastName.Text;
                entity.HomeName    = txtHomeName.Text;
                entity.Birthday    = DateTime.Parse(dtBirthday.EditValue.ToString());
                entity.DateStudy   = DateTime.Parse(dtDateStudy.EditValue.ToString());
                entity.Gender      = cbbGender.Text == "Nữ" ? false : true;
                if (Stream() != null)
                {
                    entity.Image = Stream().ToArray();
                }
                entity.EthnicGroupID = int.Parse(cbbEthnicGroup.SelectedValue.ToString());
                entity.ReligionID    = int.Parse(cbbReligion.SelectedValue.ToString());
                entity.LocationID    = int.Parse(cbbWard.SelectedValue.ToString());
                entity.AdressDetail  = txtAddressDetail.Text;
                entity.Note          = txtNote.Text;
                entity.Status        = chbStatus.Checked ? true : false;

                if (iFunction == 1)
                {
                    int NewstudentID = m_StudentDAO.StudentInsert(entity);

                    if (NewstudentID > 0)
                    {
                        entity2.StudentID = NewstudentID;
                        entity2.Password  = MD5Hash.PasswordEncryptor.MD5Hash("12345");
                        entity3.ClassID   = int.Parse(txtClassID.Text);
                        entity3.StudentID = NewstudentID;
                        entity3.Status    = chbStatus.Checked ? true : false;
                        m_StudentParentsDAO.ParentsInsert(entity2);
                        m_StudentClassDAO.StudentClassInsert(entity3);
                        if (XtraMessageBox.Show("Bạn có muốn thêm thông tin khác ngay bây giờ? ", "Thêm học sinh thành công", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            frmStudentDetail m_StudentDetail = new frmStudentDetail();
                            m_StudentDetail.iFunction      = 2;
                            m_StudentDetail.Student        = new StudentDAO().GetByID(NewstudentID);
                            m_StudentDetail.StudentParents = new StudentParentsDAO().GetByID(NewstudentID);
                            m_StudentDetail.Class          = new ClassDAO().GetByClassID(int.Parse(txtClassID.Text));

                            m_StudentDetail.ShowDialog();
                        }
                    }
                    else
                    {
                        XtraMessageBox.Show("Hệ thống đã xảy ra lỗi", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            else
            {
                XtraMessageBox.Show("Mời bạn nhập đầy đủ thông tin!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Exemple #2
0
        private void UpdateHocSinh()
        {
            if (txtStudentCode.Text != "" &&
                txtFirstName.Text != "" &&
                txtLastName.Text != "" &&
                dtBirthday.Text != "" &&
                dtDateStudy.Text != "" &&
                txtHobby.Text != "" &&
                txtTalen.Text != "" &&
                txtAddressDetail.Text != "" &&
                txtFatherName.Text != "" &&
                dtFatherBirthday.Text != "" &&
                txtFatherPhone.Text != "" &&
                txtFatherJob.Text != "" &&
                txtMotherName.Text != "" &&
                txtMotherJob.Text != "" &&
                txtMotherPhone.Text != "" &&
                dtMotherBirthday.Text != "")
            {
                DataConnect.Student       entity  = new DataConnect.Student();
                DataConnect.StudentParent entity2 = new DataConnect.StudentParent();
                entity.StudentCode = txtStudentCode.Text;
                entity.FirstName   = txtFirstName.Text;
                entity.LastName    = txtLastName.Text;
                entity.HomeName    = txtHomeName.Text;
                entity.Birthday    = DateTime.Parse(dtBirthday.EditValue.ToString());
                entity.DateStudy   = DateTime.Parse(dtDateStudy.EditValue.ToString());
                entity.Gender      = cbbGender.Text == "Nữ" ? false : true;
                entity.Hobby       = txtHobby.Text;
                entity.Talent      = txtTalen.Text;
                if (Stream() != null)
                {
                    entity.Image = Stream().ToArray();
                }
                entity.EthnicGroupID = int.Parse(cbbEthnicGroup.SelectedValue.ToString());
                entity.ReligionID    = int.Parse(cbbReligion.SelectedValue.ToString());
                entity.LocationID    = int.Parse(cbbWard.SelectedValue.ToString());
                entity.AdressDetail  = txtAddressDetail.Text;
                entity.Note          = txtNote.Text;
                entity.Status        = chbStatus.Checked ? true : false;

                entity2.FatherName     = txtFatherName.Text;
                entity2.FatherBirthday = DateTime.Parse(dtFatherBirthday.EditValue.ToString());
                entity2.FatherJob      = txtFatherJob.Text;
                entity2.FatherPhone    = txtFatherPhone.Text;
                entity2.MotherName     = txtMotherName.Text;
                entity2.MotherBirthday = DateTime.Parse(dtMotherBirthday.EditValue.ToString());
                entity2.MotherJob      = txtMotherJob.Text;
                entity2.MotherPhone    = txtMotherPhone.Text;

                StudentDAO        m_StudentDAO        = new StudentDAO();
                StudentParentsDAO m_StudentParentsDAO = new StudentParentsDAO();

                if (iFunction == 2)
                {
                    entity.StudentID         = Student.StudentID;
                    entity2.StudentParentsID = StudentParents.StudentParentsID;
                    if (m_StudentDAO.StudentUpdate(entity) == true && m_StudentParentsDAO.ParentsUpdate(entity2) == true)
                    {
                        XtraMessageBox.Show("Cập nhật thành công!", "Thông Báo");
                        DialogResult = DialogResult.OK;
                        this.Close();
                    }
                    else
                    {
                        XtraMessageBox.Show("Hệ thống đã xảy ra lỗi", "Thông Báo");
                    }
                }
            }
            else
            {
                XtraMessageBox.Show("Mời bạn nhập đầy đủ thông tin!");
            }
        }