Beispiel #1
0
 private void sửaToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (txtStudentID.Text == null)
     {
         XtraMessageBox.Show("Vui lòng chọn học sinh cần xem", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         frmStudentDetail m_StudentDetail = new frmStudentDetail();
         m_StudentDetail.iFunction      = 2;
         m_StudentDetail.Student        = new StudentDAO().GetByID(int.Parse(txtStudentID.Text));
         m_StudentDetail.StudentParents = new StudentParentsDAO().GetByID(int.Parse(txtStudentID.Text));
         m_StudentDetail.Class          = new ClassDAO().GetByClassID(int.Parse(cmbLopHoc.SelectedValue.ToString()));
         m_StudentDetail.ShowDialog();
         if (m_StudentDetail.DialogResult == DialogResult.OK)
         {
             FillGridControl(int.Parse(cmbLopHoc.SelectedValue.ToString()));
         }
     }
 }
Beispiel #2
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);
            }
        }