Exemplo n.º 1
0
        public int XoaHocKi(QLHS_DTO ma)
        {
            int       nRow     = 0;
            DBConnect provider = new DBConnect();

            try
            {
                string strSql = "DELETE FROM HOCKI WHERE MaHocKi = @MaHocKi;";
                provider.Connect();
                nRow = provider.ExecuteNonQuery(CommandType.Text, strSql,
                                                new SqlParameter {
                    ParameterName = "@MaHocKi", Value = ma.MaHocKi
                }
                                                );
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                provider.DisConnect();
            }
            return(nRow);
        }
Exemplo n.º 2
0
        private void btn_XacNhan_Click(object sender, EventArgs e)
        {
            try
            {
                if (txt_mamonhoc.Text != "" && txt_tenmonhoc.Text != "")
                {
                    QLHS_DTO hs = new QLHS_DTO();
                    hs.MaMonHoc  = txt_mamonhoc.Text;
                    hs.TenMonHoc = txt_tenmonhoc.Text;
                    QLHS_BUS bus = new QLHS_BUS();
                    bus.ThemMonHoc(hs);
                    MessageBox.Show("Thêm thành công môn học " + txt_tenmonhoc.Text + " !", "Thông báo");
                    LoadData();
                    btn_themmon.Visible = true;
                    btn_XacNhan.Visible = false;

                    txt_mamonhoc.Enabled       = false;
                    txt_tenmonhoc.Enabled      = false;
                    btn_capnhatmon.Enabled     = true;
                    btn_xoa.Enabled            = true;
                    btn_nhapdiemmonhoc.Enabled = true;
                }
                else
                {
                    MessageBox.Show("Mời nhập đầy đủ thông tin Môn Học!");
                }
            }
            catch
            {
                MessageBox.Show("Mã môn học này đã tồn tại!");
            }
        }
Exemplo n.º 3
0
 private void btn_htthem_Click(object sender, EventArgs e)
 {
     try
     {
         QLHS_DTO hs = new QLHS_DTO();
         hs.MaKhoiLop  = txt_makhoilop.Text;
         hs.TenKhoiLop = txt_tenkhoilop.Text;
         QLHS_BUS bus = new QLHS_BUS();
         bus.ThemKhoiLop(hs);
         MessageBox.Show("Thêm thành công khối lớp " + txt_tenkhoilop.Text + " !", "Thông báo");
         LoadData();
         btn_themkhoilop.Visible    = true;
         btn_capnhatkhoilop.Enabled = true;
         btn_xoakhoilop.Enabled     = true;
         btn_htthem.Visible         = false;
         btn_themlop.Enabled        = true;
         btn_htcapnhat.Visible      = false;
         btn_htthem.Visible         = false;
         txt_makhoilop.Enabled      = false;
         txt_tenkhoilop.Enabled     = false;
         txt_makhoilop.DataBindings.Clear();
         txt_makhoilop.DataBindings.Add("Text", dtgv_khoilop.DataSource, "MaKhoiLop");
         txt_tenkhoilop.DataBindings.Clear();
         txt_tenkhoilop.DataBindings.Add("Text", dtgv_khoilop.DataSource, "TenKhoiLop");
     }
     catch
     {
         MessageBox.Show("Đã tồn tại mã Khối!");
     }
 }
Exemplo n.º 4
0
 public void LoadData()
 {
     try
     {
         QLHS_BUS  bus  = new QLHS_BUS();
         DataTable dt   = bus.DSLop();
         DataTable dt_1 = bus.LayKhoiLop();
         dtgv_danhsachlop.DataSource = dt;
         cb_khoi.DataSource          = dt_1;
         cb_khoi.DisplayMember       = "MaKhoiLop";
         cb_khoi.ValueMember         = "MaKhoiLop";
         if (dt.Rows.Count > 0)
         {
             dtgv_danhsachlop.Rows[0].Selected = true;
             RowSelected            = new QLHS_DTO();
             RowSelected.MaHocSinh  = dtgv_danhsachlop.SelectedRows[0].Cells["MaHocSinh"].Value.ToString();
             RowSelected.HoTen      = dtgv_danhsachlop.SelectedRows[0].Cells["HoTen"].Value.ToString();
             RowSelected.TenKhoiLop = dtgv_danhsachlop.SelectedRows[0].Cells["TenKhoiLop"].Value.ToString();
             RowSelected.TenLop     = dtgv_danhsachlop.SelectedRows[0].Cells["TenLop"].Value.ToString();
             RowSelected.SiSo       = dtgv_danhsachlop.SelectedRows[0].Cells["SiSo"].Value.ToString();
         }
     }
     catch (Exception ex)
     {
     }
 }
Exemplo n.º 5
0
 private void btn_htcapnhat_Click(object sender, EventArgs e)
 {
     try
     {
         if ((txt_makhoilop.Text != "") && (txt_tenkhoilop.Text != ""))
         {
             QLHS_DTO hs = new QLHS_DTO();
             hs.MaKhoiLop  = txt_makhoilop.Text;
             hs.TenKhoiLop = txt_tenkhoilop.Text;
             QLHS_BUS bus = new QLHS_BUS();
             bus.CapNhatKhoiLop(hs);
             MessageBox.Show("Cập nhật thành công khối lớp " + txt_makhoilop.Text + " !", "Thông báo");
             LoadData();
             btn_themkhoilop.Enabled    = true;
             btn_xoakhoilop.Enabled     = true;
             btn_capnhatkhoilop.Visible = true;
             btn_themlop.Enabled        = true;
             btn_htthem.Visible         = false;
             btn_htcapnhat.Visible      = false;
             txt_makhoilop.Enabled      = false;
             txt_tenkhoilop.Enabled     = false;
             txt_makhoilop.DataBindings.Clear();
             txt_makhoilop.DataBindings.Add("Text", dtgv_khoilop.DataSource, "MaKhoiLop");
             txt_tenkhoilop.DataBindings.Clear();
             txt_tenkhoilop.DataBindings.Add("Text", dtgv_khoilop.DataSource, "TenKhoiLop");
         }
         else
         {
             MessageBox.Show("Cập nhật không thành công! Mời bạn xem lại dữ liệu nhập! ", "Thông báo");
         }
     }
     catch (Exception ex)
     {
     }
 }
Exemplo n.º 6
0
        public int CapNhatLop(QLHS_DTO hs)
        {
            int       nRow     = 0;
            DBConnect provider = new DBConnect();

            try
            {
                string strSql = "UPDATE DANHSACHLOP SET MaLop = @MaLop, TenLop = @TenLop, SiSo = @SiSo, MaKhoiLop = @MaKhoiLop WHERE MaLop = @MaLop";
                provider.Connect();
                nRow = provider.ExecuteNonQuery(CommandType.Text, strSql,
                                                new SqlParameter {
                    ParameterName = "@MaLop", Value = hs.MaLop
                },
                                                new SqlParameter {
                    ParameterName = "@TenLop", Value = hs.TenLop
                },
                                                new SqlParameter {
                    ParameterName = "@SiSo", Value = hs.SiSo
                },
                                                new SqlParameter {
                    ParameterName = "@MaKhoiLop", Value = hs.MaKhoiLop
                }
                                                );
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                provider.DisConnect();
            }
            return(nRow);
        }
Exemplo n.º 7
0
        public int CapNhatHocKi(QLHS_DTO hs)
        {
            int       nRow     = 0;
            DBConnect provider = new DBConnect();

            try
            {
                string strSql = "UPDATE HOCKI SET MaHocKi = @MaHocKi, TenHocKi = @TenHocKi";
                provider.Connect();
                nRow = provider.ExecuteNonQuery(CommandType.Text, strSql,
                                                new SqlParameter {
                    ParameterName = "@MaHocKi", Value = hs.MaHocKi
                },
                                                new SqlParameter {
                    ParameterName = "@TenHocKi", Value = hs.TenHocKi
                }
                                                );
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                provider.DisConnect();
            }
            return(nRow);
        }
Exemplo n.º 8
0
        private void btn_xoalop_Click(object sender, EventArgs e)
        {
            try
            {
                DialogResult DR = MessageBox.Show("Bạn có chắc chắn xoá lớp này!", "Thông báo", MessageBoxButtons.YesNo);
                if (DialogResult.Yes == DR)
                {
                    QLHS_DTO hs = new QLHS_DTO();
                    hs.MaLop = txt_malop.Text;
                    QLHS_BUS bus = new QLHS_BUS();
                    bus.XoaLop(hs);
                    MessageBox.Show("Xoá thành công lớp " + txt_malop.Text + " !", "Thông báo");
                    LoadData();
                    txt_tenlop.DataBindings.Clear();
                    txt_tenlop.DataBindings.Add("Text", dtgv_themlop.DataSource, "TenLop");
                    txt_siso.DataBindings.Clear();
                    txt_siso.DataBindings.Add("Text", dtgv_themlop.DataSource, "SiSo");
                    txt_malop.DataBindings.Clear();
                    txt_malop.DataBindings.Add("Text", dtgv_themlop.DataSource, "MaLop");
                    cb_Khoi_LopHoc.DataBindings.Clear();
                    cb_Khoi_LopHoc.DataBindings.Add("Text", dtgv_themlop.DataSource, "MaKhoiLop");
                }
                else
                {
                    LoadData();
                }
            }

            catch (Exception ex)
            {
            }
        }
Exemplo n.º 9
0
        public int ThemHocKi(QLHS_DTO hs)
        {
            int       nRow     = 0;
            DBConnect provider = new DBConnect();

            try
            {
                string strSql = "INSERT INTO HOCKI(MaHocKi, TenHocKi) VALUES(@MaHocKi, @TenHocKi)";
                provider.Connect();
                nRow = provider.ExecuteNonQuery(CommandType.Text, strSql,
                                                new SqlParameter {
                    ParameterName = "@MaHocKi", Value = hs.MaHocKi
                },
                                                new SqlParameter {
                    ParameterName = "@TenHocKi", Value = hs.TenHocKi
                }

                                                );
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                provider.DisConnect();
            }
            return(nRow);
        }
Exemplo n.º 10
0
        public int ThemCTDSLOP(QLHS_DTO hs)
        {
            int       nRow     = 0;
            DBConnect provider = new DBConnect();

            try
            {
                string strSql = "INSERT INTO CHITIETDSLOP(MaChiTietDSLop, MaHocSinh) VALUES(@MaHocSinh, @MaHocSinh)";
                provider.Connect();
                nRow = provider.ExecuteNonQuery(CommandType.Text, strSql,
                                                new SqlParameter {
                    ParameterName = "@MaHocSinh", Value = hs.MaHocSinh
                }
                                                );
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                provider.DisConnect();
            }
            return(nRow);
        }
Exemplo n.º 11
0
        public int ThemLop(QLHS_DTO hs)
        {
            int       nRow     = 0;
            DBConnect provider = new DBConnect();

            try
            {
                string strSql = "INSERT INTO DANHSACHLOP(MaLop, TenLop, SiSo, MaKhoiLop) VALUES(@MaLop, @TenLop, @SiSo, @MaKhoiLop)";
                provider.Connect();
                nRow = provider.ExecuteNonQuery(CommandType.Text, strSql,
                                                new SqlParameter {
                    ParameterName = "@MaLop", Value = hs.MaLop
                },
                                                new SqlParameter {
                    ParameterName = "@TenLop", Value = hs.TenLop
                },
                                                new SqlParameter {
                    ParameterName = "@SiSo", Value = hs.SiSo
                },
                                                new SqlParameter {
                    ParameterName = "@MaKhoiLop", Value = hs.MaKhoiLop
                }

                                                );
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                provider.DisConnect();
            }
            return(nRow);
        }
Exemplo n.º 12
0
        public int ThemKhoiLop(QLHS_DTO hs)
        {
            int       nRow     = 0;
            DBConnect provider = new DBConnect();

            if (Check_MaKL(hs.MaKhoiLop) == true)
            {
                try
                {
                    string strSql = "INSERT INTO KHOILOP(MaKhoiLop, TenKhoiLop) VALUES(@MaKhoiLop, @TenKhoiLop)";
                    provider.Connect();
                    nRow = provider.ExecuteNonQuery(CommandType.Text, strSql,
                                                    new SqlParameter {
                        ParameterName = "@MaKhoiLop", Value = hs.MaKhoiLop
                    },
                                                    new SqlParameter {
                        ParameterName = "@TenKhoiLop", Value = hs.TenKhoiLop
                    }
                                                    );
                }
                catch (SqlException ex)
                {
                    throw ex;
                }
                finally
                {
                    provider.DisConnect();
                }
            }
            return(nRow);
        }
Exemplo n.º 13
0
        private void btn_luu_Click(object sender, EventArgs e)
        {
            try
            {
                if ((txt_diem15phut.Text != "") && (txt_diem1tiet.Text != "") && (txt_diemck.Text != "") && (txt_mahocsinh.Text != "") && (txt_tenhs.Text != ""))
                {
                    QLHS_DTO hs = new QLHS_DTO();

                    hs.MaHocSinh  = txt_mahocsinh.Text;
                    hs.MaMonHoc   = lb_mamonhoc.Text;
                    hs.Diem15phut = txt_diem15phut.Text;
                    hs.Diem1tiet  = txt_diem1tiet.Text;
                    hs.DiemCuoiKi = txt_diemck.Text;
                    QLHS_BUS bus = new QLHS_BUS();
                    bus.ThemBangDiem(hs);
                    MessageBox.Show("Thêm thành công bảng điểm cho học sinh " + txt_mahocsinh.Text + " !", "Thông báo");
                    LoadData();
                }
                else
                {
                    MessageBox.Show("Thêm không thành công! Mời bạn xem lại dữ liệu nhập! ", "Thông báo");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemplo n.º 14
0
 public void LoadData()
 {
     try
     {
         QLHS_BUS  bus  = new QLHS_BUS();
         DataTable dt   = bus.LayTatCaLop();
         DataTable dt_1 = bus.LayKhoiLop();
         dtgv_themlop.DataSource      = dt;
         cb_Khoi_LopHoc.DataSource    = dt_1;
         cb_Khoi_LopHoc.DisplayMember = "MaKhoiLop";
         cb_Khoi_LopHoc.ValueMember   = "MaKhoiLop ";
         if (dt.Rows.Count > 0)
         {
             dtgv_themlop.Rows[0].Selected = true;
             RowSelected           = new QLHS_DTO();
             RowSelected.MaLop     = dtgv_themlop.SelectedRows[0].Cells["MaLop"].Value.ToString();
             RowSelected.TenLop    = dtgv_themlop.SelectedRows[0].Cells["TenLop"].Value.ToString();
             RowSelected.SiSo      = dtgv_themlop.SelectedRows[0].Cells["SiSo"].Value.ToString();
             RowSelected.MaKhoiLop = dtgv_themlop.SelectedRows[0].Cells["MaKhoiLop"].Value.ToString();
         }
     }
     catch (Exception ex)
     {
     }
 }
Exemplo n.º 15
0
 public void LoadData()
 {
     try
     {
         QLHS_BUS  bus  = new QLHS_BUS();
         DataTable dt   = bus.LayTatCaBangDiem();
         DataTable dt_1 = bus.LayDSMonHoc();
         cb_tenmh.DataSource              = dt_1;
         cb_tenmh.DisplayMember           = "TenMonHoc";
         cb_tenmh.ValueMember             = "TenMonHoc";
         dtgv_danhsachbangdiem.DataSource = dt;
         if (dt.Rows.Count > 0)
         {
             dtgv_danhsachbangdiem.Rows[0].Selected = true;
             RowSelected            = new QLHS_DTO();
             RowSelected.MaBangDiem = dtgv_danhsachbangdiem.SelectedRows[0].Cells["MaBangDiem"].Value.ToString();
             RowSelected.MaHocSinh  = dtgv_danhsachbangdiem.SelectedRows[0].Cells["MaHocSinh"].Value.ToString();
             RowSelected.MaMonHoc   = dtgv_danhsachbangdiem.SelectedRows[0].Cells["MaMonHoc"].Value.ToString();
             RowSelected.Diem15phut = dtgv_danhsachbangdiem.SelectedRows[0].Cells["Diem15phut"].Value.ToString();
             RowSelected.Diem1tiet  = dtgv_danhsachbangdiem.SelectedRows[0].Cells["Diem1tiet"].Value.ToString();
             RowSelected.DiemCuoiKi = dtgv_danhsachbangdiem.SelectedRows[0].Cells["DiemCuoiKi"].Value.ToString();
         }
     }
     catch (Exception ex)
     {
     }
 }
Exemplo n.º 16
0
 public int ThemCTDSLOP(QLHS_DTO hs)
 {
     try
     {
         DAL_HOCSINH dal = new DAL_HOCSINH();
         return(dal.ThemCTDSLOP(hs));
     }
     catch (SqlException ex)
     {
         throw ex;
     }
 }
Exemplo n.º 17
0
 public int CapNhatHocKi(QLHS_DTO hs)
 {
     try
     {
         DAL_HOCSINH dal = new DAL_HOCSINH();
         return(dal.CapNhatHocKi(hs));
     }
     catch (SqlException ex)
     {
         throw ex;
     }
 }
Exemplo n.º 18
0
        private void btn_themhocki_Click(object sender, EventArgs e)
        {
            QLHS_DTO hs = new QLHS_DTO();

            hs.MaHocKi  = txt_mahocki.Text;
            hs.TenHocKi = txt_tenhocki.Text;
            QLHS_BUS bus = new QLHS_BUS();

            bus.ThemHocKi(hs);
            MessageBox.Show("Thêm thành công học kì " + txt_tenhocki.Text + " !", "Thông báo");
            LoadData();
        }
Exemplo n.º 19
0
 public int XoaHocKi(QLHS_DTO ma)
 {
     try
     {
         DAL_HOCSINH dal = new DAL_HOCSINH();
         return(dal.XoaHocKi(ma));
     }
     catch (SqlException ex)
     {
         throw ex;
     }
 }
Exemplo n.º 20
0
 public int ThemKhoiLop(QLHS_DTO hs)
 {
     try
     {
         DAL_HOCSINH dal = new DAL_HOCSINH();
         return(dal.ThemKhoiLop(hs));
     }
     catch (SqlException ex)
     {
         return(0);
     }
 }
Exemplo n.º 21
0
 private void btn_Luu_HS_Click(object sender, EventArgs e)
 {
     try
     {
         if ((txt_hovaten.Text != "") && (dt_ngaysinh.Value.ToString() != "") && (cb_gioitinh.Text != "") && (txt_diachi.Text != "") && (txt_email.Text != ""))
         {
             QLHS_DTO hs = new QLHS_DTO();
             hs.MaHocSinh = txt_mahocsinh.Text;
             hs.HoTen     = txt_hovaten.Text;
             hs.NgaySinh  = dt_ngaysinh.Value.ToString();
             hs.GioiTinh  = cb_gioitinh.Text;
             hs.DiaChi    = txt_diachi.Text;
             hs.Email     = txt_email.Text;
             QLHS_BUS bus = new QLHS_BUS();
             bus.CapNhatHocSinh(hs);
             MessageBox.Show("Cập nhật thành công học sinh " + txt_mahocsinh.Text + " !", "Thông báo");
             btn_capnhathocsinh.Visible = true;
             btn_ThemHS.Visible         = true;
             btn_Luu_HS.Visible         = false;
             txt_mahocsinh.Enabled      = true;
             txt_mahocsinh.Enabled      = false;
             txt_hovaten.Enabled        = false;
             txt_email.Enabled          = false;
             txt_diachi.Enabled         = false;
             cb_gioitinh.Enabled        = false;
             dt_ngaysinh.Enabled        = false;
             LoadData();
             txt_hovaten.DataBindings.Clear();
             txt_hovaten.DataBindings.Add("Text", dtgv_danhsachhocsinh.DataSource, "HoTen");
             txt_mahocsinh.DataBindings.Clear();
             txt_mahocsinh.DataBindings.Add("Text", dtgv_danhsachhocsinh.DataSource, "MaHocSinh");
             txt_email.DataBindings.Clear();
             txt_email.DataBindings.Add("Text", dtgv_danhsachhocsinh.DataSource, "Email");
             txt_diachi.DataBindings.Clear();
             txt_diachi.DataBindings.Add("Text", dtgv_danhsachhocsinh.DataSource, "DiaChi");
             cb_gioitinh.DataBindings.Clear();
             cb_gioitinh.DataBindings.Add("Text", dtgv_danhsachhocsinh.DataSource, "GioiTinh");
             dt_ngaysinh.DataBindings.Clear();
             dt_ngaysinh.DataBindings.Add("Text", dtgv_danhsachhocsinh.DataSource, "NgaySinh");
         }
         else
         {
             MessageBox.Show("Cập nhật không thành công! Mời bạn xem lại dữ liệu nhập! ", "Thông báo");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Exemplo n.º 22
0
 private void txt_mahocsinh_TextChanged(object sender, EventArgs e)
 {
     try
     {
         QLHS_BUS bus = new QLHS_BUS();
         QLHS_DTO hs  = new QLHS_DTO();
         hs.MaHocSinh = txt_mahocsinh.Text;
         DataTable dt = bus.TIMHSBANGMA(hs.MaHocSinh);
         txt_tenhs.Text = dt.Rows[0]["HoTen"].ToString();
     }
     catch (Exception ex)
     {
         txt_tenhs.Text = "";
     }
 }
Exemplo n.º 23
0
 private void txt_mahocsinh_TextChanged(object sender, EventArgs e)
 {
     try
     {
         QLHS_BUS bus = new QLHS_BUS();
         QLHS_DTO hs  = new QLHS_DTO();
         hs.MaHocSinh = txt_mahocsinh.Text;
         DataTable dt = bus.TIMHSBANGMA(hs.MaHocSinh);
         txt_tenhocsinh.Text      = dt.Rows[0]["HoTen"].ToString();
         dt_ngaysinh.Format       = DateTimePickerFormat.Custom;
         dt_ngaysinh.CustomFormat = "dd/MM/yyyy";
         dt_ngaysinh.Text         = dt.Rows[0]["NgaySinh"].ToString();
     }
     catch (Exception ex)
     {
     }
 }
Exemplo n.º 24
0
 private void btn_XacNhan_Click(object sender, EventArgs e)
 {
     btn_XacNhan.Visible = false;
     btn_them.Visible    = true;
     try
     {
         QLHS_BUS  bus = new QLHS_BUS();
         DataTable dt  = bus.ThamSo();
         string    t   = txt_siso.Text.ToString();
         if ((0 < Int32.Parse(t) && Int32.Parse(t) < Int32.Parse(dt.Rows[0]["SiSo"].ToString())))
         {
             QLHS_DTO hs = new QLHS_DTO();
             hs.MaLop     = txt_malop.Text;
             hs.TenLop    = txt_tenlop.Text;
             hs.SiSo      = txt_siso.Text;
             hs.MaKhoiLop = cb_Khoi_LopHoc.Text;
             bus.ThemLop(hs);
             MessageBox.Show("Thêm thành công lớp " + txt_malop.Text + " !", "Thông báo");
             LoadData();
             btn_capnhatlop.Enabled = true;
             btn_xoalop.Enabled     = true;
             btn_xeplop.Enabled     = true;
             txt_malop.Enabled      = false;
             txt_siso.Enabled       = false;
             txt_tenlop.Enabled     = false;
             cb_Khoi_LopHoc.Enabled = false;
             txt_tenlop.DataBindings.Clear();
             txt_tenlop.DataBindings.Add("Text", dtgv_themlop.DataSource, "TenLop");
             txt_siso.DataBindings.Clear();
             txt_siso.DataBindings.Add("Text", dtgv_themlop.DataSource, "SiSo");
             txt_malop.DataBindings.Clear();
             txt_malop.DataBindings.Add("Text", dtgv_themlop.DataSource, "MaLop");
             cb_Khoi_LopHoc.DataBindings.Clear();
             cb_Khoi_LopHoc.DataBindings.Add("Text", dtgv_themlop.DataSource, "MaKhoiLop");
         }
         else
         {
             MessageBox.Show("Sỉ số lớp sai quy định");
         }
     }
     catch
     {
         MessageBox.Show("Mời nhập lại đúng quy định!");
     }
 }
Exemplo n.º 25
0
 public void LoadData()
 {
     try
     {
         QLHS_BUS  bus = new QLHS_BUS();
         DataTable dt  = bus.LayTatCaKhoiLop();
         dtgv_khoilop.DataSource = dt;
         if (dt.Rows.Count > 0)
         {
             dtgv_khoilop.Rows[0].Selected = true;
             RowSelected            = new QLHS_DTO();
             RowSelected.MaKhoiLop  = dtgv_khoilop.SelectedRows[0].Cells["MaKhoiLop"].Value.ToString();
             RowSelected.TenKhoiLop = dtgv_khoilop.SelectedRows[0].Cells["TenKhoiLop"].Value.ToString();
         }
     }
     catch (Exception ex)
     {
     }
 }
Exemplo n.º 26
0
 public void LoadData()
 {
     try
     {
         QLHS_BUS  bus = new QLHS_BUS();
         DataTable dt  = bus.LayTatCaHocKi();
         dtgv_danhsachhocki.DataSource = dt;
         if (dt.Rows.Count > 0)
         {
             dtgv_danhsachhocki.Rows[0].Selected = true;
             RowSelected          = new QLHS_DTO();
             RowSelected.MaHocKi  = dtgv_danhsachhocki.SelectedRows[0].Cells["MaHocKi"].Value.ToString();
             RowSelected.TenHocKi = dtgv_danhsachhocki.SelectedRows[0].Cells["TenHocKi"].Value.ToString();
         }
     }
     catch (Exception ex)
     {
     }
 }
Exemplo n.º 27
0
 public void LoadData()
 {
     try
     {
         QLHS_BUS  bus = new QLHS_BUS();
         DataTable dt  = bus.LayTatCaMonHoc();
         dtgv_danhsachmonhoc.DataSource = dt;
         if (dt.Rows.Count > 0)
         {
             dtgv_danhsachmonhoc.Rows[0].Selected = true;
             RowSelected           = new QLHS_DTO();
             RowSelected.MaHocSinh = dtgv_danhsachmonhoc.SelectedRows[0].Cells["MaMonHoc"].Value.ToString();
             RowSelected.HoTen     = dtgv_danhsachmonhoc.SelectedRows[0].Cells["TenMonHoc"].Value.ToString();
         }
     }
     catch (Exception ex)
     {
     }
 }
Exemplo n.º 28
0
 private void btn_Luu_Lai_Click(object sender, EventArgs e)
 {
     try
     {
         if ((txt_malop.Text != "") && (txt_tenlop.Text != "") && (txt_siso.Text != "") && (cb_Khoi_LopHoc.Text != ""))
         {
             QLHS_DTO hs = new QLHS_DTO();
             hs.MaLop     = txt_malop.Text;
             hs.TenLop    = txt_tenlop.Text;
             hs.SiSo      = txt_siso.Text;
             hs.MaKhoiLop = cb_Khoi_LopHoc.Text;
             QLHS_BUS bus = new QLHS_BUS();
             bus.CapNhatLop(hs);
             MessageBox.Show("Cập nhật thành công lớp " + txt_malop.Text + " !", "Thông báo");
             LoadData();
             btn_capnhatlop.Visible = true;
             btn_Luu_Lai.Visible    = false;
             btn_them.Enabled       = true;
             btn_xoalop.Enabled     = true;
             btn_xeplop.Enabled     = true;
             txt_malop.Enabled      = false;
             txt_siso.Enabled       = false;
             txt_tenlop.Enabled     = false;
             cb_Khoi_LopHoc.Enabled = false;
             txt_tenlop.DataBindings.Clear();
             txt_tenlop.DataBindings.Add("Text", dtgv_themlop.DataSource, "TenLop");
             txt_siso.DataBindings.Clear();
             txt_siso.DataBindings.Add("Text", dtgv_themlop.DataSource, "SiSo");
             txt_malop.DataBindings.Clear();
             txt_malop.DataBindings.Add("Text", dtgv_themlop.DataSource, "MaLop");
             cb_Khoi_LopHoc.DataBindings.Clear();
             cb_Khoi_LopHoc.DataBindings.Add("Text", dtgv_themlop.DataSource, "MaKhoiLop");
         }
         else
         {
             MessageBox.Show("Cập nhật không thành công! Mời bạn xem lại dữ liệu nhập! ", "Thông báo");
         }
     }
     catch (Exception ex)
     {
     }
 }
Exemplo n.º 29
0
        public int ThemHocSinh(QLHS_DTO hs)
        {
            int       nRow     = 0;
            DBConnect provider = new DBConnect();

            try
            {
                string strSql = "INSERT INTO HOCSINH(MaHocSinh, HoTen, NgaySinh, GioiTinh, DiaChi, Email) VALUES(@MaHocSinh, @HoTen, @NgaySinh, @GioiTinh, @DiaChi, @Email)";
                provider.Connect();
                nRow = provider.ExecuteNonQuery(CommandType.Text, strSql,
                                                new SqlParameter {
                    ParameterName = "@MaHocSinh", Value = hs.MaHocSinh
                },
                                                new SqlParameter {
                    ParameterName = "@HoTen", Value = hs.HoTen
                },
                                                new SqlParameter {
                    ParameterName = "@NgaySinh", Value = hs.NgaySinh
                },
                                                new SqlParameter {
                    ParameterName = "@GioiTinh", Value = hs.GioiTinh
                },
                                                new SqlParameter {
                    ParameterName = "@DiaChi", Value = hs.DiaChi
                },
                                                new SqlParameter {
                    ParameterName = "@Email", Value = hs.Email
                }
                                                );
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                provider.DisConnect();
            }
            return(nRow);
        }
Exemplo n.º 30
0
        public int CapNhatHocSinh(QLHS_DTO hs)
        {
            int       nRow     = 0;
            DBConnect provider = new DBConnect();

            try
            {
                string strSql = "UPDATE HOCSINH SET HoTen = @HoTen, NgaySinh = @NgaySinh, GioiTinh = @GioiTinh, DiaChi = @DiaChi, Email = @Email WHERE MaHocSinh = @MaHocSinh";
                provider.Connect();
                nRow = provider.ExecuteNonQuery(CommandType.Text, strSql,
                                                new SqlParameter {
                    ParameterName = "@MaHocSinh", Value = hs.MaHocSinh
                },
                                                new SqlParameter {
                    ParameterName = "@HoTen", Value = hs.HoTen
                },
                                                new SqlParameter {
                    ParameterName = "@NgaySinh", Value = hs.NgaySinh
                },
                                                new SqlParameter {
                    ParameterName = "@GioiTinh", Value = hs.GioiTinh
                },
                                                new SqlParameter {
                    ParameterName = "@DiaChi", Value = hs.DiaChi
                },
                                                new SqlParameter {
                    ParameterName = "@Email", Value = hs.Email
                }
                                                );
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                provider.DisConnect();
            }
            return(nRow);
        }