Exemplo n.º 1
0
 public bool Insert(HOADONDV item)
 {
     try
     {
         using (var db = new QLPhongKaraokeEntities())
         {
             db.HOADONDVs.Add(item);
             db.SaveChanges();
         }
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Exemplo n.º 2
0
        public bool Begin(int id, DateTime tgbatdau, string tenkh)
        {
            try
            {
                using (var db = new QLPhongKaraokeEntities())
                {
                    var x = from s in db.PHONGs
                            where s.ID == id && s.Deleted == 0
                            select s;
                    var sv = x.FirstOrDefault();
                    if (sv != null)
                    {
                        if (sv.StatusID != 1)
                        {
                            return(false);
                        }
                        sv.StatusID = 3; //busy
                        sv.TGStart  = tgbatdau;
                        db.SaveChanges();

                        //bat dau thi tao hoa don dv
                        var item = new HOADONDV()
                        {
                            ID_Phong   = id,
                            NgayGioLap = tgbatdau,
                            SoGio      = 0,
                            TenKH      = tenkh ?? "",
                            TongTien   = 0
                        };
                        db.HOADONDVs.Add(item);
                        db.SaveChanges();
                    }
                }
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Exemplo n.º 3
0
 public bool Update(HOADONDV item)
 {
     try
     {
         using (var db = new QLPhongKaraokeEntities())
         {
             var x = from s in db.HOADONDVs
                     where s.ID == item.ID && s.Deleted == 0
                     select s;
             var sv = x.FirstOrDefault();
             if (sv != null)
             {
                 sv.TenKH    = item.TenKH;
                 sv.ID_Phong = item.ID_Phong;
                 db.SaveChanges();
             }
         }
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }