Esempio n. 1
0
        private void DrawLines(Lbl.Charts.Serie Serie, System.Drawing.Graphics Canvas, System.Drawing.Size Size)
        {
            Canvas.DrawLine(System.Drawing.Pens.WhiteSmoke, 0, Size.Height - 1, 2000, Size.Height - 1);
            if (Serie.Elements == null)
            {
                return;
            }

            int ElementNumber = 1;

            if (Serie.Elements.Length > 0 && CacheMax != 0)
            {
                System.Drawing.PointF LastPoint = new PointF(0, 65000);
                float ElementWidth = Size.Width / (Serie.Elements.Length - 1);
                foreach (Lbl.Charts.Element El in Serie.Elements)
                {
                    if (El != null)
                    {
                        PointF ThisPoint = new PointF(ElementWidth * (ElementNumber - 1), Size.Height - (int)(El.Value / CacheMax * Size.Height));
                        if (ElementNumber == 1)
                        {
                            LastPoint = ThisPoint;
                        }

                        Canvas.DrawLine(new System.Drawing.Pen(Serie.Color, 2), LastPoint, ThisPoint);
                        LastPoint = ThisPoint;
                    }
                    ElementNumber++;
                }
            }
        }
Esempio n. 2
0
        private void DrawSerie(Lbl.Charts.Serie DrawSerie, System.Drawing.Graphics Canvas, System.Drawing.Size Size)
        {
            switch (GraphicType)
            {
            case GraphicTypes.Pie:
                DrawPie(DrawSerie, Canvas, Size);
                break;

            default:
                DrawLines(DrawSerie, Canvas, Size);
                break;
            }
        }
Esempio n. 3
0
        private static void DrawPie(Lbl.Charts.Serie Serie, System.Drawing.Graphics Canvas, System.Drawing.Size Size)
        {
            decimal Sum = Serie.GetSum();

            Rectangle PieRect = new Rectangle(0, 0, Size.Width, Size.Height);

            if (PieRect.Width > PieRect.Height)
            {
                PieRect.X    += (PieRect.Width - PieRect.Height) / 2;
                PieRect.Width = PieRect.Height;
            }
            else
            {
                PieRect.Y     += (PieRect.Height - PieRect.Width) / 2;
                PieRect.Height = PieRect.Width;
            }

            float LastAngle = 0;

            foreach (Lbl.Charts.Element El in Serie.Elements)
            {
                float ElementAngle = (float)(El.Value / Sum * 360);

                Canvas.FillPie(System.Drawing.Brushes.Tomato, PieRect, LastAngle, LastAngle + ElementAngle);
                LastAngle += ElementAngle;
            }

            LastAngle = 0;
            foreach (Lbl.Charts.Element El in Serie.Elements)
            {
                float ElementAngle = (float)(El.Value / Sum * 360);

                Canvas.DrawPie(System.Drawing.Pens.Black, PieRect, LastAngle, LastAngle + ElementAngle);
                LastAngle += ElementAngle;
            }
        }
Esempio n. 4
0
                public void RentabilidadAnual(int anio, Lui.Forms.Chart Chrt)
                {
                        if (Chrt.Series == null)
                                Chrt.Series = new System.Collections.Generic.List<Lbl.Charts.Serie>();

                        Lbl.Charts.Element[] ElFacturacion = new Lbl.Charts.Element[12];
                        Lbl.Charts.Element[] ElCosto = new Lbl.Charts.Element[12];
                        Lbl.Charts.Element[] ElGastos = new Lbl.Charts.Element[12];
                        Lbl.Charts.Element[] ElRentabilidad = new Lbl.Charts.Element[12];

                        for (int mes = 1; mes <= 12; mes++) {

                                if (anio > DateTime.Now.Year || (anio == DateTime.Now.Year && mes > DateTime.Now.Month)) {
                                        //Nada ?
                                } else {
                                        ElFacturacion[mes - 1] = new Lbl.Charts.Element();
                                        ElCosto[mes - 1] = new Lbl.Charts.Element();
                                        ElGastos[mes - 1] = new Lbl.Charts.Element();
                                        ElRentabilidad[mes - 1] = new Lbl.Charts.Element();

                                        string Fecha1Sql = anio.ToString("0000") + "-" + mes.ToString("00") + "-01";
                                        string Fecha2Sql = anio.ToString("0000") + "-" + mes.ToString("00") + "-31";

                                        decimal Facturas = this.Connection.FieldDecimal("SELECT SUM(total) FROM comprob WHERE tipo_fac IN ('FA', 'FB', 'FC', 'FE', 'FM', 'NDA', 'NDB', 'NDC', 'NDE', 'NDM') AND impresa>0 AND compra=0 AND anulada=0 AND fecha BETWEEN '" + Fecha1Sql + "' AND '" + Fecha2Sql + "'");
                                        decimal NotasCredito = this.Connection.FieldDecimal("SELECT SUM(total) FROM comprob WHERE tipo_fac IN ('NCA', 'NCB', 'NCC', 'NCE', 'NCM') AND impresa>0 AND compra=0 AND anulada=0 AND fecha BETWEEN '" + Fecha1Sql + "' AND '" + Fecha2Sql + "'");
                                        decimal Costo = this.Connection.FieldDecimal("SELECT SUM(costo*cantidad) FROM comprob, comprob_detalle WHERE comprob.id_comprob=comprob_detalle.id_comprob AND comprob.tipo_fac IN ('FA', 'FB', 'FC', 'FE', 'FM', 'NDA', 'NDB', 'NDC', 'NDE', 'NDM') AND comprob.compra=0 AND comprob.numero>0 AND comprob.anulada=0 AND comprob_detalle.precio>0 AND comprob.fecha BETWEEN '" + Fecha1Sql + "' AND '" + Fecha2Sql + "'");
                                        decimal CostoNotasCredito = this.Connection.FieldDecimal("SELECT SUM(costo*cantidad) FROM comprob, comprob_detalle WHERE comprob.id_comprob=comprob_detalle.id_comprob AND comprob.tipo_fac IN ('NCA', 'NCB', 'NCC', 'NCE', 'NCM') AND comprob.impresa>0 AND comprob.compra=0 AND comprob.anulada=0 AND comprob.fecha BETWEEN '" + Fecha1Sql + "' AND '" + Fecha2Sql + "'");
                                        //decimal CostoCapital = this.Connection.FieldDecimal("SELECT SUM(importe) FROM cajas_movim WHERE id_concepto IN (SELECT id_concepto FROM conceptos WHERE grupo=220) AND fecha BETWEEN '" + Fecha1Sql + "' AND '" + Fecha2Sql + "'");
                                        decimal GastosFijos = this.Connection.FieldDecimal("SELECT SUM(importe) FROM cajas_movim WHERE id_concepto IN (SELECT id_concepto FROM conceptos WHERE grupo=230) AND fecha BETWEEN '" + Fecha1Sql + "' AND '" + Fecha2Sql + "'");
                                        decimal GastosVariables = this.Connection.FieldDecimal("SELECT SUM(importe) FROM cajas_movim WHERE id_concepto IN (SELECT id_concepto FROM conceptos WHERE grupo=240) AND fecha BETWEEN '" + Fecha1Sql + "' AND '" + Fecha2Sql + "'");
                                        decimal OtrosEgresos = this.Connection.FieldDecimal("SELECT SUM(importe) FROM cajas_movim WHERE importe<0 AND id_concepto IN (SELECT id_concepto FROM conceptos WHERE grupo NOT IN (110, 210, 220, 230, 240, 300)) AND id_concepto<>26030 AND fecha BETWEEN '" + Fecha1Sql + "' AND '" + Fecha2Sql + "'");

                                        ElFacturacion[mes - 1].Value = Facturas - NotasCredito;
                                        ElCosto[mes - 1].Value = Costo - CostoNotasCredito;
                                        ElGastos[mes - 1].Value = Math.Abs(GastosFijos + GastosVariables + OtrosEgresos);
                                        ElRentabilidad[mes - 1].Value = ElFacturacion[mes - 1].Value - ElCosto[mes - 1].Value - ElGastos[mes - 1].Value;
                                }

                        }
                        Lbl.Charts.Serie Serie1 = new Lbl.Charts.Serie("Facturación");
                        Lbl.Charts.Serie Serie2 = new Lbl.Charts.Serie("Gastos");
                        Lbl.Charts.Serie Serie3 = new Lbl.Charts.Serie("Rentabilidad");

                        Serie1.Elements = ElFacturacion;
                        Serie2.Elements = ElGastos;
                        Serie3.Elements = ElRentabilidad;

                        if (anio == DateTime.Now.Year) {
                                Serie1.Color = System.Drawing.Color.Goldenrod;
                                Serie2.Color = System.Drawing.Color.Red;
                                Serie3.Color = System.Drawing.Color.Green;
                        } else {
                                Serie1.Color = System.Drawing.Color.LightGoldenrodYellow;
                                Serie2.Color = System.Drawing.Color.Pink;
                                Serie3.Color = System.Drawing.Color.LightGreen;
                        }

                        Chrt.Series.Add(Serie1);
                        Chrt.Series.Add(Serie2);
                        Chrt.Series.Add(Serie3);
                }
Esempio n. 5
0
        public void RentabilidadAnual(int anio, Lui.Forms.Chart Chrt)
        {
            if (Chrt.Series == null)
            {
                Chrt.Series = new System.Collections.Generic.List <Lbl.Charts.Serie>();
            }

            Lbl.Charts.Element[] ElFacturacion  = new Lbl.Charts.Element[12];
            Lbl.Charts.Element[] ElCosto        = new Lbl.Charts.Element[12];
            Lbl.Charts.Element[] ElGastos       = new Lbl.Charts.Element[12];
            Lbl.Charts.Element[] ElRentabilidad = new Lbl.Charts.Element[12];

            for (int mes = 1; mes <= 12; mes++)
            {
                if (anio > DateTime.Now.Year || (anio == DateTime.Now.Year && mes > DateTime.Now.Month))
                {
                    //Nada ?
                }
                else
                {
                    ElFacturacion[mes - 1]  = new Lbl.Charts.Element();
                    ElCosto[mes - 1]        = new Lbl.Charts.Element();
                    ElGastos[mes - 1]       = new Lbl.Charts.Element();
                    ElRentabilidad[mes - 1] = new Lbl.Charts.Element();

                    string Fecha1Sql = anio.ToString("0000") + "-" + mes.ToString("00") + "-01";
                    string Fecha2Sql = anio.ToString("0000") + "-" + mes.ToString("00") + "-31";

                    decimal Facturas          = this.Connection.FieldDecimal("SELECT SUM(total) FROM comprob WHERE tipo_fac IN ('FA', 'FB', 'FC', 'FE', 'FM', 'NDA', 'NDB', 'NDC', 'NDE', 'NDM') AND impresa>0 AND compra=0 AND anulada=0 AND fecha BETWEEN '" + Fecha1Sql + "' AND '" + Fecha2Sql + "'");
                    decimal NotasCredito      = this.Connection.FieldDecimal("SELECT SUM(total) FROM comprob WHERE tipo_fac IN ('NCA', 'NCB', 'NCC', 'NCE', 'NCM') AND impresa>0 AND compra=0 AND anulada=0 AND fecha BETWEEN '" + Fecha1Sql + "' AND '" + Fecha2Sql + "'");
                    decimal Costo             = this.Connection.FieldDecimal("SELECT SUM(costo*cantidad) FROM comprob, comprob_detalle WHERE comprob.id_comprob=comprob_detalle.id_comprob AND comprob.tipo_fac IN ('FA', 'FB', 'FC', 'FE', 'FM', 'NDA', 'NDB', 'NDC', 'NDE', 'NDM') AND comprob.compra=0 AND comprob.numero>0 AND comprob.anulada=0 AND comprob_detalle.precio>0 AND comprob.fecha BETWEEN '" + Fecha1Sql + "' AND '" + Fecha2Sql + "'");
                    decimal CostoNotasCredito = this.Connection.FieldDecimal("SELECT SUM(costo*cantidad) FROM comprob, comprob_detalle WHERE comprob.id_comprob=comprob_detalle.id_comprob AND comprob.tipo_fac IN ('NCA', 'NCB', 'NCC', 'NCE', 'NCM') AND comprob.impresa>0 AND comprob.compra=0 AND comprob.anulada=0 AND comprob.fecha BETWEEN '" + Fecha1Sql + "' AND '" + Fecha2Sql + "'");
                    //decimal CostoCapital = this.Connection.FieldDecimal("SELECT SUM(importe) FROM cajas_movim WHERE id_concepto IN (SELECT id_concepto FROM conceptos WHERE grupo=220) AND fecha BETWEEN '" + Fecha1Sql + "' AND '" + Fecha2Sql + "'");
                    decimal GastosFijos     = this.Connection.FieldDecimal("SELECT SUM(importe) FROM cajas_movim WHERE id_concepto IN (SELECT id_concepto FROM conceptos WHERE grupo=230) AND fecha BETWEEN '" + Fecha1Sql + "' AND '" + Fecha2Sql + "'");
                    decimal GastosVariables = this.Connection.FieldDecimal("SELECT SUM(importe) FROM cajas_movim WHERE id_concepto IN (SELECT id_concepto FROM conceptos WHERE grupo=240) AND fecha BETWEEN '" + Fecha1Sql + "' AND '" + Fecha2Sql + "'");
                    decimal OtrosEgresos    = this.Connection.FieldDecimal("SELECT SUM(importe) FROM cajas_movim WHERE importe<0 AND id_concepto IN (SELECT id_concepto FROM conceptos WHERE grupo NOT IN (110, 210, 220, 230, 240, 300)) AND id_concepto<>26030 AND fecha BETWEEN '" + Fecha1Sql + "' AND '" + Fecha2Sql + "'");

                    ElFacturacion[mes - 1].Value  = Facturas - NotasCredito;
                    ElCosto[mes - 1].Value        = Costo - CostoNotasCredito;
                    ElGastos[mes - 1].Value       = Math.Abs(GastosFijos + GastosVariables + OtrosEgresos);
                    ElRentabilidad[mes - 1].Value = ElFacturacion[mes - 1].Value - ElCosto[mes - 1].Value - ElGastos[mes - 1].Value;
                }
            }
            Lbl.Charts.Serie Serie1 = new Lbl.Charts.Serie("Facturación");
            Lbl.Charts.Serie Serie2 = new Lbl.Charts.Serie("Gastos");
            Lbl.Charts.Serie Serie3 = new Lbl.Charts.Serie("Rentabilidad");

            Serie1.Elements = ElFacturacion;
            Serie2.Elements = ElGastos;
            Serie3.Elements = ElRentabilidad;

            if (anio == DateTime.Now.Year)
            {
                Serie1.Color = System.Drawing.Color.Goldenrod;
                Serie2.Color = System.Drawing.Color.Red;
                Serie3.Color = System.Drawing.Color.Green;
            }
            else
            {
                Serie1.Color = System.Drawing.Color.LightGoldenrodYellow;
                Serie2.Color = System.Drawing.Color.Pink;
                Serie3.Color = System.Drawing.Color.LightGreen;
            }

            Chrt.Series.Add(Serie1);
            Chrt.Series.Add(Serie2);
            Chrt.Series.Add(Serie3);
        }