private void btnEliminar_Click(object sender, EventArgs e) { try { if (MessageBox.Show("¿Desea eliminar los gráficos?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Graficos g = ObtenerSeleccionado(); if (g != null) { g.Eliminar(); Buscar(); } else { MessageBox.Show("Seleccione los gráficos a eliminar", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (SqlException) { MessageBox.Show("Los gráficos seleccionados están en uso por un procesador en existencia", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//public ActionResult Index2(int id = 1, string id2 = "grafico") public ActionResult Index2(int id = 1, string id2 = "mapadechile_engeochart_2021.csv") { ViewBag.grafico = id2; Graficos db = new Graficos(); ViewBag.Resultado = db.BuscarGrafico(id); return(View()); }
public ActionResult mapa(int id = 6, string id2 = "mapa") { ViewBag.grafico = id2; Graficos db = new Graficos(); ViewBag.Resultado = db.BuscarGrafico(id); return(View()); }
// GET: Info public ActionResult Index(int id = 1, string id2 = "grafico", string id3 = "Geo_CL_provinces_.csv") { ViewBag.grafico = id2; ViewBag.file = id3; Graficos db = new Graficos(); ViewBag.Resultado = db.BuscarGrafico(id); return(View()); }
public JsonResult GetDtMedicao(int idInd, string ano) { string query = "select convert(varchar,max(T_DATA),120)DATA from vw_SGI_PARAMETRO_RELMEDICOES WHERE IND_ID = '" + idInd.ToString() + "' "; //Filtra ano atual if (ano != "" && ano != null) { query += "AND LEFT(MES,4) = '" + ano + "' "; } var grafico = new Graficos(); var dtMedicao = db.Database.SqlQuery <string>(query).ToList(); return(this.Json(new { dtMedicao = dtMedicao }, JsonRequestBehavior.AllowGet)); }
// GET: Relatorio public ActionResult Index() { var resultado = db.bicicleta.SqlQuery("SELECT * FROM bicicleta WHERE vendida != ' 1 ' ORDER BY codigo"); string dados = ""; foreach (var item in resultado) { dados += "['" + item.nome + "'," + item.vezesAlugada.ToString() + "],"; } dados = dados.Substring(0, dados.Length - 1); ViewBag.GraficoPizza = Graficos.GerarGraficoPizza("Frequencia Aluguel", dados); return(View()); }
private void btnModificar_Click(object sender, EventArgs e) { Graficos g = ObtenerSeleccionado(); if (g != null) { ZonaDatos(true); numID.Value = g.Id; txtModelo.Text = g.Modelo; } else { MessageBox.Show("Seleccione los gráficos a modificar", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
protected void Guardar(object sender, EventArgs e) { phBtnPrint.Visible = true; Double[] totales = ControlesDinamicos.Calcular_ReporteTrabajadores_A_B(panel1, "B"); Double[] valores = { totales[0], totales[1] }; lbTotalSi.Text = "" + totales[0]; lbTotalNo.Text = "" + totales[1]; lbObservaciones.Text = "El porcentaje de riesgo indican condiciones de trabajo que pueden estar asociadas a " + "alto riesgo de lesión o enfermedad es de: " + totales[2] + "%"; ltReporte.Text = Graficos.AddGraficoTorta_ReporteTrabajadores_A_B(totales[0], totales[1]); btnGuardar.Focus(); }
private void btnGuardar_Click(object sender, EventArgs e) { try { if (txtModelo.Text == "") { throw new Exception("Complete el modelo"); } Graficos g = new Graficos(); g.Id = (int)numID.Value; g.Modelo = txtModelo.Text; g.Guardar(); ZonaDatos(false); MessageBox.Show("Se guardo correctamente", "", MessageBoxButtons.OK, MessageBoxIcon.Information); Buscar(); } catch (Exception ex) { MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
// GET: Info public ActionResult Index(int id = 1, string id2 = "grafico", string id3 = "Geo_CL_provinces_.csv") { ViewBag.grafico = id2; ViewBag.file = id3; Graficos db = new Graficos(); ViewBag.Resultado = null; //db.BuscarGrafico(id); GRAFICO graf = dbGrafico.GRAFICO.Where(x => x.id == id).First(); ViewBag.Elemento = graf; // var listaAsociado = dbGrafico.PRODUCTO.Where(x => x.SECTOR_id == graf.CATEGORIA.PRODUCTO.SECTOR_id).ToList(); var listaAsociado = dbGrafico.GRAFICO.Where(x => x.CATEGORIA.PRODUCTO.SECTOR_id == graf.CATEGORIA.PRODUCTO.SECTOR_id).ToList(); ViewBag.listaAsociado = listaAsociado; /* var listaOtrosContenidos = dbGrafico.CATEGORIA.Where(x => x.PRODUCTO_id == graf.CATEGORIA.PRODUCTO_id).ToList(); */ //List<int> idproductos = new List<int>(); var rand = new Random(); List <CATEGORIA> listaCategorias = new List <CATEGORIA>(); foreach (var item in dbGrafico.INDUSTRIA) { var listcatAuxiliar = dbGrafico.CATEGORIA.Where(x => x.PRODUCTO.SECTOR.INDUSTRIA_id == item.id).ToList(); try { CATEGORIA catAuxiliar = listcatAuxiliar[rand.Next(listcatAuxiliar.Count)]; listaCategorias.Add(catAuxiliar); } catch (Exception) { } } var listaOtrosContenidos = listaCategorias; ViewBag.listaOtrosContenidos = listaOtrosContenidos; return(View()); }
internal void iniciarSoftware() { Graficos g = new Graficos(); g.Show(); }
//Funcion que permite crear grafico para estadistica de mecanicos midiendo en horas protected void Crear_Grafico_Mecanicos() { System.Web.UI.WebControls.Image imagenEst = new System.Web.UI.WebControls.Image(); imagenEst = Graficos.Generador_Grafico(imagenEst, "Gráfico de Actividades de Mecánicos", TipoGraficos.COLUMNAS, "Mecánicos", "Horas", this.Cadena_Datos_Mecanicos(3, 5, 7, 9)); Response.Write("<script language:javascript>w=window.open('../est/esttemp.gif','','HEIGHT=" + imagenEst.Height + ",WIDTH=" + imagenEst.Width + "');</script>"); }
protected void Crear_Grafico_Operaciones() { System.Web.UI.WebControls.Image imagenOper = new System.Web.UI.WebControls.Image(); imagenOper = Graficos.Generador_Grafico(imagenOper, "gráfico de operaciones en taller", TipoGraficos.COLUMNAS, "Tipo de Trabajo", "Horas", this.Cadena_Datos_Operaciones(1, 2, 3, 4, 5, 6)); Response.Write("<script language:javascript>w=window.open('../est/esttemp.gif','','HEIGHT=420,WIDTH=540');</script>"); }
public ActionResult Index(int?nPageSize, int?page, int?idGrupo, int?idUnidade, int?idNegocio, int?idDepartamento, string pAno, string pGrafico, string search) { db.Database.CommandTimeout = 999; int userId = Convert.ToInt32(HttpContext.User.Identity.Name); var usuario = db.T_Usuario.Find(userId); //Defini layout #region ViewDataLayout ViewData["mainmenu_scroll"] = "fixedscroll"; //pagescroll , fixedscroll ViewData["body_class"] = "sidebar-collapse"; ViewData["html_class"] = ""; ViewData["pagetopbar_class"] = "sidebar_shift"; ViewData["maincontent_class"] = "sidebar_shift"; ViewData["maincontent_type"] = ""; ViewData["pagesidebar_class"] = "collapseit"; ViewData["pagechatapi_class"] = ""; ViewData["chatapiwindows_demo"] = ""; ViewData["chatapiwindows_class"] = ""; #endregion ViewDataLayout #region Variaveis var grafico = new Graficos(); #endregion Variaveis #region ViewBags ViewBag.idNegocio = new SelectList(db.T_Negocio.OrderBy(x => x.NEG_DESCRICAO), "NEG_ID", "NEG_DESCRICAO", idNegocio); ViewBag.idGrupo = new SelectList(db.T_Grupo.Where(x => x.EXIBELISTA == (int)YesNo.Sim).OrderBy(x => x.NOME), "GRU_ID", "NOME", idGrupo); ViewBag.idUnidade = new SelectList(db.T_Unidade.OrderBy(x => x.DESCRICAO), "UNI_ID", "UN", idUnidade); ViewBag.idDepartamento = new SelectList(db.T_Departamentos.OrderBy(x => x.DEP_NOME), "DEP_ID", "DEP_NOME", idDepartamento); var anos = db.T_Medicoes.Select(x => new { Ano = x.MED_DATAMEDICAO.Substring(0, 4) }).GroupBy(x => new { x.Ano }).OrderByDescending(x => x.Key.Ano).ToList(); pAno = (pAno == "" || pAno == null && anos.Count > 0 ? anos.FirstOrDefault().Key.Ano : pAno); ViewBag.anoAtual = pAno; ViewBag.search = search; ViewBag.negAtual = idNegocio; ViewBag.grpAtual = idGrupo; ViewBag.unAtual = idUnidade; ViewBag.grafico = pGrafico ?? "G"; ViewBag.departamentoAtu = idDepartamento; ViewBag.pAno = new SelectList(anos, "Key.Ano", "Key.Ano", pAno); #endregion ViewBags //Busca favoritos grafico.Favoritos = db.T_Favoritos.Where(x => x.ID_USUARIO == usuario.ID_USUARIO).ToList(); //Chama metódo para trazer dados agrupados por indicadores e metas var indicadores = Util.ExtratorMedidor.GetIndicadores(nPageSize, page, idNegocio, idGrupo, idUnidade, idDepartamento, pAno, search, grafico.Favoritos); if (!string.IsNullOrEmpty(pAno)) { //Chama metódo para poder buscar dados de medições grafico.Medicoes = Util.ExtratorMedidor.GetMedicoes(indicadores.ToList(), pAno); grafico.AnoAnterior = Util.QueryAnaliser.AnoAnterior(pAno); ViewBag.anoAnterior = grafico.AnoAnterior.Count > 0 ? grafico.AnoAnterior.FirstOrDefault().Mes.Substring(0, 4) : ""; } else { grafico.Medicoes = new List <vw_SGI_PARAMETRO_RELMEDICOES>(); grafico.AnoAnterior = new List <vw_SGI_PARAMETRO_RELMEDICOES>(); ViewBag.anoAnterior = null; } //Busca lista de indicadores grafico.Indicadores = indicadores; if (grafico.Medicoes.Count > 0) { //Busca informações complementares var infComplementares = db.T_Informacoes_Complementares.ToList(); infComplementares = infComplementares.Where(x => grafico.Medicoes.Any(j => j.MET_ID == x.MET_ID)).ToList(); grafico.Complementares = infComplementares; } //Busca planos de ações var planos = db.T_PlanoAcao.ToList(); planos = planos.Where(x => indicadores.Any(i => i.IND_ID == x.T_Metas.IND_ID)).ToList(); grafico.PlanoAcoes = planos; var listaMetas = ""; if (pGrafico == "M") { ViewBag.listaMetas = db.Database.SqlQuery <V_PAINEL_LISTA_METAS>("select * from V_PAINEL_LISTA_METAS ").ToList(); } return(View(grafico)); }
/// <summary> /// Metódo para poder preencher o gráfico na tela /// </summary> /// <param name="idIndicador">Código do indicador</param> /// <param name="ano">Ano a ser filtrado</param> /// <returns>Objeto json preenchido</returns> /// **grafico public JsonResult GetGrafico(int idInd, int tipoGrafico, string ano, int dimensao, string periodo, string strDataIni, string strDataFim, string subDime) { // testar o tipo do grafico // testar se a medicao possui sub dimencoes caso sim o grafico deve ser mostrado em pizza onde todos os fotos+ subdimencoes sao agrupadas na pizza continua explicacao em baixo // em caso de grafico de linha o eixo x sera preenchido com os fatos e as linhas serao as subdimencoes // neste caso o filtro sempre sera por data. DateTime dataDe = DateTime.Now; DateTime dataAte = DateTime.Now; DateTime dataAux = DateTime.Now; periodo = periodo.Trim(); if ((string.IsNullOrEmpty(periodo) && !string.IsNullOrEmpty(strDataIni) && !string.IsNullOrEmpty(strDataFim)) || (periodo == "D")) { dataDe = DateTime.ParseExact(strDataIni, "dd-MM-yyyy", System.Globalization.CultureInfo.InvariantCulture); dataAte = DateTime.ParseExact(strDataFim, "dd-MM-yyyy", System.Globalization.CultureInfo.InvariantCulture); dataAux = dataAte; } string query = ""; if (periodo == "M") { query = @"select * from vw_SGI_PARAMETRO_RELMEDICOES WHERE IND_ID = '" + idInd.ToString() + "' AND DimId = " + dimensao + " AND LEFT(PerId, 1) ='" + periodo + "'"; //Filtra ano atual if (ano != "" && ano != null) { query += " AND ((LEFT(MES,4) = '" + (Convert.ToInt32(ano) - 1) + "' and PerId in ('MAC', 'DAC' )) or LEFT(MES,4) = '" + ano + "')"; } if (subDime != "null" && subDime.Trim() != "") { query += " AND DimSubId = '" + subDime + "' "; } query += "order by IND_ID,Mes"; } else if (periodo == "D") { query = string.Format(@"select * from vw_SGI_PARAMETRO_RELMEDICOES WHERE IND_ID = {0} AND MED_DATA_MEDICAO between {1} and {2} AND LEFT(PerId, 1) = 'D' AND DimId = {3} " , idInd.ToString() , dataDe.ToString("yyyyMMdd") , dataAte.ToString("yyyyMMdd") //, dataAtual.AddDays(-30).ToString("yyyyMMdd") //, dataAtual.ToString("yyyyMMdd") , dimensao); if (subDime != "null" && subDime.Trim() != "") { query += " AND DimSubId = '" + subDime + "' "; } query += " order by MED_DATA_MEDICAO "; } else if (string.IsNullOrEmpty(periodo) && !string.IsNullOrEmpty(strDataIni) && !string.IsNullOrEmpty(strDataFim)) { query = string.Format(@"select * from vw_SGI_PARAMETRO_RELMEDICOES WHERE IND_ID = {0} AND MED_DATA_MEDICAO between {1} and {2} AND LEFT(PerId, 1) = 'D' AND DimId = {3} " , idInd.ToString() , dataDe.ToString("yyyyMMdd") , dataAte.ToString("yyyyMMdd") , dimensao); if (subDime != "null" && subDime.Trim() != "") { query += " AND DimSubId = '" + subDime + "' "; } query += " order by MED_DATA_MEDICAO "; } var grafico = new Graficos(); List <vw_SGI_PARAMETRO_RELMEDICOES> medicao = db.Database.SqlQuery <vw_SGI_PARAMETRO_RELMEDICOES>(query).ToList(); List <object> fatos = new List <object>(); List <object> dados = new List <object>(); List <string> cabecalho = new List <string>(); List <string> legenda = new List <string>(); string temDimSubId = ""; //var fatosDesc = medicao.Select(x => new { x.FatDescricao, x.DimSubId }).Distinct().ToList(); var fatosId = medicao.Select(x => new { x.FatId, x.FatDescricao }).Distinct().ToList(); var subDimensao = medicao.Select(x => new { x.DimSubId, x.DimSubDescricao }).Distinct().ToList();//medicao.Select(x => x.FatId).Distinct().ToList(); //var fatosDesc = medicao.Select(x => new { x.FatDescricao, x.DimSubId }).Distinct().ToList(); if (medicao.Count > 0) { fatosId = medicao.Select(x => new { x.FatId, x.FatDescricao }).Distinct().ToList(); subDimensao = medicao.Select(x => new { x.DimSubId, x.DimSubDescricao }).Distinct().ToList();//medicao.Select(x => x.FatId).Distinct().ToList(); var indicador = db.T_Indicadores.Find(idInd); indicador.DIM_ID = dimensao; indicador.PER_ID = periodo; indicador.IND_GRAFICO = tipoGrafico; string tipoCompMeta = indicador.IND_TIPOCOMPARADOR.ToString(); //db.T_Indicadores.Find(idInd).IND_TIPOCOMPARADOR.ToString(); db.SaveChanges(); //Salva mudanças if (!string.IsNullOrEmpty(periodo)) { if (!string.IsNullOrEmpty(subDimensao[0].DimSubId)) // teste se tem sub dimentcao { temDimSubId = "T"; foreach (var s in subDimensao) { List <object> medicoesGrafico = new List <object>(); vw_SGI_PARAMETRO_RELMEDICOES med = null; foreach (var f in fatosId) { var medicaoFato = medicao.Where(x => x.FatId.Trim() == f.FatId.Trim() && x.DimSubId.Trim() == s.DimSubId.Trim() && x.PerId.Trim() == periodo.Trim()).GroupBy(g => new { g.DimSubId, g.FatId, g.FatDescricao }).Select(g => new { subDesc = g.Key.DimSubId, name = g.Key.FatDescricao, value = g.Sum(m => m.Valor) }).FirstOrDefault(); if (medicaoFato != null) { medicoesGrafico.Add(new { ano = "", mes = "", un = "", meta = "", valor = medicaoFato.value, tipo = 0, dimId = 0, dimDescricao = "", fatId = f.FatId, fatDescricao = f.FatDescricao, perId = "D", perDescricao = "Dia", dimSubId = s.DimSubId, dimSubDescricao = s.DimSubDescricao }); } else { medicoesGrafico.Add(new { ano = "", mes = "", un = "", meta = "", valor = "", ac = 0, tipo = 0, data = "", dimId = 0, dimDescricao = "", fatId = "", fatDescricao = "", perId = "", perDescricao = "", medId = "", dimSubId = "" }); } } fatos.Add(medicoesGrafico); } } else { foreach (var f in fatosId) { var medicaoFato = medicao.Where(x => x.FatId == f.FatId).ToList(); List <object> medicoesGrafico = new List <object>(); vw_SGI_PARAMETRO_RELMEDICOES med = null; if (periodo == "M") { for (int i = 0; i < 14; i++) { string mes; if (i + 1 < 10) { mes = "0" + (i + 1); } else { mes = (i + 1).ToString(); } if (i == 12) { med = medicaoFato.Where(x => x.PerId.Trim() == "MAC" && x.Mes.Substring(0, 4) == ano).FirstOrDefault(); } else if (i == 13) { med = medicaoFato.Where(x => x.PerId.Trim() == "MAC" && x.Mes.Substring(0, 4) == (Convert.ToInt32(ano) - 1).ToString()).FirstOrDefault(); } else { med = medicaoFato.Where(x => x.Mes.Substring(4, 2) == mes && x.PerId.Trim() == "M").FirstOrDefault(); } if (med != null) { medicoesGrafico.Add(new { ano = med.Mes.Substring(0, 4), mes = med.Mes.Substring(4, 2), un = med.UNID, meta = med.META, valor = med.Valor, tipo = tipoCompMeta, dimId = med.DimId, dimDescricao = med.DimDescricao, fatId = med.FatId, fatDescricao = med.FatDescricao, perId = med.PerId, perDescricao = med.DimDescricao, dimSubId = med.DimSubId, dimSubDescricao = med.DimSubDescricao }); } else { medicoesGrafico.Add(new { ano = "", mes = "", un = "", meta = "", valor = "", ac = 0, tipo = 0, data = "", dimId = 0, dimDescricao = "", fatId = "", fatDescricao = "", perId = "", perDescricao = "", medId = "", dimSubId = "" }); } } } else if (periodo == "D") { dataAux = dataDe; while (dataAte >= dataAux) { cabecalho.Add(dataAux.Day.ToString()); med = medicaoFato.Where(x => x.MED_DATA.Date == dataAux.Date && x.PerId.Trim().ToUpper() == "D").FirstOrDefault(); if (med != null) { medicoesGrafico.Add(new { ano = med.Mes.Substring(4, 2), mes = med.Mes.Substring(0, 4), un = med.UNID, meta = med.META, valor = med.Valor, tipo = tipoCompMeta, data = med.MED_DATA.ToShortTimeString(), dimId = med.DimId, dimDescricao = med.DimDescricao, fatId = med.FatId, fatDescricao = med.FatDescricao, perId = med.PerId, perDescricao = med.DimDescricao, dimSubId = med.DimSubId, dimSubDescricao = med.DimSubDescricao }); } else { medicoesGrafico.Add(new { ano = "", mes = "", un = "", meta = "", valor = "", ac = 0, tipo = 0, data = "", dimId = 0, dimDescricao = "", fatId = "", fatDescricao = "", perId = "", perDescricao = "", medId = "", dimSubId = "" }); } dataAux = dataAux.AddDays(1); } } fatos.Add(medicoesGrafico); } } } else { var g1 = medicao.GroupBy(g => new { g.DimSubId, g.FatId, g.FatDescricao }).Select(g => new { subDesc = g.Key.DimSubId, name = g.Key.FatDescricao, value = g.Sum(m => m.Valor) }).ToList(); var g2 = medicao.GroupBy(g => new { g.DimSubId }).Select(g => new { subDesc = g.Key.DimSubId, value = g.Sum(m => m.Valor) }).ToList(); foreach (var dt in g2) { foreach (var d in g1) { if (d.subDesc == dt.subDesc) { float percentual = (float)((d.value / dt.value) * 100); //dados.Add(new { subDesc = d.subDesc, name = d.name, value = d.value, percent = (d.value / dt.value) * 100 }); dados.Add(new { d.subDesc, d.name, d.value, percent = Math.Round(percentual, 2) }); } } } if (!string.IsNullOrEmpty(subDimensao[0].DimSubId)) // teste se tem sub dimentcao { temDimSubId = "T"; } } //mota o cabeçalio que é a escala do grafico if (temDimSubId == "T") { foreach (var f in fatosId) { cabecalho.Add(f.FatDescricao.ToString().Trim()); } // legenda if (tipoGrafico == 3)// pizzaa { var temp = medicao.Select(x => new { x.FatDescricao, x.DimSubId }).Distinct().ToList(); foreach (var t in temp) { legenda.Add(t.FatDescricao.ToString().Trim() + " - " + t.DimSubId.ToString().Trim()); } } else { var temp = medicao.Select(x => new { x.DimSubId }).Distinct().ToList(); foreach (var t in temp) { legenda.Add(t.DimSubId.ToString().Trim()); } } } else { var temp = medicao.Select(x => new { x.FatDescricao }).Distinct().ToList(); foreach (var t in temp) { legenda.Add(t.FatDescricao.ToString().Trim()); } if (periodo == "M") { cabecalho.Add("01"); cabecalho.Add("02"); cabecalho.Add("03"); cabecalho.Add("04"); cabecalho.Add("05"); cabecalho.Add("06"); cabecalho.Add("07"); cabecalho.Add("08"); cabecalho.Add("09"); cabecalho.Add("10"); cabecalho.Add("11"); cabecalho.Add("12"); cabecalho.Add("AC"); cabecalho.Add("AN"); } else if (periodo == "D") { dataAux = dataDe; while (dataAte >= dataAux) { cabecalho.Add(dataAux.Day.ToString()); dataAux = dataAux.AddDays(1); } } } } // fatos = serie cabecalho = eicho X xAxis return(this.Json(new { fatos, dados, legenda, cabecalho, temDimSubId, subDimensao }, JsonRequestBehavior.AllowGet)); }
private void button2_Click(object sender, EventArgs e) { dgv.DataSource = null; dgv.DataSource = Graficos.Buscar(); lblTitulo.Text = "gráficos integrados"; }
public bool Gera(char tipo, string arquivo, string titulo, bool idt_inicial, DateTime data_inicial, bool idt_final, DateTime data_final, bool pagos, bool abertos) { FluxoCaixa fluxo = new FluxoCaixa(); /* * PDF pdf = new PDF(arquivo); * pdf.Abre(); * fluxo.Parte1(pdf, titulo, idt_inicial, data_inicial, idt_final, data_final); */ FileStream fs = new FileStream(arquivo, FileMode.Create); Document doc = new Document(PageSize.LETTER.Rotate()); PdfWriter writer = PdfWriter.GetInstance(doc, fs); doc.Open(); PdfContentByte buf = writer.DirectContent; string periodo = ""; if (idt_inicial || idt_final) { periodo = "Período: "; if (idt_inicial && idt_final) { periodo += "de " + data_inicial.ToString("dd/MM/yyyy") + " até " + data_final.ToString("dd/MM/yyyy"); } else { if (idt_inicial) { periodo += "a partir de " + data_inicial.ToString("dd/MM/yyyy"); } else { periodo += "até " + data_final.ToString("dd/MM/yyyy"); } } } if (pagos && !abertos) { Graficos.Cabecalho(doc, titulo + "- Pagos", periodo); } else if (!pagos && abertos) { Graficos.Cabecalho(doc, titulo + "- Abertos", periodo); } else { Graficos.Cabecalho(doc, titulo, periodo); } string where; string where2 = ""; string col_cod; string col_per; if (tipo == 'v') { col_cod = "O.COD_VENDEDOR"; col_per = "P.PER_VENDEDOR"; if (pagos && abertos) { where = "where P.DAT_PEDIDO is not null "; } else if (pagos) { where = "where P.IDT_VENDEDOR = 'S' and P.DAT_PEDIDO is not null "; } else { where = "where P.IDT_VENDEDOR <> 'S' and P.DAT_PEDIDO is not null "; } } else if (tipo == 'c') { col_cod = "O.COD_CONSULTOR"; col_per = "P.PER_CONSULTOR"; if (pagos && abertos) { where = "where P.DAT_PEDIDO is not null "; } else if (pagos) { where = "where P.IDT_CONSULTOR = 'S' and P.DAT_PEDIDO is not null "; } else { where = "where P.IDT_CONSULTOR <> 'S' and P.DAT_PEDIDO is not null "; } } else { col_cod = "P.COD_FORNECEDOR"; col_per = "0"; where = "where P.COD_PEDIDO = '1' and P.DAT_PEDIDO is not null "; where2 = "where P.COD_PEDIDO = '2' and P.DAT_PEDIDO is not null "; } if (idt_inicial || idt_final) { if (idt_inicial && idt_final) { where += "and (P.DAT_PEDIDO between '" + data_inicial.ToString("M/d/yyyy") + "' and '" + data_final.ToString("M/d/yyyy") + "') "; where2 += "and (P.DAT_PEDIDO between '" + data_inicial.ToString("M/d/yyyy") + "' and '" + data_final.ToString("M/d/yyyy") + "') "; } else { if (idt_inicial) { where += "and (P.DAT_PEDIDO >= '" + data_inicial.ToString("M/d/yyyy") + "') "; where2 += "and (P.DAT_PEDIDO >= '" + data_inicial.ToString("M/d/yyyy") + "') "; } else { where += "and (P.DAT_PEDIDO <= '" + data_final.ToString("M/d/yyyy") + "') "; where2 += "and (P.DAT_PEDIDO <= '" + data_final.ToString("M/d/yyyy") + "') "; } } } string sql = "select " + col_cod + "," + "P.VLR_PEDIDO," + col_per + "," + "O.PER_CONSULTOR as PER_CONSULTOR_ORC," + "O.VLR_ORCAMENTO," + "O.VLR_DESCONTO," + "O.COD_CARACTERISTICA," + "C.PER_LIMIAR," + "C.PER_FILIAL," + "O.COD_FORNECEDOR," + "P.VLR_FRETE," + "C.PER_FRETE," + "P.DAT_ORCAMENTO," + "P.COD_ORCAMENTO," + "P.COD_PEDIDO " + "from PEDIDOS P " + "inner join ORCAMENTOS O " + "on O.COD_FORNECEDOR=P.COD_FORNECEDOR and O.DAT_ORCAMENTO=P.DAT_ORCAMENTO and O.COD_ORCAMENTO=P.COD_ORCAMENTO " + "inner join CARACTERISTICAS C " + "on C.COD_FORNECEDOR=O.COD_FORNECEDOR and C.COD_CARACTERISTICA=O.COD_CARACTERISTICA " + where; if (tipo == 'f') { sql = sql + "union " + "select " + "'SERVICO-' || P.COD_FORNECEDOR," + "P.VLR_PEDIDO," + col_per + "," + "O.PER_CONSULTOR as PER_CONSULTOR_ORC, " + "O.VLR_ORCAMENTO," + "O.VLR_DESCONTO," + "O.COD_CARACTERISTICA," + "C.PER_LIMIAR," + "C.PER_FILIAL," + "O.COD_FORNECEDOR," + "P.VLR_FRETE," + "C.PER_FRETE," + "P.DAT_ORCAMENTO," + "P.COD_ORCAMENTO," + "P.COD_PEDIDO " + "from PEDIDOS P " + "inner join ORCAMENTOS O " + "on O.COD_FORNECEDOR=P.COD_FORNECEDOR and O.DAT_ORCAMENTO=P.DAT_ORCAMENTO and O.COD_ORCAMENTO=P.COD_ORCAMENTO " + "inner join CARACTERISTICAS C " + "on C.COD_FORNECEDOR=O.COD_FORNECEDOR and C.COD_CARACTERISTICA=O.COD_CARACTERISTICA " + where2; } sql = sql + "order by 1"; StreamWriter log = new StreamWriter("gerencial.log"); log.WriteLine(sql); log.Flush(); FbCommand cmd = new FbCommand(sql, Globais.bd); FbDataReader reader = cmd.ExecuteReader(CommandBehavior.Default); string codigo; float valor; float percentual; string ultimo = ""; float total = 0; ArrayList valores = new ArrayList(); ArrayList descricoes = new ArrayList(); VendedorConsultor vendedor_consultor = null; ArrayList lista = new ArrayList(); cOrcamentos orcamento = new cOrcamentos(); cComissaoLimiar comissao = new cComissaoLimiar(); cCaracteristicas carac = new cCaracteristicas(); while (reader.Read()) { codigo = reader.GetString(0); valor = reader.GetFloat(1); percentual = reader.GetFloat(2); float vlr_itens = reader.GetFloat(4); float vlr_desconto = reader.GetFloat(5); string caracteristica = reader.GetString(6); float limiar = reader.GetFloat(7); string fornecedor = reader.GetString(9); float vlr_frete = reader.IsDBNull(10) ? 0 : reader.GetFloat(10); float per_frete = reader.IsDBNull(11) ? 0 : reader.GetFloat(11); DateTime dat_orcamento = reader.GetDateTime(12); short cod_orcamento = reader.GetInt16(13); short cod_pedido = reader.GetInt16(14); float vlr_frete_item = 0; if (vlr_frete > 0) { vlr_frete_item = cPedidos.RateiaFrete(fornecedor, dat_orcamento, cod_orcamento, cod_pedido, ref vlr_frete); } string venpro = "", venser = "", conpro = "", conser = "", filpro = "", filser = ""; carac.FormulasComissao(fornecedor, caracteristica, ref venpro, ref venser, ref conpro, ref conser, ref filpro, ref filser); if (percentual == 0) { if (tipo == 'v') { if (codigo.StartsWith("SERVICO-")) { //Globais.CalculaFormula(ref valor, venser, 0, per_frete, vlr_frete_item); } else { //Globais.CalculaFormula(ref valor, venpro, 0, per_frete, vlr_frete_item); } percentual = reader.GetFloat(3); // consultor float vlr_orcamento = vlr_itens - vlr_desconto; float sinal = orcamento.CalculaSinal(fornecedor, caracteristica, vlr_itens, vlr_desconto, percentual, limiar); percentual = comissao.Calcula(fornecedor, caracteristica, valor, sinal); } else if (tipo == 'c') { if (codigo.StartsWith("SERVICO-")) { //Globais.CalculaFormula(ref valor, conser, 0, per_frete, vlr_frete_item); } else { //Globais.CalculaFormula(ref valor, conpro, 0, per_frete, vlr_frete_item); } percentual = reader.GetFloat(3); } else { if (codigo.StartsWith("SERVICO-")) { //Globais.CalculaFormula(ref valor, filser, 0, per_frete, vlr_frete_item); percentual = 100; } else { //Globais.CalculaFormula(ref valor, filpro, 0, per_frete, vlr_frete_item); percentual = reader.GetFloat(8); } } } if (!codigo.Equals(ultimo)) { if (!ultimo.Equals("")) { lista.Add(vendedor_consultor); } ultimo = codigo; vendedor_consultor = new VendedorConsultor(); vendedor_consultor.codigo = codigo; vendedor_consultor.vendas = 0; vendedor_consultor.percentual = 0; vendedor_consultor.n = 0; } vendedor_consultor.vendas += valor; vendedor_consultor.percentual += percentual; if (percentual > 0.01) { vendedor_consultor.n++; } total += valor; log.WriteLine(valor.ToString() + " " + total.ToString()); log.Flush(); } log.Close(); if (!ultimo.Equals("")) { lista.Add(vendedor_consultor); } reader.Close(); foreach (VendedorConsultor vc in lista) { valores.Add(vc.vendas); descricoes.Add(vc.codigo); } //if (valores.Count > 12) //{ ArrayList valores12 = new ArrayList(); ArrayList descricoes12 = new ArrayList(); int max = valores.Count > 12 ? 11 : valores.Count; //for (int i=0; i<11; i++) for (int i = 0; i < max; i++) { float maior = -1; int v = 0, imaior = -1; foreach (float vlr in valores) { if (vlr > maior) { maior = vlr; imaior = v; } v++; } float vmaior = float.Parse(valores[imaior].ToString()); string dmaior = descricoes[imaior].ToString(); valores12.Add(vmaior); descricoes12.Add(dmaior); valores.RemoveAt(imaior); descricoes.RemoveAt(imaior); } if (valores.Count > 12) { float voutros = 0; foreach (float vlr in valores) { voutros += vlr; } valores12.Add(voutros); descricoes12.Add("OUTROS"); } Graficos.Pizza(buf, valores12, descricoes12, 200, 250, 120); //} //else //Graficos.Pizza(buf, valores, descricoes, 200, 250, 120); doc.NewPage(); Tabela table = new Tabela(tipo == 'f' ? 3 : 4); if (tipo == 'v') { fluxo.AdicionaCelula(table, "Vendedor", BaseFont.HELVETICA_BOLD, 8, iTextSharp.text.Color.LIGHT_GRAY, 1); } else if (tipo == 'c') { fluxo.AdicionaCelula(table, "Consultor", BaseFont.HELVETICA_BOLD, 8, iTextSharp.text.Color.LIGHT_GRAY, 1); } else { fluxo.AdicionaCelula(table, "Fornecedor", BaseFont.HELVETICA_BOLD, 8, iTextSharp.text.Color.LIGHT_GRAY, 1); } fluxo.AdicionaCelula(table, "Vendas", BaseFont.HELVETICA_BOLD, 8, iTextSharp.text.Color.LIGHT_GRAY, Element.ALIGN_RIGHT, 1); fluxo.AdicionaCelula(table, "% Total", BaseFont.HELVETICA_BOLD, 8, iTextSharp.text.Color.LIGHT_GRAY, Element.ALIGN_RIGHT, 1); if (tipo != 'f') { fluxo.AdicionaCelula(table, "Média Comissão", BaseFont.HELVETICA_BOLD, 8, iTextSharp.text.Color.LIGHT_GRAY, Element.ALIGN_RIGHT, 1); } foreach (VendedorConsultor vc in lista) { fluxo.AdicionaCelula(table, vc.codigo, BaseFont.HELVETICA, 8, Element.ALIGN_LEFT, 1); fluxo.AdicionaCelula(table, vc.vendas.ToString("#,###,##0.00"), BaseFont.HELVETICA, 8, Element.ALIGN_RIGHT, 1); fluxo.AdicionaCelula(table, (vc.vendas * 100 / total).ToString("#,###,##0.00"), BaseFont.HELVETICA, 8, Element.ALIGN_RIGHT, 1); if (tipo != 'f') { fluxo.AdicionaCelula(table, (vc.percentual / vc.n).ToString("#,###,##0.00"), BaseFont.HELVETICA, 8, Element.ALIGN_RIGHT, 1); } } fluxo.AdicionaCelula(table, "Total", BaseFont.HELVETICA_BOLD, 8, Color.GRAY, 1); fluxo.AdicionaCelula(table, total.ToString("#,###,##0.00"), BaseFont.HELVETICA, 8, Color.GRAY, Element.ALIGN_RIGHT, 1); fluxo.AdicionaCelula(table, "", BaseFont.HELVETICA_BOLD, 8, Color.GRAY, tipo == 'f' ? 1 : 2); doc.Add(table); doc.Close(); return(true); }
private void FormProcesador_Load(object sender, EventArgs e) { dgv.DataSource = Procesador.Buscar(); cmbGraficos.DataSource = Graficos.Buscar(); cmbMarca.DataSource = Marca.Buscar(); }
void BtnConfirmaClick(object sender, EventArgs e) { valores.Clear(); descricoes.Clear(); if (origem == 'p') { titulos_pagar.FixoVariavel(dtpInicial.Value, dtpFinal.Value, ref valores, ref descricoes); } else { titulos_receber.FixoVariavel(dtpInicial.Value, dtpFinal.Value, ref valores, ref descricoes); } FileStream fs = new FileStream("fixo_variavel.pdf", FileMode.Create); Document doc = new Document(PageSize.LETTER.Rotate()); PdfWriter writer = PdfWriter.GetInstance(doc, fs); doc.Open(); PdfContentByte buf = writer.DirectContent; Graficos.Cabecalho(doc, "Fixo x Variável", ""); Graficos.Pizza(buf, valores, descricoes, 200, 250, 120); doc.Close(); System.Diagnostics.Process.Start("explorer", "fixo_variavel.pdf"); Close(); /* * int i=0; * foreach (string descricao in descricoes) * { * int j = 0; * string valor=""; * foreach (float v in valores) * { * valor = v.ToString("#,###,##0.00"); * if (j++ == i) break; * } * switch (i++) * { * case 0: * v1.Text = valor; * d1.Text = descricao; * v1.Visible = true; * c1.Visible = true; * d1.Visible = true; * c1.BackColor = Color.FromArgb(255, 255, 0, 0); * break; * case 1: * v2.Text = valor; * d2.Text = descricao; * v2.Visible = true; * c2.Visible = true; * d2.Visible = true; * c2.BackColor = Color.FromArgb(255, 0, 255, 0); * break; * } * * } * selecionado = true; * pnlGrafico.Refresh(); */ }
private void Buscar() { dgvGraficos.DataSource = null; dgvGraficos.DataSource = Graficos.Buscar(); }
void BtnConfirmaClick(object sender, EventArgs e) { valores.Clear(); descricoes.Clear(); if (origem == 'p') { titulos_pagar.AgrupaPorVencimento(dtpInicial.Value, dtpFinal.Value, ref valores, ref descricoes, 11); } else { titulos_receber.AgrupaPorVencimento(dtpInicial.Value, dtpFinal.Value, ref valores, ref descricoes, 11); } FileStream fs = new FileStream("despesas_natureza.pdf", FileMode.Create); Document doc = new Document(PageSize.LETTER.Rotate()); PdfWriter writer = PdfWriter.GetInstance(doc, fs); doc.Open(); PdfContentByte buf = writer.DirectContent; Graficos.Cabecalho(doc, "Despesas x Natureza", ""); Graficos.Pizza(buf, valores, descricoes, 200, 250, 120); doc.NewPage(); if (origem == 'p') { cTitulosPagar.GeraDespesasNatureza(doc, dtpInicial.Value, dtpFinal.Value); } else { cTitulosXeceber.GeraDespesasNatureza(doc, dtpInicial.Value, dtpFinal.Value); }; doc.Close(); System.Diagnostics.Process.Start("explorer", "despesas_natureza.pdf"); Close(); /* * int i=0; * foreach (string descricao in descricoes) * { * int j = 0; * string valor=""; * foreach (float v in valores) * { * valor = v.ToString("#,###,##0.00"); * if (j++ == i) break; * } * switch (i++) * { * case 0: * v1.Text = valor; * d1.Text = descricao; * v1.Visible = true; * c1.Visible = true; * d1.Visible = true; * c1.BackColor = System.Drawing.Color.FromArgb(255, 255, 0, 0); * break; * case 1: * v2.Text = valor; * d2.Text = descricao; * v2.Visible = true; * c2.Visible = true; * d2.Visible = true; * c2.BackColor = System.Drawing.Color.FromArgb(255, 0, 255, 0); * break; * case 2: * v3.Text = valor; * d3.Text = descricao; * v3.Visible = true; * c3.Visible = true; * d3.Visible = true; * c3.BackColor = System.Drawing.Color.FromArgb(255, 0, 0, 255); * break; * case 3: * v4.Text = valor; * d4.Text = descricao; * v4.Visible = true; * c4.Visible = true; * d4.Visible = true; * c4.BackColor = System.Drawing.Color.FromArgb(255, 255, 255, 0); * break; * case 4: * v5.Text = valor; * d5.Text = descricao; * v5.Visible = true; * c5.Visible = true; * d5.Visible = true; * c5.BackColor = System.Drawing.Color.FromArgb(255, 0, 255, 255); * break; * case 5: * v6.Text = valor; * d6.Text = descricao; * v6.Visible = true; * c6.Visible = true; * d6.Visible = true; * c6.BackColor = System.Drawing.Color.FromArgb(255, 255, 0, 255); * break; * case 6: * v7.Text = valor; * d7.Text = descricao; * v7.Visible = true; * c7.Visible = true; * d7.Visible = true; * c7.BackColor = System.Drawing.Color.FromArgb(255, 255, 128, 0); * break; * case 7: * v8.Text = valor; * d8.Text = descricao; * v8.Visible = true; * c8.Visible = true; * d8.Visible = true; * c8.BackColor = System.Drawing.Color.FromArgb(255, 0, 255, 128); * break; * case 8: * v9.Text = valor; * d9.Text = descricao; * v9.Visible = true; * c9.Visible = true; * d9.Visible = true; * c9.BackColor = System.Drawing.Color.FromArgb(255, 128, 0, 255); * break; * case 9: * v10.Text = valor; * d10.Text = descricao; * v10.Visible = true; * c10.Visible = true; * d10.Visible = true; * c10.BackColor = System.Drawing.Color.FromArgb(255, 255, 128, 128); * break; * case 10: * v11.Text = valor; * d11.Text = descricao; * v11.Visible = true; * c11.Visible = true; * d11.Visible = true; * c11.BackColor = System.Drawing.Color.FromArgb(255, 128, 255, 128); * break; * case 11: * v12.Text = valor; * d12.Text = descricao; * v12.Visible = true; * c12.Visible = true; * d12.Visible = true; * c12.BackColor = System.Drawing.Color.FromArgb(255, 128, 128, 255); * break; * } * * } * selecionado = true; * pnlGrafico.Refresh(); */ }
void BtnConfirmaClick(object sender, EventArgs e) { string natureza = cbxNaturezas.Text.Trim(); if (natureza.Length == 0) { MessageBox.Show("Natureza", "Campo Obrigatório", MessageBoxButtons.OK, MessageBoxIcon.Warning); cbxNaturezas.Focus(); return; } int mes = dtpInicial.Value.Month, ano = dtpInicial.Value.Year, n = 0; while ((ano < dtpFinal.Value.Year) || ((ano == dtpFinal.Value.Year) && (mes <= dtpFinal.Value.Month))) { n++; mes++; if (mes > 12) { mes = 1; ano++; } } if (n > 12) { MessageBox.Show("O período selecionado deve ser de no máximo 12 meses", "Intervalo", MessageBoxButtons.OK, MessageBoxIcon.Warning); cbxNaturezas.Focus(); return; } n = cbxNaturezas.SelectedIndex; natureza = cbxCodNaturezas.Items[n].ToString(); string des_natureza = cbxNaturezas.Items[n].ToString(); valores.Clear(); datas.Clear(); float max = 0; if (origem == 'p') { max = titulos_pagar.SomaPorVencimento(natureza, dtpInicial.Value, dtpFinal.Value, ref valores, ref datas); } else { max = titulos_receber.SomaPorVencimento(natureza, dtpInicial.Value, dtpFinal.Value, ref valores, ref datas); } FileStream fs = new FileStream("tendencia.pdf", FileMode.Create); Document doc = new Document(PageSize.LETTER.Rotate()); PdfWriter writer = PdfWriter.GetInstance(doc, fs); doc.Open(); PdfContentByte buf = writer.DirectContent; Graficos.Cabecalho(doc, "Tendência", des_natureza); Graficos.Barras(buf, valores, datas, 150, max); doc.Close(); System.Diagnostics.Process.Start("explorer", "tendencia.pdf"); Close(); /* * float vlr=100; * while (vlr < max) vlr *= 2; * d = vlr / 10; * label12.Text = vlr.ToString("#,###,##0.00"); vlr-=d; * label11.Text = vlr.ToString("#,###,##0.00"); vlr-=d; * label10.Text = vlr.ToString("#,###,##0.00"); vlr-=d; * label9.Text = vlr.ToString("#,###,##0.00"); vlr-=d; * label8.Text = vlr.ToString("#,###,##0.00"); vlr-=d; * label7.Text = vlr.ToString("#,###,##0.00"); vlr-=d; * label6.Text = vlr.ToString("#,###,##0.00"); vlr-=d; * label5.Text = vlr.ToString("#,###,##0.00"); vlr-=d; * label4.Text = vlr.ToString("#,###,##0.00"); vlr-=d; * label3.Text = vlr.ToString("#,###,##0.00"); * int i=0; * int x=115; * Pen pen = new Pen(Color.Black, 1); * foreach (string descricao in datas) * { * int j = 0; * string valor=""; * foreach (float v in valores) * { * valor = v.ToString("#,###,##0.00"); * if (j++ == i) break; * } * switch (i++) * { * case 0: * v1.Text = valor; * d1.Text = descricao; * v1.Visible = true; * c1.Visible = true; * d1.Visible = true; * c1.BackColor = Color.FromArgb(255, 255, 0, 0); * break; * case 1: * v2.Text = valor; * d2.Text = descricao; * v2.Visible = true; * c2.Visible = true; * d2.Visible = true; * c2.BackColor = Color.FromArgb(255, 0, 255, 0); * break; * case 2: * v3.Text = valor; * d3.Text = descricao; * v3.Visible = true; * c3.Visible = true; * d3.Visible = true; * c3.BackColor = Color.FromArgb(255, 0, 0, 255); * break; * case 3: * v4.Text = valor; * d4.Text = descricao; * v4.Visible = true; * c4.Visible = true; * d4.Visible = true; * c4.BackColor = Color.FromArgb(255, 255, 255, 0); * break; * case 4: * v5.Text = valor; * d5.Text = descricao; * v5.Visible = true; * c5.Visible = true; * d5.Visible = true; * c5.BackColor = Color.FromArgb(255, 0, 255, 255); * break; * case 5: * v6.Text = valor; * d6.Text = descricao; * v6.Visible = true; * c6.Visible = true; * d6.Visible = true; * c6.BackColor = Color.FromArgb(255, 255, 0, 255); * break; * case 6: * v7.Text = valor; * d7.Text = descricao; * v7.Visible = true; * c7.Visible = true; * d7.Visible = true; * c7.BackColor = Color.FromArgb(255, 255, 128, 0); * break; * case 7: * v8.Text = valor; * d8.Text = descricao; * v8.Visible = true; * c8.Visible = true; * d8.Visible = true; * c8.BackColor = Color.FromArgb(255, 0, 255, 128); * break; * case 8: * v9.Text = valor; * d9.Text = descricao; * v9.Visible = true; * c9.Visible = true; * d9.Visible = true; * c9.BackColor = Color.FromArgb(255, 128, 0, 255); * break; * case 9: * v10.Text = valor; * d10.Text = descricao; * v10.Visible = true; * c10.Visible = true; * d10.Visible = true; * c10.BackColor = Color.FromArgb(255, 255, 128, 128); * break; * case 10: * v11.Text = valor; * d11.Text = descricao; * v11.Visible = true; * c11.Visible = true; * d11.Visible = true; * c11.BackColor = Color.FromArgb(255, 128, 255, 128); * break; * case 11: * v12.Text = valor; * d12.Text = descricao; * v12.Visible = true; * c12.Visible = true; * d12.Visible = true; * c12.BackColor = Color.FromArgb(255, 128, 128, 255); * break; * case 12: * v13.Text = valor; * d13.Text = descricao; * v13.Visible = true; * c13.Visible = true; * d13.Visible = true; * c13.BackColor = Color.FromArgb(255, 128, 128, 0); * break; * } * x += 40; * } * pnlGrafico.Refresh(); */ }