Пример #1
0
        static void Main(string[] args)
        {
            //DatosCom del Manager funciona
            Manager     manager   = new Manager();
            ComercialVO comercial = new ComercialVO(1);
            string      data      = manager.DatosCom(comercial);

            Console.WriteLine(data);
            //Si leo directamente los datos del DAL funciona
            AccesoDatos fichero = new AccesoDatos();

            string [] resultados = fichero.LeerFacturacion();
            resultados = resultados.Skip(1).ToArray();
            foreach (var linea in resultados)
            {
                //introducimos cada línea en un nuevo array por la separación de las comas
                var valores = linea.Split(',');
                Console.WriteLine(valores[0]);
                Console.WriteLine(valores[1]);

                /*foreach (var dato in valores)
                 * {
                 *  Console.WriteLine(dato);
                 * }*/
                string uno = valores[0];
                string dos = valores[1];
                //Console.WriteLine(valores[0]);
            }
            string empresa = manager.DatosEmp(comercial);

            //Console.WriteLine(resultados[0]);
            Console.WriteLine(empresa);
        }
Пример #2
0
        public string gestionaDatos(ComercialVO comercial)
        {
            ComercialDAL comercialDatos = new ComercialDAL();

            comercialDatos.leerDatosComercial(comercial);

            return(comercial.ToString());
        }
Пример #3
0
        private void btnComercial3_Click(object sender, EventArgs e)
        {
            //tlp.Controls.Add(gb, 0, 0); // Lo añade en la columna 1, fila 1

            this.comercial = new ComercialVO(3);
            numComercial   = 3;

            pnSeleccion.Location = btnComercial3.Location;
            pnSeleccion.Visible  = true;
            pnIzq.Visible        = false;
        }
Пример #4
0
        private void b_com3_Click(object sender, EventArgs e)
        {
            b_Empresa.Enabled   = true;
            b_Resultado.Enabled = true;

            numero = 3;
            ComercialVO comercial = ElegirComercial();

            detalle.tB_detalle.Text = manager.DatosCom(comercial);

            tlp.Controls.Add(detalle, 1, 0);
        }
Пример #5
0
        public string DatosCom(ComercialVO comercial)
        {
            //Aceedemos a los datos de DAL
            AccesoDatos fichero = new AccesoDatos();
            var         datos   = fichero.LeerComerciales();

            //Realizamos operaciones para obtener retorno
            ControlDatos lectura  = new ControlDatos();
            string       datosCom = lectura.LeerComercial(comercial, datos);

            return(datosCom);
        }
Пример #6
0
        public Dictionary <string, int> DatosMensual(ComercialVO comercial)
        {
            //Aceedemos a los datos de DAL
            AccesoDatos fichero = new AccesoDatos();

            string[] datos = fichero.LeerFacturacion();

            ControlDatos lectura = new ControlDatos();


            //Instanciamos el Dictionary que vamos a devolver
            Dictionary <string, int> rdoMensual = lectura.LeerMensual(comercial, datos);

            return(rdoMensual);
        }
Пример #7
0
        private void b_Empresa_Click(object sender, EventArgs e)
        {
            tlp.Controls.Remove(grafico);
            if (numero == 1 || numero == 2 || numero == 3)
            {
                ComercialVO comercial = new ComercialVO(numero);
                ComercialVO emp       = new ComercialVO(0);
                Manager     manager   = new Manager();
                string[]    datos     = manager.DatosEmp(comercial);
                string[]    datosEmp  = manager.DatosEmp(emp);

                double totalCom      = double.Parse(datos[2]);
                double totalEmp      = double.Parse(datosEmp[2]);
                double porcentaje    = (totalCom / totalEmp) * 100;
                double porcentajeRed = Math.Round(porcentaje, 2);

                empresa.tB_comEmp.Text     = numero.ToString();
                empresa.tB_emp1.Text       = datos[0];
                empresa.tB_emp2.Text       = datos[1];
                empresa.tB_total.Text      = datos[2];
                empresa.tB_porcentaje.Text = porcentajeRed.ToString();

                tlp.Controls.Add(empresa, 0, 1);
            }
            else if (numero == 0)
            {
                ComercialVO emp      = new ComercialVO(numero);
                Manager     manager  = new Manager();
                string[]    datosEmp = manager.DatosEmp(emp);

                double total1         = double.Parse(datosEmp[0]);
                double total2         = double.Parse(datosEmp[1]);
                double totalEmp       = double.Parse(datosEmp[2]);
                double porcentaje1    = (total1 / totalEmp) * 100;
                double porcentaje2    = (total2 / totalEmp) * 100;
                double porcentajeRed1 = Math.Round(porcentaje1, 2);
                double porcentajeRed2 = Math.Round(porcentaje2, 2);

                total.c_totales.Titles["Title1"].Text = "Total facturado: " + totalEmp.ToString();
                total.c_totales.Series["Series1"].Points.AddXY("Empresa 1\n " + porcentajeRed1.ToString() + "%", total1);
                total.c_totales.Series["Series1"].Points.AddXY("Empresa 2\n " + porcentajeRed2.ToString() + "%", total2);

                tlp.Controls.Add(total, 0, 1);
            }
        }
Пример #8
0
        private void b_Resultado_Click(object sender, EventArgs e)
        {
            tlp.Controls.Remove(empresa);

            ComercialVO comercial        = new ComercialVO(numero);
            Manager     manager          = new Manager();
            Dictionary <string, int> dic = manager.DatosMensual(comercial);

            //string key = "ENERO";

            //tB_comercial.Text = dic[key].ToString();

            foreach (KeyValuePair <string, int> d in dic)
            {
                grafico.c_mensual.Series["Series1"].Points.AddXY(d.Key, d.Value);
            }

            tlp.Controls.Add(grafico, 0, 1);
        }
Пример #9
0
        public string [] DatosEmp(ComercialVO comercial)
        {
            string[] facturacionAnual = new string[3];

            //Aceedemos a los datos de DAL
            AccesoDatos fichero = new AccesoDatos();

            string[] datos = fichero.LeerFacturacion();

            //Realizamos operaciones para obtener retorno
            ControlDatos lectura   = new ControlDatos();
            string       empresa_1 = lectura.LeerEmpresa(comercial, 1, datos);
            string       empresa_2 = lectura.LeerEmpresa(comercial, 2, datos);

            int total = int.Parse(empresa_1) + int.Parse(empresa_2);

            facturacionAnual[0] = empresa_1;
            facturacionAnual[1] = empresa_2;
            facturacionAnual[2] = total.ToString();

            return(facturacionAnual);
        }
Пример #10
0
        public void leerDatosComercial(ComercialVO comercial)
        {
            try
            {
                var reader = new StreamReader(File.OpenRead(@"..\..\..\DashboardDAL\BD\1_datos_comerciales.csv"));
                // Salta la primera fila del archivo csv
                reader.ReadLine();
                while (!reader.EndOfStream)
                {
                    var line   = reader.ReadLine();
                    var values = line.Split(',');

                    // Se recorre todo el contenido de values y se guardan los valores en linea menos la primera columna(el id)
                    for (int i = 1; i < values.Length; i++)
                    {
                        // Si el id es igual al que se le pasa guarda los valores
                        if (comercial.Id == int.Parse(values[0]))
                        {
                            comercial.Nombre    = values[1];
                            comercial.Apellido  = values[2];
                            comercial.Localidad = values[3];
                            comercial.Edad      = int.Parse(values[4]);
                        }
                    }
                }
                reader.Close();
                //return comercial.ToString();
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception: " + e.Message);
            }
            finally
            {
                Console.WriteLine("Se ha leido correctamente");
            }
        }
Пример #11
0
        //prueba con radio buttton, no se activan....
        public ComercialVO ElegirComercial()
        {
            ComercialVO comercialElegido = new ComercialVO(numero);

            return(comercialElegido);
        }