Beispiel #1
0
        //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");
            }
        }
Beispiel #2
0
        private void btnNuevo_Click(object sender, EventArgs e)
        {
            InfoClient    client = new InfoClient();
            personaFisica fisica = new personaFisica();

            string query1 = "select max(Id) from clientes";
            string query2 = "select max(Id) from clientesFisicos";
            // 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.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.guardarCliente.Visible = true;
                fisica.ShowDialog();
            }
            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;
                        client.IDtxtbox.Text = pcountAdd.ToString();
                    }
                    else if (pcount2 != "")
                    {
                        int pcountAdd = Convert.ToInt32(pcount2) + 1;
                        client.IDtxtbox.Text = pcountAdd.ToString();
                    }
                    else if (pcount1 != "")
                    {
                        int pcountAdd = Convert.ToInt32(pcount1) + 1;
                        client.IDtxtbox.Text = pcountAdd.ToString();
                    }
                    else
                    {
                        client.IDtxtbox.Text = "1";
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    con.Close();
                }
                client.save.Visible     = true;
                client.SaveEdit.Visible = false;
                client.ShowDialog();
            }
        }