Example #1
0
        public List <DTO_HocSinh> load_GV()
        {
            string query = "select * from HocSinh";

            conn.Open();
            DataTable data = base.GetDataTable(query);

            if (data.Rows.Count == 0)
            {
                return(null);
            }
            List <DTO_HocSinh> listGV = new List <DTO_HocSinh>();

            for (int i = 0; i < data.Rows.Count; i++)
            {
                DTO_HocSinh gv = new DTO_HocSinh();
                gv.MaHocSinh = data.Rows[i]["Ma_GiaoVien"].ToString();
                gv.HoTen     = data.Rows[i]["HoTen"].ToString();
                gv.GioiTinh  = data.Rows[i]["GioiTinh"].ToString();
                gv.NgaySinh  = DateTime.Parse(data.Rows[i]["NgaySinh"].ToString());
                gv.Email     = data.Rows[i]["Email"].ToString();
                gv.Lop       = data.Rows[i]["Lop"].ToString();

                listGV.Add(gv);
            }
            conn.Close();
            return(listGV);
        }
Example #2
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            DTO_HocSinh gv = new DTO_HocSinh();

            gv.MaHocSinh = txtMa.Text;
            gv.HoTen     = txtHoten.Text;

            gv.NgaySinh = DateTime.Parse(dateTimePicker1.Text);

            gv.Email    = txtEmail.Text;
            gv.Lop      = txtLop.Text;
            gv.GioiTinh = txtGioiTinh.Text;


            if (gv.MaHocSinh != "" && gv.HoTen != "" && gv.Email != "" && gv.GioiTinh != "")
            {
                if (bus.Them(gv) == true)
                {
                    MessageBox.Show("thêm thành công", "thông báo");
                    loadHocSinh();
                }
                else
                {
                    MessageBox.Show("thêm thất bại", "thông báo");
                }
            }
            else
            {
                MessageBox.Show("thêm thất bại", "thông báo");
            }
        }
Example #3
0
        public bool Them(DTO_HocSinh gv)
        {
            string query = "INSERT INTO dbo.HocSinh ( MaHocSinh , TenHocSinh ,NgaySinh ,GioiTinh , Email ,Lop ) VALUES  ( '" + gv.MaHocSinh + "' , N'" + gv.HoTen + "' , '" + gv.NgaySinh + "',N'" + gv.GioiTinh + "' , '" + gv.Email + "' ,  '" + gv.Lop + "'  )";

            conn.Open();
            try
            {
                base.executeQuery(query);
                conn.Close();
                return(true);
            }
            catch (Exception ex)
            {
                conn.Close();
                return(false);
            }
        }
Example #4
0
        public bool SuaThongTin(DTO_HocSinh a)
        {
            conn.Open();
            string SQL = "UPDATE dbo.HocSinh SET MaHocSinh='" + a.MaHocSinh + "',HoTen=N'" + a.HoTen + "',NgaySinh='" + a.NgaySinh.ToString() + "',GioiTinh=N'" + a.GioiTinh + "',Email='" + a.Email + "',Lop='" + a.Lop + "')";

            try
            {
                SqlCommand cmd = new SqlCommand(SQL, conn);

                // Query và kiểm tra
                cmd.ExecuteNonQuery();
                conn.Close();
                return(true);
            }
            catch (Exception ex)
            {
                conn.Close();
                return(false);
            }
        }
Example #5
0
        private void btnSua_Click(object sender, EventArgs e)
        {
            DTO_HocSinh gv = new DTO_HocSinh();

            gv.MaHocSinh = txtMa.Text;
            gv.HoTen     = txtHoten.Text;

            gv.NgaySinh = DateTime.Parse(dateTimePicker1.Text);

            gv.Email    = txtEmail.Text;
            gv.Lop      = txtLop.Text;
            gv.GioiTinh = txtGioiTinh.Text;
            if (bus.sua(gv))
            {
                MessageBox.Show("Thay đổi thông tin giáo viên thành công", "Thông báo");
            }
            else
            {
                MessageBox.Show("Thay đổi thông tin giáo viên That bai", "Thông báo");
            }
            loadHocSinh();
        }
Example #6
0
 public bool sua(DTO_HocSinh a)
 {
     return(dAL.SuaThongTin(a));
 }
Example #7
0
 public bool Them(DTO_HocSinh hs)
 {
     return(dAL.Them(hs));
 }