Exemplo n.º 1
0
 private void BtnEliminar_Click(object sender, EventArgs e)
 {
     try
     {
         const string eliminar = "DELETE FROM Vendedores WHERE IdVendedor=@Id";
         var          cmd      = new OleDbCommand(eliminar, Cnx)
         {
             CommandType = CommandType.Text
         };
         cmd.Parameters.AddWithValue("@Id", TxtId.Text);
         Cnx.Open();
         cmd.ExecuteNonQuery();
         Cnx.Close();
         MessageBox.Show(@"El Contacto Fue Eliminado....");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, null, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     TxtId.Clear();
     TxtNombre.Clear();
     TxtFechaAlta.Clear();
     TxtNIF.Clear();
     TxtFechaNac.Clear();
     TxtDireccion.Clear();
     TxtPoblacion.Clear();
     TxtTelefono.Clear();
     TxtEstadoCivil.Clear();
     pictureBox1.ImageLocation = "";
     TxtId.Focus();
 }
Exemplo n.º 2
0
 private void BtnLimpiar_Click_1(object sender, EventArgs e)
 {
     TxtId.Clear();
     TxtNombre.Clear();
     TxtFechaAlta.Clear();
     TxtNIF.Clear();
     TxtFechaNac.Clear();
     TxtDireccion.Clear();
     TxtPoblacion.Clear();
     TxtTelefono.Clear();
     TxtEstadoCivil.Clear();
     pictureBox1.ImageLocation = "";
     TxtId.Focus();
 }
Exemplo n.º 3
0
 private void BtnAgregar_Click(object sender, EventArgs e)
 {
     try
     {
         const string insertar = @"Insert Into Vendedores Values (@IdVendedor, @NombreVendedor,
         @FechaAlta, @NIF, @FechaNac,@Direccion,@Poblacion,@Telefono,@EstadoCivil,@Fotografia)";
         var          cmd      = new OleDbCommand(insertar, Cnx)
         {
             CommandType = CommandType.Text
         };
         cmd.Parameters.AddWithValue("@IdVendedor", TxtId.Text);
         cmd.Parameters.AddWithValue("@NombreVendedor", TxtNombre.Text);
         cmd.Parameters.AddWithValue("@FechaAlta", TxtFechaAlta.Text);
         cmd.Parameters.AddWithValue("@NIF", TxtNIF.Text);
         cmd.Parameters.AddWithValue("@FechaNac", TxtFechaNac.Text);
         cmd.Parameters.AddWithValue("@Direccion", TxtDireccion.Text);
         cmd.Parameters.AddWithValue("@Poblacion", TxtPoblacion.Text);
         cmd.Parameters.AddWithValue("@Telefono", TxtTelefono.Text);
         cmd.Parameters.AddWithValue("@EstadoCivil", TxtEstadoCivil.Text);
         pictureBox1.ImageLocation = StrFileName;
         cmd.Parameters.AddWithValue("@Fotografia", pictureBox1.ImageLocation);
         Cnx.Open();
         cmd.ExecuteNonQuery();
         Cnx.Close();
         MessageBox.Show(@"El Contacto Fue Registrado");
     }
     catch (Exception ex)
     {
         MessageBox.Show(@"La Clave a Registrar Ya Existe", ex.Message);
     }
     TxtId.Clear();
     TxtNombre.Clear();
     TxtFechaAlta.Clear();
     TxtNIF.Clear();
     TxtFechaNac.Clear();
     TxtDireccion.Clear();
     TxtPoblacion.Clear();
     TxtTelefono.Clear();
     TxtEstadoCivil.Clear();
     pictureBox1.ImageLocation = "";
     TxtId.Focus();
 }
Exemplo n.º 4
0
 private void BtnModificar_Click(object sender, EventArgs e)
 {
     try
     {
         const string actualizar = @"UPDATE Vendedores SET IdVendedor=@Id, NombreVendedor=@Nombre ,FechaAlta = @FechaAlta,
                             NIF = @NIF, FechaNac = @FechaNac, Direccion = @Direccion, Poblacion = @Poblacion,
                             Telefon = @Telefon, EstalCivil = @EstalCivil,Fotografia = @Fotografia WHERE IdVendedor = @Id";
         var          cmd        = new OleDbCommand(actualizar, Cnx)
         {
             CommandType = CommandType.Text
         };
         cmd.Parameters.AddWithValue("@Id", TxtId.Text);
         cmd.Parameters.AddWithValue("@Nombre", TxtNombre.Text);
         cmd.Parameters.AddWithValue("@FechaAlta", TxtFechaAlta.Text);
         cmd.Parameters.AddWithValue("@NIF", TxtNIF.Text);
         cmd.Parameters.AddWithValue("@FechaNac", TxtFechaNac.Text);
         cmd.Parameters.AddWithValue("@Direccion", TxtDireccion.Text);
         cmd.Parameters.AddWithValue("@Poblacion", TxtPoblacion.Text);
         cmd.Parameters.AddWithValue("@Telefon", TxtTelefono.Text);
         cmd.Parameters.AddWithValue("@EstalCivil", TxtEstadoCivil.Text);
         cmd.Parameters.AddWithValue("@Fotografia", pictureBox1.ImageLocation);
         Cnx.Open();
         cmd.ExecuteNonQuery();
         Cnx.Close();
         MessageBox.Show(@"Los Datos Del Contacto Fueron Actualizados");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, null, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     TxtId.Clear();
     TxtNombre.Clear();
     TxtFechaAlta.Clear();
     TxtNIF.Clear();
     TxtFechaNac.Clear();
     TxtDireccion.Clear();
     TxtPoblacion.Clear();
     TxtTelefono.Clear();
     TxtEstadoCivil.Clear();
     pictureBox1.ImageLocation = "";
     TxtId.Focus();
 }
Exemplo n.º 5
0
 private void BtnGuardar_Click(object sender, EventArgs e)
 {
     if (TxtNombre.Text == "")
     {
         MessageBox.Show("Falta el Nombre!!", "Doctores", MessageBoxButtons.OK, MessageBoxIcon.Information);
         TxtNombre.Focus();
     }
     else if (TxtApPat.Text == "")
     {
         MessageBox.Show("Falta el Apellido Paterno!!", "Doctores", MessageBoxButtons.OK, MessageBoxIcon.Information);
         TxtApPat.Focus();
     }
     else if (TxtApMat.Text == "")
     {
         MessageBox.Show("Falta el Apellido Materno!!", "Doctores", MessageBoxButtons.OK, MessageBoxIcon.Information);
         TxtApMat.Focus();
     }
     else if (TxtDomicilio.Text == "")
     {
         MessageBox.Show("Falta el Domicilio!!", "Doctores", MessageBoxButtons.OK, MessageBoxIcon.Information);
         TxtDomicilio.Focus();
     }
     else if (TxtTelefono.Text == "")
     {
         MessageBox.Show("Falta el Teléfono!!", "Doctores", MessageBoxButtons.OK, MessageBoxIcon.Information);
         TxtTelefono.Focus();
     }
     else if (TxtFechaNac.Text == "/" || TxtFechaNac.Text == "__/__/____")
     {
         MessageBox.Show("Falta la fecha de Nacimiento!!", "Doctores", MessageBoxButtons.OK, MessageBoxIcon.Information);
         TxtFechaNac.Focus();
     }
     else if (CmbSexo.Text == "")
     {
         MessageBox.Show("Falta elegir el Sexo!!", "Doctores", MessageBoxButtons.OK, MessageBoxIcon.Information);
         CmbSexo.Focus();
     }
     else if (TxtCedula.Text == "")
     {
         MessageBox.Show("Falta la Cédula Profésional", "Doctores", MessageBoxButtons.OK, MessageBoxIcon.Information);
         TxtCedula.Focus();
     }
     else if (CmbEspecialidad.Text == "")
     {
         MessageBox.Show("Falta elegir la Especialidad", "Doctores", MessageBoxButtons.OK, MessageBoxIcon.Information);
         CmbEspecialidad.Focus();
     }
     else
     {
         try
         {
             if (Estado == true)
             {
                 GuardaNuevo();
                 MessageBox.Show("Registro Guardado!!", "Doctores", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 BtnGuardar.Enabled = false;
             }
             else
             {
                 modifica();
                 MessageBox.Show("Los Cambios se Guardaron Exitosamente!!", "Doctores", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 BtnGuardar.Enabled = false;
             }
         }
         catch
         {
             MessageBox.Show("Error!!", "Doctores");
         }
     }
 }