Exemplo n.º 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"));
            }
        }
Exemplo n.º 2
0
 public ActionResult ThemCalg(tblCatalog cal)
 {
     if (ModelState.IsValid)
     {
         data.tblCatalogs.InsertOnSubmit(cal);
         data.SubmitChanges();
     }
     return(RedirectToAction("Catalog"));
 }
Exemplo n.º 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"));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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"));
        }
Exemplo n.º 7
0
 public void Create(tblCatalog oCatalog)
 {
     try
     {
         using (var ctx = new CRUDSampleEntities())
         {
             ctx.tblCatalogs.Add(oCatalog);
             ctx.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 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;
     }
 }
Exemplo n.º 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;
     }
 }
Exemplo n.º 10
0
 public JsonResult IsBarCodeUnique(tblCatalog catalog)
 {
     return(Json(!new CatalogBL().IsCatalogExist(catalog.CatalogName, catalog.Barcode)));
 }