Exemple #1
0
        public ActionResult Save(tblCatalog oCatalog)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    bool Add_Flg = new CommonBL().isNewEntry(oCatalog.Id);
                    if (Add_Flg)
                    {
                        new CatalogBL().Create(oCatalog);
                    }
                    else
                    {
                        new CatalogBL().Update(oCatalog);
                    }

                    //TempData["successmsg"] = CommonMsg.Success_Update(EntityNames.Company);
                    return(RedirectToAction("ManageCatalog", new { id = oCatalog.Id }));
                }
                catch (Exception ex)
                {
                    //TempData["errormsg"] = CommonMsg.Error();
                    return(RedirectToAction("Index"));
                }
            }
            else
            {
                //TempData["errormsg"] = CommonMsg.Error();
                return(RedirectToAction("Index"));
            }
        }
Exemple #2
0
 public ActionResult ThemCalg(tblCatalog cal)
 {
     if (ModelState.IsValid)
     {
         data.tblCatalogs.InsertOnSubmit(cal);
         data.SubmitChanges();
     }
     return(RedirectToAction("Catalog"));
 }
Exemple #3
0
        public ActionResult XNLuuCalg(string id)
        {
            tblCatalog cal = data.tblCatalogs.SingleOrDefault(n => n.id == id);

            if (ModelState.IsValid)
            {
                UpdateModel(cal);
                data.SubmitChanges();
            }
            return(RedirectToAction("Catalog"));
        }
Exemple #4
0
        public ActionResult EditCalg(string id)
        {
            tblCatalog cal = data.tblCatalogs.SingleOrDefault(n => n.id == id);

            if (cal == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            return(View(cal));
        }
Exemple #5
0
        public PartialViewResult ManageCatalog(int id)
        {
            tblCatalog catalog = new tblCatalog();

            if (id != 0)
            {
                catalog = new CatalogBL().GetById(id);
            }
            ViewBag.Types = new CatalogTypeBL().GetAllCatalogTypes();

            return(PartialView("_Manage", catalog));
        }
Exemple #6
0
        public ActionResult XNXoaC(string id)
        {
            tblCatalog cal = data.tblCatalogs.SingleOrDefault(n => n.id == id);

            if (cal == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            data.tblCatalogs.DeleteOnSubmit(cal);
            data.SubmitChanges();
            return(RedirectToAction("Catalog"));
        }
Exemple #7
0
 public void Create(tblCatalog oCatalog)
 {
     try
     {
         using (var ctx = new CRUDSampleEntities())
         {
             ctx.tblCatalogs.Add(oCatalog);
             ctx.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #8
0
 public void Update(tblCatalog oCatalog)
 {
     try
     {
         using (var ctx = new CRUDSampleEntities())
         {
             ctx.Entry(oCatalog).State = EntityState.Modified;
             ctx.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #9
0
 public void Delete(int id)
 {
     try
     {
         using (var ctx = new CRUDSampleEntities())
         {
             tblCatalog oCatalog = ctx.tblCatalogs.Where(c => c.Id == id).FirstOrDefault();
             ctx.tblCatalogs.Remove(oCatalog);
             ctx.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #10
0
 public JsonResult IsBarCodeUnique(tblCatalog catalog)
 {
     return(Json(!new CatalogBL().IsCatalogExist(catalog.CatalogName, catalog.Barcode)));
 }