Ejemplo n.º 1
0
 public ActionResult AddOrEdit(Registro reg)
 {
     try
     {
         if (reg.CargarImagen != null)
         {
             string fileName  = Path.GetFileNameWithoutExtension(reg.CargarImagen.FileName);
             string extension = Path.GetExtension(reg.CargarImagen.FileName);
             fileName = fileName + DateTime.Now.ToString("yymmssfff") + extension;
             reg.Foto = "~/AppFiles/Imagenes/" + fileName;
             reg.CargarImagen.SaveAs(Path.Combine(Server.MapPath("~/AppFiles/Imagenes/"), fileName));
         }
         using (DBModel3 db = new DBModel3())
         {
             if (reg.Id == 0)
             {
                 db.Registroes.Add(reg);
                 db.SaveChanges();
             }
             else
             {
                 db.Entry(reg).State = EntityState.Modified;
                 db.SaveChanges();
             }
         }
         return(Json(new { success = true, html = GlobalClass.RenderRazorViewToString(this, "ViewAll", GetAllRegistro()), message = "Datos enviados con exito" }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(new { success = false, message = ex.Message }, JsonRequestBehavior.AllowGet));
     }
 }
        public ActionResult Create([Bind(Include = "SupplyId,SupplierName,ItemName,UnitPrice,NoOfUnits,TotalPrice,Date")] SupplyDetail supplyDetail)
        {
            if (ModelState.IsValid)
            {
                db.SupplyDetails.Add(supplyDetail);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(supplyDetail));
        }
        public ActionResult Create([Bind(Include = "outgoingId,employeeSalary,supplierCost,purchaseFood,tax,utilityBills,transportCost")] Outgoing outgoing)
        {
            if (ModelState.IsValid)
            {
                db.Outgoings.Add(outgoing);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(outgoing));
        }
Ejemplo n.º 4
0
        public ActionResult Create([Bind(Include = "deliveryId,CustomerName,DeliveryPerson,Amount,DeliveryAddress,ProductName")] Delivery delivery)
        {
            if (ModelState.IsValid)
            {
                db.Deliveries.Add(delivery);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(delivery));
        }
        public ActionResult Create([Bind(Include = "incomeId,soldFoodItems")] Income income)
        {
            if (ModelState.IsValid)
            {
                db.Incomes.Add(income);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(income));
        }
Ejemplo n.º 6
0
        public ActionResult Create([Bind(Include = "SupplierId,SupplierName,SupplierEmail,SupplierPhone")] SupplierDetail supplierDetail)
        {
            if (ModelState.IsValid)
            {
                db.SupplierDetails.Add(supplierDetail);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(supplierDetail));
        }
Ejemplo n.º 7
0
        public ActionResult Create([Bind(Include = "MenuId,Name,Ingredients,Date,Note,Price,Description")] Menu menu)
        {
            if (ModelState.IsValid)
            {
                db.Menus.Add(menu);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(menu));
        }
Ejemplo n.º 8
0
        public ActionResult Create([Bind(Include = "CustomerId,FirstName,LastName,Age,Gender,Address,Email,ContactNo")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                db.Customers.Add(customer);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(customer));
        }
        public ActionResult Create([Bind(Include = "ItemCode,ItemName,Type,Condition,Quantity,ExpireDate,UnitPrice,SupplierName")] Stock stock)
        {
            if (ModelState.IsValid)
            {
                db.Stocks.Add(stock);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(stock));
        }
Ejemplo n.º 10
0
 public ActionResult Delete(int id)
 {
     try
     {
         using (DBModel3 db = new DBModel3())
         {
             Registro reg = db.Registroes.Where(x => x.Id == id).FirstOrDefault <Registro>();
             db.Registroes.Remove(reg);
             db.SaveChanges();
         }
         return(Json(new { success = true, html = GlobalClass.RenderRazorViewToString(this, "ViewAll", GetAllRegistro()), message = "Registro eliminado con exito." }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(new { success = false, message = ex.Message }, JsonRequestBehavior.AllowGet));
     }
 }