//Info client private void button1_Click(object sender, EventArgs e) { InfoClient cli = new InfoClient(); cli.SaveEdit.Visible = false; cli.save.Visible = false; personaFisica fisica = new personaFisica(); fisica.btnEditCliente.Visible = false; fisica.guardarCliente.Visible = false; if (dataGridView1.SelectedRows.Count > 0) { //Editar = true; cli.IDtxtbox.Text = dataGridView1.CurrentRow.Cells["Id"].Value.ToString(); cli.Nametxt.Text = dataGridView1.CurrentRow.Cells["name"].Value.ToString(); cli.RFCtxt.Text = dataGridView1.CurrentRow.Cells["RFC"].Value.ToString(); cli.phonetxt.Text = dataGridView1.CurrentRow.Cells["phone"].Value.ToString(); cli.mailtxt.Text = dataGridView1.CurrentRow.Cells["email"].Value.ToString(); cli.addrestxt.Text = dataGridView1.CurrentRow.Cells["address"].Value.ToString(); cli.citytxt.Text = dataGridView1.CurrentRow.Cells["city"].Value.ToString(); cli.statetxt.Text = dataGridView1.CurrentRow.Cells[7].Value.ToString(); cli.countrytxt.Text = dataGridView1.CurrentRow.Cells["country"].Value.ToString(); cli.CPtxt.Text = dataGridView1.CurrentRow.Cells["codigopostal"].Value.ToString(); cli.identytxt.Text = dataGridView1.CurrentRow.Cells["identidadfiscal"].Value.ToString(); cli.tasatxt.Text = dataGridView1.CurrentRow.Cells["tasa"].Value.ToString(); cli.statustxt.Text = dataGridView1.CurrentRow.Cells["status"].Value.ToString(); cli.vendortxt.Text = dataGridView1.CurrentRow.Cells["vendedor"].Value.ToString(); cli.paytxt.Text = dataGridView1.CurrentRow.Cells["payment"].Value.ToString(); cli.cfditxt.Text = dataGridView1.CurrentRow.Cells["CFDI"].Value.ToString(); cli.note.Text = dataGridView1.CurrentRow.Cells["note"].Value.ToString(); idCliente = dataGridView1.CurrentRow.Cells["Id"].Value.ToString(); cli.ShowDialog(); } else if (dataGridView2.SelectedRows.Count > 0) { fisica.IDtxtbox.Text = dataGridView2.CurrentRow.Cells["Id"].Value.ToString(); fisica.txtNombres.Text = dataGridView2.CurrentRow.Cells["nombres"].Value.ToString(); fisica.txtPapellido.Text = dataGridView2.CurrentRow.Cells["primerApellido"].Value.ToString(); fisica.txtSapellido.Text = dataGridView2.CurrentRow.Cells["segundoApellido"].Value.ToString(); fisica.txtFiscal.Text = dataGridView2.CurrentRow.Cells["registroFiscal"].Value.ToString(); fisica.txtRazon.Text = dataGridView2.CurrentRow.Cells["razonSocial"].Value.ToString(); fisica.txtCiudad.Text = dataGridView2.CurrentRow.Cells["ciudad"].Value.ToString(); fisica.txtCalle.Text = dataGridView2.CurrentRow.Cells["calle"].Value.ToString(); fisica.txtNum.Text = dataGridView2.CurrentRow.Cells["numero"].Value.ToString(); fisica.txtLada.Text = dataGridView2.CurrentRow.Cells["lada"].Value.ToString(); fisica.txtTel.Text = dataGridView2.CurrentRow.Cells["telefono"].Value.ToString(); fisica.txtFax.Text = dataGridView2.CurrentRow.Cells["fax"].Value.ToString(); fisica.txtCorreo.Text = dataGridView2.CurrentRow.Cells["correo"].Value.ToString(); idCliente = dataGridView2.CurrentRow.Cells["Id"].Value.ToString(); fisica.ShowDialog(); } else { MessageBox.Show("seleccione una fila por favor"); } }
//info supplier private void button1_Click(object sender, EventArgs e) { Supplier sup = new Supplier(); personaFisica fisica = new personaFisica(); if (dataGridView1.SelectedRows.Count > 0) { sup.saveEdit.Visible = false; sup.saveNew.Visible = false; sup.IDtxtbox.Text = dataGridView1.CurrentRow.Cells["Id"].Value.ToString(); sup.Nametxt.Text = dataGridView1.CurrentRow.Cells["name"].Value.ToString(); sup.RFCtxt.Text = dataGridView1.CurrentRow.Cells["RFC"].Value.ToString(); sup.phonetxt.Text = dataGridView1.CurrentRow.Cells["phone"].Value.ToString(); sup.mailtxt.Text = dataGridView1.CurrentRow.Cells["email"].Value.ToString(); sup.addrestxt.Text = dataGridView1.CurrentRow.Cells["addres"].Value.ToString(); sup.countrytxt.Text = dataGridView1.CurrentRow.Cells["country"].Value.ToString(); sup.statettxt.Text = dataGridView1.CurrentRow.Cells["state"].Value.ToString(); sup.citytxt.Text = dataGridView1.CurrentRow.Cells["city"].Value.ToString(); sup.divisa.Text = dataGridView1.CurrentRow.Cells["currency"].Value.ToString(); idSup = dataGridView1.CurrentRow.Cells["Id"].Value.ToString(); sup.ShowDialog(); } else if (dataGridView2.SelectedRows.Count > 0) { fisica.btnEditPro.Visible = false; fisica.guardarPro.Visible = false; fisica.IDtxtbox.Text = dataGridView2.CurrentRow.Cells["Id"].Value.ToString(); fisica.txtNombres.Text = dataGridView2.CurrentRow.Cells["nombres"].Value.ToString(); fisica.txtPapellido.Text = dataGridView2.CurrentRow.Cells["primerApellido"].Value.ToString(); fisica.txtSapellido.Text = dataGridView2.CurrentRow.Cells["segundoApellido"].Value.ToString(); fisica.txtFiscal.Text = dataGridView2.CurrentRow.Cells["registroFiscal"].Value.ToString(); fisica.txtRazon.Text = dataGridView2.CurrentRow.Cells["razonSocial"].Value.ToString(); fisica.txtCiudad.Text = dataGridView2.CurrentRow.Cells["ciudad"].Value.ToString(); fisica.txtCalle.Text = dataGridView2.CurrentRow.Cells["calle"].Value.ToString(); fisica.txtNum.Text = dataGridView2.CurrentRow.Cells["numero"].Value.ToString(); fisica.txtLada.Text = dataGridView2.CurrentRow.Cells["lada"].Value.ToString(); fisica.txtTel.Text = dataGridView2.CurrentRow.Cells["telefono"].Value.ToString(); fisica.txtFax.Text = dataGridView2.CurrentRow.Cells["fax"].Value.ToString(); fisica.txtCorreo.Text = dataGridView2.CurrentRow.Cells["correo"].Value.ToString(); idSup = dataGridView2.CurrentRow.Cells["Id"].Value.ToString(); fisica.ShowDialog(); } else { MessageBox.Show("Seleccione una fila por favor."); } }
//nuevo proveedor private void btnNuevo_Click(object sender, EventArgs e) { Supplier sup = new Supplier(); personaFisica fisica = new personaFisica(); string query1 = "select max(Id) from supplier"; string query2 = "select max(Id) from ProveedorFisicos"; //jess SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\William carmona\Documents\Desarrollo\Cagada Adrian\WaareDev\BD\fruteria.mdf;Integrated Security=True"); //karina //SqlConnection con = new SqlConnection(@"Server=tcp:OMEN-LAPTOP18\SQLEXPRESS02,49172;DataBase= fruteria; User Id=Cliente ; Password=cliente1234"); SqlCommand cmd1 = new SqlCommand(query1, con); SqlCommand cmd2 = new SqlCommand(query2, con); DialogResult respuesta = MessageBox.Show("¿Desea agregar a una persona Física?", "Mensaje", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (respuesta == DialogResult.No) { try { con.Open(); string pcount1 = Convert.ToString(cmd1.ExecuteScalar()); string pcount2 = Convert.ToString(cmd2.ExecuteScalar()); int maximo = 0; if (pcount2 != "" && pcount1 != "") { if (Convert.ToInt32(pcount1) > Convert.ToInt32(pcount2)) { maximo = Convert.ToInt32(pcount1); } else { maximo = Convert.ToInt32(pcount2); } } if (maximo != 0) { int pcountAdd = maximo + 1; sup.IDtxtbox.Text = pcountAdd.ToString(); } else if (pcount2 != "") { int pcountAdd = Convert.ToInt32(pcount2) + 1; sup.IDtxtbox.Text = pcountAdd.ToString(); } else if (pcount1 != "") { int pcountAdd = Convert.ToInt32(pcount1) + 1; sup.IDtxtbox.Text = pcountAdd.ToString(); } else { sup.IDtxtbox.Text = "1"; } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { con.Close(); } sup.saveNew.Visible = true; sup.saveEdit.Visible = false; sup.ShowDialog(); } if (respuesta == DialogResult.Yes) { try { con.Open(); string pcount1 = Convert.ToString(cmd1.ExecuteScalar()); string pcount2 = Convert.ToString(cmd2.ExecuteScalar()); int maximo = 0; if (pcount2 != "" && pcount1 != "") { if (Convert.ToInt32(pcount1) > Convert.ToInt32(pcount2)) { maximo = Convert.ToInt32(pcount1); } else { maximo = Convert.ToInt32(pcount2); } } if (maximo != 0) { int pcountAdd = maximo + 1; fisica.IDtxtbox.Text = pcountAdd.ToString(); } else if (pcount2 != "") { int pcountAdd = Convert.ToInt32(pcount2) + 1; fisica.IDtxtbox.Text = pcountAdd.ToString(); } else if (pcount1 != "") { int pcountAdd = Convert.ToInt32(pcount1) + 1; fisica.IDtxtbox.Text = pcountAdd.ToString(); } else { fisica.IDtxtbox.Text = "1"; } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { con.Close(); } fisica.guardarPro.Visible = true; fisica.btnEditPro.Visible = false; fisica.ShowDialog(); } }