Ejemplo n.º 1
0
        private void BtEditar_Click(object sender, EventArgs e)
        {
            if (TxtNombre.Text == "" | TxtCedula.Text == "" | TxtDireccion.Text == "" | TxtTargetaNum.Text == "" | TxtLimiteCredito.Text == "")
            {
                MessageBox.Show("Faltan campos por llenar", "Error");
            }
            else
            {
                try
                {
                    con = Conexion.getSqlConexion();
                    con.Open();

                    string sql = "UPDATE Cliente SET NombreCliente = " + "'" + TxtNombre.Text + "'" + ", CedulaCliente = " + "'" + TxtCedula.Text + "'" + ", DireccionCliente = " + "'" + TxtDireccion + "'" + ", NoTarjetaCR = " + "'" + TxtTargetaNum.Text + "'" + ", LimiteCredito = " + "'" + TxtLimiteCredito.Text + "'" + ",TipoPersona = " + "'" + "@TipoPersona" + "'" + "where IdInspeccion = " + "'" + cmbId.SelectedValue + "'" + " ";

                    SqlCommand comando = new SqlCommand(sql, con);



                    if (Rbfisica.Checked)
                    {
                        try
                        {
                            comando.Parameters.AddWithValue("@TipoPersona", "Fisica");
                        }
                        catch (Exception)
                        {
                            MessageBox.Show("Error al seleccionar tipo Persona");
                            Rbfisica.Focus();
                            return;
                        }
                    }

                    if (Rbjuridica.Checked)
                    {
                        try
                        {
                            comando.Parameters.AddWithValue("@TipoPersona", "Juridica");
                        }
                        catch (Exception)
                        {
                            MessageBox.Show("Error al seleccionar tipo Persona");
                            Rbjuridica.Focus();
                            return;
                        }
                    }
                    comando.ExecuteNonQuery();
                    MessageBox.Show("Ha sido actualizado");

                    this.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Ejemplo n.º 2
0
        private void Registrar()
        {
            if (TxtNombre.Text == "" | TxtCedula.Text == "" | TxtDireccion.Text == "" | TxtTargetaNum.Text == "" | TxtLimiteCredito.Text == "")
            {
                MessageBox.Show("Faltan campos por llenar", "Error");
            }
            else
            {
                try
                {
                    con = Conexion.getSqlConexion();
                    con.Open();
                    string     sql     = "INSERT INTO Cliente (NombreCliente,CedulaCliente, DireccionCliente,NoTarjetaCR,LimiteCredito,TipoPersona) VALUES (@nombre,@cedula,@Direccion,@Targeta,@LimiteCredito,@TipoPersona) ";
                    SqlCommand comando = new SqlCommand(sql, con);
                    comando.Parameters.AddWithValue("@nombre", TxtNombre.Text);
                    comando.Parameters.AddWithValue("@cedula", TxtCedula.Text);
                    comando.Parameters.AddWithValue("@Direccion", TxtDireccion.Text);
                    comando.Parameters.AddWithValue("@Targeta", TxtTargetaNum.Text);
                    comando.Parameters.AddWithValue("@LimiteCredito", TxtLimiteCredito.Text);

                    if (Rbfisica.Checked)
                    {
                        try
                        {
                            comando.Parameters.AddWithValue("@TipoPersona", "Fisica");
                        }
                        catch (Exception)
                        {
                            MessageBox.Show("Error al seleccionar tipo Persona");
                            Rbfisica.Focus();
                            return;
                        }
                    }

                    if (Rbjuridica.Checked)
                    {
                        try
                        {
                            comando.Parameters.AddWithValue("@TipoPersona", "Juridica");
                        }
                        catch (Exception)
                        {
                            MessageBox.Show("Error al seleccionar tipo Persona");
                            Rbjuridica.Focus();
                            return;
                        }
                    }
                    comando.ExecuteNonQuery();
                    MessageBox.Show("Ha sido registrado");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Ejemplo n.º 3
0
        private void Registrar()
        {
            try
            {
                con = new SqlConnection("Data Source=DESKTOP-7UG5AJD\\SQLEXPRESS02;Initial Catalog=RentCar;Integrated Security=True");
                con.Open();
                string     sql     = "INSERT INTO Cliente (NombreCliente,CedulaCliente, DireccionCliente,NoTarjetaCR,LimiteCredito,TipoPersona) VALUES (@nombre,@cedula,@Direccion,@Targeta,@LimiteCredito,@TipoPersona) ";
                SqlCommand comando = new SqlCommand(sql, con);
                comando.Parameters.AddWithValue("@nombre", TxtNombre.Text);
                comando.Parameters.AddWithValue("@cedula", TxtCedula.Text);
                comando.Parameters.AddWithValue("@Direccion", TxtDireccion.Text);
                comando.Parameters.AddWithValue("@Targeta", TxtTargetaNum.Text);
                comando.Parameters.AddWithValue("@LimiteCredito", TxtLimiteCredito.Text);

                if (Rbfisica.Checked)
                {
                    try
                    {
                        comando.Parameters.AddWithValue("@TipoPersona", "Fisica");
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Error al seleccionar tipo Persona");
                        Rbfisica.Focus();
                        return;
                    }
                }

                if (Rbjuridica.Checked)
                {
                    try
                    {
                        comando.Parameters.AddWithValue("@TipoPersona", "Juridica");
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Error al seleccionar tipo Persona");
                        Rbjuridica.Focus();
                        return;
                    }
                }
                comando.ExecuteNonQuery();
                MessageBox.Show("Ha sido registrado");

                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 4
0
        private void BtEditar_Click(object sender, EventArgs e)
        {
            try
            {
                con = new SqlConnection("Data Source=DESKTOP-7UG5AJD\\SQLEXPRESS02;Initial Catalog=RentCar;Integrated Security=True");
                con.Open();

                string sql = "UPDATE Cliente SET NombreCliente = " + "'" + TxtNombre.Text + "'" + ", CedulaCliente = " + "'" + TxtCedula.Text + "'" + ", DireccionCliente = " + "'" + TxtDireccion + "'" + ", NoTarjetaCR = " + "'" + TxtTargetaNum.Text + "'" + ", LimiteCredito = " + "'" + TxtLimiteCredito.Text + "'" + ",TipoPersona = " + "'" + "@TipoPersona" + "'" + "where IdInspeccion = " + "'" + cmbId.SelectedValue + "'" + " ";

                SqlCommand comando = new SqlCommand(sql, con);



                if (Rbfisica.Checked)
                {
                    try
                    {
                        comando.Parameters.AddWithValue("@TipoPersona", "Fisica");
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Error al seleccionar tipo Persona");
                        Rbfisica.Focus();
                        return;
                    }
                }

                if (Rbjuridica.Checked)
                {
                    try
                    {
                        comando.Parameters.AddWithValue("@TipoPersona", "Juridica");
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Error al seleccionar tipo Persona");
                        Rbjuridica.Focus();
                        return;
                    }
                }
                comando.ExecuteNonQuery();
                MessageBox.Show("Ha sido actualizado");

                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }