Exemplo n.º 1
0
        public string guardarPresupuesto(ref DatosPresupuesto presupuesto, string[] sociedadcpt, string[] periodocpt, string[] sociedadsap, string[] periodosap, string usuario, string opciong, string idioma, int pagina)
        {
            TruequeEntities db = new TruequeEntities();
            string          mensaje = "", soc = "", pre = "";
            int             ide      = 0;
            string          opc      = "1";
            string          sociedad = "";

            if (opciong != "on")
            {
                opc = "2";
            }
            if (presupuesto.presupuestoCPT.Count > 0)
            {
                soc = ""; pre = "";
                sociedadPeriodo(sociedadcpt, periodocpt, true, ref soc, ref pre);
                var id = db.CSP_PRESUPUESTO_ADD(Convert.ToInt32(presupuesto.presupuestoCPT[0].ANIO), soc, pre, usuario, "0", 1).ToList();
                if (id.Count > 0)
                {
                    ide = Convert.ToInt32(id[0].ToString());
                    if (ide != 0)
                    {
                        for (int i = 0; i < presupuesto.presupuestoCPT.Count; i++)
                        {
                            presupuesto.presupuestoCPT[i].ID = ide;
                        }
                        db.BulkInsert(presupuesto.presupuestoCPT);
                        for (int i = 0; i < sociedadcpt.Length; i++)
                        {
                            sociedad += sociedadcpt[i] + ",";
                        }
                        presupuesto.bannerscanal = db.CSP_BANNERSINCANAL(sociedad).ToList();
                        mensaje = mensajes(15, idioma, pagina); //"Guardado Correctamente CPT.";
                    }
                    else
                    {
                        mensaje = mensajes(10, idioma, pagina); //"El usuario con el que se esta cargando los datos no exitene en el sistema.";
                    }
                }
                else
                {
                    mensaje = mensajes(11, idioma, pagina); //"Ocurrio algo mientra se guardaba.";
                }
            }
            if (presupuesto.presupuestoSAP.Count > 0)
            {
                soc = ""; pre = "";
                sociedadPeriodo(sociedadsap, periodosap, false, ref soc, ref pre);
                var id = db.CSP_PRESUPUESTO_ADD(presupuesto.presupuestoSAP[0].ANIO, soc, pre, usuario, opc, 2).ToList();//0 remplazar 1 añadir
                if (id.Count > 0)
                {
                    ide = Convert.ToInt32(id[0].ToString());
                    if (ide != 0)
                    {
                        for (int i = 0; i < presupuesto.presupuestoSAP.Count; i++)
                        {
                            presupuesto.presupuestoSAP[i].ID = ide;
                        }
                        db.BulkInsert(presupuesto.presupuestoSAP);
                        mensaje = mensajes(12, idioma, pagina); //"Guardado Correctamente SAP.";
                    }
                    else
                    {
                        mensaje = mensajes(10, idioma, pagina); //"El usuario con el que se esta cargando los datos no exitene en el sistema.";
                    }
                }
                else
                {
                    mensaje = mensajes(13, idioma, pagina); //"Ocurrio algo mientra se guardaba.";
                }
            }
            return(mensaje);
        }