示例#1
0
        public ActionResult Index()
        {
            if (!this.currentUser()) { return RedirectToAction("Ingresar", "Admin"); }
            ViewBag.Title += "Proformas";
            MenuNavBarSelected(12);

            UsuarioDTO currentUser = getCurrentUser();
            var lista = new ProformaBL().getProformaEnEmpresa(currentUser.IdEmpresa);
            
            return View(lista);
        }
示例#2
0
 public ActionResult Proforma(Int32 id)
 {
     if (!this.currentUser()) { return RedirectToAction("Ingresar", "Admin"); }
     var lista = new ProformaBL().getProformaId(id);
     ViewBag.Title += "Proforma";
     MenuNavBarSelected(12);
     return View(lista);
 }
示例#3
0
 public ActionResult GetDetalleProforma(Int32 IdProforma)
 {
     var lista = new ProformaBL().getDetalleProformaPorId(IdProforma);
     return Json(lista, JsonRequestBehavior.AllowGet);
 }
示例#4
0
        public ActionResult SaveProforma(ProformaDTO Proforma)
        {
            UsuarioDTO currentUser = getCurrentUser();
            //ProformaDTO Proforma = new ProformaDTO();
            //TryUpdateModel(Proforma);

            Proforma.IdEmpresa = currentUser.IdEmpresa;
            if (Proforma.FechaRegistro == null) { Proforma.FechaRegistro = DateTime.Now; }
            var lista = new ProformaBL().SaveProforma(Proforma);
            return Json(lista, JsonRequestBehavior.AllowGet);
        }
示例#5
0
 public ActionResult NuevaProforma(Int32? id)
 {
     if (!this.currentUser()) { return RedirectToAction("Ingresar", "Admin"); }
     UsuarioDTO currentUser = getCurrentUser();
     ProformaDTO pro = new ProformaDTO();
     
     if (id.HasValue)
     {
         pro = new ProformaBL().getProformaId(id.Value);
     }
     ViewBag.Title += " - Editar Proforma";
     MenuNavBarSelected(10);
     return View(pro);
 }
示例#6
0
        public ActionResult ExportarProformas()
        {
            EmpresaDTO empresa = (new EmpresaBL()).getEmpresa(getCurrentUser().IdEmpresa);

            ProformaBL objBL = new ProformaBL();
            List<ProformaDTO> lista = objBL.getProformasExportarEnEmpresa(empresa.IdEmpresa);

            System.Data.DataTable dt = new System.Data.DataTable();
            dt.Clear();

            dt.Columns.Add("Codigo de Proforma");
            dt.Columns.Add("Nombre Cliente");
            dt.Columns.Add("Atención");
            dt.Columns.Add("Cargo");
            dt.Columns.Add("Email");
            dt.Columns.Add("Telefono");
            dt.Columns.Add("Celular");
            dt.Columns.Add("Fecha Registro");
            dt.Columns.Add("Fecha Proforma");
            dt.Columns.Add("Validez");
            dt.Columns.Add("Método de Pago");
            dt.Columns.Add("Fecha de Entrega");
            dt.Columns.Add("Lugar de Entrega");
            dt.Columns.Add("Sub Total");
            dt.Columns.Add("IGV");
            dt.Columns.Add("Total");
            dt.Columns.Add("Cuenta Bancaria");
            dt.Columns.Add("Estado");
            dt.Columns.Add("Observaciones de la Proforma");
            dt.Columns.Add("Comentarios adicionales");

            foreach (var item in lista)
            {
                System.Data.DataRow row = dt.NewRow();
                row["Codigo de Proforma"] = item.CodigoProforma;
                row["Nombre Cliente"] = item.EntidadResponsable.Nombre;
                row["Atención"] = item.Contacto.Nombre;
                row["Cargo"] = item.Contacto.Cargo;
                row["Email"] = item.Contacto.Email;
                row["Telefono"] = item.Contacto.Telefono;
                row["Celular"] = item.Contacto.Celular;
                row["Fecha Registro"] = item.FechaRegistro != null ? item.FechaRegistro.GetValueOrDefault().ToString("dd/MMM/yyyy", CultureInfo.CreateSpecificCulture("en-GB")) : "";
                row["Fecha Proforma"] = item.FechaProforma != null ? item.FechaProforma.GetValueOrDefault().ToString("dd/MMM/yyyy", CultureInfo.CreateSpecificCulture("en-GB")) : "";
                row["Validez"] = item.ValidezOferta + "día(s)";
                row["Método de Pago"] = item.MetodoPago;
                row["Fecha de Entrega"] = item.FechaEntrega;
                row["Lugar de Entrega"] = item.LugarEntrega;
                row["Sub Total"] = item.DetalleProforma.Sum(x => x.MontoTotal).GetValueOrDefault().ToString("N2", CultureInfo.InvariantCulture);
                row["IGV"] = item.DetalleProforma.Sum(x => x.Igv).GetValueOrDefault().ToString("N2", CultureInfo.InvariantCulture);
                row["Total"] = item.DetalleProforma.Sum(x => x.MontoTotal + x.Igv).GetValueOrDefault().ToString("N2", CultureInfo.InvariantCulture);
                row["Cuenta Bancaria"] = item.NombreCuentaBancaria;
                row["Estado"] = item.Estado == 1 ? "Pendiente" : (item.Estado == 2 ? "Aprobada" : "Rechazada");
                row["Observaciones de la Proforma"] = item.ComentarioProforma;
                row["Comentarios adicionales"] = item.ComentarioAdiccional;
                dt.Rows.Add(row);
            }

            GenerarProformaPdf(dt, "Detalle de Proformas", "Detalle_de_Proformas", empresa, Response);
            createResponseMessage(CONSTANTES.SUCCESS, CONSTANTES.SUCCESS_FILE);
            return RedirectToAction("Index", "Proformas"); ;
        }
示例#7
0
        public ActionResult AddProforma(ProformaDTO dto)
        {
            if (!this.currentUser()) { return RedirectToAction("Ingresar", "Admin", new { Area = string.Empty }); }
            if (getCurrentUser().IdRol == 4) { return RedirectToAction("Index", "Proformas"); }
            try
            {
                if(dto != null)
                {
                    dto.DetalleProforma = (List<DetalleProformaDTO>)TempData["lstDetalleProforma"] ?? new List<DetalleProformaDTO>();
                }

                ProformaBL objBL = new ProformaBL();

                if (dto.IdProforma == 0)
                {
                    if (objBL.SaveProforma(dto))
                    {
                        createResponseMessage(CONSTANTES.SUCCESS);
                        return RedirectToAction("Index", "Proformas");
                    }
                    else
                    {
                        createResponseMessage(CONSTANTES.ERROR, CONSTANTES.ERROR_INSERT_MESSAGE);
                    }
                }
                else if (dto.IdProforma > 0)
                {
                    if (objBL.SaveProforma(dto))
                    {
                        createResponseMessage(CONSTANTES.SUCCESS);
                        return RedirectToAction("Index", "Proformas");
                    }
                    else
                    {
                        createResponseMessage(CONSTANTES.ERROR, CONSTANTES.ERROR_UPDATE_MESSAGE);
                    }
                }
            }
            catch(Exception e)
            {
                if (dto.IdProforma != 0)
                    createResponseMessage(CONSTANTES.ERROR, CONSTANTES.ERROR_UPDATE_MESSAGE);
                else createResponseMessage(CONSTANTES.ERROR, CONSTANTES.ERROR_INSERT_MESSAGE);
            }
            TempData["Proforma"] = dto;
            return RedirectToAction("Proforma", "Proformas", new { id = dto.IdProforma });
        }
示例#8
0
        public ActionResult ProformaDetalle(int id)
        {
            if (!this.currentUser()) { return RedirectToAction("Ingresar", "Admin", new { Area = string.Empty }); }
            ViewBag.Title += "Detalle Proforma";
            MenuNavBarSelected(12);

            var obj = new ProformaBL().getProformaId(id);

            return View(obj);
        }
示例#9
0
        public ActionResult Proforma(int? id)
        {
            if (!this.currentUser()) { return RedirectToAction("Ingresar", "Admin", new { Area = string.Empty }); }
            ViewBag.Title += "Proforma";
            MenuNavBarSelected(12);

            UsuarioDTO user = getCurrentUser();


            EntidadResponsableBL entBL = new EntidadResponsableBL();
            ViewBag.lstClientes = entBL.getEntidadesResponsablesActivasPorTipoEnEmpresa(user.IdEmpresa, 1);
            EmpresaBL empBL = new EmpresaBL();
            ViewBag.lstMonedas = empBL.getListaMonedasAll();
            MovimientoInvBL movItmBL = new MovimientoInvBL();
            ViewBag.lstItems = movItmBL.getItemsEnEmpresa_PorTipoMov(user.IdEmpresa, 1);
            CuentaBancariaBL cbBL = new CuentaBancariaBL();
            ViewBag.lstCuentasBancarias = cbBL.getCuentasBancariasActivasPorTipoEnEmpresa(user.IdEmpresa, 1);
            ViewBag.lstContactos = new List<ContactoDTO>();

            var objSent = TempData["Proforma"];
            if (objSent != null) { TempData["Proforma"] = null; return View(objSent); }

            ProformaDTO obj;
            if(id != null && id > 0)
            {
                obj = new ProformaBL().getProformaId((int)id);
                return View(obj);
            }
            obj = new ProformaDTO();
            obj.IdEmpresa = user.IdEmpresa;
            obj.FechaProforma = DateTime.Now;
            obj.DetalleProforma = new List<DetalleProformaDTO>();

            return View(obj);
        }