예제 #1
0
 public ActionResult AddOrEdit(GarmentViewModel sm)
 {
     using (ELaundryDBEntities db = new ELaundryDBEntities())
     {
         if (sm.GarmentId == 0)
         {
             tblGarment tb = new tblGarment();
             tb.CategoryId  = sm.CategoryId;
             tb.GarmentName = sm.GarmentName;
             tb.UnitPrice   = sm.UnitPrice;
             db.tblGarments.Add(tb);
             db.SaveChanges();
             return(Json(new { success = true, message = "Saved Successfully" }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             tblGarment tbm = db.tblGarments.Where(m => m.GarmentId == sm.GarmentId).FirstOrDefault();
             tbm.CategoryId  = sm.CategoryId;
             tbm.GarmentName = sm.GarmentName;
             tbm.UnitPrice   = sm.UnitPrice;
             db.SaveChanges();
             return(Json(new { success = true, message = "Updated Successfully" }, JsonRequestBehavior.AllowGet));
         }
     }
 }
예제 #2
0
        public JsonResult HighestSalesGarment()
        {
            DateTime      dt         = Convert.ToDateTime(DateTime.Today);
            var           lstgarment = _db.GetTotalGarmentOrderCount();
            List <object> iData      = new List <object>();
            //Creating sample data
            DataTable dtt = new DataTable();

            dtt.Columns.Add("GarmentName", System.Type.GetType("System.String"));
            dtt.Columns.Add("TotalOrdered", System.Type.GetType("System.Int32"));
            foreach (var item in lstgarment)
            {
                DataRow    dr = dtt.NewRow();
                tblGarment tb = _db.tblGarments.Where(p => p.GarmentId == item.GarmentId).FirstOrDefault();

                dr["GarmentName"]  = tb.GarmentName;
                dr["TotalOrdered"] = item.TotalOrdered;
                dtt.Rows.Add(dr);
            }
            //Looping and extracting each DataColumn to List<Object>
            foreach (DataColumn dc in dtt.Columns)
            {
                List <object> x = new List <object>();
                x = (from DataRow drr in dtt.Rows select drr[dc.ColumnName]).ToList();
                iData.Add(x);
            }
            //Source data returned as JSON
            return(Json(iData, JsonRequestBehavior.AllowGet));
        }
예제 #3
0
 public ActionResult AdminRegProduct(tblGarment collection)
 {
     try
     {
         //Registro de imagen
         HttpPostedFileBase FileBase = Request.Files[0];
         WebImage           image    = new WebImage(FileBase.InputStream);
         string             idUser   = System.Web.HttpContext.Current.Session["id"].ToString();
         SqlParameter       param1   = new SqlParameter("@name", collection.gmtName);
         SqlParameter       param2   = new SqlParameter("@tipo", collection.gmtType);
         SqlParameter       param3   = new SqlParameter("@condicion", collection.gmtCondition);
         SqlParameter       param4   = new SqlParameter("@precio", collection.gmtPrice);
         SqlParameter       param5   = new SqlParameter("@user", idUser);
         SqlParameter       param6   = new SqlParameter("@img", collection.gmtImage = image.GetBytes());
         //Registro de producto
         var db = new DBPawnshopEntitiesConection();
         db.Database.ExecuteSqlCommand("setGarmet @name, @tipo, @condicion, @precio,@user,@img", param1, param2, param3, param4, param5, param6);
         TempData["Prueba"] = "SI";
         @ViewData["ID"]    = TempData["Prueba"];
         return(View());
     }
     catch (Exception e)
     {
         return(View(e.Message));
     }
 }
예제 #4
0
        public ActionResult ManageOrder(List <tblTempOrder> lst)
        {
            if (lst != null)
            {
                //List<tblTempOrder> neworder = new List<tblTempOrder>();
                List <TempOrderViewModel> neworder = new List <TempOrderViewModel>();
                foreach (var item in lst)
                {
                    TempOrderViewModel tb    = new TempOrderViewModel();
                    tblGarment         tbpro = _db.tblGarments.Where(p => p.GarmentId == item.GarmentId).FirstOrDefault();

                    tb.GarmentId   = item.GarmentId;
                    tb.GarmentName = tbpro.GarmentName;
                    tb.UnitPrice   = item.UnitPrice;
                    tb.Quantity    = item.Quantity;
                    tb.Total       = item.Total;
                    tb.TokenNo     = item.TokenNo;
                    tb.TW          = item.TW;
                    tb.BranchId    = Convert.ToInt32(Session["branchid"]);
                    tb.ItemState   = "Queued";
                    neworder.Add(tb);
                }
                TempData["mytemp"] = neworder;
                //List<tblTempOrder> temporder = TempData["mytemp"] as List<tblTempOrder>;
                return(Json(1, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(0, JsonRequestBehavior.AllowGet));
            }
        }
예제 #5
0
        public ActionResult UserRegSolicitud(tblGarment collection)
        {
            //Creación de sesión del producto
            var optionValue = Request.Form["Producto"];

            System.Web.HttpContext.Current.Session["idGar"] = optionValue;
            return(RedirectToAction("UserRegSolicitud2"));
        }
예제 #6
0
        public ActionResult AdminDeleteProduct(tblGarment collection)
        {
            //Selección del producto
            var optionValue = Request.Form["Producto"];

            System.Web.HttpContext.Current.Session["idGar"] = optionValue;
            return(RedirectToAction("AdminDeleteProduct2"));
        }
예제 #7
0
 public ActionResult Delete(int id)
 {
     using (ELaundryDBEntities db = new ELaundryDBEntities())
     {
         tblGarment sm = db.tblGarments.Where(x => x.GarmentId == id).FirstOrDefault();
         db.tblGarments.Remove(sm);
         db.SaveChanges();
         return(Json(new { success = true, message = "Deleted Successfully" }, JsonRequestBehavior.AllowGet));
     }
 }
예제 #8
0
        //Obtención de imagen de producto
        public ActionResult getImageGar(string id)
        {
            var        db  = new DBPawnshopEntitiesConection();
            tblGarment img = db.tblGarment.Find(id);

            byte[]       byteImage    = img.gmtImage;
            MemoryStream memoryStream = new MemoryStream(byteImage);

            System.Drawing.Image image = System.Drawing.Image.FromStream(memoryStream);
            memoryStream = new MemoryStream();
            image.Save(memoryStream, ImageFormat.Jpeg);
            memoryStream.Position = 0;
            return(File(memoryStream, "image/jpg"));
        }
예제 #9
0
        public JsonResult CheckGarment(string GarmentName)
        {
            bool       isexists = false;
            tblGarment tb       = db.tblGarments.Where(c => c.GarmentName == GarmentName).FirstOrDefault();

            if (tb != null)
            {
                isexists = true;
            }
            else
            {
                isexists = false;
            }
            return(Json(isexists, JsonRequestBehavior.AllowGet));
        }
예제 #10
0
        public ActionResult getImage()
        {
            //Obtención de imagen
            string     idProd = System.Web.HttpContext.Current.Session["idProduct"].ToString();
            var        db     = new DBPawnshopEntitiesConection();
            tblGarment img    = db.tblGarment.Find(idProd);

            byte[] byteImage = img.gmtImage;
            //Asignación a memoria
            MemoryStream memoryStream = new MemoryStream(byteImage);

            System.Drawing.Image image = System.Drawing.Image.FromStream(memoryStream);
            memoryStream = new MemoryStream();
            image.Save(memoryStream, ImageFormat.Jpeg);
            memoryStream.Position = 0;
            return(File(memoryStream, "image/jpg"));
        }
예제 #11
0
        public ActionResult AdminEditProduct2(tblGarment collection)
        {
            //Obtención de datos del formulario
            var                db       = new DBPawnshopEntitiesConection();
            tblGarment         _dbp     = new tblGarment();
            HttpPostedFileBase FileBase = Request.Files[0];
            string             idProd   = System.Web.HttpContext.Current.Session["idGar"].ToString();
            string             idUser   = System.Web.HttpContext.Current.Session["id"].ToString();

            //Validación de edición de imagen
            if (FileBase.ContentLength == 0)
            {
                //Edición de producto con misma imagen
                _dbp = db.tblGarment.Find(idProd);
                SqlParameter param1 = new SqlParameter("@id", idProd);
                SqlParameter param2 = new SqlParameter("@name", collection.gmtName);
                SqlParameter param3 = new SqlParameter("@tipo", collection.gmtType);
                SqlParameter param4 = new SqlParameter("@condicion", collection.gmtCondition);
                SqlParameter param5 = new SqlParameter("@precio", collection.gmtPrice);
                SqlParameter param6 = new SqlParameter("@user", idUser);
                SqlParameter param7 = new SqlParameter("@img", collection.gmtImage = _dbp.gmtImage);
                var          data   = db.Database.ExecuteSqlCommand("updateGarmetData @id, @name,@tipo,@condicion,@precio,@user,@img", param1, param2, param3, param4, param5, param6, param7);
                TempData["Prueba"] = "SI";
                @ViewData["ID"]    = TempData["Prueba"];
                return(View());
            }
            else
            {
                //Edición de producto con nueva imagen
                WebImage     image  = new WebImage(FileBase.InputStream);
                SqlParameter param1 = new SqlParameter("@id", idProd);
                SqlParameter param2 = new SqlParameter("@name", collection.gmtName);
                SqlParameter param3 = new SqlParameter("@tipo", collection.gmtType);
                SqlParameter param4 = new SqlParameter("@condicion", collection.gmtCondition);
                SqlParameter param5 = new SqlParameter("@precio", collection.gmtPrice);
                SqlParameter param6 = new SqlParameter("@user", idUser);
                SqlParameter param7 = new SqlParameter("@img", collection.gmtImage = image.GetBytes());
                var          data   = db.Database.ExecuteSqlCommand("updateGarmetData @id, @name,@tipo,@condicion,@precio,@user,@img", param1, param2, param3, param4, param5, param6, param7);
                TempData["Prueba"] = "SI";
                @ViewData["ID"]    = TempData["Prueba"];
                return(View());
            }
        }