Example #1
0
 public bool Insert(string MSSV, string MaNV, string Khu, string MaPhong, string HocKi, string NamHoc,
                    DateTime NgayGioDK, int ThoiHan, DateTime NgayBD, ref int identity, ref string error)
 {
     try
     {
         PHIEUDK pdk = new PHIEUDK()
         {
             MSSV      = MSSV,
             MaNV      = MaNV,
             Khu       = Khu,
             MaPhong   = MaPhong,
             HocKi     = HocKi,
             NamHoc    = NamHoc,
             NgayGioDK = NgayGioDK,
             ThoiHan   = (byte)ThoiHan,
             NgayBD    = NgayBD,
         };
         entities.PHIEUDKs.Add(pdk);
         entities.SaveChanges();
         error    = "";
         identity = pdk.MaPDK;
         return(true);
     }
     catch (Exception ex)
     {
         error = ex.Message;
         return(false);
     }
 }
Example #2
0
 private bool Delete_PhieuDK(string MaPDK, ref string error)
 {
     try
     {
         int     pdk     = Convert.ToInt32(MaPDK);
         PHIEUDK PhieuDK = new PHIEUDK()
         {
             MaPDK = pdk
         };
         entities.PHIEUDKs.Attach(PhieuDK);
         entities.PHIEUDKs.Remove(PhieuDK);
         entities.SaveChanges();
         error = "";
         return(true);
     }
     catch (Exception ex)
     {
         error = ex.Message;
         return(false);
     }
 }