private void button2_Click(object sender, EventArgs e) { object celda = dataGridView1.CurrentCell.Value; string id = lbl_id.Text; string data = ""; string campo = ""; string campo2 = ""; switch (id) { case "1": data = mtb_cedula_c.Text; campo = "a.cedula"; campo2 = "cedula_c"; break; case "2": data = maskedTextBox1.Text; campo = "a.cedula"; campo2 = "cedula_c"; break; case "3": data = textBox4.Text; campo = "a.nombre"; campo2 = "nombre_c"; break; case "4": data = textBox2.Text; campo = "a.apellido"; campo2 = "apellido_c"; break; } //string datos = cbx_estado.SelectedItem.ToString(); con.Open(); MySqlCommand cmd = con.CreateCommand(); frm_facturacion fac = new frm_facturacion(celda, id, data); cmd.CommandType = CommandType.Text; cmd.CommandText = "SELECT b.nombre as Gasto, b.monto as Monto, b.detalle as Detalle, a.nombre as Nombre, a.apellido as Apellido, a.cedula as Cedula, a.oficialia_civil as Oficialia FROM pr_clientes AS a INNER JOIN pr_gastos AS b ON a.client_Id = b.client_Id where a.hidden=0 and " + campo + "='" + data + "' and b.tipo = '" + celda + "'"; cmd.ExecuteNonQuery(); DataTable dt = new DataTable(); MySqlDataAdapter da = new MySqlDataAdapter(cmd); fac.dataGridView2.Visible = true; da.Fill(dt); fac.dataGridView2.DataSource = dt; con.Close(); fac.txt_sub_total.Text = txt_sub_total.Text; fac.textBox1.Text = textBox1.Text; fac.textBox3.Text = textBox3.Text; // fac.textBox5.Text = label8.Text; fac.Show(); }