public static bool delete(CongNoDaiLy congno)
 {
     try
     {
         using (EntitiesDataContext db = new EntitiesDataContext())
         {
             CONGNODAILY cn;
             cn = (from d in db.CONGNODAILies
                   where d.masodaily.Equals(congno.MaSoDaiLy) &&
                   d.masosach.Equals(congno.MaSoSach) &&
                   d.thang.Month.Equals(congno.Thang.Month) &&
                   d.thang.Year.Equals(congno.Thang.Year)
                   select d).SingleOrDefault();
             if (cn == null)
             {
                 return(false);            //Nếu đại lý không tồn tại
             }
             db.CONGNODAILies.DeleteOnSubmit(cn);
             db.SubmitChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         return(false);
     }
 }
        public JsonResult GetPropertiesChiTietNo(string request)
        {
            List <string> results = new List <string>();

            foreach (string pro in CongNoDaiLy.searchKeys())
            {
                results.Add(request + pro);
            }
            return(Json(results, JsonRequestBehavior.AllowGet));
        }
 public static int add(CongNoDaiLy congno)
 {
     try
     {
         using (EntitiesDataContext db = new EntitiesDataContext())
         {
             CONGNODAILY cn;
             cn = (from c in db.CONGNODAILies
                   where c.masodaily.Equals(congno.MaSoDaiLy) &&
                   c.masosach.Equals(congno.MaSoSach) &&
                   c.thang.Month.Equals(congno.Thang.Month) &&
                   c.thang.Year.Equals(congno.Thang.Year)
                   select c).SingleOrDefault();
             if (cn != null)
             {
                 cn.soluong += congno.SoLuong;
                 db.SubmitChanges();
                 return(1);
             }
             else
             {
                 cn           = new CONGNODAILY();
                 cn.masodaily = congno.MaSoDaiLy;
                 cn.masosach  = congno.MaSoSach;
                 cn.soluong   = congno.SoLuong;
                 cn.dongia    = congno.DonGia;
                 cn.thang     = congno.Thang;
                 db.CONGNODAILies.InsertOnSubmit(cn);
                 db.SubmitChanges();
                 return(1);
             }
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         return(0);
     }
 }