public Pantalla_Mostrar_Factura(int id_compra, Decimal cod_publi, DateTime fechaCompra) { InitializeComponent(); factuAdapter = new GD1C2016DataSetTableAdapters.facturasTableAdapter(); factuData = new GD1C2016DataSet.facturasDataTable(); factuData = factuAdapter.busquedaDeFacturas(id_compra); nro_fact = Convert.ToInt32(factuData[0][0]); total = Convert.ToDecimal(factuData[0][5]); dataGridView1.Rows.Add(nro_fact, id_compra, cod_publi, fechaCompra, total); }
private void button3_Click(object sender, EventArgs e) { factuAdapter = new GD1C2016DataSetTableAdapters.facturasTableAdapter(); factuData = new GD1C2016DataSet.facturasDataTable(); if (dataGridView1.Rows.Count > 0) { MessageBox.Show("Debes limpiar la grilla antes de seguir con otra búsqueda"); } else { pageNumber = 1; elementoInicial = 0; if (!checkBox1.Checked && (textBox2.Text == "" || textBox1.Text == "") && textBox4.Text == "" && textBox3.Text == "") { MessageBox.Show("Ingrese algún tipo de filtro"); } else { if (((textBox1.Text != "" && textBox2.Text == "") || (textBox2.Text != "" && textBox1.Text == "")) && (checkBox1.Checked || textBox4.Text != "" || textBox3.Text != "")) { MessageBox.Show("Filtros incorrectos"); } else { if (checkBox1.Checked) { fecha1 = dateTimePicker1.Value; fecha2 = dateTimePicker2.Value; } if (textBox3.Text != "") { GD1C2016DataSetTableAdapters.usuariosTableAdapter userAdapter = new GD1C2016DataSetTableAdapters.usuariosTableAdapter(); GD1C2016DataSet.usuariosDataTable userData = new GD1C2016DataSet.usuariosDataTable(); idConsulta = (Decimal)userAdapter.consultaID(textBox3.Text); if (idConsulta == null) { MessageBox.Show("No existe ese usuario"); } } if (textBox1.Text != "" && textBox2.Text != "") { importe1 = textBox1.Text; importe2 = textBox2.Text; } detalle = textBox4.Text; elementoInicial = (pageNumber - 1) * 6; cantRows = Convert.ToDouble(factuAdapter.cantidadDeFacturas(idConsulta, fecha1, fecha2, importe1, importe2, detalle)); maxPages = Math.Ceiling(cantRows / 6); if (maxPages != 0) { if (maxPages > 1) { button8.Enabled = true; } label9.Text = Convert.ToString(maxPages); factuData = factuAdapter.consultaDeFacturas(idConsulta, fecha1, fecha2, importe1, importe2, detalle, elementoInicial); foreach (DataRow row in factuData.Rows) { dataGridView1.Rows.Add(row.Field <Decimal>("nro_fact"), row.Field <String>("descripcion"), row.Field <Object>("id_compra"), row.Field <DateTime>("fecha"), row.Field <Object>("total")); } } else { fecha1 = null; fecha2 = null; importe1 = null; importe2 = null; detalle = null; idConsulta = null; } } } } }