Exemplo n.º 1
0
        // GET: Correos/Details/5
        public ActionResult Details(decimal id, bool?mail)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var dOCUMENTO = db.DOCUMENTOes.Where(x => x.NUM_DOC == id).FirstOrDefault();

            ViewBag.workflow = db.FLUJOes.Where(a => a.NUM_DOC.Equals(id)).OrderBy(a => a.POS).ToList();
            ViewBag.acciones = db.FLUJOes.Where(a => a.NUM_DOC.Equals(id) & a.ESTATUS.Equals("P") & a.USUARIOA_ID.Equals(User.Identity.Name)).FirstOrDefault();
            ViewBag.url      = "http://localhost:64497";
            ViewBag.url      = "http://192.168.1.77";
            ViewBag.url      = Request.Url.AbsoluteUri.Replace(Request.Url.AbsolutePath, "");
            if (dOCUMENTO == null)
            {
                return(HttpNotFound());
            }

            //MGC 08-10-2018 Obtener el nombre del cliente
            var prov = db.PROVEEDORs.Where(p => p.LIFNR == dOCUMENTO.PAYER_ID).FirstOrDefault().NAME1;

            ViewBag.prov = prov;

            //Obtener miles y dec
            FORMATO formato = new FORMATO();

            formato       = db.FORMATOes.Where(f => f.ACTIVO == true).FirstOrDefault();
            ViewBag.miles = formato.MILES;
            ViewBag.dec   = formato.DECIMALES;


            //ViewBag.miles = dOCUMENTO.PAI.MILES;//LEJGG 090718
            //ViewBag.dec = dOCUMENTO.PAI.DECIMAL;//LEJGG 090718
            FormatosC fc = new FormatosC();

            ViewBag.monto = fc.toShow((decimal?)dOCUMENTO.MONTO_DOC_MD, formato.DECIMALES);
            if (mail == null)
            {
                mail = true;
            }
            //B20180803 MGC Correos............
            string mailv = "";

            if (mail != null)
            {
                if (mail == true)
                {
                    mailv = "X";
                }
            }

            ViewBag.mail = mailv;
            //B20180803 MGC Correos............
            return(View(dOCUMENTO));
        }
Exemplo n.º 2
0
        // GET: Correos
        public ActionResult Backorder(decimal id, bool?mail)
        {
            var dOCUMENTO = db.DOCUMENTOes.Where(x => x.NUM_DOC == id).FirstOrDefault();
            var flujo     = db.FLUJOes.Where(x => x.NUM_DOC == id).OrderByDescending(o => o.POS).Select(s => s.POS).ToList();

            ViewBag.Pos = flujo[0];
            ViewBag.url = "http://localhost:64497";
            ViewBag.url = "http://192.168.1.77";
            ViewBag.url = Request.Url.AbsoluteUri.Replace(Request.Url.PathAndQuery, "");

            DOCUMENTOL dl = dOCUMENTO.DOCUMENTOLs.OrderByDescending(x => x.POS).FirstOrDefault();
            FormatosC  fc = new FormatosC();

            ViewBag.monto = fc.toShow((decimal)dOCUMENTO.MONTO_DOC_MD, dOCUMENTO.PAI.DECIMAL);
            ViewBag.mes   = dl.FECHAF.Value.Month;
            ViewBag.venta = fc.toShow((decimal)dl.MONTO_VENTA, dOCUMENTO.PAI.DECIMAL);
            DOCUMENTOREC dr = db.DOCUMENTORECs.Where(x => x.DOC_REF == dOCUMENTO.NUM_DOC).FirstOrDefault();

            ViewBag.objetivo = fc.toShow((decimal)dr.MONTO_BASE, dOCUMENTO.PAI.DECIMAL);
            ViewBag.porc     = fc.toShowPorc((decimal)dr.PORC, dOCUMENTO.PAI.DECIMAL);
            if (dl.MONTO_VENTA < dr.MONTO_BASE)
            {
                ViewBag.tsol = dOCUMENTO.TSOL.TSOLR;
                ViewBag.nota = false;
            }
            else
            {
                ViewBag.tsol = "";
                ViewBag.nota = true;
            }
            if (mail == null)
            {
                mail = true;
            }
            //B20180803 MGC Correos............
            string mailv = "";

            if (mail != null)
            {
                if (mail == true)
                {
                    mailv = "X";
                }
            }

            ViewBag.mail = mailv;
            //B20180803 MGC Correos............
            return(View(dOCUMENTO));
        }
Exemplo n.º 3
0
        // GET: Correos/Details/5
        public ActionResult Details(decimal id, bool?mail)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var dOCUMENTO = db.DOCUMENTOes.Where(x => x.NUM_DOC == id).FirstOrDefault();

            ViewBag.workflow = db.FLUJOes.Where(a => a.NUM_DOC.Equals(id)).OrderBy(a => a.POS).ToList();
            ViewBag.acciones = db.FLUJOes.Where(a => a.NUM_DOC.Equals(id) & a.ESTATUS.Equals("P") & a.USUARIOA_ID.Equals(User.Identity.Name)).FirstOrDefault();
            ViewBag.url      = "http://localhost:64497";
            ViewBag.url      = "http://192.168.1.77";
            ViewBag.url      = Request.Url.AbsoluteUri.Replace(Request.Url.AbsolutePath, "");
            if (dOCUMENTO == null)
            {
                return(HttpNotFound());
            }
            //ViewBag.miles = dOCUMENTO.PAI.MILES;//LEJGG 090718
            //ViewBag.dec = dOCUMENTO.PAI.DECIMAL;//LEJGG 090718
            FormatosC fc = new FormatosC();

            //ViewBag.monto = fc.toShow((decimal)dOCUMENTO.MONTO_DOC_MD, dOCUMENTO.PAI.DECIMAL);
            ViewBag.monto = fc.toShow((decimal)dOCUMENTO.MONTO_DOC_MD, dOCUMENTO.PAI.DECIMAL) + " " + dOCUMENTO.MONEDA_ID;
            if (mail == null)
            {
                mail = true;
            }
            //B20180803 MGC Correos............
            string mailv = "";

            if (mail != null)
            {
                if (mail == true)
                {
                    mailv = "X";
                }
            }

            ViewBag.mail = mailv;
            //B20180803 MGC Correos............
            return(View(dOCUMENTO));
        }
Exemplo n.º 4
0
        // GET: CartaD/Details/5
        public ActionResult Create(decimal id)
        {
            int pagina = 232; //ID EN BASE DE DATOS

            using (TAT001Entities db = new TAT001Entities())
            {
                string u    = User.Identity.Name;
                var    user = db.USUARIOs.Where(a => a.ID.Equals(u)).FirstOrDefault();
                ViewBag.permisos = db.PAGINAVs.Where(a => a.ID.Equals(user.ID)).ToList();
                ViewBag.carpetas = db.CARPETAVs.Where(a => a.USUARIO_ID.Equals(user.ID)).ToList();
                ViewBag.usuario  = user;
                ViewBag.rol      = user.PUESTO.PUESTOTs.Where(a => a.SPRAS_ID.Equals(user.SPRAS_ID)).FirstOrDefault().TXT50;
                ViewBag.Title    = db.PAGINAs.Where(a => a.ID.Equals(pagina)).FirstOrDefault().PAGINATs.Where(b => b.SPRAS_ID.Equals(user.SPRAS_ID)).FirstOrDefault().TXT50;
                ViewBag.warnings = db.WARNINGVs.Where(a => (a.PAGINA_ID.Equals(pagina) || a.PAGINA_ID.Equals(0)) && a.SPRAS_ID.Equals(user.SPRAS_ID)).ToList();
                ViewBag.textos   = db.TEXTOes.Where(a => (a.PAGINA_ID.Equals(pagina) || a.PAGINA_ID.Equals(0)) && a.SPRAS_ID.Equals(user.SPRAS_ID)).ToList();
                ViewBag.de       = db.TEXTOCVs.Where(t => t.SPRAS_ID.Equals(user.SPRAS_ID) & t.CAMPO == "de").Select(t => t.TEXTO).FirstOrDefault();
                ViewBag.al       = db.TEXTOCVs.Where(t => t.SPRAS_ID.Equals(user.SPRAS_ID) & t.CAMPO == "a").Select(t => t.TEXTO).FirstOrDefault();
                ViewBag.mon      = db.TEXTOCVs.Where(t => t.SPRAS_ID.Equals(user.SPRAS_ID) & t.CAMPO == "monto").Select(t => t.TEXTO).FirstOrDefault();

                try
                {
                    string p = Session["pais"].ToString();
                    ViewBag.pais = p + ".png";
                }
                catch
                {
                    //ViewBag.pais = "mx.png";
                    //return RedirectToAction("Pais", "Home");
                }

                DOCUMENTO d  = new DOCUMENTO();
                PUESTOT   pp = new PUESTOT();
                d = db.DOCUMENTOes.Include("SOCIEDAD").Include("USUARIO").Where(a => a.NUM_DOC.Equals(id)).First();

                //Formatos para numeros
                d.PAI = db.PAIS.Where(a => a.LAND.Equals(d.PAIS_ID)).FirstOrDefault();
                string miles     = d.PAI.MILES;     //B20180730 MGC 2018.07.30 Formatos
                string decimales = d.PAI.DECIMAL;   //B20180730 MGC 2018.07.30 Formatos

                FormatosC format = new FormatosC(); //B20180730 MGC 2018.07.30 Formatos

                //B20180726 MGC 2018.07.26
                bool fact = false;
                try
                {
                    fact = db.TSOLs.Where(ts => ts.ID == d.TSOL_ID).FirstOrDefault().FACTURA;
                }
                catch (Exception)
                {
                }

                List <string> lista            = new List <string>();
                List <string> armadoCuerpoTab  = new List <string>();
                List <string> armadoCuerpoTab2 = new List <string>();
                List <int>    numfilasTabla    = new List <int>();
                int           contadorTabla    = 0;
                HeaderFooter  hfc = new HeaderFooter();
                hfc.eliminaArchivos();
                CartaD cv = new CartaD();

                if (d != null)
                {
                    d.CLIENTE = db.CLIENTEs.Where(a => a.VKORG.Equals(d.VKORG)
                                                  & a.VTWEG.Equals(d.VTWEG)
                                                  & a.SPART.Equals(d.SPART)
                                                  & a.KUNNR.Equals(d.PAYER_ID)).First();
                    string sp = Session["spras"].ToString();
                    pp = db.PUESTOTs.Where(a => a.SPRAS_ID.Equals(sp) && a.PUESTO_ID == d.USUARIO.PUESTO_ID).FirstOrDefault();
                }
                ViewBag.legal = db.LEYENDAs.Where(a => a.PAIS_ID.Equals(d.PAIS_ID) && a.ACTIVO == true).FirstOrDefault();


                /////////////////////////////////////////////DATOS PARA LA TABLA 1 MATERIALES EN LA VISTA///////////////////////////////////////
                //B20180720P MGC 2018.07.25
                var  cabeza    = new List <string>();
                bool varligada = Convert.ToBoolean(d.LIGADA);
                if (varligada != true)
                {
                    var con = db.DOCUMENTOPs.Select(x => new { x.NUM_DOC, x.VIGENCIA_DE, x.VIGENCIA_AL }).Where(a => a.NUM_DOC.Equals(id)).GroupBy(f => new { f.VIGENCIA_DE, f.VIGENCIA_AL }).ToList();

                    foreach (var item in con)
                    {
                        lista.Add(item.Key.VIGENCIA_DE.ToString() + item.Key.VIGENCIA_AL.ToString());
                    }

                    for (int i = 0; i < lista.Count; i++)
                    {
                        contadorTabla = 0;

                        DateTime a1 = DateTime.Parse(lista[i].Remove(lista[i].Length / 2));
                        DateTime a2 = DateTime.Parse(lista[i].Remove(0, lista[i].Length / 2));

                        var con2 = db.DOCUMENTOPs
                                   .Where(x => x.NUM_DOC.Equals(id) & x.VIGENCIA_DE == a1 && x.VIGENCIA_AL == a2)
                                   .Join(db.MATERIALs, x => x.MATNR, y => y.ID, (x, y) => new { x.NUM_DOC, x.MATNR, x.MATKL, y.MAKTX, x.MONTO, y.PUNIT, x.PORC_APOYO, x.MONTO_APOYO, resta = (x.MONTO - x.MONTO_APOYO), x.PRECIO_SUG, x.VOLUMEN_EST, x.VOLUMEN_REAL, x.APOYO_EST, x.APOYO_REAL })           //B20180726 MGC 2018.07.26
                                   .ToList();

                        if (con2.Count > 0)
                        {
                            foreach (var item2 in con2)
                            {
                                armadoCuerpoTab.Add(item2.MATNR.TrimStart('0'));
                                armadoCuerpoTab.Add(item2.MATKL);
                                armadoCuerpoTab.Add(item2.MAKTX);
                                //armadoCuerpoTab.Add(Math.Round(item2.MONTO, 2).ToString());//B20180730 MGC 2018.07.30 Formatos
                                armadoCuerpoTab.Add(format.toShow(Math.Round(item2.MONTO, 2), decimales));          //B20180730 MGC 2018.07.30 Formatos
                                //armadoCuerpoTab.Add(Math.Round(item2.PORC_APOYO, 2).ToString());//B20180730 MGC 2018.07.30 Formatos
                                armadoCuerpoTab.Add(format.toShowPorc(Math.Round(item2.PORC_APOYO, 2), decimales)); //B20180730 MGC 2018.07.30 Formatos
                                //armadoCuerpoTab.Add(Math.Round(item2.MONTO_APOYO, 2).ToString());//B20180730 MGC 2018.07.30 Formatos
                                armadoCuerpoTab.Add(format.toShow(Math.Round(item2.MONTO_APOYO, 2), decimales));    //B20180730 MGC 2018.07.30 Formatos
                                //armadoCuerpoTab.Add(Math.Round(item2.resta, 2).ToString());//B20180730 MGC 2018.07.30 Formatos
                                armadoCuerpoTab.Add(format.toShow(Math.Round(item2.resta, 2), decimales));          //B20180730 MGC 2018.07.30 Formatos
                                //armadoCuerpoTab.Add(Math.Round(item2.PRECIO_SUG, 2).ToString());//B20180730 MGC 2018.07.30 Formatos
                                armadoCuerpoTab.Add(format.toShow(Math.Round(item2.PRECIO_SUG, 2), decimales));     //B20180730 MGC 2018.07.30 Formatos
                                //B20180726 MGC 2018.07.26
                                //armadoCuerpoTab.Add(Math.Round(Convert.ToDouble(item2.APOYO_EST), 2).ToString());
                                //armadoCuerpoTab.Add(Math.Round(Convert.ToDouble(item2.APOYO_REAL), 2).ToString());
                                //Volumen y apoyo
                                if (fact)
                                {
                                    //armadoCuerpoTab.Add(Math.Round(Convert.ToDouble(item2.VOLUMEN_REAL), 2).ToString());//B20180730 MGC 2018.07.30 Formatos
                                    //armadoCuerpoTab.Add(Math.Round(Convert.ToDouble(item2.VOLUMEN_REAL), 2).ToString());//B20180730 MGC 2018.07.30 Formatos
                                    armadoCuerpoTab.Add(format.toShowNum(Math.Round(Convert.ToDecimal(item2.VOLUMEN_REAL), 2), decimales)); //B20180730 MGC 2018.07.30 Formatos
                                    armadoCuerpoTab.Add(format.toShow(Math.Round(Convert.ToDecimal(item2.APOYO_REAL), 2), decimales));      //B20180730 MGC 2018.07.30 Formatos
                                }
                                else
                                {
                                    //armadoCuerpoTab.Add(Math.Round(Convert.ToDouble(item2.VOLUMEN_EST), 2).ToString());//B20180730 MGC 2018.07.30 Formatos
                                    //armadoCuerpoTab.Add(Math.Round(Convert.ToDouble(item2.VOLUMEN_EST), 2).ToString());//B20180730 MGC 2018.07.30 Formatos
                                    armadoCuerpoTab.Add(format.toShowNum(Math.Round(Convert.ToDecimal(item2.VOLUMEN_EST), 2), decimales)); //B20180730 MGC 2018.07.30 Formatos
                                    armadoCuerpoTab.Add(format.toShow(Math.Round(Convert.ToDecimal(item2.APOYO_EST), 2), decimales));      //B20180730 MGC 2018.07.30 Formatos
                                }
                                contadorTabla++;
                            }
                        }
                        else
                        {
                            var con3 = db.DOCUMENTOPs
                                       .Where(x => x.NUM_DOC.Equals(id) & x.VIGENCIA_DE == a1 && x.VIGENCIA_AL == a2)
                                       .Join(db.MATERIALGPs, x => x.MATKL, y => y.ID, (x, y) => new { x.NUM_DOC, x.MATNR, x.MATKL, y.ID, x.MONTO, x.PORC_APOYO, y.MATERIALGPTs.Where(a => a.SPRAS_ID.Equals(d.CLIENTE.SPRAS)).FirstOrDefault().TXT50, x.MONTO_APOYO, resta = (x.MONTO - x.MONTO_APOYO), x.PRECIO_SUG, x.VOLUMEN_EST, x.VOLUMEN_REAL, x.APOYO_EST, x.APOYO_REAL })        //B20180726 MGC 2018.07.26
                                       .ToList();

                            foreach (var item2 in con3)
                            {
                                armadoCuerpoTab.Add("");
                                armadoCuerpoTab.Add(item2.MATKL);
                                armadoCuerpoTab.Add(item2.TXT50);
                                //armadoCuerpoTab.Add(Math.Round(item2.MONTO, 2).ToString());//B20180730 MGC 2018.07.30 Formatos
                                armadoCuerpoTab.Add(format.toShow(Math.Round(item2.MONTO, 2), decimales));          //B20180730 MGC 2018.07.30 Formatos
                                //armadoCuerpoTab.Add(Math.Round(item2.PORC_APOYO, 2).ToString());//B20180730 MGC 2018.07.30 Formatos
                                armadoCuerpoTab.Add(format.toShowPorc(Math.Round(item2.PORC_APOYO, 2), decimales)); //B20180730 MGC 2018.07.30 Formatos
                                //armadoCuerpoTab.Add(Math.Round(item2.MONTO_APOYO, 2).ToString());//B20180730 MGC 2018.07.30 Formatos
                                armadoCuerpoTab.Add(format.toShow(Math.Round(item2.MONTO_APOYO, 2), decimales));    //B20180730 MGC 2018.07.30 Formatos
                                //armadoCuerpoTab.Add(Math.Round(item2.resta, 2).ToString());//B20180730 MGC 2018.07.30 Formatos
                                armadoCuerpoTab.Add(format.toShow(Math.Round(item2.resta, 2), decimales));          //B20180730 MGC 2018.07.30 Formatos
                                //armadoCuerpoTab.Add(Math.Round(item2.PRECIO_SUG, 2).ToString());//B20180730 MGC 2018.07.30 Formatos
                                armadoCuerpoTab.Add(format.toShow(Math.Round(item2.PRECIO_SUG, 2), decimales));     //B20180730 MGC 2018.07.30 Formatos
                                //B20180726 MGC 2018.07.26
                                //armadoCuerpoTab.Add(Math.Round(Convert.ToDouble(item2.APOYO_EST), 2).ToString());
                                //armadoCuerpoTab.Add(Math.Round(Convert.ToDouble(item2.APOYO_REAL), 2).ToString());
                                if (fact)
                                {
                                    //armadoCuerpoTab.Add(Math.Round(Convert.ToDouble(item2.VOLUMEN_REAL), 2).ToString());//B20180730 MGC 2018.07.30 Formatos
                                    //armadoCuerpoTab.Add(Math.Round(Convert.ToDouble(item2.APOYO_REAL), 2).ToString());//B20180730 MGC 2018.07.30 Formatos
                                    armadoCuerpoTab.Add(format.toShowNum(Math.Round(Convert.ToDecimal(item2.VOLUMEN_REAL), 2), decimales)); //B20180730 MGC 2018.07.30 Formatos
                                    armadoCuerpoTab.Add(format.toShow(Math.Round(Convert.ToDecimal(item2.APOYO_REAL), 2), decimales));      //B20180730 MGC 2018.07.30 Formatos
                                }
                                else
                                {
                                    //armadoCuerpoTab.Add(Math.Round(Convert.ToDouble(item2.VOLUMEN_EST), 2).ToString());//B20180730 MGC 2018.07.30 Formatos
                                    //armadoCuerpoTab.Add(Math.Round(Convert.ToDouble(item2.APOYO_EST), 2).ToString());//B20180730 MGC 2018.07.30 Formatos
                                    armadoCuerpoTab.Add(format.toShowNum(Math.Round(Convert.ToDecimal(item2.VOLUMEN_EST), 2), decimales)); //B20180730 MGC 2018.07.30 Formatos
                                    armadoCuerpoTab.Add(format.toShow(Math.Round(Convert.ToDecimal(item2.APOYO_EST), 2), decimales));      //B20180730 MGC 2018.07.30 Formatos
                                }
                                contadorTabla++;
                            }
                        }
                        numfilasTabla.Add(contadorTabla);
                    }


                    //var cabeza = new List<string>();//B20180720P MGC 2018.07.25
                    cabeza.Add(db.TEXTOCVs.Where(x => x.SPRAS_ID == user.SPRAS_ID & x.CAMPO == "materialC").Select(x => x.TEXTO).FirstOrDefault());
                    cabeza.Add(db.TEXTOCVs.Where(x => x.SPRAS_ID == user.SPRAS_ID & x.CAMPO == "categoriaC").Select(x => x.TEXTO).FirstOrDefault());
                    cabeza.Add(db.TEXTOCVs.Where(x => x.SPRAS_ID == user.SPRAS_ID & x.CAMPO == "descripcionC").Select(x => x.TEXTO).FirstOrDefault());
                    cabeza.Add(db.TEXTOCVs.Where(x => x.SPRAS_ID == user.SPRAS_ID & x.CAMPO == "costouC").Select(x => x.TEXTO).FirstOrDefault());
                    cabeza.Add(db.TEXTOCVs.Where(x => x.SPRAS_ID == user.SPRAS_ID & x.CAMPO == "apoyopoC").Select(x => x.TEXTO).FirstOrDefault());
                    cabeza.Add(db.TEXTOCVs.Where(x => x.SPRAS_ID == user.SPRAS_ID & x.CAMPO == "apoyopiC").Select(x => x.TEXTO).FirstOrDefault());
                    cabeza.Add(db.TEXTOCVs.Where(x => x.SPRAS_ID == user.SPRAS_ID & x.CAMPO == "costoaC").Select(x => x.TEXTO).FirstOrDefault());
                    cabeza.Add(db.TEXTOCVs.Where(x => x.SPRAS_ID == user.SPRAS_ID & x.CAMPO == "preciosC").Select(x => x.TEXTO).FirstOrDefault());
                    //B20180726 MGC 2018.07.26
                    //cabeza.Add(db.TEXTOCVs.Where(x => x.SPRAS_ID == user.SPRAS_ID & x.CAMPO == "apoyoeC").Select(x => x.TEXTO).FirstOrDefault());
                    //cabeza.Add(db.TEXTOCVs.Where(x => x.SPRAS_ID == user.SPRAS_ID & x.CAMPO == "apoyorC").Select(x => x.TEXTO).FirstOrDefault());
                    //Volumen
                    if (fact)
                    {
                        cabeza.Add(db.TEXTOCVs.Where(x => x.SPRAS_ID == user.SPRAS_ID & x.CAMPO == "volumenrC").Select(x => x.TEXTO).FirstOrDefault());
                    }
                    else
                    {
                        cabeza.Add(db.TEXTOCVs.Where(x => x.SPRAS_ID == user.SPRAS_ID & x.CAMPO == "volumeneC").Select(x => x.TEXTO).FirstOrDefault());
                    }
                    //Apoyo
                    //B20180726 MGC 2018.07.26
                    if (fact)
                    {
                        cabeza.Add(db.TEXTOCVs.Where(x => x.SPRAS_ID == user.SPRAS_ID & x.CAMPO == "apoyorC").Select(x => x.TEXTO).FirstOrDefault());
                    }
                    else
                    {
                        cabeza.Add(db.TEXTOCVs.Where(x => x.SPRAS_ID == user.SPRAS_ID & x.CAMPO == "apoyoeC").Select(x => x.TEXTO).FirstOrDefault());
                    }

                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                }
                /////////////////////////////////////////////DATOS PARA LA TABLA 2 RECURRENCIAS EN LA VISTA///////////////////////////////////////
                var cabeza2 = new List <string>();
                cabeza2.Add(db.TEXTOCVs.Where(x => x.SPRAS_ID == user.SPRAS_ID & x.CAMPO == "posC2").Select(x => x.TEXTO).FirstOrDefault());
                cabeza2.Add(db.TEXTOCVs.Where(x => x.SPRAS_ID == user.SPRAS_ID & x.CAMPO == "tipoC2").Select(x => x.TEXTO).FirstOrDefault());
                cabeza2.Add(db.TEXTOCVs.Where(x => x.SPRAS_ID == user.SPRAS_ID & x.CAMPO == "fechaC2").Select(x => x.TEXTO).FirstOrDefault());
                cabeza2.Add(db.TEXTOCVs.Where(x => x.SPRAS_ID == user.SPRAS_ID & x.CAMPO == "montoC2").Select(x => x.TEXTO).FirstOrDefault());
                cabeza2.Add(db.TEXTOCVs.Where(x => x.SPRAS_ID == user.SPRAS_ID & x.CAMPO == "porcentajeC2").Select(x => x.TEXTO).FirstOrDefault());

                var con4 = db.DOCUMENTORECs
                           .Where(x => x.NUM_DOC.Equals(id))
                           .Join(db.DOCUMENTOes, x => x.NUM_DOC, y => y.NUM_DOC, (x, y) => new { x.POS, y.TSOL_ID, x.FECHAF, x.MONTO_BASE, x.PORC })
                           .ToList();

                foreach (var item in con4)
                {
                    DateTime a = Convert.ToDateTime(item.FECHAF);

                    armadoCuerpoTab2.Add(item.POS.ToString());
                    armadoCuerpoTab2.Add(db.TSOLs.Where(x => x.ID == item.TSOL_ID).Select(x => x.DESCRIPCION).First());
                    armadoCuerpoTab2.Add(a.ToShortDateString());
                    armadoCuerpoTab2.Add(item.MONTO_BASE.ToString());
                    armadoCuerpoTab2.Add(item.PORC.ToString());
                }
                //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

                //TABLA 1 MATERIALES
                cv.listaFechas      = lista;           //////////////RANGO DE FECHAS QUE DETERMINAN EL NUMERO DE TABLAS
                cv.numfilasTabla    = numfilasTabla;   ////NUMERO FILAS POR TABLA CALCULADA
                cv.listaCuerpo      = armadoCuerpoTab; ////NUMERO TOTAL DE FILAS CON LA INFO CORRESPONDIENTE QUE POSTERIORMENTE ES DISTRIBUIDA EN LAS TABLAS
                cv.numColEncabezado = cabeza;          ////////NUMERO DE COLUMNAS PARA LAS TABLAS
                cv.secondTab_x      = true;
                cv.costoun_x        = true;
                cv.apoyo_x          = true;
                cv.apoyop_x         = true;
                cv.costoap_x        = true;
                cv.precio_x         = true;
                //cv.apoyoEst_x = true;
                //cv.apoyoRea_x = true;
                //B20180726 MGC 2018.07.26
                cv.volumen_x    = true;
                cv.apoyototal_x = true;
                /////////////////////////////////

                //TABLA 2 RECURRENCIAS
                cv.numColEncabezado2 = cabeza2;          ////////NUMERO DE COLUMNAS PARA LAS TABLAS
                cv.numfilasTabla2    = con4.Count();     //////NUMERO FILAS TOTAL PARA LA TABLA
                cv.listaCuerpoRec    = armadoCuerpoTab2; //NUMERO TOTAL DE FILAS CON LA INFO CORRESPONDIENTE
                ///////////////////////////////

                cv.num_doc     = id;
                cv.company     = d.SOCIEDAD.BUTXT;
                cv.company_x   = true;
                cv.taxid       = d.SOCIEDAD.LAND;
                cv.taxid_x     = true;
                cv.concepto    = d.CONCEPTO;
                cv.concepto_x  = true;
                cv.cliente     = d.PAYER_NOMBRE;
                cv.cliente_x   = true;
                cv.puesto      = " ";
                cv.puesto_x    = false;
                cv.direccion   = d.CLIENTE.STRAS_GP;
                cv.direccion_x = true;
                cv.folio       = d.NUM_DOC.ToString();
                cv.folio_x     = true;
                cv.lugar       = d.CIUDAD.Trim() + ", " + d.ESTADO.Trim();
                cv.lugar_x     = true;
                cv.lugarFech   = DateTime.Now.ToShortDateString();
                cv.lugarFech_x = true;
                cv.payerId     = d.CLIENTE.PAYER;
                cv.payerId_x   = true;
                cv.payerNom    = d.CLIENTE.NAME1;
                cv.payerNom_x  = true;
                cv.estimado    = d.PAYER_NOMBRE;
                cv.estimado_x  = true;
                cv.mecanica    = d.NOTAS;
                cv.mecanica_x  = true;
                cv.nombreE     = d.USUARIO.NOMBRE + " " + d.USUARIO.APELLIDO_P + " " + d.USUARIO.APELLIDO_M;
                cv.nombreE_x   = true;
                if (pp != null)
                {
                    cv.puestoE = pp.TXT50;
                }
                cv.puestoE_x   = true;
                cv.companyC    = cv.company;
                cv.companyC_x  = true;
                cv.nombreC     = d.PAYER_NOMBRE;
                cv.nombreC_x   = true;
                cv.puestoC     = " ";
                cv.puestoC_x   = false;
                cv.companyCC   = d.CLIENTE.NAME1;
                cv.companyCC_x = true;
                if (ViewBag.legal != null)
                {
                    cv.legal = ViewBag.legal.LEYENDA1;
                }
                cv.legal_x       = true;
                cv.mail          = db.TEXTOCVs.Where(x => x.SPRAS_ID == user.SPRAS_ID & x.CAMPO == "correo").Select(x => x.TEXTO).FirstOrDefault() + " " + d.PAYER_EMAIL;
                cv.mail_x        = true;
                cv.comentarios   = "";
                cv.comentarios_x = true;
                cv.compromisoK   = "";
                cv.compromisoK_x = true;
                cv.compromisoC   = "";
                cv.compromisoC_x = true;
                cv.monto_x       = true;
                cv.monto         = d.MONTO_DOC_MD.ToString();
                cv.moneda        = d.MONEDA_ID;

                //B20180720P MGC 2018.07.25
                ViewBag.varligada = varligada;

                //B20180801 MGC Formato
                //v.monto = monto_enviar;
                decimal montod = 0;
                try
                {
                    montod = Convert.ToDecimal(cv.monto);
                }
                catch (Exception)
                {
                }

                @ViewBag.montoformat = format.toShow(montod, decimales);

                return(View(cv));
            }
        }
Exemplo n.º 5
0
        public ActionResult Create(CartaD v)
        {
            using (TAT001Entities db = new TAT001Entities())
            {
                string u    = User.Identity.Name;
                var    user = db.USUARIOs.Where(a => a.ID.Equals(u)).FirstOrDefault();

                List <string> encabezadoFech   = new List <string>();
                List <string> armadoCuerpoTab  = new List <string>();
                List <string> armadoCuerpoTab2 = new List <string>();
                List <int>    numfilasTab      = new List <int>();

                int       contadorTabla = 0;
                DOCUMENTO d             = db.DOCUMENTOes.Find(v.num_doc);

                //B20180726 MGC 2018.07.26
                bool fact = false;
                try
                {
                    d    = db.DOCUMENTOes.Find(v.num_doc);
                    fact = db.TSOLs.Where(ts => ts.ID == d.TSOL_ID).FirstOrDefault().FACTURA;
                }
                catch (Exception)
                {
                }

                //Formatos para numeros
                d.PAI = db.PAIS.Where(a => a.LAND.Equals(d.PAIS_ID)).FirstOrDefault();
                string miles     = d.PAI.MILES;     //B20180730 MGC 2018.07.30 Formatos
                string decimales = d.PAI.DECIMAL;   //B20180730 MGC 2018.07.30 Formatos

                FormatosC format = new FormatosC(); //B20180730 MGC 2018.07.30 Formatos

                /////////////////////////////////////////////DATOS PARA LA TABLA 1 MATERIALES EN EL PDF///////////////////////////////////////
                //B20180720P MGC 2018.07.25
                var  cabeza    = new List <string>();
                bool varligada = Convert.ToBoolean(d.LIGADA);
                if (varligada != true)
                {
                    var con = db.DOCUMENTOPs.Select(x => new { x.NUM_DOC, x.VIGENCIA_DE, x.VIGENCIA_AL }).Where(a => a.NUM_DOC.Equals(v.num_doc)).GroupBy(f => new { f.VIGENCIA_DE, f.VIGENCIA_AL }).ToList();

                    foreach (var item in con)
                    {
                        encabezadoFech.Add(item.Key.VIGENCIA_DE.ToString() + item.Key.VIGENCIA_AL.ToString());
                    }

                    for (int i = 0; i < encabezadoFech.Count; i++)
                    {
                        contadorTabla = 0;
                        DateTime a1 = DateTime.Parse(encabezadoFech[i].Remove(encabezadoFech[i].Length / 2));
                        DateTime a2 = DateTime.Parse(encabezadoFech[i].Remove(0, encabezadoFech[i].Length / 2));

                        var con2 = db.DOCUMENTOPs
                                   .Where(x => x.NUM_DOC.Equals(v.num_doc) & x.VIGENCIA_DE == a1 && x.VIGENCIA_AL == a2)
                                   .Join(db.MATERIALs, x => x.MATNR, y => y.ID, (x, y) => new { x.MATNR, x.MATKL, y.MAKTX, x.MONTO, y.PUNIT, x.PORC_APOYO, x.MONTO_APOYO, resta = (x.MONTO - x.MONTO_APOYO), x.PRECIO_SUG, x.VOLUMEN_EST, x.VOLUMEN_REAL, x.APOYO_EST, x.APOYO_REAL })        //B20180726 MGC 2018.07.26
                                   .ToList();


                        if (con2.Count > 0)
                        {
                            foreach (var item2 in con2)
                            {
                                armadoCuerpoTab.Add(item2.MATNR.TrimStart('0'));
                                armadoCuerpoTab.Add(item2.MATKL);
                                armadoCuerpoTab.Add(item2.MAKTX);
                                if (v.costoun_x == true)
                                {
                                    //armadoCuerpoTab.Add(Math.Round(item2.MONTO, 2).ToString());//B20180730 MGC 2018.07.30 Formatos
                                    armadoCuerpoTab.Add(format.toShow(Math.Round(item2.MONTO, 2), decimales));//B20180730 MGC 2018.07.30 Formatos
                                }
                                if (v.apoyo_x == true)
                                {
                                    //armadoCuerpoTab.Add(Math.Round(item2.PORC_APOYO, 2).ToString());//B20180730 MGC 2018.07.30 Formatos
                                    armadoCuerpoTab.Add(format.toShowPorc(Math.Round(item2.PORC_APOYO, 2), decimales));//B20180730 MGC 2018.07.30 Formatos
                                }
                                if (v.apoyop_x == true)
                                {
                                    //armadoCuerpoTab.Add(Math.Round(item2.MONTO_APOYO, 2).ToString());//B20180730 MGC 2018.07.30 Formatos
                                    armadoCuerpoTab.Add(format.toShow(Math.Round(item2.MONTO_APOYO, 2), decimales));//B20180730 MGC 2018.07.30 Formatos
                                }
                                if (v.costoap_x == true)
                                {
                                    //armadoCuerpoTab.Add(Math.Round(item2.resta, 2).ToString());//B20180730 MGC 2018.07.30 Formatos
                                    armadoCuerpoTab.Add(format.toShow(Math.Round(item2.resta, 2), decimales));//B20180730 MGC 2018.07.30 Formatos
                                }
                                if (v.precio_x == true)
                                {
                                    //armadoCuerpoTab.Add(Math.Round(item2.PRECIO_SUG, 2).ToString());//B20180730 MGC 2018.07.30 Formatos
                                    armadoCuerpoTab.Add(format.toShow(Math.Round(item2.PRECIO_SUG, 2), decimales));//B20180730 MGC 2018.07.30 Formatos
                                }
                                //B20180726 MGC 2018.07.26
                                //if (v.apoyoEst_x == true) { armadoCuerpoTab.Add(Math.Round(Convert.ToDouble(item2.APOYO_EST), 2).ToString()); }
                                //if (v.apoyoRea_x == true) { armadoCuerpoTab.Add(Math.Round(Convert.ToDouble(item2.APOYO_REAL), 2).ToString()); }
                                //Volumen
                                //B20180726 MGC 2018.07.26
                                if (v.volumen_x == true)
                                {
                                    if (fact)
                                    {
                                        //armadoCuerpoTab.Add(Math.Round(Convert.ToDouble(item2.VOLUMEN_REAL), 2).ToString());//B20180730 MGC 2018.07.30 Formatos
                                        armadoCuerpoTab.Add(format.toShowNum(Math.Round(Convert.ToDecimal(item2.VOLUMEN_REAL), 2), decimales));//B20180730 MGC 2018.07.30 Formatos
                                        //carp.VOLUMEN_REAL = docmod.VOLUMEN_REAL;
                                    }
                                    else
                                    {
                                        //armadoCuerpoTab.Add(Math.Round(Convert.ToDouble(item2.VOLUMEN_EST), 2).ToString());//B20180730 MGC 2018.07.30 Formatos
                                        armadoCuerpoTab.Add(format.toShowNum(Math.Round(Convert.ToDecimal(item2.VOLUMEN_EST), 2), decimales));//B20180730 MGC 2018.07.30 Formatos
                                        //carp.VOLUMEN_EST = docmod.VOLUMEN_EST;
                                    }
                                }

                                //Apoyo
                                //B20180726 MGC 2018.07.26
                                if (v.apoyototal_x == true)
                                {
                                    if (fact)
                                    {
                                        //armadoCuerpoTab.Add(Math.Round(Convert.ToDouble(item2.APOYO_REAL), 2).ToString());//B20180730 MGC 2018.07.30 Formatos
                                        armadoCuerpoTab.Add(format.toShow(Math.Round(Convert.ToDecimal(item2.APOYO_REAL), 2), decimales));//B20180730 MGC 2018.07.30 Formatos
                                    }
                                    else
                                    {
                                        //armadoCuerpoTab.Add(Math.Round(Convert.ToDouble(item2.APOYO_EST), 2).ToString());//B20180730 MGC 2018.07.30 Formatos
                                        armadoCuerpoTab.Add(format.toShow(Math.Round(Convert.ToDecimal(item2.APOYO_EST), 2), decimales));//B20180730 MGC 2018.07.30 Formatos
                                    }
                                }
                                contadorTabla++;
                            }
                        }
                        else
                        {
                            var con3 = db.DOCUMENTOPs
                                       .Where(x => x.NUM_DOC.Equals(v.num_doc) & x.VIGENCIA_DE == a1 && x.VIGENCIA_AL == a2)
                                       .Join(db.CATEGORIAs, x => x.MATKL, y => y.ID, (x, y) => new { x.NUM_DOC, x.MATNR, x.MATKL, y.ID, x.MONTO, x.PORC_APOYO, y.CATEGORIATs.Where(a => a.SPRAS_ID.Equals(d.CLIENTE.SPRAS)).FirstOrDefault().TXT50, x.MONTO_APOYO, resta = (x.MONTO - x.MONTO_APOYO), x.PRECIO_SUG, x.VOLUMEN_REAL, x.VOLUMEN_EST, x.APOYO_EST, x.APOYO_REAL })         //B20180726 MGC 2018.07.26
                                       .ToList();

                            foreach (var item2 in con3)
                            {
                                armadoCuerpoTab.Add("");
                                armadoCuerpoTab.Add(item2.MATKL);
                                armadoCuerpoTab.Add(item2.TXT50);
                                if (v.costoun_x == true)
                                {
                                    //armadoCuerpoTab.Add(Math.Round(item2.MONTO, 2).ToString());//B20180730 MGC 2018.07.30 Formatos
                                    armadoCuerpoTab.Add(format.toShow(Math.Round(item2.MONTO, 2), decimales));//B20180730 MGC 2018.07.30 Formatos
                                }
                                if (v.apoyo_x == true)
                                {
                                    //armadoCuerpoTab.Add(Math.Round(item2.PORC_APOYO, 2).ToString());//B20180730 MGC 2018.07.30 Formatos
                                    armadoCuerpoTab.Add(format.toShowPorc(Math.Round(item2.PORC_APOYO, 2), decimales));//B20180730 MGC 2018.07.30 Formatos
                                }
                                if (v.apoyop_x == true)
                                {
                                    //armadoCuerpoTab.Add(Math.Round(item2.MONTO_APOYO, 2).ToString());//B20180730 MGC 2018.07.30 Formatos
                                    armadoCuerpoTab.Add(format.toShow(Math.Round(item2.MONTO_APOYO, 2), decimales));//B20180730 MGC 2018.07.30 Formatos
                                }
                                //if (v.costoap_x == true) { armadoCuerpoTab.Add(Math.Round(item2.resta, 2).ToString());//B20180730 MGC 2018.07.30 Formatos
                                if (v.costoap_x == true)
                                {
                                    armadoCuerpoTab.Add(format.toShow(Math.Round(item2.resta, 2), decimales));//B20180730 MGC 2018.07.30 Formatos
                                }
                                if (v.precio_x == true)
                                {
                                    //armadoCuerpoTab.Add(Math.Round(item2.PRECIO_SUG, 2).ToString());//B20180730 MGC 2018.07.30 Formatos
                                    armadoCuerpoTab.Add(format.toShow(Math.Round(item2.PRECIO_SUG, 2), decimales));//B20180730 MGC 2018.07.30 Formatos
                                }
                                //B20180726 MGC 2018.07.26
                                //if (v.apoyoEst_x == true) { armadoCuerpoTab.Add(Math.Round(Convert.ToDouble(item2.APOYO_EST), 2).ToString()); }
                                //if (v.apoyoRea_x == true) { armadoCuerpoTab.Add(Math.Round(Convert.ToDouble(item2.APOYO_REAL), 2).ToString()); }
                                //Volumen
                                //B20180726 MGC 2018.07.26
                                if (v.volumen_x == true)
                                {
                                    if (fact)
                                    {
                                        //armadoCuerpoTab.Add(Math.Round(Convert.ToDouble(item2.VOLUMEN_REAL), 2).ToString());//B20180730 MGC 2018.07.30 Formatos
                                        armadoCuerpoTab.Add(format.toShowNum(Math.Round(Convert.ToDecimal(item2.VOLUMEN_REAL), 2), decimales));//B20180730 MGC 2018.07.30 Formatos
                                        //carp.VOLUMEN_REAL = docmod.VOLUMEN_REAL;
                                    }
                                    else
                                    {
                                        //armadoCuerpoTab.Add(Math.Round(Convert.ToDouble(item2.VOLUMEN_EST), 2).ToString());//B20180730 MGC 2018.07.30 Formatos
                                        armadoCuerpoTab.Add(format.toShowNum(Math.Round(Convert.ToDecimal(item2.VOLUMEN_EST), 2), decimales));//B20180730 MGC 2018.07.30 Formatos
                                        //carp.VOLUMEN_EST = docmod.VOLUMEN_EST;
                                    }
                                }

                                //Apoyo
                                //B20180726 MGC 2018.07.26
                                if (v.apoyototal_x == true)
                                {
                                    if (fact)
                                    {
                                        //armadoCuerpoTab.Add(Math.Round(Convert.ToDouble(item2.APOYO_REAL), 2).ToString());//B20180730 MGC 2018.07.30 Formatos
                                        armadoCuerpoTab.Add(format.toShow(Math.Round(Convert.ToDecimal(item2.APOYO_REAL), 2), decimales));//B20180730 MGC 2018.07.30 Formatos
                                    }
                                    else
                                    {
                                        //armadoCuerpoTab.Add(Math.Round(Convert.(item2.APOYO_EST), 2).ToString());//B20180730 MGC 2018.07.30 Formatos
                                        armadoCuerpoTab.Add(format.toShow(Math.Round(Convert.ToDecimal(item2.APOYO_EST), 2), decimales));//B20180730 MGC 2018.07.30 Formatos
                                    }
                                }
                                contadorTabla++;
                            }
                        }
                        numfilasTab.Add(contadorTabla);
                    }

                    //var cabeza = new List<string>();//B20180720P MGC 2018.07.25
                    cabeza.Add(db.TEXTOCVs.Where(x => x.SPRAS_ID == user.SPRAS_ID & x.CAMPO == "materialC").Select(x => x.TEXTO).FirstOrDefault());
                    cabeza.Add(db.TEXTOCVs.Where(x => x.SPRAS_ID == user.SPRAS_ID & x.CAMPO == "categoriaC").Select(x => x.TEXTO).FirstOrDefault());
                    cabeza.Add(db.TEXTOCVs.Where(x => x.SPRAS_ID == user.SPRAS_ID & x.CAMPO == "descripcionC").Select(x => x.TEXTO).FirstOrDefault());
                    if (v.costoun_x == true)
                    {
                        cabeza.Add(db.TEXTOCVs.Where(x => x.SPRAS_ID == user.SPRAS_ID & x.CAMPO == "costouC").Select(x => x.TEXTO).FirstOrDefault());
                    }
                    if (v.apoyo_x == true)
                    {
                        cabeza.Add(db.TEXTOCVs.Where(x => x.SPRAS_ID == user.SPRAS_ID & x.CAMPO == "apoyopoC").Select(x => x.TEXTO).FirstOrDefault());
                    }
                    if (v.apoyop_x == true)
                    {
                        cabeza.Add(db.TEXTOCVs.Where(x => x.SPRAS_ID == user.SPRAS_ID & x.CAMPO == "apoyopiC").Select(x => x.TEXTO).FirstOrDefault());
                    }
                    if (v.costoap_x == true)
                    {
                        cabeza.Add(db.TEXTOCVs.Where(x => x.SPRAS_ID == user.SPRAS_ID & x.CAMPO == "costoaC").Select(x => x.TEXTO).FirstOrDefault());
                    }
                    if (v.precio_x == true)
                    {
                        cabeza.Add(db.TEXTOCVs.Where(x => x.SPRAS_ID == user.SPRAS_ID & x.CAMPO == "preciosC").Select(x => x.TEXTO).FirstOrDefault());
                    }
                    //B20180726 MGC 2018.07.26
                    //if (v.apoyoEst_x == true) { cabeza.Add(db.TEXTOCVs.Where(x => x.SPRAS_ID == user.SPRAS_ID & x.CAMPO == "apoyoeC").Select(x => x.TEXTO).FirstOrDefault()); }
                    //if (v.apoyoRea_x == true) { cabeza.Add(db.TEXTOCVs.Where(x => x.SPRAS_ID == user.SPRAS_ID & x.CAMPO == "apoyorC").Select(x => x.TEXTO).FirstOrDefault()); }
                    //Volumen
                    //B20180726 MGC 2018.07.26
                    if (v.volumen_x == true)
                    {
                        if (fact)
                        {
                            cabeza.Add(db.TEXTOCVs.Where(x => x.SPRAS_ID == user.SPRAS_ID & x.CAMPO == "volumenrC").Select(x => x.TEXTO).FirstOrDefault());
                        }
                        else
                        {
                            cabeza.Add(db.TEXTOCVs.Where(x => x.SPRAS_ID == user.SPRAS_ID & x.CAMPO == "volumeneC").Select(x => x.TEXTO).FirstOrDefault());
                        }
                    }
                    //Apoyo
                    //B20180726 MGC 2018.07.26
                    if (v.apoyototal_x == true)
                    {
                        if (fact)
                        {
                            cabeza.Add(db.TEXTOCVs.Where(x => x.SPRAS_ID == user.SPRAS_ID & x.CAMPO == "apoyorC").Select(x => x.TEXTO).FirstOrDefault());
                        }
                        else
                        {
                            cabeza.Add(db.TEXTOCVs.Where(x => x.SPRAS_ID == user.SPRAS_ID & x.CAMPO == "apoyoeC").Select(x => x.TEXTO).FirstOrDefault());
                        }
                    }
                }
                else
                {
                    v.monto_x = false;//B20180720P MGC 2018.07.25
                }
                /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

                /////////////////////////////////////////////DATOS PARA LA TABLA 2 RECURRENCIAS EN PDF///////////////////////////////////////
                var cabeza2 = new List <string>();
                cabeza2.Add(db.TEXTOCVs.Where(x => x.SPRAS_ID == user.SPRAS_ID & x.CAMPO == "posC2").Select(x => x.TEXTO).FirstOrDefault());
                cabeza2.Add(db.TEXTOCVs.Where(x => x.SPRAS_ID == user.SPRAS_ID & x.CAMPO == "tipoC2").Select(x => x.TEXTO).FirstOrDefault());
                cabeza2.Add(db.TEXTOCVs.Where(x => x.SPRAS_ID == user.SPRAS_ID & x.CAMPO == "fechaC2").Select(x => x.TEXTO).FirstOrDefault());
                cabeza2.Add(db.TEXTOCVs.Where(x => x.SPRAS_ID == user.SPRAS_ID & x.CAMPO == "montoC2").Select(x => x.TEXTO).FirstOrDefault());
                cabeza2.Add(db.TEXTOCVs.Where(x => x.SPRAS_ID == user.SPRAS_ID & x.CAMPO == "porcentajeC2").Select(x => x.TEXTO).FirstOrDefault());

                var con4 = db.DOCUMENTORECs
                           .Where(x => x.NUM_DOC.Equals(v.num_doc))
                           .Join(db.DOCUMENTOes, x => x.NUM_DOC, y => y.NUM_DOC, (x, y) => new { x.POS, y.TSOL_ID, x.FECHAF, x.MONTO_BASE, x.PORC })
                           .ToList();

                foreach (var item in con4)
                {
                    DateTime a = Convert.ToDateTime(item.FECHAF);
                    armadoCuerpoTab2.Add(item.POS.ToString());
                    armadoCuerpoTab2.Add(db.TSOLs.Where(x => x.ID == item.TSOL_ID).Select(x => x.DESCRIPCION).First());
                    armadoCuerpoTab2.Add(a.ToShortDateString());
                    armadoCuerpoTab2.Add(item.MONTO_BASE.ToString());
                    armadoCuerpoTab2.Add(item.PORC.ToString());
                }
                //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

                //MARCA DE AGUA
                bool aprob = false;
                aprob = (d.ESTATUS_WF.Equals("A") | d.ESTATUS_WF.Equals("S"));

                //PARA LA TABLA 1 MATERIALES
                v.numColEncabezado = cabeza;
                v.listaFechas      = encabezadoFech;
                v.numfilasTabla    = numfilasTab;
                v.listaCuerpo      = armadoCuerpoTab;
                //PARA LA TABLA 2 RECURRENCIAS
                v.numColEncabezado2 = cabeza2;
                v.numfilasTabla2    = con4.Count();
                v.listaCuerpoRec    = armadoCuerpoTab2;

                //B20180801 MGC Formato
                decimal montod = 0;
                try
                {
                    montod = Convert.ToDecimal(v.monto);
                }
                catch (Exception)
                {
                }

                v.monto = format.toShow(montod, decimales);

                CartaD          carta = v;
                CartaDEsqueleto cve   = new CartaDEsqueleto();
                cve.crearPDF(carta, user.SPRAS_ID, aprob);
                string recibeRuta = Convert.ToString(Session["rutaCompletaV"]);
                return(RedirectToAction("Index", new { ruta = recibeRuta, ids = v.num_doc }));
            }
        }
Exemplo n.º 6
0
        // GET: CartaD/Details/5
        public ActionResult Create(decimal id, bool?Viewlista)
        {
            int pagina_id = 232; //ID EN BASE DE DATOS

            if (Viewlista == true)
            {
                TempData["return"]     = "LIST";
                TempData["ESTATUS_WF"] = TempData["swf"];
            }
            using (TAT001Entities db = new TAT001Entities())
            {
                string spras_id = FnCommon.ObtenerSprasId(db, User.Identity.Name);
                FnCommon.ObtenerConfPage(db, pagina_id, User.Identity.Name, this.ControllerContext.Controller);

                ViewBag.de  = FnCommonCarta.ObtenerTexto(db, spras_id, "de");
                ViewBag.al  = FnCommonCarta.ObtenerTexto(db, spras_id, "a");
                ViewBag.mon = FnCommonCarta.ObtenerTexto(db, spras_id, "monto");

                try
                {
                    string p = Session["pais"].ToString();
                    ViewBag.pais = p + ".png";
                }
                catch
                {
                    //ViewBag.pais = "mx.png";
                    //return RedirectToAction("Pais", "Home");
                }

                DOCUMENTO d  = new DOCUMENTO();
                PUESTOT   pp = new PUESTOT();
                d = db.DOCUMENTOes.Include("SOCIEDAD").Include("USUARIO").Where(a => a.NUM_DOC.Equals(id)).First();

                ViewBag.dec = d.PAI.DECIMAL;//LEJGG 090718

                List <string> lista = new List <string>();
                List <string> armadoCuerpoTabStr = new List <string>();
                List <int>    numfilasTabla      = new List <int>();
                HeaderFooter  hfc = new HeaderFooter();
                hfc.eliminaArchivos();
                CartaD cv = new CartaD();

                if (d != null)
                {
                    d.CLIENTE = db.CLIENTEs.Where(a => a.VKORG.Equals(d.VKORG) &&
                                                  a.VTWEG.Equals(d.VTWEG) &&
                                                  a.SPART.Equals(d.SPART) &&
                                                  a.KUNNR.Equals(d.PAYER_ID)).First();
                    pp = db.PUESTOTs.Where(a => a.SPRAS_ID.Equals(spras_id) && a.PUESTO_ID == d.USUARIO.PUESTO_ID).FirstOrDefault();
                }
                ViewBag.legal = db.LEYENDAs.Where(a => a.PAIS_ID.Equals(d.PAIS_ID) && a.ACTIVO == true).FirstOrDefault();


                /////////////////////////////////////////////DATOS PARA LA TABLA 1 MATERIALES EN LA VISTA///////////////////////////////////////

                FormatosC format    = new FormatosC();
                string    decimales = d.PAI.DECIMAL; //B20180730 MGC 2018.07.30 Formatos

                //B20180720P MGC 2018.07.25
                bool editmonto = false;
                var  cabeza    = new List <string>();
                List <listacuerpoc> armadoCuerpoTab = null;
                bool varligada = Convert.ToBoolean(d.LIGADA);
                if (!varligada)
                {
                    FnCommonCarta.ObtenerCartaProductos(db, d, null, null, spras_id, false,
                                                        ref lista,
                                                        ref armadoCuerpoTab,
                                                        ref armadoCuerpoTabStr,
                                                        ref numfilasTabla,
                                                        ref cabeza,
                                                        ref editmonto);

                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                }
                /////////////////////////////////////////////DATOS PARA LA TABLA 2 RECURRENCIAS EN LA VISTA///////////////////////////////////////
                var           cabeza2          = new List <string>();
                var           cabeza3          = new List <string>();
                List <string> armadoCuerpoTab2 = new List <string>();
                List <string> armadoCuerpoTab3 = new List <string>();
                int           rowsRecs         = 0;
                int           rowsObjQs        = 0;
                FnCommonCarta.ObtenerCartaRecurrentes(db, d, spras_id,
                                                      ref cabeza2,
                                                      ref armadoCuerpoTab2,
                                                      ref rowsRecs,
                                                      ref cabeza3,
                                                      ref armadoCuerpoTab3,
                                                      ref rowsObjQs,
                                                      false, format.toShow((decimal)d.MONTO_DOC_MD, decimales));//RSG 27.12.2018

                //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

                //TABLA 1 MATERIALES
                cv.listaFechas      = lista;              //////////////RANGO DE FECHAS QUE DETERMINAN EL NUMERO DE TABLAS
                cv.numfilasTabla    = numfilasTabla;      ////NUMERO FILAS POR TABLA CALCULADA
                cv.listaCuerpo      = armadoCuerpoTabStr; ////NUMERO TOTAL DE FILAS CON LA INFO CORRESPONDIENTE QUE POSTERIORMENTE ES DISTRIBUIDA EN LAS TABLAS
                cv.numColEncabezado = cabeza;             ////////NUMERO DE COLUMNAS PARA LAS TABLAS
                cv.secondTab_x      = true;
                cv.tercerTab_x      = true;
                cv.material_x       = (armadoCuerpoTabStr != null && armadoCuerpoTabStr.Any() && !string.IsNullOrEmpty(armadoCuerpoTabStr.First()));
                cv.costoun_x        = true;
                cv.apoyo_x          = true;
                cv.apoyop_x         = true;
                cv.costoap_x        = true;
                cv.precio_x         = true;
                //B20180726 MGC 2018.07.26
                cv.volumen_x    = true;
                cv.apoyototal_x = true;
                /////////////////////////////////

                //TABLA 2 RECURRENCIAS
                cv.numColEncabezado2 = cabeza2;          ////////NUMERO DE COLUMNAS PARA LAS TABLAS
                cv.numfilasTabla2    = rowsRecs;         //////NUMERO FILAS TOTAL PARA LA TABLA
                cv.listaCuerpoRec    = armadoCuerpoTab2; //NUMERO TOTAL DE FILAS CON LA INFO CORRESPONDIENTE
                ///////////////////////////////

                //TABLA 3 OBJECTIVO Q
                cv.numColEncabezado3 = cabeza3;          ////////NUMERO DE COLUMNAS PARA LAS TABLAS
                cv.numfilasTabla3    = rowsObjQs;        //////NUMERO FILAS TOTAL PARA LA TABLA
                cv.listaCuerpoObjQ   = armadoCuerpoTab3; //NUMERO TOTAL DE FILAS CON LA INFO CORRESPONDIENTE
                ///////////////////////////////

                cv.num_doc     = id;
                cv.company     = d.SOCIEDAD.BUTXT;
                cv.company_x   = true;
                cv.taxid       = d.SOCIEDAD.LAND;
                cv.taxid_x     = true;
                cv.concepto    = d.CONCEPTO;
                cv.concepto_x  = true;
                cv.cliente     = d.PAYER_NOMBRE;
                cv.cliente_x   = true;
                cv.puesto      = " ";
                cv.puesto_x    = false;
                cv.direccion   = d.CLIENTE.STRAS_GP;
                cv.direccion_x = true;
                cv.folio       = d.NUM_DOC.ToString();
                cv.folio_x     = true;
                cv.lugar       = d.CIUDAD.Trim() + ", " + d.ESTADO.Trim();
                cv.lugar_x     = true;
                cv.lugarFech   = DateTime.Now.ToShortDateString();
                cv.lugarFech_x = true;
                cv.payerId     = d.CLIENTE.PAYER;
                cv.payerId_x   = true;
                cv.payerNom    = d.CLIENTE.NAME1;
                cv.payerNom_x  = true;
                cv.estimado    = d.PAYER_NOMBRE;
                cv.estimado_x  = true;
                cv.mecanica    = d.NOTAS;
                cv.mecanica_x  = true;
                cv.nombreE     = d.USUARIO.NOMBRE + " " + d.USUARIO.APELLIDO_P + " " + d.USUARIO.APELLIDO_M;
                cv.nombreE_x   = true;
                if (pp != null)
                {
                    cv.puestoE = pp.TXT50;
                }
                cv.puestoE_x   = true;
                cv.companyC    = cv.company;
                cv.companyC_x  = true;
                cv.nombreC     = d.PAYER_NOMBRE;
                cv.nombreC_x   = true;
                cv.puestoC     = " ";
                cv.puestoC_x   = false;
                cv.companyCC   = d.CLIENTE.NAME1;
                cv.companyCC_x = true;
                if (ViewBag.legal != null)
                {
                    cv.legal = ViewBag.legal.LEYENDA1;
                }
                cv.legal_x       = true;
                cv.mail          = FnCommonCarta.ObtenerTexto(db, spras_id, "correo") + " " + d.PAYER_EMAIL;
                cv.mail_x        = true;
                cv.comentarios   = "";
                cv.comentarios_x = true;
                cv.compromisoK   = "";
                cv.compromisoK_x = true;
                cv.compromisoC   = "";
                cv.compromisoC_x = true;
                cv.monto_x       = true;
                cv.monto         = d.MONTO_DOC_MD.ToString();
                cv.moneda        = d.MONEDA_ID;

                //B20180720P MGC 2018.07.25
                ViewBag.varligada = varligada;

                //B20180801 MGC Formato
                decimal montod = 0;
                try
                {
                    montod = Convert.ToDecimal(cv.monto);
                }
                catch (Exception e)
                {
                    Log.ErrorLogApp(e, "CartaD", "Create");
                }

                ViewBag.montoformat = format.toShow(montod, decimales);

                return(View(cv));
            }
        }
Exemplo n.º 7
0
        public ActionResult Create(CartaD v)
        {
            TempData["lista"] = TempData["vista"];
            using (TAT001Entities db = new TAT001Entities())
            {
                string spras_id = FnCommon.ObtenerSprasId(db, User.Identity.Name);

                List <string> encabezadoFech     = new List <string>();
                List <string> armadoCuerpoTabStr = new List <string>();
                List <int>    numfilasTab        = new List <int>();

                DOCUMENTO d = db.DOCUMENTOes.Find(v.num_doc);


                //Formatos para numeros
                d.PAI = db.PAIS.Where(a => a.LAND.Equals(d.PAIS_ID)).FirstOrDefault();
                // string miles = d.PAI.MILES; //B20180730 MGC 2018.07.30 Formatos
                string decimales = d.PAI.DECIMAL;   //B20180730 MGC 2018.07.30 Formatos

                FormatosC format = new FormatosC(); //B20180730 MGC 2018.07.30 Formatos

                /////////////////////////////////////////////DATOS PARA LA TABLA 1 MATERIALES EN EL PDF///////////////////////////////////////
                //B20180720P MGC 2018.07.25
                bool editmonto = false;
                var  cabeza    = new List <string>();
                List <listacuerpoc> armadoCuerpoTab = null;
                bool varligada = Convert.ToBoolean(d.LIGADA);
                if (!varligada)
                {
                    FnCommonCarta.ObtenerCartaProductos(db, d, v, null, spras_id, false,
                                                        ref encabezadoFech,
                                                        ref armadoCuerpoTab,
                                                        ref armadoCuerpoTabStr,
                                                        ref numfilasTab,
                                                        ref cabeza,
                                                        ref editmonto);

                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                }
                /////////////////////////////////////////////DATOS PARA LA TABLA 2 RECURRENCIAS EN LA VISTA///////////////////////////////////////
                var           cabeza2          = new List <string>();
                var           cabeza3          = new List <string>();
                List <string> armadoCuerpoTab2 = new List <string>();
                List <string> armadoCuerpoTab3 = new List <string>();
                int           rowsRecs         = 0;
                int           rowsObjQs        = 0;
                FnCommonCarta.ObtenerCartaRecurrentes(db, d, spras_id,
                                                      ref cabeza2,
                                                      ref armadoCuerpoTab2,
                                                      ref rowsRecs,
                                                      ref cabeza3,
                                                      ref armadoCuerpoTab3,
                                                      ref rowsObjQs,
                                                      true, format.toShow((decimal)d.MONTO_DOC_MD, decimales));//RSG 27.12.2018

                //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

                //MARCA DE AGUA
                bool aprob = false;
                bool apTS  = (d.ESTATUS_WF.Equals("P") && db.FLUJOes.Any(x => x.STATUS == "N  PRP  0" && x.NUM_DOC == d.NUM_DOC));
                aprob = (d.ESTATUS_WF.Equals("A") || d.ESTATUS_WF.Equals("S") || apTS);

                //PARA LA TABLA 1 MATERIALES
                v.numColEncabezado = cabeza;
                v.listaFechas      = encabezadoFech;
                v.numfilasTabla    = numfilasTab;
                v.listaCuerpo      = armadoCuerpoTabStr;
                //PARA LA TABLA 2 RECURRENCIAS
                v.numColEncabezado2 = cabeza2;
                v.numfilasTabla2    = rowsRecs;
                v.listaCuerpoRec    = armadoCuerpoTab2;

                //TABLA 3 OBJECTIVO Q
                v.numColEncabezado3 = cabeza3;          ////////NUMERO DE COLUMNAS PARA LAS TABLAS
                v.numfilasTabla3    = rowsObjQs;        //////NUMERO FILAS TOTAL PARA LA TABLA
                v.listaCuerpoObjQ   = armadoCuerpoTab3; //NUMERO TOTAL DE FILAS CON LA INFO CORRESPONDIENTE
                ///////////////////////////////
                //B20180801 MGC Formato
                decimal montod = 0;
                try
                {
                    montod = Convert.ToDecimal(v.monto);
                }
                catch (Exception e)
                {
                    Log.ErrorLogApp(e, "CartaD", "Create");
                }

                v.monto = format.toShow(montod, decimales);

                CartaD          carta      = v;
                CartaDEsqueleto cve        = new CartaDEsqueleto();
                string          recibeRuta = cve.crearPDF(carta, spras_id, aprob);
                return(RedirectToAction("Index", new { ruta = recibeRuta, ids = v.num_doc }));
            }
        }
Exemplo n.º 8
0
        public SOLICITUD_MOD getSolicitud(string num, string num2, string d) //RSG 07.06.2018---------------------------------------------
        {
            TAT001.Models.SOLICITUD_MOD sm     = new SOLICITUD_MOD();
            Services.FormatosC          format = new FormatosC();

            //Obtener info solicitud
            if (num == null | num == "" | num == "0.00")
            {
                sm.S_NUM    = num = "";
                sm.S_MONTOB = format.toShow(Convert.ToDecimal(num2), d);
                sm.S_MONTOP = sm.S_MONTOB;
                sm.S_MONTOA = "-";
                sm.S_REMA   = "-";
                sm.S_IMPA   = "-";
                sm.S_IMPB   = "-";
                sm.S_IMPC   = "-";
                sm.S_RET    = "-";
                sm.S_TOTAL  = format.toShow(Convert.ToDecimal(num2), d);;
            }
            else
            {
                decimal hola = Convert.ToDecimal(num);
                var     rev  = db.DOCUMENTOes.Where(x => x.DOCUMENTO_REF == hola).ToList();
                ;

                if (rev.Count() == 0)
                {
                    //CON UN RELACIONADO
                    var     rev2 = db.DOCUMENTOes.Where(x => x.NUM_DOC == hola).FirstOrDefault();
                    decimal?rem2 = (rev2.MONTO_DOC_MD - Convert.ToDecimal(num2));

                    sm.S_MONTOB = format.toShow(Convert.ToDecimal(num2), d);
                    sm.S_MONTOP = format.toShow(0, d);
                    sm.S_MONTOA = "-";
                    sm.S_REMA   = format.toShow((decimal)rem2, d);
                    sm.S_IMPA   = "-";
                    sm.S_IMPB   = "-";
                    sm.S_IMPC   = "-";
                    sm.S_RET    = "-";
                    sm.S_TOTAL  = format.toShow(Convert.ToDecimal(num2), d);;
                }
                else if (rev.Count() == 1)
                {
                    //CON DOS RELACIONADOS
                    var     rev3  = db.DOCUMENTOes.Where(x => x.NUM_DOC == hola).FirstOrDefault();
                    var     rev33 = db.DOCUMENTOes.Where(x => x.DOCUMENTO_REF == hola).FirstOrDefault();
                    decimal?rem3  = ((rev3.MONTO_DOC_MD - rev33.MONTO_DOC_MD) - (Convert.ToDecimal(num2)));

                    sm.S_MONTOB = format.toShow(Convert.ToDecimal(num2), d);
                    sm.S_MONTOP = format.toShow((decimal)rev3.MONTO_DOC_MD, d);
                    sm.S_MONTOA = format.toShow((decimal)rev33.MONTO_DOC_MD - Convert.ToDecimal(num2), d);
                    sm.S_REMA   = format.toShow((decimal)rem3 + Convert.ToDecimal(num2), d);
                    sm.S_IMPA   = "-";
                    sm.S_IMPB   = "-";
                    sm.S_IMPC   = "-";
                    sm.S_RET    = "-";
                    sm.S_TOTAL  = format.toShow(Convert.ToDecimal(num2), d);;
                }
                else if (rev.Count() > 1)
                {
                    var     rev4  = db.DOCUMENTOes.Where(x => x.NUM_DOC == hola).FirstOrDefault();
                    var     rev44 = db.DOCUMENTOes.Where(x => x.DOCUMENTO_REF == hola).Select(x => x.MONTO_DOC_MD);
                    decimal sum   = 0;

                    foreach (var k in rev44)
                    {
                        sum = sum + k.Value;
                    }
                    decimal?rem4 = ((rev4.MONTO_DOC_MD - sum) - (Convert.ToDecimal(num2)));

                    sm.S_MONTOB = format.toShow(Convert.ToDecimal(num2), d);
                    sm.S_MONTOP = format.toShow((decimal)rev4.MONTO_DOC_MD, d);
                    sm.S_MONTOA = format.toShow(sum - Convert.ToDecimal(num2), d);
                    sm.S_REMA   = format.toShow((-sum + (decimal)rev4.MONTO_DOC_MD + Convert.ToDecimal(num2)), d);
                    sm.S_IMPA   = "-";
                    sm.S_IMPB   = "-";
                    sm.S_IMPC   = "-";
                    sm.S_RET    = "-";
                    sm.S_TOTAL  = format.toShow(Convert.ToDecimal(num2), d);
                }
            }

            //JsonResult cc = Json(sm, JsonRequestBehavior.AllowGet);
            return(sm);
        }
Exemplo n.º 9
0
        // GET: Correos
        public ActionResult Index(decimal id, bool?mail)  //B20180803 MGC Correos
        {
            var dOCUMENTO = db.DOCUMENTOes.Where(x => x.NUM_DOC == id).FirstOrDefault();
            var flujo     = db.FLUJOes.Where(x => x.NUM_DOC == id).OrderByDescending(o => o.POS).Select(s => s.POS).ToList();

            ViewBag.Pos = flujo[0];
            ViewBag.url = "http://localhost:64497";
            ViewBag.url = "http://192.168.1.77";
            ViewBag.url = Request.Url.AbsoluteUri.Replace(Request.Url.AbsolutePath, "");
            //ViewBag.miles = dOCUMENTOes.PAI.MILES;//LEJGG 090718
            //ViewBag.dec = dOCUMENTOes.PAI.DECIMAL;//LEJGG 090718
            FormatosC fc = new FormatosC();

            ViewBag.monto = fc.toShow((decimal)dOCUMENTO.MONTO_DOC_MD, dOCUMENTO.PAI.DECIMAL) + " " + dOCUMENTO.MONEDA_ID;
            if (mail == null)
            {
                mail = true;
            }
            //B20180803 MGC Correos............
            string mailv = "";

            if (mail != null)
            {
                if (mail == true)
                {
                    mailv = "X";
                }
            }

            ViewBag.mail = mailv;
            //B20180803 MGC Correos............

            //B20180803 MGC Presupuesto............
            Models.PresupuestoModels carga = new Models.PresupuestoModels();
            ViewBag.ultMod = carga.consultarUCarga();

            dOCUMENTO.PAI = db.PAIS.Where(a => a.LAND.Equals(dOCUMENTO.PAIS_ID)).FirstOrDefault();
            if (dOCUMENTO.PAI != null)
            {
                ViewBag.miles = dOCUMENTO.PAI.MILES;   //LEJGG 090718
                ViewBag.dec   = dOCUMENTO.PAI.DECIMAL; //LEJGG 090718
            }

            CLIENTE_MOD cli = new CLIENTE_MOD();

            cli = SelectCliente(dOCUMENTO.PAYER_ID);

            ViewBag.kunnr = cli.KUNNR + "-" + cli.NAME1;
            ViewBag.vtweg = cli.VTWEG;

            Services.FormatosC format = new FormatosC();

            PRESUPUESTO_MOD presu = new PRESUPUESTO_MOD();

            presu = getPresupuesto(dOCUMENTO.PAYER_ID);

            decimal pcanal = 0;

            try
            {
                pcanal = Convert.ToDecimal(presu.P_CANAL) / 1;
            }
            catch (Exception)
            {
            }
            decimal pbanner = 0;

            try
            {
                pbanner = Convert.ToDecimal(presu.P_BANNER) / 1;
            }
            catch (Exception)
            {
            }
            decimal pcc = 0;

            try
            {
                pcc = Convert.ToDecimal(presu.PC_C) / 1 * -1;
            }
            catch (Exception)
            {
            }
            decimal pca = 0;

            try
            {
                pca = Convert.ToDecimal(presu.PC_A) / 1 * -1;
            }
            catch (Exception)
            {
            }
            decimal pcp = 0;

            try
            {
                pcp = Convert.ToDecimal(presu.PC_P) / 1 * -1;
            }
            catch (Exception)
            {
            }
            decimal pct = 0;

            try
            {
                pct = Convert.ToDecimal(presu.PC_T) / 1 * -1;
            }
            catch (Exception)
            {
            }
            decimal consu = 0;

            try
            {
                consu = Convert.ToDecimal(presu.CONSU) / 1;
            }
            catch (Exception)
            {
            }
            ViewBag.pcan  = format.toShowG(pcanal, dOCUMENTO.PAI.DECIMAL);
            ViewBag.pban  = format.toShowG(pbanner, dOCUMENTO.PAI.DECIMAL);
            ViewBag.pcc   = format.toShowG(pcc, dOCUMENTO.PAI.DECIMAL);
            ViewBag.pca   = format.toShowG(pca, dOCUMENTO.PAI.DECIMAL);
            ViewBag.pcp   = format.toShowG(pcp, dOCUMENTO.PAI.DECIMAL);
            ViewBag.pct   = format.toShowG(pct, dOCUMENTO.PAI.DECIMAL);
            ViewBag.consu = format.toShowG(consu, dOCUMENTO.PAI.DECIMAL);

            SOLICITUD_MOD sol = new SOLICITUD_MOD();

            if (dOCUMENTO.DOCUMENTO_REF == null)
            {
                sol = getSolicitud("0.00", dOCUMENTO.MONTO_DOC_MD + "", dOCUMENTO.PAI.DECIMAL);
            }
            else
            {
                sol = getSolicitud(dOCUMENTO.DOCUMENTO_REF + "", dOCUMENTO.MONTO_DOC_MD + "", dOCUMENTO.PAI.DECIMAL);
            }

            ViewBag.S_IMPA     = sol.S_IMPA;
            ViewBag.S_IMPB     = sol.S_IMPB;
            ViewBag.S_IMPC     = sol.S_IMPC;
            ViewBag.S_MONTOA   = sol.S_MONTOA;
            ViewBag.S_MONTOB   = sol.S_MONTOB;
            ViewBag.S_MONTOP   = sol.S_MONTOP;
            ViewBag.S_NUM      = sol.S_NUM;
            ViewBag.S_REMA     = sol.S_REMA;
            ViewBag.rema_color = "";
            if (format.toNum(sol.S_REMA, dOCUMENTO.PAI.MILES, dOCUMENTO.PAI.DECIMAL) < 0)
            {
                ViewBag.rema_color = "#F44336 !important";
            }

            ViewBag.S_RET   = sol.S_RET;
            ViewBag.S_TOTAL = sol.S_TOTAL;

            //B20180803 MGC Presupuesto............

            return(View(dOCUMENTO));
        }
Exemplo n.º 10
0
        public static void ObtenerCartaRecurrentes(TruequeEntities db, DOCUMENTO d, string spras_id,
                                                   ref List <string> cabeza2,
                                                   ref List <string> armadoCuerpoTab2,
                                                   ref int rowsRecs,
                                                   ref List <string> cabeza3,
                                                   ref List <string> armadoCuerpoTab3,
                                                   ref int rowsObjQs,
                                                   bool esPdf, string monto)
        {
            FormatosC format    = new FormatosC();
            string    decimales = d.PAI.DECIMAL; //B20180730 MGC 2018.07.30 Formatos
            bool      varligada = Convert.ToBoolean(d.LIGADA);
            bool      conRan    = db.DOCUMENTORANs.Any(x => x.LIN == 1 && x.NUM_DOC == d.NUM_DOC);
            int       rowRan    = 0;

            cabeza2.Add(ObtenerTexto(db, spras_id, "posC2"));
            cabeza2.Add(ObtenerTexto(db, spras_id, "periodoC"));
            cabeza2.Add(ObtenerTexto(db, spras_id, "tipoC2"));
            if (varligada)
            {
                cabeza2.Add(ObtenerTexto(db, spras_id, "porcentajeC2"));
                if (conRan)
                {
                    cabeza2.Add(ObtenerTexto(db, spras_id, "objetivo"));
                }
                else if (!esPdf)
                {
                    cabeza2.Add("");
                }
            }
            else
            {
                if (d.TIPO_TECNICO == "P")
                {
                    cabeza2.Add(ObtenerTexto(db, spras_id, "porcentajeC2"));
                    if (!esPdf)
                    {
                        cabeza2.Add("");
                    }
                }
                else
                {
                    cabeza2.Add(ObtenerTexto(db, spras_id, "montoC2"));
                    if (!esPdf)
                    {
                        cabeza2.Add("");
                    }
                }
            }

            var con4 = db.DOCUMENTORECs
                       .Where(x => x.NUM_DOC.Equals(d.NUM_DOC))
                       .Join(db.DOCUMENTOes, x => x.NUM_DOC, y => y.NUM_DOC, (x, y) => new { x.POS, y.TSOL_ID, x.MONTO_BASE, x.PORC, x.PERIODO, x.EJERCICIO })
                       .ToList();

            foreach (var item in con4)
            {
                string periodo = "P" + item.PERIODO + "-" + item.EJERCICIO;
                string tsol    = tiposSolicitudesDao.ListaTiposSolicitudes(spras_id, item.TSOL_ID).First().TXT50;
                string posStr  = item.POS.ToString() + "/" + con4.Count.ToString();

                armadoCuerpoTab2.Add(posStr);
                armadoCuerpoTab2.Add(periodo);
                armadoCuerpoTab2.Add(tsol);
                if (varligada)
                {
                    if (conRan)
                    {
                        DOCUMENTORAN docRan = db.DOCUMENTORANs.First(x => x.LIN == 1 && x.NUM_DOC == d.NUM_DOC && x.POS == item.POS);

                        armadoCuerpoTab2.Add(format.toShowPorc(docRan.PORCENTAJE.Value, decimales));
                        armadoCuerpoTab2.Add(format.toShow(Math.Round(docRan.OBJETIVOI.Value, 2), decimales));

                        foreach (DOCUMENTORAN itemTan in db.DOCUMENTORANs.Where(x => x.LIN != 1 && x.NUM_DOC == d.NUM_DOC && x.POS == item.POS))
                        {
                            armadoCuerpoTab2.AddRange(new List <string> {
                                "", "", ""
                            });
                            armadoCuerpoTab2.Add(format.toShowPorc(itemTan.PORCENTAJE.Value, decimales));
                            armadoCuerpoTab2.Add(format.toShow(Math.Round(itemTan.OBJETIVOI.Value, 2), decimales));
                            rowRan++;
                        }
                    }
                    else
                    {
                        armadoCuerpoTab2.Add(format.toShowPorc(item.PORC.Value, decimales));
                        if (!esPdf)
                        {
                            armadoCuerpoTab2.Add("");
                        }
                    }
                }
                else
                {
                    if (d.TIPO_TECNICO == "P")
                    {
                        armadoCuerpoTab2.Add(format.toShowPorc(item.PORC.Value, decimales));
                        if (!esPdf)
                        {
                            armadoCuerpoTab2.Add("");
                        }
                    }
                    else
                    {
                        ////armadoCuerpoTab2.Add(format.toShow(Math.Round(item.MONTO_BASE.Value, 2), decimales));
                        armadoCuerpoTab2.Add(monto);//ADD RSG 27.12.2018
                        if (!esPdf)
                        {
                            armadoCuerpoTab2.Add("");
                        }
                    }
                }
            }
            rowsRecs = (con4.Count + rowRan);


            bool conObjetivoQ = (d.OBJETIVOQ != null && d.OBJETIVOQ.Value);

            ///TABLA OBJETIVO Q
            if (conObjetivoQ)
            {
                cabeza3.Add(ObtenerTexto(db, spras_id, "posC2"));
                cabeza3.Add(ObtenerTexto(db, spras_id, "periodoC"));
                cabeza3.Add(ObtenerTexto(db, spras_id, "tipoC2"));


                cabeza3.Add(ObtenerTexto(db, spras_id, "porcentajeC2"));
                if (conRan)
                {
                    cabeza3.Add(ObtenerTexto(db, spras_id, "objetivo"));
                }
                else if (!esPdf)
                {
                    cabeza3.Add("");
                }

                foreach (var item in con4)
                {
                    string periodo = "P" + item.PERIODO + "-" + item.EJERCICIO;
                    string tsol    = tiposSolicitudesDao.ListaTiposSolicitudes(spras_id, item.TSOL_ID).First().TXT50;
                    string posStr  = item.POS.ToString() + "/" + con4.Count.ToString();
                    armadoCuerpoTab3.Add(posStr);
                    armadoCuerpoTab3.Add(periodo);
                    armadoCuerpoTab3.Add(tsol);

                    if (conRan)
                    {
                        DOCUMENTORAN docRan = db.DOCUMENTORANs.First(x => x.LIN == 1 && x.NUM_DOC == d.NUM_DOC && x.POS == item.POS);

                        armadoCuerpoTab3.Add(format.toShowPorc(d.OBJQ_PORC.Value, decimales));
                        armadoCuerpoTab3.Add(format.toShow(Math.Round(docRan.OBJETIVOI.Value, 2), decimales));
                    }
                    else
                    {
                        armadoCuerpoTab3.Add(format.toShowPorc(d.OBJQ_PORC.Value, decimales));
                        if (!esPdf)
                        {
                            armadoCuerpoTab2.Add("");
                        }
                    }
                }
                rowsObjQs = con4.Count;
            }
        }
Exemplo n.º 11
0
        public static void ObtenerCartaCategoriasHtml(List <DOCUMENTOP_CAT> con3, string decimales, bool fact, string tipo_tecnico,
                                                      ref List <listacuerpoc> armadoCuerpoTab,
                                                      ref int contadorTabla)
        {
            FormatosC format = new FormatosC();

            foreach (var item2 in con3)
            {
                //B20180710 MGC 2018.07.10 Modificaciones para editar los campos de distribución se agrego los objetos
                listacuerpoc lc1 = new listacuerpoc();
                lc1.val   = "";
                lc1.clase = "ni";
                armadoCuerpoTab.Add(lc1);

                listacuerpoc lc2 = new listacuerpoc();
                lc2.val   = item2.MATKL;
                lc2.clase = "ni";
                armadoCuerpoTab.Add(lc2);

                listacuerpoc lc3 = new listacuerpoc();
                lc3.val   = item2.TXT50;
                lc3.clase = "ni";
                armadoCuerpoTab.Add(lc3);

                //Costo unitario
                listacuerpoc lc4 = new listacuerpoc();
                lc4.val   = format.toShow(0, decimales); //B20180730 MGC 2018.07.30 Formatos
                lc4.clase = "ni";
                armadoCuerpoTab.Add(lc4);

                //Porcentaje de apoyo
                listacuerpoc lc5 = new listacuerpoc();
                //Definición si la distribución es monto o porcentaje
                if (tipo_tecnico == "M")
                {
                    lc5.val = format.toShowPorc(0, decimales); //B20180730 MGC 2018.07.30 Formatos
                }
                else if (tipo_tecnico == "P")
                {
                    lc5.val = format.toShowPorc(Math.Round(item2.PORC_APOYO, 2), decimales); //B20180730 MGC 2018.07.30 Formatos
                }

                lc5.clase = "ni";
                armadoCuerpoTab.Add(lc5);

                //Apoyo por pieza
                listacuerpoc lc6 = new listacuerpoc();
                lc6.val   = format.toShow(0, decimales); //B20180730 MGC 2018.07.30 Formatos
                lc6.clase = "ni";
                armadoCuerpoTab.Add(lc6);

                //Costo con apoyo
                listacuerpoc lc7 = new listacuerpoc();
                lc7.val   = format.toShow(0, decimales); //B20180730 MGC 2018.07.30 Formatos
                lc7.clase = "ni";
                armadoCuerpoTab.Add(lc7);

                //Precio Sugerido
                listacuerpoc lc8 = new listacuerpoc();
                lc8.val   = format.toShow(0, decimales); //B20180730 MGC 2018.07.30 Formatos
                lc8.clase = "ni";
                armadoCuerpoTab.Add(lc8);
                //Modificación 9 y 10 dependiendo del campo de factura en tsol
                //fact = true es real

                //Volumen
                listacuerpoc lc9 = new listacuerpoc();
                lc9.val = format.toShowNum(0, decimales); //B20180730 MGC 2018.07.30 Formatos

                lc9.clase = "ni";
                armadoCuerpoTab.Add(lc9);

                //Apoyo
                listacuerpoc lc10 = new listacuerpoc();
                if (fact)
                {
                    lc10.val = format.toShow(Math.Round(Convert.ToDecimal(item2.APOYO_REAL), 2), decimales); //B20180730 MGC 2018.07.30 Formatos
                }
                else
                {
                    lc10.val = format.toShow(Math.Round(Convert.ToDecimal(item2.APOYO_EST), 2), decimales); //B20180730 MGC 2018.07.30 Formatos
                }
                //Definición si la distribución es monto o porcentaje
                if (tipo_tecnico == "M")
                {
                    lc10.clase = "input_oper numberd input_dc total cat mon";
                }
                else if (tipo_tecnico == "P")
                {
                    lc10.clase = "ni";
                }

                armadoCuerpoTab.Add(lc10);

                contadorTabla++;
            }
        }
Exemplo n.º 12
0
        public static void ObtenerCartaCategoriasPdf(TruequeEntities db, CartaD cd, CartaV cv, List <DOCUMENTOP_CAT> con3, string decimales, bool fact, bool guardar,
                                                     ref int indexp,
                                                     ref List <string> armadoCuerpoTabStr,
                                                     ref int contadorTabla)
        {
            FormatosC format = new FormatosC();

            foreach (var item2 in con3)
            {
                if (guardar)
                {
                    int pos = db.CARTAs.Where(a => a.NUM_DOC.Equals(cv.num_doc)).OrderByDescending(a => a.POS).First().POS;
                    GuardarCartaPCategorias(db, cv, item2.MATKL, pos, ref indexp, fact, item2.VIGENCIA_DE.Value, item2.VIGENCIA_AL.Value);
                }
                if (cd != null || cv != null)
                {
                    DOCUMENTOP_MOD docmod = new DOCUMENTOP_MOD();
                    if (cv != null)
                    {
                        docmod = cv.DOCUMENTOP.FirstOrDefault(x => x.MATKL_ID == item2.MATKL);
                    }
                    if (cd != null)
                    {
                        docmod = new DOCUMENTOP_MOD
                        {
                            MONTO        = item2.MONTO,
                            PORC_APOYO   = item2.PORC_APOYO,
                            MONTO_APOYO  = item2.MONTO_APOYO,
                            PRECIO_SUG   = item2.PRECIO_SUG,
                            VOLUMEN_REAL = item2.VOLUMEN_REAL,
                            VOLUMEN_EST  = item2.VOLUMEN_EST,
                            APOYO_REAL   = item2.APOYO_REAL,
                            APOYO_EST    = item2.APOYO_EST
                        };
                    }
                    if ((cd != null && cd.material_x) || (cv != null && cv.material_x))
                    {
                        armadoCuerpoTabStr.Add("");
                    }
                    armadoCuerpoTabStr.Add(item2.MATKL);
                    MATERIALGP mt = db.MATERIALGPs.Where(x => x.ID == item2.MATKL).FirstOrDefault();//RSG 03.10.2018
                    if (mt != null)
                    {
                        armadoCuerpoTabStr.Add(mt.DESCRIPCION);//RSG 03.10.2018
                    }
                    else
                    {
                        armadoCuerpoTabStr.Add("");
                    }

                    if ((cd != null && cd.costoun_x) || (cv != null && cv.costoun_x))
                    {
                        armadoCuerpoTabStr.Add(format.toShow(Math.Round(docmod.MONTO, 2), decimales));//B20180730 MGC 2018.07.30 Formatos
                    }
                    if ((cd != null && cd.apoyo_x) || (cv != null && cv.apoyo_x))
                    {
                        armadoCuerpoTabStr.Add(format.toShowPorc(Math.Round(docmod.PORC_APOYO, 2), decimales));//B20180730 MGC 2018.07.30 Formatos
                    }
                    if ((cd != null && cd.apoyop_x) || (cv != null && cv.apoyop_x))
                    {
                        armadoCuerpoTabStr.Add(format.toShow(Math.Round(docmod.MONTO_APOYO, 2), decimales));//B20180730 MGC 2018.07.30 Formatos
                    }

                    if ((cd != null && cd.costoap_x) || (cv != null && cv.costoap_x))
                    {
                        armadoCuerpoTabStr.Add(format.toShow(Math.Round((docmod.MONTO - docmod.MONTO_APOYO), 2), decimales));//B20180730 MGC 2018.07.30 Formatos
                    }
                    if ((cd != null && cd.precio_x) || (cv != null && cv.precio_x))
                    {
                        armadoCuerpoTabStr.Add(format.toShow(Math.Round(docmod.PRECIO_SUG, 2), decimales));//B20180730 MGC 2018.07.30 Formatos
                    }

                    //Volumen
                    //B20180726 MGC 2018.07.26
                    if ((cd != null && cd.volumen_x) || (cv != null && cv.volumen_x))
                    {
                        if (fact)
                        {
                            armadoCuerpoTabStr.Add(format.toShowNum(Math.Round(Convert.ToDecimal(docmod.VOLUMEN_REAL), 2), decimales));//B20180730 MGC 2018.07.30 Formatos
                        }
                        else
                        {
                            armadoCuerpoTabStr.Add(format.toShowNum(Math.Round(Convert.ToDecimal(docmod.VOLUMEN_EST), 2), decimales));//B20180730 MGC 2018.07.30 Formatos
                        }
                    }

                    //Apoyo
                    //B20180726 MGC 2018.07.26
                    if ((cd != null && cd.apoyototal_x) || (cv != null && cv.apoyototal_x))
                    {
                        if (fact)
                        {
                            armadoCuerpoTabStr.Add(format.toShow(Math.Round(Convert.ToDecimal(docmod.APOYO_REAL), 2), decimales));//B20180730 MGC 2018.07.30 Formatos
                        }
                        else
                        {
                            armadoCuerpoTabStr.Add(format.toShow(Math.Round(Convert.ToDecimal(docmod.APOYO_EST), 2), decimales));//B20180730 MGC 2018.07.30 Formatos
                        }
                    }
                }
                else
                {
                    armadoCuerpoTabStr.Add("");
                    armadoCuerpoTabStr.Add(item2.MATKL);
                    armadoCuerpoTabStr.Add(item2.TXT50);
                    armadoCuerpoTabStr.Add(format.toShow(Math.Round(item2.MONTO, 2), decimales));          //B20180730 MGC 2018.07.30 Formatos
                    armadoCuerpoTabStr.Add(format.toShowPorc(Math.Round(item2.PORC_APOYO, 2), decimales)); //B20180730 MGC 2018.07.30 Formatos
                    armadoCuerpoTabStr.Add(format.toShow(Math.Round(item2.MONTO_APOYO, 2), decimales));    //B20180730 MGC 2018.07.30 Formatos
                    armadoCuerpoTabStr.Add(format.toShow(Math.Round(item2.RESTA, 2), decimales));          //B20180730 MGC 2018.07.30 Formatos
                    armadoCuerpoTabStr.Add(format.toShow(Math.Round(item2.PRECIO_SUG, 2), decimales));     //B20180730 MGC 2018.07.30 Formatos
                                                                                                           //B20180726 MGC 2018.07.26
                    if (fact)
                    {
                        armadoCuerpoTabStr.Add(format.toShowNum(Math.Round(Convert.ToDecimal(item2.VOLUMEN_REAL), 2), decimales)); //B20180730 MGC 2018.07.30 Formatos
                        armadoCuerpoTabStr.Add(format.toShow(Math.Round(Convert.ToDecimal(item2.APOYO_REAL), 2), decimales));      //B20180730 MGC 2018.07.30 Formatos
                    }
                    else
                    {
                        armadoCuerpoTabStr.Add(format.toShowNum(Math.Round(Convert.ToDecimal(item2.VOLUMEN_EST), 2), decimales)); //B20180730 MGC 2018.07.30 Formatos
                        armadoCuerpoTabStr.Add(format.toShow(Math.Round(Convert.ToDecimal(item2.APOYO_EST), 2), decimales));      //B20180730 MGC 2018.07.30 Formatos
                    }
                }

                contadorTabla++;
            }
        }
Exemplo n.º 13
0
        public static void ObtenerCartaProductosHtml(List <DOCUMENTOP_SP> con2, string decimales, string porclass, string totalm, bool fact,
                                                     ref List <listacuerpoc> armadoCuerpoTab,
                                                     ref int contadorTabla)
        {
            FormatosC format = new FormatosC();

            foreach (var item2 in con2)
            {
                //B20180710 MGC 2018.07.10 Modificaciones para editar los campos de distribución se agrego los objetos
                listacuerpoc lc1 = new listacuerpoc
                {
                    val   = item2.MATNR.TrimStart('0'),
                    clase = "ni"
                };
                armadoCuerpoTab.Add(lc1);

                listacuerpoc lc2 = new listacuerpoc
                {
                    val   = item2.DESCRIPCION,
                    clase = "ni"
                };
                armadoCuerpoTab.Add(lc2);

                listacuerpoc lc3 = new listacuerpoc
                {
                    val   = item2.MAKTX,
                    clase = "ni"
                };
                armadoCuerpoTab.Add(lc3);

                //Costo unitario
                listacuerpoc lc4 = new listacuerpoc
                {
                    val   = format.toShow(Math.Round(item2.MONTO, 2), decimales), //B20180730 MGC 2018.07.30 Formatos
                    clase = "input_oper numberd input_dc mon" + porclass
                };
                armadoCuerpoTab.Add(lc4);

                //Porcentaje de apoyo
                listacuerpoc lc5 = new listacuerpoc
                {
                    val   = format.toShowPorc(Math.Round(item2.PORC_APOYO, 2), decimales),//B20180730 MGC 2018.07.30 Formatos
                    clase = "input_oper numberd porc input_dc" + porclass
                };
                armadoCuerpoTab.Add(lc5);

                //Apoyo por pieza
                listacuerpoc lc6 = new listacuerpoc
                {
                    val   = format.toShow(Math.Round(item2.MONTO_APOYO, 2), decimales),//B20180730 MGC 2018.07.30 Formatos
                    clase = "input_oper numberd costoa input_dc mon" + porclass
                };
                armadoCuerpoTab.Add(lc6);

                //Costo con apoyo
                listacuerpoc lc7 = new listacuerpoc
                {
                    val   = format.toShow(Math.Round(item2.RESTA, 2), decimales), //B20180730 MGC 2018.07.30 Formatos
                    clase = "input_oper numberd costoa input_dc mon" + porclass   //Importante costoa para validación en vista
                };
                armadoCuerpoTab.Add(lc7);

                //Precio Sugerido
                listacuerpoc lc8 = new listacuerpoc
                {
                    val   = format.toShow(Math.Round(item2.PRECIO_SUG, 2), decimales),//B20180730 MGC 2018.07.30 Formatos
                    clase = "input_oper numberd input_dc mon" + porclass
                };
                armadoCuerpoTab.Add(lc8);

                //Modificación 9 y 10 dependiendo del campo de factura en tsol
                //Volumen
                listacuerpoc lc9 = new listacuerpoc();
                if (fact)
                {
                    lc9.val = format.toShowNum(Math.Round(Convert.ToDecimal(item2.VOLUMEN_REAL), 2), decimales);//B20180730 MGC 2018.07.30 Formatos
                }
                else
                {
                    lc9.val = format.toShowNum(Math.Round(Convert.ToDecimal(item2.VOLUMEN_EST), 2), decimales);//B20180730 MGC 2018.07.30 Formatos
                }
                lc9.clase = "input_oper numberd input_dc num" + porclass;
                armadoCuerpoTab.Add(lc9);

                //Apoyo
                listacuerpoc lc10 = new listacuerpoc();
                if (fact)
                {
                    lc10.val = format.toShow(Math.Round(Convert.ToDecimal(item2.APOYO_REAL), 2), decimales);//B20180730 MGC 2018.07.30 Formatos
                }
                else
                {
                    lc10.val = format.toShow(Math.Round(Convert.ToDecimal(item2.APOYO_EST), 2), decimales);//B20180730 MGC 2018.07.30 Formatos
                }
                lc10.clase = "input_oper numberd input_dc mon" + totalm + "" + porclass;
                armadoCuerpoTab.Add(lc10);

                contadorTabla++;
            }
        }
Exemplo n.º 14
0
        // GET: Correos
        public ActionResult Index(decimal id, bool?mail)  //B20180803 MGC Correos
        {
            var dOCUMENTO = db.DOCUMENTOes.Where(x => x.NUM_DOC == id).FirstOrDefault();
            var flujo     = db.FLUJOes.Where(x => x.NUM_DOC == id).OrderByDescending(o => o.POS).Select(s => s.POS).ToList();

            ViewBag.Pos = flujo[0];
            ViewBag.url = "http://localhost:60621";
            ViewBag.url = "http://192.168.1.30";
            ViewBag.url = Request.Url.AbsoluteUri.Replace(Request.Url.AbsolutePath, "");
            //ViewBag.miles = dOCUMENTOes.PAI.MILES;//LEJGG 090718
            //ViewBag.dec = dOCUMENTOes.PAI.DECIMAL;//LEJGG 090718

            //Obtener miles y dec
            FORMATO formato = new FORMATO();

            formato       = db.FORMATOes.Where(f => f.ACTIVO == true).FirstOrDefault();
            ViewBag.miles = formato.MILES;
            ViewBag.dec   = formato.DECIMALES;


            FormatosC fc = new FormatosC();

            ViewBag.monto = fc.toShow((decimal?)dOCUMENTO.MONTO_DOC_MD, formato.DECIMALES);
            if (mail == null)
            {
                mail = true;
            }
            //B20180803 MGC Correos............
            string mailv = "";

            if (mail != null)
            {
                if (mail == true)
                {
                    mailv = "X";
                }
            }

            ViewBag.mail = mailv;
            //B20180803 MGC Correos............

            //B20180803 MGC Presupuesto............
            //Models.PresupuestoModels carga = new Models.PresupuestoModels();
            ViewBag.ultMod = "";//carga.consultarUCarga();

            //MGC 08-10-2018 Obtener el nombre del cliente
            var prov = db.PROVEEDORs.Where(p => p.LIFNR == dOCUMENTO.PAYER_ID).FirstOrDefault().NAME1;

            ViewBag.prov = prov;


            //CLIENTE_MOD cli = new CLIENTE_MOD();

            //cli = SelectCliente(dOCUMENTO.PAYER_ID);

            ViewBag.kunnr = ""; // cli.KUNNR;
            ViewBag.vtweg = ""; // cli.VTWEG;

            Services.FormatosC format = new FormatosC();

            //PRESUPUESTO_MOD presu = new PRESUPUESTO_MOD();
            //presu = getPresupuesto(dOCUMENTO.PAYER_ID);

            //decimal pcanal = 0;
            //try
            //{
            //    pcanal = Convert.ToDecimal(presu.P_CANAL) / 1;
            //}
            //catch (Exception)
            //{

            //}
            //decimal pbanner = 0;
            //try
            //{
            //    pbanner = Convert.ToDecimal(presu.P_BANNER) / 1;
            //}
            //catch (Exception)
            //{

            //}
            //decimal pcc = 0;
            //try
            //{
            //    pcc = Convert.ToDecimal(presu.PC_C) / 1;
            //}
            //catch (Exception)
            //{

            //}
            //decimal pca = 0;
            //try
            //{
            //    pca = Convert.ToDecimal(presu.PC_A) / 1;
            //}
            //catch (Exception)
            //{

            //}
            //decimal pcp = 0;
            //try
            //{
            //    pcp = Convert.ToDecimal(presu.PC_P) / 1;
            //}
            //catch (Exception)
            //{

            //}
            //decimal pct = 0;
            //try
            //{
            //    pct = Convert.ToDecimal(presu.PC_T) / 1;
            //}
            //catch (Exception)
            //{

            //}
            //decimal consu = 0;
            //try
            //{
            //    consu = Convert.ToDecimal(presu.CONSU) / 1;
            //}
            //catch (Exception)
            //{

            //}
            ViewBag.pcan  = ""; //format.toShow(pcanal, dOCUMENTO.PAI.DECIMAL);
            ViewBag.pban  = ""; //format.toShow(pbanner, dOCUMENTO.PAI.DECIMAL);
            ViewBag.pcc   = ""; //format.toShow(pcc, dOCUMENTO.PAI.DECIMAL);
            ViewBag.pca   = ""; //format.toShow(pca, dOCUMENTO.PAI.DECIMAL);
            ViewBag.pcp   = ""; //format.toShow(pcp, dOCUMENTO.PAI.DECIMAL);
            ViewBag.pct   = ""; //format.toShow(pct, dOCUMENTO.PAI.DECIMAL);
            ViewBag.consu = ""; //format.toShow(consu, dOCUMENTO.PAI.DECIMAL);

            //B20180803 MGC Presupuesto............

            return(View(dOCUMENTO));
        }