Exemple #1
0
        //Constructor posteos
        public Form1(string path)
        {
            pathGlobaV     = eliminarSlash(path);
            controlDeCasos = 1;
            pantallaCarga.Show();
            pantallaCarga.aumentarCarga(10);

            InitializeComponent();
            listo = false;

            promotores         = new Dictionary <int, Paquete>();
            diccionarioNomFija = new Dictionary <int, int>();
            this.path          = path;
            pathA = Directory.GetCurrentDirectory() + "\\PROMOTORES.accdb";
            //this.pathA = pathA;

            ComisionesN = new List <Comisiones>();
            Console.WriteLine("VOY A AUMENTAR LA BARRA");
            pantallaCarga.aumentarCarga(10);
            string pathComisiones = Directory.GetCurrentDirectory() + "\\comisiones1.accdb";

            promotoresN = new List <Promotor>();
            celulasN    = new List <Celula>();

            manipuladorA = new ManipuladorAcces(pathA);
            manipuladorA.DatosPromotorN(promotoresN);
            manipuladorA.DatosComisiones(ComisionesN, pathComisiones);
            Console.WriteLine("Este: " + pathA);
            manipuladorA.celulasN(celulasN, Directory.GetCurrentDirectory() + "\\CELULASN.accdb");
            pantallaCarga.aumentarCarga(10);
            manipulador = new ManipuladorExcel(path, promotoresN);
            pantallaCarga.aumentarCarga(30);
            manipulador.SepararEstrategias("test");
            foreach (string i in manipulador.Estrageias)
            {
                comboBox2.Items.Add(i);
            }
            comboBox2.SelectedItem = manipulador.Estrageias.ElementAt(0);
            string pathAux = manipulador.Copiar("F");

            //tabla.DataSource = manipuladorA.conexion();
            manipuladorA.DatosPromotor(manipulador.promotores);
            //manipuladorA.DatosPromotor(manipulador.promotoresVariable);

            //manipulador.ImprimirPromo();
            //CHECAR
            manipulador.AñadirDatos(manipulador.promotores[comboBox2.SelectedIndex]);
            //manipulador.crearRespaldo(2);
            manipulador.generaRespaldo1();

            //manipulador.AñadirDatos(promotoresN);
            //manipuladorA.nombresPromotor();
            //
            pantallaCarga.aumentarCarga(10);
            destPath  = pathAux;
            destPath1 = pathAux;
            manipulador.nominaFijaExcel(destPath, manipulador.promotores);
            string excelConectionConfig;

            excelConectionConfig  = "Provider=Microsoft.ACE.OLEDB.12.0; ";
            excelConectionConfig += "Data Source =" + pathAux + "; ";
            excelConectionConfig += "Extended Properties=\"Excel 12.0; HDR=YES\" ";

            tabla.Columns.Clear();
            OleDbConnection excelConnection = default(OleDbConnection);

            excelConnection = new OleDbConnection(excelConectionConfig);
            OleDbCommand filterRows = default(OleDbCommand);

            filterRows = new OleDbCommand("Select * From [Hoja1$]", excelConnection);
            excelConnection.Open();
            pantallaCarga.aumentarCarga(10);
            DataSet ds = new DataSet();

            try
            {
                OleDbDataAdapter adaptador = default(OleDbDataAdapter);
                adaptador = new OleDbDataAdapter();
                adaptador.SelectCommand = filterRows;
                adaptador.Fill(ds);

                tabla.DataSource = ds.Tables[0];
                excelConnection.Close();
            }
            catch (Exception e2)
            {
                Console.WriteLine(e2.ToString());
            }
            pantallaCarga.aumentarCarga(10);
            //

            /*
             * List<Promotor> lista = (from p in promotoresN
             *                      group p by new { p.claveInter, p.clavePromotor, p.estrategia, p.nombrePromotor, p.celula, p.banco, p.nominaFija, p.nominaVariable } into grupo
             *                      where grupo.Count() > 1
             *                      select new Promotor()
             *                      {
             *                          claveInter = grupo.Key.claveInter,
             *                          clavePromotor = grupo.Key.clavePromotor,
             *                          estrategia = grupo.Key.estrategia,
             *                          nombrePromotor = grupo.Key.nombrePromotor,
             *                          celula = grupo.Key.celula,
             *                          banco = grupo.Key.banco,
             *                          nominaFija = grupo.Key.nominaFija,
             *                          nominaVariable = grupo.Key.nominaVariable
             *                      }).ToList();
             * promotoresN = lista;
             */
            /*for (int i = 0; i < tabla.Rows.Count - 2; i++)
             * {
             *
             *  //Console.WriteLine("WEA:  " + tabla[2, i].Value.ToString());
             *  if (tabla[2, i].Value.ToString().Length>0)
             *  {
             *      int val = int.Parse(tabla[2, i].Value.ToString());
             *      if (!promotores.ContainsKey(val))
             *      {
             *          promotores.Add(val, new Paquete(manipulador.nomPaquetes, tabla[3, i].Value.ToString()));
             *          promotores[val].aumentar(tabla[5, i].Value.ToString());
             *      }
             *      else
             *      {
             *      promotores[val].aumentar(tabla[5, i].Value.ToString());
             *      }
             *  }
             * }*/

            promotoresNaux = new List <Promotor>(promotoresN);
            pantallaCarga.aumentarCarga(10);
            for (int i = 0; i < tabla.Rows.Count - 2; i++)
            {
                int contadorDeIngresos = 0;
                //Console.WriteLine("WEA:  " + tabla[2, i].Value.ToString());
                if (tabla[2, i].Value.ToString().Length > 0)
                {
                    int  val             = int.Parse(tabla[2, i].Value.ToString());
                    bool banderaDePosteo = false;
                    foreach (Promotor j in promotoresN)
                    {
                        if (j.clavePromotor == val)
                        {
                            banderaDePosteo = true;
                            string statusPisa = tabla[8, i].Value.ToString();
                            if (statusPisa.Equals("ABIERTA") || statusPisa.Equals("POSTEADA") || statusPisa.Equals(" ABIERTA") || statusPisa.Equals(" POSTEADA") || statusPisa.Equals("ABIERTA ") || statusPisa.Equals("POSTEADA "))
                            {
                                contadorDeIngresos += 1;
                                // Console.WriteLine("El estatus pisa de " + val + " es " + tabla[8, i].Value.ToString() +" Y lleva "+contadorDeIngresos+ " ingresos");
                                int x = promotoresNaux.IndexOf(j);
                                promotoresNaux.ElementAt(x).ingresos += 1;
                            }
                        }
                    }

                    if (!banderaDePosteo)
                    {
                        Console.WriteLine("Un promotor en el excel, no se encuentra en el acces");
                    }
                }
            }
            double nFija;

            //Lenado de la nomina fija
            foreach (Promotor i in promotoresNaux)
            {
                if (i.ingresos > 0)
                {
                    int x = promotoresN.IndexOf(i);
                    promotoresN.ElementAt(x).ingresos = i.ingresos;
                    if (i.estrategia >= 5)
                    {
                        nFija = i.ingresos * 138.64;
                        promotoresN.ElementAt(x).nominaFija = nFija;
                    }
                    else
                    {
                        nFija = i.ingresos * 115.38;
                        promotoresN.ElementAt(x).nominaFija = nFija;
                    }
                    totalNominaFIja += nFija;
                    Console.WriteLine("El promotor" + i.nombrePromotor + " Realizó " + i.ingresos + " ingresos");
                }
            }

            //Console.WriteLine("Para el promotor MORALES PEREZ SAMUEL");
            //GenerarFormato();

            Paquetes.Columns.Clear();

            string excelConectionConfig1;

            excelConectionConfig1  = "Provider=Microsoft.ACE.OLEDB.12.0; ";
            excelConectionConfig1 += "Data Source =" + pathAux + "; ";
            excelConectionConfig1 += "Extended Properties=\"Excel 12.0; HDR=YES\" ";

            OleDbConnection excelConnection1 = default(OleDbConnection);

            excelConnection1 = new OleDbConnection(excelConectionConfig1);
            OleDbCommand filterRows1 = default(OleDbCommand);

            filterRows1 = new OleDbCommand("Select * From [Hoja2$]", excelConnection1);
            excelConnection1.Open();

            DataSet ds1 = new DataSet();

            try
            {
                OleDbDataAdapter adaptador1 = default(OleDbDataAdapter);
                adaptador1 = new OleDbDataAdapter();
                adaptador1.SelectCommand = filterRows1;
                adaptador1.Fill(ds1);

                Paquetes.DataSource = ds1.Tables[0];
                excelConnection1.Close();
            }
            catch (Exception e2)
            {
                Console.WriteLine(e2.ToString());
            }
            listo = true;
            pantallaCarga.Close();
        }
Exemple #2
0
        //Constructor posteos e ingresos
        public Form1(string pathI, string pathE)
        {
            pathGlobaF     = eliminarSlash(pathI);
            pathGlobaV     = eliminarSlash(pathE);
            controlDeCasos = 2;
            pantallaCarga.Show();
            pantallaCarga.aumentarCarga(10);
            listo = false;
            InitializeComponent();
            Console.WriteLine("VOY A AUMENTAR LA BARRA");
            pathA = Directory.GetCurrentDirectory() + "\\PROMOTORES.accdb";
            //this.pathA = pathA;

            promotores          = new Dictionary <int, Paquete>();
            promotoresV         = new Dictionary <int, Paquete>();
            diccionarioNomFija  = new Dictionary <int, int>();
            diccionarioNomFijaV = new Dictionary <int, int>();
            this.path           = pathI;
            this.pathV          = pathE;

            pantallaCarga.aumentarCarga(10);
            ComisionesN   = new List <Comisiones>();
            ComisisonesNV = new List <Comisiones>();

            string pathComisiones = Directory.GetCurrentDirectory() + "\\comisiones1.accdb";

            promotoresN  = new List <Promotor>();
            promotoresNV = new List <Promotor>();
            celulasN     = new List <Celula>();
            celulasNV    = new List <Celula>();

            manipuladorA = new ManipuladorAcces(pathA);
            manipuladorA.DatosPromotorN(promotoresN);
            manipuladorA.DatosPromotorN(promotoresNV);
            manipuladorA.DatosComisiones(ComisionesN, pathComisiones);
            manipuladorA.DatosComisiones(ComisisonesNV, pathComisiones);
            Console.WriteLine("Este: " + pathA);
            manipuladorA.celulasN(celulasN, Directory.GetCurrentDirectory() + "\\CELULASN.accdb");

            manipuladorV = new ManipuladorExcel(pathV, promotoresNV);
            pantallaCarga.aumentarCarga(20);
            manipuladorV.SepararEstrategias("testV");
            manipulador = new ManipuladorExcel(path, promotoresN);
            manipulador.SepararEstrategias("test");
            pantallaCarga.aumentarCarga(20);

            foreach (string i in manipulador.Estrageias)
            {
                comboBox2.Items.Add(i);
            }

            foreach (string i in manipuladorV.Estrageias)
            {
                comboPosteos.Items.Add(i);
            }

            comboBox2.SelectedItem    = manipulador.Estrageias.ElementAt(0);
            comboPosteos.SelectedItem = manipuladorV.Estrageias.ElementAt(0);
            string pathAux  = manipulador.Copiar("F");
            string pathAuxV = manipuladorV.Copiar("V");

            pantallaCarga.aumentarCarga(10);

            //tabla.DataSource = manipuladorA.conexion();
            manipuladorA.DatosPromotor(manipulador.promotores);
            manipuladorA.DatosPromotor(manipuladorV.promotores);
            //manipuladorA.DatosPromotor(manipulador.promotoresVariable);
            //manipuladorA.DatosPromotor(manipuladorV.promotoresVariable);

            //manipulador.ImprimirPromo();
            //CHECAR
            manipuladorV.AñadirDatos(manipuladorV.promotores[comboBox2.SelectedIndex]);
            //manipuladorV.crearRespaldo(2);
            manipuladorV.generaRespaldo1();
            manipulador.AñadirDatos(manipulador.promotores[comboBox2.SelectedIndex]);
            //manipulador.crearRespaldo(1);
            manipulador.generaRespaldo1();

            //manipulador.AñadirDatos(promotoresN);
            //manipuladorA.nombresPromotor();

            manipulador.AñadirMontoFijo(pathA);
            //manipuladorV.AñadirMontoFijo(pathA);
            manipuladorV.CalcularNominaVariable();
            manipuladorV.calcularVariable();
            manipulador.calcularNominaFija();

            destPath  = pathAux;
            destPath1 = pathAuxV;
            string excelConectionConfig;

            excelConectionConfig  = "Provider=Microsoft.ACE.OLEDB.12.0; ";
            excelConectionConfig += "Data Source =" + pathAux + "; ";
            excelConectionConfig += "Extended Properties=\"Excel 12.0; HDR=YES\" ";

            tabla.Columns.Clear();
            OleDbConnection excelConnection = default(OleDbConnection);

            excelConnection = new OleDbConnection(excelConectionConfig);
            OleDbCommand filterRows = default(OleDbCommand);

            filterRows = new OleDbCommand("Select * From [Hoja" + (comboBox2.SelectedIndex + 1) + "$]", excelConnection);
            excelConnection.Open();

            DataSet ds = new DataSet();

            pantallaCarga.aumentarCarga(20);
            try
            {
                OleDbDataAdapter adaptador = default(OleDbDataAdapter);
                adaptador = new OleDbDataAdapter();
                adaptador.SelectCommand = filterRows;
                adaptador.Fill(ds);

                tabla.DataSource = ds.Tables[0];
                excelConnection.Close();
            }
            catch (Exception e2)
            {
                Console.WriteLine(e2.ToString());
            }

            promotoresNaux = new List <Promotor>(promotoresN);

            for (int i = 0; i < tabla.Rows.Count - 2; i++)
            {
                int contadorDeIngresos = 0;
                //Console.WriteLine("WEA:  " + tabla[2, i].Value.ToString());
                if (tabla[2, i].Value.ToString().Length > 0)
                {
                    int  val             = int.Parse(tabla[2, i].Value.ToString());
                    bool banderaDePosteo = false;
                    foreach (Promotor j in promotoresN)
                    {
                        if (j.clavePromotor == val)
                        {
                            banderaDePosteo = true;
                            string statusPisa = tabla[8, i].Value.ToString();
                            if (statusPisa.Equals("ABIERTA") || statusPisa.Equals("POSTEADA") || statusPisa.Equals(" ABIERTA") || statusPisa.Equals(" POSTEADA") || statusPisa.Equals("ABIERTA ") || statusPisa.Equals("POSTEADA "))
                            {
                                contadorDeIngresos += 1;
                                // Console.WriteLine("El estatus pisa de " + val + " es " + tabla[8, i].Value.ToString() +" Y lleva "+contadorDeIngresos+ " ingresos");
                                int x = promotoresNaux.IndexOf(j);
                                promotoresNaux.ElementAt(x).ingresos += 1;
                            }
                        }
                    }

                    if (!banderaDePosteo)
                    {
                        Console.WriteLine("Un promotor en el excel, no se encuentra en el acces");
                    }
                }
            }
            double nFija;

            //Lenado de la nomina fija
            foreach (Promotor i in promotoresNaux)
            {
                if (i.ingresos > 0)
                {
                    int x = promotoresN.IndexOf(i);
                    promotoresN.ElementAt(x).ingresos = i.ingresos;
                    if (i.estrategia >= 5)
                    {
                        nFija = i.ingresos * 138.64;
                        promotoresN.ElementAt(x).nominaFija = nFija;
                    }
                    else
                    {
                        nFija = i.ingresos * 115.38;
                        promotoresN.ElementAt(x).nominaFija = nFija;
                    }
                    totalNominaFIja += nFija;
                    Console.WriteLine("El promotor" + i.nombrePromotor + " Realizó " + i.ingresos + " ingresos");
                }
            }

            //Console.WriteLine("Para el promotor MORALES PEREZ SAMUEL");
            //GenerarFormato();

            /*
             * Paquetes.Columns.Clear();
             *
             * string excelConectionConfig1;
             * excelConectionConfig1 = "Provider=Microsoft.ACE.OLEDB.12.0; ";
             * excelConectionConfig1 += "Data Source =" + pathAux + "; ";
             * excelConectionConfig1 += "Extended Properties=\"Excel 12.0; HDR=YES\" ";
             *
             * OleDbConnection excelConnection1 = default(OleDbConnection);
             * excelConnection1 = new OleDbConnection(excelConectionConfig1);
             * OleDbCommand filterRows1 = default(OleDbCommand);
             * filterRows1 = new OleDbCommand("Select * From [Hoja2$]", excelConnection1);
             * excelConnection1.Open();
             *
             * DataSet ds1 = new DataSet();
             *
             * try
             * {
             *  OleDbDataAdapter adaptador1 = default(OleDbDataAdapter);
             *  adaptador1 = new OleDbDataAdapter();
             *  adaptador1.SelectCommand = filterRows1;
             *  adaptador1.Fill(ds1);
             *
             *  Paquetes.DataSource = ds1.Tables[0];
             *  excelConnection1.Close();
             * }
             * catch (Exception e2)
             * {
             *  Console.WriteLine(e2.ToString());
             * }*/

            llenaPaquetes(comboBox2.Text);


            excelConectionConfig  = "Provider=Microsoft.ACE.OLEDB.12.0; ";
            excelConectionConfig += "Data Source =" + pathAuxV + "; ";
            excelConectionConfig += "Extended Properties=\"Excel 12.0; HDR=YES\" ";

            tablaPosteos.Columns.Clear();
            excelConnection = new OleDbConnection(excelConectionConfig);
            filterRows      = new OleDbCommand("Select * From [Hoja" + (comboBox2.SelectedIndex + 1) + "$]", excelConnection);
            excelConnection.Open();

            DataSet dsV = new DataSet();

            try
            {
                OleDbDataAdapter adaptador = default(OleDbDataAdapter);
                adaptador = new OleDbDataAdapter();
                adaptador.SelectCommand = filterRows;
                adaptador.Fill(dsV);

                tablaPosteos.DataSource = dsV.Tables[0];
                excelConnection.Close();
            }
            catch (Exception e2)
            {
                Console.WriteLine(e2.ToString());
            }
            listo = true;
            pantallaCarga.Close();
        }