Пример #1
0
 public static bool CapNhat(DocGia dg)
 {
     try
     {
         DocGia docGia = DocGia.GetDocGiaTheoID(dg.IDDocGia);
         if (docGia != null)
         {
             string query  = @"Update DocGia Set MaDocGia = @madocgia ,
                 HoTen = @hoten ,
                 NgaySinh = @ngaysinh ,
                 IDLop = @idlop ,
                 DiaChi = @diachi ,
                 DienThoai = @dienthoai ,
                 Email = @email ,
                 NgayLapThe = @ngaylapthe ,
                 Lock = @lock Where IDDocGia = @idDocGia ";
             int    result = DataProvider.ExecuteNonQuery(query, new object[] { dg.MaDocGia, dg.HoTen, dg.NgaySinh, dg.IDLop, dg.DiaChi, dg.DienThoai, dg.Email, dg.NgayLapThe, dg.Lock, dg.IDDocGia });
             if (result == 1)
             {
                 return(true);
             }
         }
         return(false);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         return(false);
     }
 }
Пример #2
0
 public static List <DocGia> GetDSDocGia()
 {
     try
     {
         string        query = "Select * from DocGia";
         DataTable     dt    = DataProvider.ExecuteQuery(query);
         List <DocGia> list  = new List <DocGia>();
         foreach (DataRow dr in dt.Rows)
         {
             DocGia dg = new DocGia();
             dg.IDDocGia   = Convert.ToInt32(dr["IDDocGia"]);
             dg.IDLop      = Convert.ToInt32(dr["IDLop"]);
             dg.MaDocGia   = dr["MaDocGia"].ToString();
             dg.HoTen      = dr["HoTen"].ToString();
             dg.DiaChi     = dr["DiaChi"].ToString();
             dg.DienThoai  = dr["DienThoai"].ToString();
             dg.Email      = dr["Email"].ToString();
             dg.NgaySinh   = Convert.ToDateTime(dr["NgaySinh"]);
             dg.NgayLapThe = Convert.ToDateTime(dr["NgayLapThe"]);
             dg.Lock       = Convert.ToBoolean(dr["Lock"]);
             list.Add(dg);
         }
         return(list);
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #3
0
 public static bool TaoMoi(DocGia dg)
 {
     try
     {
         string queryCheckExist = string.Format("Select * from DocGia where MaDocGia = N'{0}'", dg.MaDocGia);
         if (DataProvider.ExecuteQuery(queryCheckExist).Rows.Count > 0)
         {
             throw new Exception("Mã độc giả đã tồn tại!!!");
         }
         else
         {
             string query  = @"Insert into DocGia (MaDocGia,HoTen,NgaySinh,IDLop,DiaChi,DienThoai,Email,NgayLapThe,Lock) 
                             Values ( @madocgia , @hoten , @ngaySinh , @idLop , @diachi , @dienthoai , @email , @ngaylapthe , @lock )";
             int    result = DataProvider.ExecuteNonQuery(query, new object[] { dg.MaDocGia, dg.HoTen, dg.NgaySinh, dg.IDLop, dg.DiaChi, dg.DienThoai, dg.Email, dg.NgayLapThe, dg.Lock });
             if (result == 1)
             {
                 return(true);
             }
         }
         return(false);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         return(false);
     }
 }
Пример #4
0
 public static DocGia GetDocGiaTheoID(int id)
 {
     try
     {
         string    query = string.Format("Select * from DocGia where IDDocGia = {0}", id);
         DataTable dt    = DataProvider.ExecuteQuery(query);
         if (dt.Rows.Count > 0)
         {
             DataRow dr     = dt.Rows[0];
             DocGia  docGia = new DocGia();
             docGia.MaDocGia  = dr["MaDocGia"].ToString();
             docGia.HoTen     = dr["HoTen"].ToString();
             docGia.NgaySinh  = Convert.ToDateTime(dr["NgaySinh"]);
             docGia.IDLop     = Convert.ToInt32(dr["IDLop"]);
             docGia.DiaChi    = dr["DiaChi"].ToString();
             docGia.DienThoai = dr["DienThoai"].ToString();
             docGia.Email     = dr["Email"].ToString();
             docGia.NgaySinh  = Convert.ToDateTime(dr["NgaySinh"]);
             docGia.Lock      = string.IsNullOrEmpty(dr["Lock"].ToString()) ? false : Convert.ToBoolean(dr["Lock"]);
             return(docGia);
         }
         else
         {
             return(null);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         return(null);
     }
 }