Exemple #1
0
 public void CopyList(BIZListaPrecio ListaPrecionueva, double factor)
 {
     try
     {
         ListaPrecio ListaT = new ListaPrecio();
         ListaT.Activo = ListaPrecionueva.Activo;
         ListaT.Detalle = ListaPrecionueva.Detalle;
         ListaT.FechaDesde = ListaPrecionueva.FechaDesde;
         ListaT.FechaUltimaMod = DateTime.Now;
         PrecioDetalle pd;
         var ListaACopiar = db.ListaPrecio.SingleOrDefault(x => x.IDListaPrecio == ListaPrecionueva.IDListaPrecio);
         foreach (var d in ListaACopiar.PrecioDetalle)
         {
             if ((bool)d.Activo)
             {
                 pd = new PrecioDetalle();
                 pd.FechaAlta = DateTime.Now;
                 pd.ListaPrecio = null;
                 pd.Producto = null;
                 pd.DocumentoDetalle = null;
                 pd.IDPrecioDetalle = d.IDPrecioDetalle;
                 pd.IDProducto = d.IDProducto;
                 pd.Precio = d.Precio * factor;
                 pd.Activo = true;
                 pd.FechaUltimaMod = DateTime.Now;
                 ListaT.PrecioDetalle.Add(pd);
             }
         }
         db.ListaPrecio.Add(ListaT);
         db.SaveChanges();
     }
     catch (Exception ex) { }
 }
        public ActionResult CopiarLista(string IDLista, string CopiaText, string CopiaFactor,string FechaDesde)
        {
            try
            {
                BIZ.BIZListaPrecio ListaACopiar = new BIZListaPrecio();
                ListaACopiar.IDListaPrecio = Convert.ToInt32(IDLista); //esto lo pongo acá aunq sea la lista a copiar
                ListaACopiar.Activo = false;
                ListaACopiar.Detalle = CopiaText;
                double factor = Convert.ToDouble(CopiaFactor);
                ListaACopiar.FechaDesde = Convert.ToDateTime(FechaDesde);
                precioWorker.copiarLista(ListaACopiar, factor);
                try
                {
                    Bita.guardarBitacora(new BIZBitacora("Informativo", "Se ha copiado la lista de precios: " + IDLista + " a una llamada: "+ CopiaText, (int)Session["userID"], Session["_ip"].ToString()));
                }
                catch (Exception ex) { }
                return Json(new { Result = ""}, JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex2)
            {
                Nullable<int> idUser = null;
                string ip = "Unknown";
                try
                {
                    idUser = (int)Session["userID"];
                }
                catch (Exception ex) { }
                try
                {
                    ip = Session["_ip"].ToString();
                }
                catch (Exception ex) { }
                try
                {
                    Bita.guardarBitacora(new BIZBitacora("Error", "Error al intentar copiar lista de precios", idUser, ip));
                }
                catch (Exception ex) { }

                return Json(new { Result = "error" }, JsonRequestBehavior.AllowGet);
            }
        }
        public ActionResult Create(BIZListaPrecio ListaPrecio)
        {
            try
            {
                ListaPrecio.FechaUltimaMod = DateTime.Now;
                precioWorker.CreateListaPrecio(ListaPrecio);
                try
                {
                    Bita.guardarBitacora(new BIZBitacora("Informativo", "Se ha creado la lista de precios: " + ListaPrecio.Detalle, (int)Session["userID"], Session["_ip"].ToString()));
                }
                catch (Exception ex) { }

                TempData["OKNormal"] = Resources.Language.OKNormal;
                return RedirectToAction("Index");
            }
            catch
            {
                Nullable<int> idUser = null;
                string ip = "Unknown";
                try
                {
                    idUser = (int)Session["userID"];
                }
                catch (Exception ex) { }
                try
                {
                    ip = Session["_ip"].ToString();
                }
                catch (Exception ex) { }
                try
                {
                    Bita.guardarBitacora(new BIZBitacora("Error", "Error al intentar crear lista de precios", idUser, ip));
                }
                catch (Exception ex) { }
                ViewBag.AlertError = Resources.Language.ErrorNormal;
                return View();
            }
        }
 public ActionResult Edit(int id, BIZListaPrecio collection)
 {
     try
     {
         precioWorker.UpdateListaPrecio(collection);
         try
         {
             Bita.guardarBitacora(new BIZBitacora("Informativo", "Se ha editado la lista de precios: " + collection.IDListaPrecio, (int)Session["userID"], Session["_ip"].ToString()));
         }
         catch (Exception ex) { }
         TempData["OKNormal"] = Resources.Language.OKNormal;
         return RedirectToAction("Index");
     }
     catch
     {
         Nullable<int> idUser = null;
         string ip = "Unknown";
         try
         {
             idUser = (int)Session["userID"];
         }
         catch (Exception ex) { }
         try
         {
             ip = Session["_ip"].ToString();
         }
         catch (Exception ex) { }
         try
         {
             Bita.guardarBitacora(new BIZBitacora("Error", "Error al intentar editar lista de precios", idUser, ip));
         }
         catch (Exception ex) { }
         TempData["ErrorNormal"] = Resources.Language.ErrorNormal;
         return RedirectToAction("Index");
     }
 }
        public ActionResult DetallesLista(string IDLista)
        {
            try
            {
                var id = Convert.ToInt32(IDLista);
                var precio = precioWorker.TraerAllListaPrecio();
                BIZListaPrecio Lista = new BIZListaPrecio();
                foreach (var p in precio)
                {
                    if (p.IDListaPrecio == id)
                    {
                        Lista = p;
                    }
                }
                var list = Lista.PrecioDetalle.ToList();
                List<PrecioDetalleM> detalles = new List<PrecioDetalleM>();
                PrecioDetalleM detalle;

                foreach (var d in list)
                {
                    detalle = new PrecioDetalleM();
                    detalle.IDPrecioDetalle = d.IDPrecioDetalle;
                    detalle.Precio = (double)d.Precio;
                    detalle.Producto = d.Producto.Nombre;
                    detalle.Estado = (bool)d.Activo;
                    detalles.Add(detalle);
                    //detalle = new PrecioDetalleM();

                }
                //return Json(new {  }, JsonRequestBehavior.AllowGet);
                return Json(new { detalles, Lista.Detalle   }, JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex)
            {
                return Json(new { Lista = "" }, JsonRequestBehavior.AllowGet);
            }
        }
Exemple #6
0
 public void UpdateListaPrecio(BIZListaPrecio collection)
 {
     precioWorker.UpdateListaPrecio(collection);
 }
Exemple #7
0
 public void CreateListaPrecio(BIZListaPrecio ListaPrecio)
 {
     precioWorker.CreateListaPrecio(ListaPrecio);
 }
Exemple #8
0
 public void copiarLista(BIZListaPrecio Lista, double factor)
 {
     precioWorker.CopyList(Lista, factor);
 }
Exemple #9
0
 public void CreateListaPrecio(BIZListaPrecio lista)
 {
     var TList = Mapper.Map<BIZListaPrecio, ListaPrecio>(lista);
     db.ListaPrecio.Add(TList);
     db.SaveChanges();
 }
Exemple #10
0
 public void UpdateListaPrecio(BIZListaPrecio Lista)
 {
     try
     {
         ListaPrecio TLista = new ListaPrecio();
         //Tprovincia = Mapper.Map<BIZProvincia, Provincia>(oProvincia);
         TLista.IDListaPrecio = Lista.IDListaPrecio;
         TLista.Activo = Lista.Activo;
         TLista.FechaDesde = Lista.FechaDesde;
         TLista.FechaUltimaMod = DateTime.Now;
         TLista.Detalle = Lista.Detalle;
         db.Entry(TLista).State = EntityState.Modified;
         db.SaveChanges();
     }
     catch (Exception ex) {  }
 }