示例#1
0
        /// <summary>
        /// Update negocioe Information
        /// </summary>
        /// <param name="Emp"></param>
        /// <returns></returns>
        public string UpdateNegocio(negocios Neg)
        {
            var    file = Request.Files[0];
            string fileName;

            if (Neg != null)
            {
                fileName = Guid.NewGuid() + Path.GetExtension(file.FileName);
                file.SaveAs(Path.Combine(Server.MapPath("~/imagenesProductos"), fileName));
                using (appUEntities1 Obj = new appUEntities1())
                {
                    var      Neg_   = Obj.Entry(Neg);
                    negocios negObj = Obj.negocios.Where(x => x.idNegocio == Neg.idNegocio).FirstOrDefault();
                    negObj.nombre              = Neg.nombre;
                    negObj.calle               = Neg.calle;
                    negObj.numero              = Neg.numero;
                    negObj.colonia             = Neg.colonia;
                    negObj.ciudad              = Neg.ciudad;
                    negObj.imgNegocio          = fileName;
                    negObj.permitePagosTarjeta = Neg.permitePagosTarjeta;
                    negObj.precioEnvio         = Neg.precioEnvio;
                    negObj.descripcion         = Neg.descripcion;
                    negObj.correo              = Neg.correo;
                    negObj.codigoPostal        = Neg.codigoPostal;
                    Obj.SaveChanges();
                    return("negocio Updated Successfully");
                }
            }
            else
            {
                return("negocio Not Updated! Try Again");
            }
        }
示例#2
0
        public JsonResult NegocioActual()
        {
            appUEntities1 db    = new appUEntities1();
            bool          proxy = db.Configuration.ProxyCreationEnabled;
            //cookie usuarioLogueado
            int idUsuario = Convert.ToInt32(Request.Cookies["LoginID"].Value);

            try
            {
                db.Configuration.ProxyCreationEnabled = false;
                negocios negocio = db.negocios.Where(x => x.fkUsuario == idUsuario).First();

                //creamos cookie idNegocio
                if (Session["negocioId"] == null)
                {
                    Session["negocioId"] = negocio.idNegocio;
                }

                return(Json(negocio, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                return(Json(e.Message));
            }
            finally
            {
                db.Configuration.ProxyCreationEnabled = proxy;
            }
        }
示例#3
0
        /// <summary>
        /// Insert New negocioe
        /// </summary>
        /// <param name="negocio"></param>
        /// <returns></returns>
        public string InsertNegocio(negocios negocio)
        {
            var    file = Request.Files[0];
            string fileName;

            if (negocio != null)
            {
                //cookie usuarioLogueado
                int idUsuario = Convert.ToInt32(Request.Cookies["LoginID"].Value);
                fileName = Guid.NewGuid() + Path.GetExtension(file.FileName);
                file.SaveAs(Path.Combine(Server.MapPath("~/imagenesProductos"), fileName));
                using (appUEntities1 Obj = new appUEntities1())
                {
                    negocio.imgNegocio = fileName;
                    negocio.fkUsuario  = idUsuario;
                    negocio.activo     = true;
                    Obj.negocios.Add(negocio);
                    Obj.SaveChanges();

                    //creamos cookie idNegocio
                    if (Session["negocioId"] == null)
                    {
                        Session["negocioId"] = negocio.idNegocio;
                    }

                    return("negocioe Added Successfully");
                }
            }
            else
            {
                return("negocioe Not Inserted! Try Again");
            }
        }
示例#4
0
        // GET: Prod
        public ActionResult GetData(negocios neg)
        {
            db.Configuration.ProxyCreationEnabled = false;
            int idNegocio = neg.idNegocio;

            try
            {
                if (idNegocio != 0)
                {
                    Session.Remove("neg");
                    //creamos cookie negocio
                    Session["neg"] = idNegocio;
                    return(new RedirectResult(@"~\Prod\Index\"));
                }
                else
                {
                    return(new RedirectResult(@"~\Home\Index\"));
                }
                //return View();
            }
            catch (Exception e)
            {
                return(View(e));
            }
        }
示例#5
0
        public ActionResult DeleteConfirmed(int id)
        {
            negocios negocios = db.negocios.Find(id);

            db.negocios.Remove(negocios);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#6
0
 public ActionResult Edit([Bind(Include = "id_negocio,nombre,descripcion,distancia,ruta")] negocios negocios)
 {
     if (ModelState.IsValid)
     {
         db.Entry(negocios).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(negocios));
 }
示例#7
0
        public ActionResult Create([Bind(Include = "id_negocio,nombre,descripcion,distancia,ruta")] negocios negocios)
        {
            if (ModelState.IsValid)
            {
                db.negocios.Add(negocios);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(negocios));
        }
示例#8
0
        // GET: Negocios/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            negocios negocios = db.negocios.Find(id);

            if (negocios == null)
            {
                return(HttpNotFound());
            }
            return(View(negocios));
        }
示例#9
0
 /// <summary>
 /// Delete negocioe Information
 /// </summary>
 /// <param name="Neg"></param>
 /// <returns></returns>
 public string Delete_negocio(negocios Neg)
 {
     if (Neg != null)
     {
         var Neg_ = db.Entry(Neg);
         if (Neg_.State == System.Data.Entity.EntityState.Detached)
         {
             db.negocios.Attach(Neg);
             db.negocios.Remove(Neg);
         }
         db.SaveChanges();
         return("negocioe Deleted Successfully");
     }
     else
     {
         return("negocioe Not Deleted! Try Again");
     }
 }
示例#10
0
 /// <summary>
 /// Update negocioe Information
 /// </summary>
 /// <param name="Emp"></param>
 /// <returns></returns>
 public string Update_negocio(negocios Neg)
 {
     if (Neg != null)
     {
         var      Neg_   = db.Entry(Neg);
         negocios negObj = db.negocios.Where(x => x.idNegocio == Neg.idNegocio).FirstOrDefault();
         negObj.nombre  = Neg.nombre;
         negObj.calle   = Neg.calle;
         negObj.numero  = Neg.numero;
         negObj.colonia = Neg.colonia;
         negObj.ciudad  = Neg.ciudad;
         db.SaveChanges();
         return("negocioe Updated Successfully");
     }
     else
     {
         return("negocioe Not Updated! Try Again");
     }
 }
示例#11
0
 /// <summary>
 /// Delete negocioe Information
 /// </summary>
 /// <param name="Neg"></param>
 /// <returns></returns>
 public string Delete_negocio(negocios Neg)
 {
     if (Neg != null)
     {
         using (appUEntities1 Obj = new appUEntities1())
         {
             var Neg_ = Obj.Entry(Neg);
             if (Neg_.State == System.Data.Entity.EntityState.Detached)
             {
                 Obj.negocios.Attach(Neg);
                 Obj.negocios.Remove(Neg);
             }
             Obj.SaveChanges();
             return("negocioe Deleted Successfully");
         }
     }
     else
     {
         return("negocioe Not Deleted! Try Again");
     }
 }
示例#12
0
        public JsonResult TraerPedido(string idV)
        {
            bool proxy = Obj.Configuration.ProxyCreationEnabled;

            try
            {
                Obj.Configuration.ProxyCreationEnabled = false;
                int idVenta = Convert.ToInt32(idV);

                //int venta = db.ventas.Where(x => x.fkUsuarioPedido == 1 && x.estatus == 0).FirstOrDefault().idventa;
                List <detalleVenta> dv = Obj.detalleVenta.Where(x => x.fkVenta == idVenta).ToList();

                ventas           venta         = Obj.ventas.Where(x => x.idventa == idVenta).FirstOrDefault();
                List <productos> productosDv   = new List <productos>();
                List <productos> ListProductos = Obj.productos.Where(x => x.fkNegocio == venta.fkNegocio && x.activo).ToList();
                foreach (detalleVenta detalle in dv)
                {
                    productos producto = ListProductos.Where(x => x.idProducto == detalle.fkProducto).FirstOrDefault();
                    if (producto != null)
                    {
                        productosDv.Add(producto);
                    }
                }

                negocios negocio = Obj.negocios.Where(x => x.idNegocio == venta.fkNegocio).FirstOrDefault();

                //falta traer los productos ligados al detalle venta
                var result = new { prod = productosDv, negocio = negocio, dv = dv, venta = venta };

                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                return(Json(e.Message));
            }
            finally
            {
                Obj.Configuration.ProxyCreationEnabled = proxy;
            }
        }
示例#13
0
        public JsonResult traerNegocioById(string idNegocio)
        {
            bool proxy = db.Configuration.ProxyCreationEnabled;

            try
            {
                db.Configuration.ProxyCreationEnabled = false;

                int      idN     = Convert.ToInt32(idNegocio);
                negocios negocio = db.negocios.Where(x => x.idNegocio == idN).FirstOrDefault();

                return(Json(negocio, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                return(Json(e.Message));
            }
            finally
            {
                db.Configuration.ProxyCreationEnabled = proxy;
            }
        }
示例#14
0
        public JsonResult traerNegocio()
        {
            bool proxy = db.Configuration.ProxyCreationEnabled;

            try
            {
                db.Configuration.ProxyCreationEnabled = false;
                var myCookieven = Request.Cookies["IdVenta"].Value;
                int idVenta     = Convert.ToInt32(myCookieven);

                int      idNegocio = db.ventas.Where(x => x.idventa == idVenta).FirstOrDefault().fkNegocio;
                negocios negocio   = db.negocios.Where(x => x.idNegocio == idNegocio).FirstOrDefault();

                return(Json(negocio, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                return(Json(e.Message));
            }
            finally
            {
                db.Configuration.ProxyCreationEnabled = proxy;
            }
        }
示例#15
0
        public Negocios()
        {
            InitializeComponent();

            BindingContext = viewModel = new negocios();  //NegociosViewModel
        }