public void cargarCX(int tipo) { if (tipo == 0) { cxReporte.Items.Add("<--Seleccione-->"); cxReporte.Items.Add("Trimestral"); cxReporte.Items.Add("Semestral"); cxReporte.Items.Add("Anual"); cxReporte.SelectedIndex = 0; } else if (tipo == 1) { cxPeriodo.Items.Clear(); cxPeriodo.Items.Add("<--Seleccione-->"); cxPeriodo.SelectedIndex = 0; cxPeriodo.Items.Add("1 - Periodo"); cxPeriodo.Items.Add("2 - Periodo"); cxPeriodo.Items.Add("3 - Periodo"); cxPeriodo.Items.Add("4 - Periodo"); } else if (tipo == 2) { cxPeriodo.Items.Clear(); cxPeriodo.Items.Add("<--Seleccione-->"); cxPeriodo.SelectedIndex = 0; cxPeriodo.Items.Add("1 - Semestre"); cxPeriodo.Items.Add("2 - Semestre"); } else if (tipo == 3) { cxSucursal.Items.Add("<--Seleccione-->"); cxSucursal.Items.Add("0 - Todas"); DataTable tb = ConexionBD.Data("SELECT * FROM sucursal"); if (tb.Rows.Count > 0 && cxSucursal.Text != "<--Seleccione-->") { for (int j = 0; j < tb.Rows.Count; j++) { cxSucursal.Items.Add(tb.Rows[j]["Id"].ToString() + " - " + tb.Rows[j]["Ubicacion"].ToString()); } } cxSucursal.SelectedIndex = 0; //cxSucursal.DataSource = ConexionBD.Data("SELECT * FROM sucursal"); //cxSucursal.DisplayMember="Ubicacion"; //cxSucursal.ValueMember = "Id"; } else if (tipo == 4) { cxVendedor.Items.Add("<--Seleccione-->"); DataTable tb = ConexionBD.Data("SELECT Id, concat(Nombre, ' ', Apellido) as Nombre FROM persona WHERE Roll_Id =" + 1); if (tb.Rows.Count > 0 && cxSucursal.Text == "<--Seleccione-->") { for (int j = 0; j < tb.Rows.Count; j++) { cxVendedor.Items.Add(tb.Rows[j]["Id"].ToString() + " - " + tb.Rows[j]["Nombre"].ToString()); } } cxVendedor.SelectedIndex = 0; } else if (tipo == 5) { cxVendedor.Items.Clear(); //cxVendedor.ResetText(); cxVendedor.Items.Add("<--Seleccione-->"); DataTable tb = ConexionBD.Data("SELECT Id, concat(Nombre, ' ', Apellido) as Nombre FROM persona WHERE Roll_Id =" + 1 + " AND Sucursal_Id=" + sucuralId); if (tb.Rows.Count > 0 && (cxSucursal.Text != "<--Seleccione-->" || cxSucursal.Text != "0 - Todas")) { //MessageBox.Show("aqui"); for (int j = 0; j < tb.Rows.Count; j++) { cxVendedor.Items.Add(tb.Rows[j]["Id"].ToString() + " - " + tb.Rows[j]["Nombre"].ToString()); } } cxVendedor.SelectedIndex = 0; } }
public ImpresionFactura() { InitializeComponent(); reportes1.SetDataSource(ConexionBD.Data("SELECT * FROM reporte WHERE 'No. Factura'= (SELECT MAX(Id) FROM ventas)")); }
private void Consultar_Click_1(object sender, EventArgs e) { /////////////////////////////// MessageBox.Show("entro al evento " + condicion); Boolean ok = true; if (tipoReporte != "<--Seleccione-->") { if (tipoReporte != "Anual" && cxPeriodo.Text == "<--Seleccione-->") { ok = false; MessageBox.Show("Debese Seleccionar El periodo que desea seleccionar", "Error 1355", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (tipoReporte == "Anual" && cxSucursal.Text == "<--Seleccione-->") { MessageBox.Show(Finicio + " -...-anual" + Ffinal); tablaReport.DataSource = null; sql = "SELECT suc.Id, Ubicacion, SUM(TotalFatura) AS 'Total Vendido' FROM ventas AS ven " + "INNER JOIN sucursal AS suc ON suc.Id = ven.Sucursal_Id " + "WHERE (Fecha BETWEEN '" + Finicio + "' AND '" + Ffinal + "' ) " + "GROUP BY Ubicacion"; tablaReport.DataSource = ConexionBD.Data(sql); bandera = "anual"; } else { if (cxSucursal.Text != "<--Seleccione-->" && cxSucursal.Text != "0 - Todas") { if (cxVendedor.Text != "<--Seleccione-->") { tablaReport.DataSource = null; sql = "SELECT ven.Id, concat(Nombre, ' ', Apellido) AS Nombre, SUM(TotalFatura) AS 'Total' FROM ventas AS ven " + "INNER JOIN persona AS per ON per.Id = ven.Vendedor_Id " + "INNER JOIN sucursal AS suc ON suc.Id = ven.Sucursal_Id " + "WHERE (Fecha BETWEEN '" + Finicio + "' AND '" + Ffinal + "' ) AND Vendedor_Id = " + vendedorId; tablaReport.DataSource = ConexionBD.Data(sql); bandera = "vendedor"; } else { MessageBox.Show("AQUI EN ESTA" + condicion, "Error 1355", MessageBoxButtons.OK, MessageBoxIcon.Information); tablaReport.DataSource = null; sql = "SELECT suc.Id, Ubicacion, TotalFatura AS 'Total Vendido' FROM ventas AS ven " + "INNER JOIN sucursal AS suc ON suc.Id = ven.Sucursal_Id " + "WHERE (Fecha BETWEEN '" + Finicio + "' AND '" + Ffinal + "' ) AND Sucursal_Id = " + sucuralId; tablaReport.DataSource = ConexionBD.Data(sql); bandera = "sucursal"; } } else if (cxSucursal.Text == "0 - Todas") { tablaReport.DataSource = null; sql = "SELECT suc.Id, Ubicacion Fecha, SUM(TotalFatura) AS 'Total Vendido' FROM ventas AS ven " + "INNER JOIN sucursal AS suc ON suc.Id = ven.Sucursal_Id " + "WHERE (Fecha BETWEEN '" + Finicio + "' AND '" + Ffinal + "' )" + "GROUP BY ven.Id"; tablaReport.DataSource = ConexionBD.Data(sql); bandera = "todas"; } else { if (cxVendedor.Text != "<--Seleccione-->") { tablaReport.DataSource = null; sql = "SELECT ven.Id, concat(Nombre, ' ', Apellido) AS Nombre, SUM(TotalFatura) AS 'Total' FROM ventas AS ven " + "INNER JOIN persona AS per ON per.Id = ven.Vendedor_Id " + "INNER JOIN sucursal AS suc ON suc.Id = ven.Sucursal_Id " + "WHERE (Fecha BETWEEN '" + Finicio + "' AND '" + Ffinal + "' ) AND Vendedor_Id = " + vendedorId; tablaReport.DataSource = ConexionBD.Data(sql); bandera = "vendedor"; } } } } else { ok = false; MessageBox.Show("Debese Seleccionar Un tipo de Reporte Primero", "Error 1355", MessageBoxButtons.OK, MessageBoxIcon.Information); } ///////////////////////////////// }