string CreateMaHocSinhMoi()
        {
            DShocsinhBLL dshsbll = new DShocsinhBLL();
            string       maHSMax = dshsbll.GetMaHSMax();

            return((Int32.Parse(maHSMax) + 1).ToString());
        }
        private void ThemSuaHocSinh_Load(object sender, EventArgs e)
        {
            List <string> listGioiTinh = new List <string>()
            {
                "Nam",
                "Nữ"
            };

            cbGioiTinh.DataSource = listGioiTinh;

            //neu day la tem moi hoc sinh thi minh se load san tbMaHocSinh bang gia tri moi
            if (this.tenHocSinh == null)
            {
                DShocsinhBLL dshsbll      = new DShocsinhBLL();
                string       maHocSinhMax = dshsbll.GetMaHSMax();

                tbMaHS.Text = (Int32.Parse(maHocSinhMax) + 1) + "";
            }
        }
示例#3
0
        private void lvdshs_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lvdshs.SelectedItems.Count > 0)
            {
                DShocsinhBLL hocsinhbll = new DShocsinhBLL();
                string       maHocSinh  = lvdshs.SelectedItems[0].SubItems[1].Text;
                HocSinh      hocsinh    = hocsinhbll.GetHocSinh(maHocSinh);

                tbMaHocSinh.Text = hocsinh.MaHocSinh;
                tbHoVaTen.Text   = hocsinh.HoVaTen;
                tbGioiTinh.Text  = hocsinh.GioiTinh;
                tbDiaChi.Text    = hocsinh.DiaChi;
                tbEmail.Text     = hocsinh.Email;
                tbNgaySinh.Text  = hocsinh.NamSinh;

                QuaTrinhHocTapBLL     quaTrinhHocbll  = new QuaTrinhHocTapBLL();
                List <QuaTrinhHocTap> listQuaTrinhHoc = quaTrinhHocbll.GetQuaTrinhHocTapCoMaHS(hocsinh.MaHocSinh);
                tbLop.Text = listQuaTrinhHoc[0].MaLop;
            }
        }
示例#4
0
 private void btnXoaHocSinh_Click(object sender, EventArgs e)
 {
     if (lvdshs.SelectedItems.Count > 0)
     {
         DShocsinhBLL dshsbll = new DShocsinhBLL();
         bool         result  = dshsbll.XoaHs(lvdshs.SelectedItems[0].SubItems[1].Text);
         if (!result)
         {
             MessageBox.Show(" Không thể xóa,Vui lòng kiểm tra lại kết nối CSDL!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else
         {
             MessageBox.Show(" Xóa thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     else
     {
         MessageBox.Show("Bạn phải chọn 1 học sinh để xóa !", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
示例#5
0
 private void btnXoaHocSinh_Click_1(object sender, EventArgs e)
 {
     if (lvdshs.SelectedItems.Count > 0)
     {
         string       maHocSinh  = lvdshs.SelectedItems[0].SubItems[1].Text;
         DShocsinhBLL hocsinhbll = new DShocsinhBLL();
         if (hocsinhbll.XoaHs(maHocSinh))
         {
             MessageBox.Show("Xóa thành công !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             LoadDSHS_DSHS();
         }
         else
         {
             MessageBox.Show("Xóa thất bại, thử kiểm tra lại kết nối CSDL!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         MessageBox.Show("Bạn phải chọn ít nhất 1 dòng để xóa!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
示例#6
0
        void LoadDSHSTheoLop(string maLop, string tenLop)
        {
            gbDSHSTheoLop.Text = "Danh sách học sinh của lớp " + tenLop;
            DShocsinhBLL   dsHocSinh = new DShocsinhBLL();
            List <HocSinh> dsHS      = dsHocSinh.GetDSHocSinhTheoLop(maLop);
            int            dem       = 1;

            lvDSHSTheoLop.Items.Clear();

            foreach (HocSinh hocsinh in dsHS)
            {
                ListViewItem lvi = new ListViewItem(dem + "");
                lvi.SubItems.Add(hocsinh.MaHocSinh);
                lvi.SubItems.Add(hocsinh.HoVaTen);
                lvi.SubItems.Add(hocsinh.GioiTinh);
                lvi.SubItems.Add(hocsinh.NamSinh);
                lvi.SubItems.Add(hocsinh.DiaChi);

                lvDSHSTheoLop.Items.Add(lvi);
                dem++;
            }
        }
        private void btnLuu_Click(object sender, EventArgs e)
        {
            if (dateTimePickerNamSinh.Value > DateTime.Now)
            {
                MessageBox.Show("Thất bại, Ngày sinh không thể lớn hơn ngày hiện tại!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            //ten hoc sinh null tuc la tao moi, nguoc lai la sua
            ErrorType    result;
            DShocsinhBLL dshsbll = new DShocsinhBLL();

            if (this.tenHocSinh == null)
            {
                result = dshsbll.ThemHS(tbMaHS.Text, tbHoTen.Text, cbGioiTinh.Text, tbDiaChi.Text, tbEmail.Text, dateTimePickerNamSinh.Value);
            }
            else
            {
                result = dshsbll.SuaHS(tbMaHS.Text, tbHoTen.Text, cbGioiTinh.Text, tbDiaChi.Text, tbEmail.Text, dateTimePickerNamSinh.Value);
            }


            switch ((int)result)
            {
            case (int)ErrorType.KI_TU_RONG:
                MessageBox.Show("Thất bại, bạn phải điền đầy đủ thông tin để thực hiện!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                break;

            case (int)ErrorType.THAT_BAI:
                MessageBox.Show("Thất bại, Xin kiểm tra lại kết nối CSDL!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                break;

            case (int)ErrorType.VUOT_MIEN_GIA_TRI:

                ThayDoiQuyDinhBLL quydinhbll = new ThayDoiQuyDinhBLL();
                List <ThamSo>     listThamSo = quydinhbll.GetListThamSo();

                int tuoiToiDa    = 0;
                int tuoiToiThieu = 0;
                foreach (ThamSo ts in listThamSo)
                {
                    //tuoi toi thieu
                    if (ts.MaThamSo == "TuoiToiDa")
                    {
                        tuoiToiDa = (int)ts.GiaTri;
                    }
                    if (ts.MaThamSo == "TuoiToiThieu")
                    {
                        tuoiToiThieu = (int)ts.GiaTri;
                    }
                }
                MessageBox.Show("Thất bại, Số tuổi phải nằm từ " + tuoiToiThieu + " đến " + tuoiToiDa, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                break;

            default:
                if (this.tenHocSinh == null)
                {
                    MessageBox.Show("Thêm thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    tbHoTen.Text  = "";
                    tbEmail.Text  = "";
                    tbDiaChi.Text = "";

                    tbMaHS.Text = "" + CreateMaHocSinhMoi();
                }
                else
                {
                    MessageBox.Show("Sửa thành công !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                break;
            }
        }
示例#8
0
        /// <summary>
        /// Load thong tin chung cua hoc sinh bao gom ca diem len listview DSHS
        /// </summary>
        void LoadDSHS_DSHS()
        {
            DShocsinhBLL hocSinhbll = new DShocsinhBLL();
            List <ThongTinChungHS_DiemTB> listThongTinChungHocSinh;

            if (cbTieuChiTimKiem.SelectedIndex == 0)
            {
                listThongTinChungHocSinh = hocSinhbll.GetDanhSachHocSinh_ThongTinChung_TimKiemTheoTen(tbTuKhoaTimKiem.Text);
            }
            else
            {
                listThongTinChungHocSinh = hocSinhbll.GetDanhSachHocSinh_ThongTinChung_TimKiemTheoLop(tbTuKhoaTimKiem.Text);
            }

            lvdshs.Items.Clear();
            int          soThuTu   = 1;
            HocKyBLL     hockybll  = new HocKyBLL();
            List <HocKy> listhocky = hockybll.GetListHocKy();

            foreach (ThongTinChungHS_DiemTB hocsinh in listThongTinChungHocSinh)
            {
                int indexHocKy = 0;
                for (int i = 0; i < listhocky.Count; i++)
                {
                    if (listhocky[i].MaHocKy == hocsinh.maHocKy)
                    {
                        indexHocKy = i + 4;
                    }
                }

                bool kiemTraTonTai = false;
                if (lvdshs.Items.Count > 0)
                {
                    foreach (ListViewItem lvitem in lvdshs.Items)
                    {
                        if (lvitem.SubItems[1].Text == hocsinh.maHocSinh)
                        {
                            kiemTraTonTai = true;
                            lvitem.SubItems[indexHocKy].Text = hocsinh.diemTB;
                            break;
                        }
                    }
                }

                if (!kiemTraTonTai)
                {
                    ListViewItem lvi = new ListViewItem(soThuTu + "");
                    lvi.SubItems.Add(hocsinh.maHocSinh);
                    lvi.SubItems.Add(hocsinh.TenHocSinh);
                    lvi.SubItems.Add(hocsinh.Lop);
                    lvi.SubItems.Add("NULL"); // diem tb hoc ki 1
                    lvi.SubItems.Add("NULL"); // dim trung binh hk 2
                    lvi.SubItems.Add("NULL"); // dim trung binh hk 3
                    lvi.SubItems.Add("NULL"); // dim trung binh hk 4


                    lvi.SubItems[indexHocKy].Text = hocsinh.diemTB;

                    lvdshs.Items.Add(lvi);
                    soThuTu++;
                }
            }
        }
示例#9
0
        /// <summary>
        /// Load thong tin chung cua hoc sinh bao gom ca diem len listview DSHS
        /// </summary>
        void LoadDSHS_DSHS()
        {
            DShocsinhBLL hocSinhbll = new DShocsinhBLL();
            List <ThongTinChungHS_DiemTB> listThongTinChungHocSinh;

            if (cbTieuChiTimKiem.SelectedIndex == 0)
            {
                listThongTinChungHocSinh = hocSinhbll.GetDanhSachHocSinh_ThongTinChung_TimKiemTheoTen(tbTuKhoaTimKiem.Text);
            }
            else
            if (cbTieuChiTimKiem.SelectedIndex == 2)
            {
                try
                {
                    string[] listdiem = tbTuKhoaTimKiem.Text.Split(' ');
                    float    canTren  = float.Parse(listdiem[1]);
                    float    canDuoi  = float.Parse(listdiem[0]);
                    listThongTinChungHocSinh = hocSinhbll.GetDanhSachHocSinh_ThongTinChung_TimKiemTheoDiemTB(canDuoi, canTren);
                }
                catch
                {
                    MessageBox.Show("Không đúng định dạng tìm kiếm", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }
            else
            //  if (cbTieuChiTimKiem.SelectedIndex == 1)
            {
                listThongTinChungHocSinh = hocSinhbll.GetDanhSachHocSinh_ThongTinChung_TimKiemTheoLop(tbTuKhoaTimKiem.Text);
            }

            lvdshs.Items.Clear();
            int          soThuTu   = 1;
            HocKyBLL     hockybll  = new HocKyBLL();
            List <HocKy> listhocky = hockybll.GetListHocKy();

            foreach (ThongTinChungHS_DiemTB hocsinh in listThongTinChungHocSinh)
            {
                int indexHocKy = 0;
                for (int i = 0; i < listhocky.Count; i++)
                {
                    if (listhocky[i].MaHocKy == hocsinh.maHocKy)
                    {
                        indexHocKy = i + 4;
                    }
                }

                bool kiemTraTonTai = false;
                if (lvdshs.Items.Count > 0)
                {
                    foreach (ListViewItem lvitem in lvdshs.Items)
                    {
                        if (lvitem.SubItems[1].Text == hocsinh.maHocSinh)
                        {
                            kiemTraTonTai = true;
                            lvitem.SubItems[indexHocKy].Text = hocsinh.diemTB;
                            break;
                        }
                    }
                }

                if (!kiemTraTonTai)
                {
                    ListViewItem lvi = new ListViewItem(soThuTu + "");
                    lvi.SubItems.Add(hocsinh.maHocSinh);
                    lvi.SubItems.Add(hocsinh.TenHocSinh);
                    lvi.SubItems.Add(hocsinh.Lop);
                    lvi.SubItems.Add("-"); // diem tb hoc ki 1
                    lvi.SubItems.Add("-"); // dim trung binh hk 2
                    lvi.SubItems.Add("-"); // dim trung binh hk 3
                    lvi.SubItems.Add("-"); // dim trung binh hk 4


                    lvi.SubItems[indexHocKy].Text = hocsinh.diemTB;

                    lvdshs.Items.Add(lvi);
                    soThuTu++;
                }
            }
        }