private void Grafico() { DateTime actual = DateTime.ParseExact(DateTime.Now.ToString("yyyy-MM-dd"), "yyyy-MM-dd", CultureInfo.InvariantCulture); try { DataTable DtVentas = new DataTable(); if (comboProyecto.Text == "TODOS LOS PROYECTOS") { DtVentas = producto.ReportVentas("2018-01-01", actual.ToString("yyyy-MM-dd")); } else if (comboProyecto.Text == "") { DtVentas = producto.ReportVentas("2018-01-01", actual.ToString("yyyy-MM-dd")); } else { DtVentas = producto.ReportVentasProyecto("2018-01-01", actual.ToString("yyyy-MM-dd"), comboProyecto.SelectedValue.ToString()); } ArrayList fechaventa = new ArrayList(); ArrayList valorventa = new ArrayList(); for (int i = 0; i < DtVentas.Rows.Count; i++) { fechaventa.Add(DtVentas.Rows[i]["Fecha"].ToString()); valorventa.Add(DtVentas.Rows[i]["Valor"].ToString()); } chart3.Series[0].Points.DataBindXY(fechaventa, valorventa); } catch (Exception e) { MessageBox.Show("Error: " + e); } }
private void CargarRpVentas() { try { dataGridView2.DataSource = ""; labelTotal.Text = ""; labelNumero.Text = ""; DataTable DtValorVentas = new DataTable(); if (comboProyecto.Text == "TODOS LOS PROYECTOS") { if (comboTipo.Text == "TODOS LOS PRODUCTOS") { DtVentas = producto.ReportVentas(dateInicio.Text, datefin.Text); DtValorVentas = producto.ValorReportVentas(dateInicio.Text, datefin.Text); } else { DtVentas = producto.ReportVentasTipo(dateInicio.Text, datefin.Text, (comboTipo.SelectedIndex - 1).ToString()); DtValorVentas = producto.ValorReportVentasTipo(dateInicio.Text, datefin.Text, (comboTipo.SelectedIndex - 1).ToString()); } } else { if (comboTipo.Text == "TODOS LOS PRODUCTOS") { DtVentas = producto.ReportVentasProyecto(dateInicio.Text, datefin.Text, comboProyecto.SelectedValue.ToString()); DtValorVentas = producto.ValorReportVentasProyecto(dateInicio.Text, datefin.Text, comboProyecto.SelectedValue.ToString()); } else { DtVentas = producto.ReportVentasProyectoTipo(dateInicio.Text, datefin.Text, comboProyecto.SelectedValue.ToString(), (comboTipo.SelectedIndex - 1).ToString()); DtValorVentas = producto.ValorReportVentasProyectoTipo(dateInicio.Text, datefin.Text, comboProyecto.SelectedValue.ToString(), (comboTipo.SelectedIndex - 1).ToString()); } } double total = double.Parse(DtValorVentas.Rows[0]["valor"].ToString()); labelTotal.Text = "VALOR VENTAS: $" + String.Format("{0:N2}", total); labelNumero.Text = "CANTIDAD: " + DtValorVentas.Rows[0]["productos"].ToString(); dataGridView2.DataSource = DtVentas; dataGridView2.Columns[3].DefaultCellStyle.Format = "n2"; dataGridView2.Columns["Cedula"].Visible = false; dataGridView2.Columns[2].Width = 80; dataGridView2.Columns[3].Width = 80; dataGridView2.Columns[4].Width = 100; dataGridView2.Columns[6].Width = 200; dataGridView2.Columns[7].Width = 200; dataGridView2.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; } catch { MessageBox.Show("Sin datos para el reporte, seleccione un nuevo atributo o rango de fechas", "No hay resultados", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void GraficoVentas(int meses) { try { DataTable DtVentas = new DataTable(); if (comboProyecto.Text == "TODOS LOS PROYECTOS") { DtVentas = producto.ReportVentas(actual.AddMonths(-meses).ToString("yyyy-MM-dd"), actual.ToString("yyyy-MM-dd")); } else { DtVentas = producto.ReportVentasProyecto(actual.AddMonths(-meses).ToString("yyyy-MM-dd"), actual.ToString("yyyy-MM-dd"), comboProyecto.SelectedValue.ToString()); } ArrayList fechaventa = new ArrayList(); ArrayList valorventa = new ArrayList(); for (int i = 0; i < DtVentas.Rows.Count; i++) { fechaventa.Add(DtVentas.Rows[i]["Fecha"].ToString()); valorventa.Add(DtVentas.Rows[i]["Valor"].ToString()); } if (fechaventa.Count > 0 && valorventa.Count > 0) { chart3.Series[0].Points.DataBindXY(fechaventa, valorventa); } else { fechaventa.Clear(); valorventa.Clear(); chart3.Series[0].Points.DataBindXY(fechaventa, valorventa); MessageBox.Show("Sin ventass para mostrar"); } } catch (Exception e) { MessageBox.Show("Error: " + e); } }