예제 #1
0
        private void btn_calcularSellout_Click(object sender, EventArgs e) //Calcula objetivo SO.
        {
            if (comboBox_SIMcaminantes.Text == "Elija caminante")
            {
                MessageBox.Show("Primero debe elegir un caminante.", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (txtBox_Sellout_objVenta.Text == String.Empty)
            {
                MessageBox.Show("Primero debe ingresar un objetivo de venta.", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            listBox_Sellout.Items.Clear();
            elementosUndoSO.Clear();
            int objVenta = Convert.ToInt32(txtBox_Sellout_objVenta.Text);

            string[] reporte_PSRagencia   = File.ReadAllLines(txtbox_REP_psragencia.Text);        //Contemplar exeptions
            string[] reporte_dealer       = File.ReadAllLines(txtBox_REPsellout_dealer.Text);     //Contemplar exeptions
            string[] reporte_prodVendidos = File.ReadAllLines(txtbox_REP_productosVendidos.Text); //Contemplar exeptions
            int      psrAgenciaLen        = reporte_PSRagencia.Length;
            int      ventaAnaliticoLen    = reporte_dealer.Length;
            int      prodVendidosLen      = reporte_prodVendidos.Length;

            var psrSellout  = new Dictionary <string, PSR>();
            int objCumplido = 0;
            int psrTotales  = 0;

            //Reporte PSR de la agencia
            for (int i = 2; i < psrAgenciaLen; i++)
            {
                string[] itemsAgencia = reporte_PSRagencia[i].Split(';');
                if (itemsAgencia[INDEX_AGENCIA_CAMINANTE] == Convert.ToString(comboBox_SIMcaminantes.SelectedItem))
                {
                    PSR clientSellout = new PSR();
                    clientSellout.CodPSR             = itemsAgencia[INDEX_AGENCIA_CODPSR];
                    clientSellout.Nombre             = itemsAgencia[INDEX_AGENCIA_RAZONSOCIAL].Replace('"', ' ').Trim();
                    clientSellout.Caminante          = itemsAgencia[INDEX_AGENCIA_CAMINANTE];
                    clientSellout.Transferencias     = 0;
                    clientSellout.StockCarga         = 0;
                    clientSellout.StockSim           = 0;
                    clientSellout.VentaMensual       = 0;
                    clientSellout.EsCumplidor        = false;
                    psrSellout[clientSellout.CodPSR] = clientSellout;
                }
            }
            psrTotales = psrSellout.Count;
            //Reporte Productos Vendidos
            for (int z = 2; z < prodVendidosLen; z++)
            {
                string[] itemspVendidos = reporte_prodVendidos[z].Split(';');
                string   auxpsrcode     = itemspVendidos[INDEX_PVENDIDOS_CODPSR];

                if (itemspVendidos[INDEX_PVENDIDOS_CHECKER] == "Carga Virtual" && itemspVendidos[INDEX_PVENDIDOS_CAMINANTE] == Convert.ToString(comboBox_SIMcaminantes.SelectedItem))
                {
                    psrSellout[auxpsrcode].Transferencias += Convert.ToInt32(itemspVendidos[INDEX_PVENDIDOS_TRANSFERENCIAS]);
                }
            }

            //Reporte Ventas Analitico
            for (int y = 5; y < ventaAnaliticoLen; y++)
            {
                string[] ventasFinales = reporte_dealer[y].Split(';');
                string   auxPsrcode    = "0" + ventasFinales[INDEX_DEALER_CODPSR];
                if (psrSellout.ContainsKey(auxPsrcode))
                {
                    psrSellout[auxPsrcode].VentaMensual = Convert.ToDouble(ventasFinales[INDEX_DEALER_VENTASFINALES]);
                }
            }
            double volumenVendedor = 0;

            foreach (var psr in psrSellout.Values)
            {
                volumenVendedor += psr.VentaMensual;

                if (psr.VentaMensual >= objVenta)
                {
                    psr.EsCumplidor = true;
                }
                if (psr.EsCumplidor)
                {
                    objCumplido++;
                }
                else
                {
                    listBox_Sellout.Items.Add(psr.Nombre + "  |  " + "Venta mensual: "
                                              + Convert.ToString(psr.VentaMensual) + "  |  " + "Total Transferido: " + Convert.ToString(psr.Transferencias));
                }
            }
            SO_psrTotales.Text      = Convert.ToString(psrTotales);
            txtB_soConObjetivo.Text = Convert.ToString(objCumplido);
            txtBox_soFaltan.Text    = Convert.ToString(listBox_Sellout.Items.Count);
            txtB_soVolumen.Text     = "$" + Convert.ToString(volumenVendedor);
            int efectividad = (objCumplido * 100) / psrTotales;

            SO_efectividad.Text = Convert.ToString(efectividad) + "%";

            listBox_Sellout.Sorted = true;
        }
예제 #2
0
        private void btn_SIM_calcular_Click_1(object sender, EventArgs e) //Calcula objetivo SIM
        {
            if (comboBox_SIMcaminantes.Text == "Elija caminante")
            {
                MessageBox.Show("Primero debe elegir un caminante.", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (txtbox_montoObjSIM.Text == String.Empty)
            {
                MessageBox.Show("Primero debe ingresar un objetivo de venta.", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            // ===== Elimina datos del listbox y del stack ===== \\
            listBox_SIM.Items.Clear();
            elementosUndoSim.Clear();
            // ================================================== \\
            //======== Se leen las lineas de los reportes =======\\
            string[] reporte_PSRagencia   = File.ReadAllLines(txtbox_REP_psragencia.Text);
            string[] reporte_pRecarga     = File.ReadAllLines(txtbox_REP_pRecarga.Text);
            string[] reporte_prodVendidos = File.ReadAllLines(txtbox_REP_productosVendidos.Text);
            //======== Variables & Diccionario =======\\
            var psrSIM          = new Dictionary <string, PSR>();
            int objVenta        = Convert.ToInt32(txtbox_montoObjSIM.Text);
            int objCumplido     = 0;
            int psrTotales      = 0;
            int invercion       = 0;
            int psrAgenciaLen   = reporte_PSRagencia.Length;
            int pRecargasLen    = reporte_pRecarga.Length;
            int prodVendidosLen = reporte_prodVendidos.Length;

            for (int i = 2; i < psrAgenciaLen; i++)
            {
                // Array con el contenido de dichas lineas.
                string[] itemsAgencia = reporte_PSRagencia[i].Split(';');
                // Si pertenece al caminante seleccionado entonces se asignan los datos al objeto PSR.
                if (itemsAgencia[INDEX_AGENCIA_CAMINANTE] == Convert.ToString(comboBox_SIMcaminantes.SelectedItem))
                {
                    PSR client = new PSR
                    {
                        CodPSR         = itemsAgencia[INDEX_AGENCIA_CODPSR],
                        Caminante      = itemsAgencia[INDEX_AGENCIA_CAMINANTE],
                        Pos            = itemsAgencia[INDEX_AGENCIA_POS],
                        Nombre         = itemsAgencia[INDEX_AGENCIA_RAZONSOCIAL].Replace('"', ' ').Trim(),
                        Calle          = itemsAgencia[INDEX_AGENCIA_DIRECCION],
                        Altura         = itemsAgencia[INDEX_AGENCIA_ALTURA],
                        NimCliente     = "",
                        PrimeraRecarga = 0,
                        IdSIM          = "",
                        Lote           = "",
                        EsCumplidor    = false
                    };
                    psrSIM[client.CodPSR] = client; // Se guarda el objeto cliente en el diccionario.
                }
            }
            psrTotales = psrSIM.Count;

            for (int y = 2; y < pRecargasLen; y++)
            {
                //Array con el contenido del segundo reporte
                string[] itemspRecarga = reporte_pRecarga[y].Trim().Split(';');

                if (itemspRecarga[INDEX_RECARGAS_CAMINANTE] == Convert.ToString(comboBox_SIMcaminantes.SelectedItem))
                {
                    string auxPSRcode  = itemspRecarga[INDEX_RECARGAS_CODPSR];
                    int    auxPrecarga = Convert.ToInt32(itemspRecarga[INDEX_RECARGAS_MONTO]);
                    string auxNim      = itemspRecarga[INDEX_RECARGAS_NIM];
                    string auxIdSim    = itemspRecarga[INDEX_RECARGAS_ID];


                    if (!psrSIM.ContainsKey(auxPSRcode))
                    {
                        PSR client = new PSR
                        {
                            CodPSR         = itemspRecarga[INDEX_RECARGAS_CODPSR],
                            Caminante      = itemspRecarga[INDEX_RECARGAS_CAMINANTE],
                            Pos            = "dado de baja",
                            Nombre         = itemspRecarga[INDEX_RECARGAS_RAZONSOCIAL],
                            NimCliente     = itemspRecarga[INDEX_RECARGAS_NIM],
                            PrimeraRecarga = Convert.ToInt32(itemspRecarga[INDEX_RECARGAS_MONTO]),
                            IdSIM          = itemspRecarga[INDEX_RECARGAS_ID],
                            Lote           = "",
                            EsCumplidor    = false,
                        };

                        /*  if (client.PrimeraRecarga >= objCumplido)
                         * {
                         *    client.EsCumplidor = true;           //Anulacion de el contador de "dados de baja"
                         * }
                         * psrSIM[client.CodPSR] = client;
                         * dadosBaja++;*/
                    }
                    else
                    {
                        if (psrSIM[auxPSRcode].PrimeraRecarga == 0)
                        {
                            psrSIM[auxPSRcode].PrimeraRecarga = auxPrecarga;
                            psrSIM[auxPSRcode].NimCliente     = auxNim;
                            psrSIM[auxPSRcode].IdSIM          = auxIdSim;
                        }
                        else if (auxPrecarga > psrSIM[auxPSRcode].PrimeraRecarga)
                        {
                            psrSIM[auxPSRcode].PrimeraRecarga = auxPrecarga;
                            psrSIM[auxPSRcode].NimCliente     = auxNim;
                            psrSIM[auxPSRcode].IdSIM          = auxIdSim;
                        }
                        if (psrSIM[auxPSRcode].PrimeraRecarga >= objVenta)
                        {
                            psrSIM[auxPSRcode].EsCumplidor = true;
                        }
                    }
                }
            }
            for (int z = 2; z < prodVendidosLen; z++)
            {
                string[] itemspVendidos = reporte_prodVendidos[z].Split(';');
                //string auxPSRcode2 = itemspVendidos[pVendidos_codpsrIndex];

                if (psrSIM.ContainsKey(itemspVendidos[INDEX_PVENDIDOS_CODPSR]) && psrSIM[itemspVendidos[INDEX_PVENDIDOS_CODPSR]].PrimeraRecarga == 0 && itemspVendidos[INDEX_PVENDIDOS_CHECKER] != "Carga Virtual")
                {
                    psrSIM[itemspVendidos[INDEX_PVENDIDOS_CODPSR]].Lote = itemspVendidos[INDEX_PVENDIDOS_LOTE];
                }
            }
            foreach (var psr in psrSIM.Values)
            {
                if (psr.EsCumplidor)
                {
                    objCumplido++;
                }
                else
                {
                    listBox_SIM.Items.Add(psr.Nombre + "  |  " + "Primera Recarga: $" + Convert.ToString(psr.PrimeraRecarga) + "  |  " + "Numero: " + psr.NimCliente + "  |  " + "Lote: " + psr.Lote);
                    int paraCumplirObj = objVenta - psr.PrimeraRecarga;
                    invercion += paraCumplirObj;
                }
            }
            int efectividad = (objCumplido * 100) / psrTotales;

            txtBox_SimConObj.Text    = Convert.ToString(objCumplido);
            txtBox_PSRTotales.Text   = Convert.ToString(psrTotales);
            txtBox_faltaCumplir.Text = Convert.ToString(listBox_SIM.Items.Count);
            //txtBox_inver.Text = Convert.ToString(dadosBaja);
            txtBox_Efectividad.Text = Convert.ToString(efectividad) + "%";
            txtBox_inver.Text       = "$" + invercion;

            listBox_SIM.Sorted = true;
        }