Ejemplo n.º 1
0
 public void ToolMouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         //DrawingObject clickObject = canvas.GetCanvasObject(e.X,e.Y);
         varChart          = new Chart(new System.Drawing.Point(e.X, e.Y));
         varChart.Endpoint = new System.Drawing.Point(e.X, e.Y);
         canvas.AddDrawingObject(varChart);
     }
     if (e.Button == MouseButtons.Right)
     {
         if (varChart.GetPointChartAll().Count == 0 || varChart.GetLabelYAll().Count == 0)
         {
             string s = "Isi point dan label x menggunakan XValue dan label y dengan YValue";
             using (Notifikasi form = new Notifikasi(s))
             {
                 if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                 {
                     form.ShowDialog();
                 }
             }
         }
         else
         {
             using (TableChart form = new TableChart(varChart, canvas))
             {
                 if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                 {
                     form.ShowDialog();
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
        public static TableChart CreateChart(Size size)
        {
            var chart = new TableChart
            {
                Size        = size,
                LineColor   = Color.Cyan,
                Rows        = 10,
                Columns     = 10,
                MergedCells = new List <DataGridMergedCell>
                {
                    new DataGridMergedCell(1, 1, 3, 3)
                },
                Texts = new string[][]
                {
                    new [] { "1", "1", "1" },
                    new [] { "1", "1", "", "", "1" },
                }
            };

            return(chart);
        }
Ejemplo n.º 3
0
        public string GenerarArchivo(List <FiltroSeleccionado> Filtros, int ClienteId, int ObjetoId, int UsuarioConsultaId)
        {
            const string chars       = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
            var          random      = new Random();
            string       token       = new string(Enumerable.Repeat(chars, 30).Select(s => s[random.Next(s.Length)]).ToArray());
            string       path        = AppDomain.CurrentDomain.BaseDirectory;
            string       filename    = token + ".csv";
            string       newfilepath = Path.Combine(path, "Temp", filename);


            try
            {
                TableChart ch = (TableChart)GetDataObjeto(Filtros, ClienteId, ObjetoId, -1, UsuarioConsultaId, 0);

                XSSFWorkbook  wbExcel  = new XSSFWorkbook();
                XSSFSheet     eSheet   = (XSSFSheet)wbExcel.CreateSheet("Tabla");
                XSSFRow       rTitulos = (XSSFRow)eSheet.CreateRow(0);
                XSSFRow       rCurrent;
                XSSFCell      cCurrent;
                XSSFCellStyle csEstilo;
                XSSFFont      fFuente;
                XSSFColor     cColor;

                int iCell = 0;
                int iRow  = 1;
                if (ch.Tipo != TipoChart.ClassicTable)
                {
                    foreach (var c in ch.Columns)
                    {
                        cCurrent = (XSSFCell)rTitulos.CreateCell(iCell);
                        cCurrent.SetCellValue(c.title.ToString());
                        iCell++;
                    }
                }
                else
                {
                    foreach (var c in ch.Valores[0])
                    {
                        cCurrent = (XSSFCell)rTitulos.CreateCell(iCell);
                        cCurrent.SetCellValue(c.Key.ToString());
                        iCell++;
                    }
                }
                foreach (var v in ch.Valores)
                {
                    iCell    = 0;
                    rCurrent = (XSSFRow)eSheet.CreateRow(iRow++);
                    foreach (var vc in v)
                    {
                        cCurrent = (XSSFCell)rCurrent.CreateCell(iCell);
                        if (vc.Value.ToString().Length != 0)
                        {
                            if (vc.Value.ToString().Substring(0, 1) == "●")
                            {
                                csEstilo = (XSSFCellStyle)wbExcel.CreateCellStyle();
                                fFuente  = (XSSFFont)wbExcel.CreateFont();
                                cColor   = new XSSFColor(ColorTranslator.FromHtml(vc.Value.ToString().Replace("●", "")));

                                fFuente.IsBold = true;
                                fFuente.SetColor(cColor);
                                fFuente.FontHeightInPoints = 16;

                                csEstilo.SetFont(fFuente);
                                csEstilo.Alignment = HorizontalAlignment.Center;

                                cCurrent.CellStyle = csEstilo;
                                cCurrent.SetCellValue(vc.Value.ToString().Substring(0, 1));
                            }
                            else
                            {
                                cCurrent.SetCellValue(vc.Value.ToString());
                            }
                        }

                        iCell++;
                    }
                }

                filename = token + ".xlsx";
                FileStream File = new FileStream(Path.Combine(path, "Temp", filename), FileMode.Create, FileAccess.Write);
                wbExcel.Write(File);
                File.Close();

                return(token);
            }
            catch (System.IO.IOException ex)
            {
                throw ex;
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Ejemplo n.º 4
0
        public Chart GetTableData(List <FiltroSeleccionado> filtros, int clienteId, int objetoId, int numeroPagina, int usuarioConsultaId, int tamanioPagina)
        {
            TableChart      chart     = new TableChart();
            ReportingObjeto obj       = GetObjeto(objetoId);
            DataTable       dtfiltros = new DataTable();

            dtfiltros.Columns.Add(new DataColumn("IdFiltro", typeof(string)));
            dtfiltros.Columns.Add(new DataColumn("Valores", typeof(string)));

            using (SqlConnection cn = new SqlConnection((new RepContext()).Database.Connection.ConnectionString.ToString()))
            {
                SqlCommand cmd = new SqlCommand(obj.SpDatos, cn);
                cmd.CommandType    = CommandType.StoredProcedure;
                cmd.CommandTimeout = 240;

                cmd.Parameters.Add("@IdCliente", SqlDbType.Int).Value = clienteId;

                if (filtros != null)
                {
                    foreach (FiltroSeleccionado f in filtros)
                    {
                        if (f.Valores != null)
                        {
                            DataRow newRow = dtfiltros.NewRow();
                            newRow[0] = f.Filtro;
                            newRow[1] = string.Join(",", f.Valores);

                            dtfiltros.Rows.Add(newRow);
                        }
                    }
                }

                cmd.Parameters.Add("@Filtros", SqlDbType.Structured).Value    = dtfiltros;
                cmd.Parameters.Add("@NumeroDePagina", SqlDbType.Int).Value    = numeroPagina;
                cmd.Parameters.Add("@Lenguaje", SqlDbType.VarChar).Value      = System.Threading.Thread.CurrentThread.CurrentCulture.Name;
                cmd.Parameters.Add("@IdUsuarioConsulta", SqlDbType.Int).Value = usuarioConsultaId;
                cmd.Parameters.Add("@TamañoPagina", SqlDbType.Int).Value      = tamanioPagina;

                cn.Open();

                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataSet        ds = new DataSet();
                da.Fill(ds);

                if (ds == null)
                {
                    return(chart);
                }

                if (ds.Tables.Count != 3 && obj.TipoChart != TipoChart.ClassicTable)
                {
                    return(chart);
                }

                //Cantidad de paginas
                //si no existe nada... (solucion "temporal?" para los T9 /20/25/30 Pivoteados que no traen nada o no tienen un manejo adecuado para el caso vacio
                if (ds.Tables.Count == 0)
                {
                    chart.pages = 0;
                    return(chart);
                }

                DataTable dt = ds.Tables[0];
                if (dt.Rows.Count <= 0)
                {
                    return(chart);
                }


                if (obj.TipoChart != TipoChart.ClassicTable)
                {
                    chart.pages = int.Parse(dt.Rows[0][0].ToString());

                    //Configuracion de columnas
                    dt = ds.Tables[1];
                    foreach (DataRow r in dt.Rows)
                    {
                        chart.Columns.Add(new TableChartColumn()
                        {
                            name = r["name"].ToString(), title = r["title"].ToString(), width = int.Parse(r["width"].ToString())
                        });
                    }

                    //Datos
                    dt = ds.Tables[2];
                    if (dt.Rows.Count == 0)
                    {
                        chart.pages = 0;
                        return(chart);
                    }
                }

                List <Dictionary <string, object> > parentRow = new List <Dictionary <string, object> >();
                Dictionary <string, object>         childRow;

                foreach (DataRow row in dt.Rows)
                {
                    childRow = new Dictionary <string, object>();
                    foreach (DataColumn col in dt.Columns)
                    {
                        childRow.Add(col.Caption, row[col].ToString());
                    }
                    parentRow.Add(childRow);
                }

                chart.Valores = parentRow;
            }

            return(chart);
        }