示例#1
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 }));
            }
        }
        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 }));
            }
        }