示例#1
0
 private void btn_Agregar_Click(object sender, EventArgs e)
 {
     try
     {
         string       Insertar = "Insert Into DBP Values (@Id, @Nombre,@Apellido, @Departamento, @Turno, @Contacto, @Imagen)";
         OleDbCommand Cmd      = new OleDbCommand(Insertar, Cnx);
         Cmd.CommandType = CommandType.Text;
         Cmd.Parameters.AddWithValue("@Id", idTextBox.Text);
         Cmd.Parameters.AddWithValue("@Nombre", nombreTextBox.Text);
         Cmd.Parameters.AddWithValue("@Apellido", apellidoTextBox.Text);
         Cmd.Parameters.AddWithValue("@Departamento", departamentoTextBox.Text);
         Cmd.Parameters.AddWithValue("@Turno", turnoTextBox.Text);
         Cmd.Parameters.AddWithValue("@Contacto", contactoTextBox.Text);
         pic_Empleado.ImageLocation = strFileName;
         Cmd.Parameters.AddWithValue("@Imagen", pic_Empleado.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);
     }
     idTextBox.Clear();
     nombreTextBox.Clear();
     apellidoTextBox.Clear();
     departamentoTextBox.Clear();
     turnoTextBox.Clear();
     contactoTextBox.Clear();
     pic_Empleado.ImageLocation = "";
     idTextBox.Focus();
 }
示例#2
0
 private void btn_Eliminar_Click(object sender, EventArgs e)
 {
     try
     {
         string       Eliminar = "DELETE FROM DBP WHERE Id=@Id";
         OleDbCommand Cmd      = new OleDbCommand(Eliminar, Cnx);
         Cmd.CommandType = CommandType.Text;
         Cmd.Parameters.AddWithValue("@Id", idTextBox.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);
     }
     idTextBox.Clear();
     nombreTextBox.Clear();
     apellidoTextBox.Clear();
     departamentoTextBox.Clear();
     turnoTextBox.Clear();
     contactoTextBox.Clear();
     pic_Empleado.ImageLocation = "";
     idTextBox.Focus();
 }
示例#3
0
        private void btn_Buscar_Click(object sender, EventArgs e)
        {
            string       BUSCAR    = "SELECT * FROM DBP WHERE Id=@Id";
            OleDbCommand CmdBuscar = new OleDbCommand(BUSCAR, Cnx);

            CmdBuscar.CommandType = CommandType.Text;
            CmdBuscar.Parameters.AddWithValue("@Id", idTextBox.Text);
            Cnx.Open();
            OleDbDataReader Lectura;

            Lectura = CmdBuscar.ExecuteReader();
            if (Lectura.Read() == true)
            {
                nombreTextBox.Text         = Lectura[1].ToString();
                apellidoTextBox.Text       = Lectura[2].ToString();
                departamentoTextBox.Text   = Lectura[3].ToString();
                turnoTextBox.Text          = Lectura[4].ToString();
                contactoTextBox.Text       = Lectura[5].ToString();
                pic_Empleado.ImageLocation = Lectura[6].ToString();
            }
            else
            {
                MessageBox.Show("Los Datos a Buscar No Estan Registrados");
                idTextBox.Clear();
                idTextBox.Focus();
            }
            Cnx.Close();
        }
示例#4
0
文件: Form1.cs 项目: jevus696/DBSQL
        private void BtnBuscar_Click_1(object sender, EventArgs e)
        {
            const string buscar    = "SELECT * FROM Vendedores WHERE IdVendedor=@Id";
            var          cmdBuscar = new OleDbCommand(buscar, Cnx)
            {
                CommandType = CommandType.Text
            };

            cmdBuscar.Parameters.AddWithValue("@Id", TxtId.Text);
            Cnx.Open();
            var lectura = cmdBuscar.ExecuteReader();

            if (lectura != null && lectura.Read() == true)
            {
                TxtNombre.Text            = lectura[1].ToString();
                TxtFechaAlta.Text         = lectura[2].ToString();
                TxtNIF.Text               = lectura[3].ToString();
                TxtFechaNac.Text          = lectura[4].ToString();
                TxtDireccion.Text         = lectura[5].ToString();
                TxtPoblacion.Text         = lectura[6].ToString();
                TxtTelefono.Text          = lectura[7].ToString();
                TxtEstadoCivil.Text       = lectura[8].ToString();
                pictureBox1.ImageLocation = lectura[9].ToString();
            }
            else
            {
                MessageBox.Show(@"Los Datos a Buscar No Estan Registrados");
                TxtId.Clear();
                TxtId.Focus();
            }
            Cnx.Close();
        }
示例#5
0
 private void btn_Modificar_Click(object sender, EventArgs e)
 {
     try
     {
         string       Actualizar = "UPDATE DBP SET Id=@Id, Nombre=@Nombre,Apellido = @Apellido,Departamento = @Departamento,Turno = @Turno,Contacto = @Contacto,Imagen = @Imagen WHERE Id = @Id";
         OleDbCommand Cmd        = new OleDbCommand(Actualizar, Cnx);
         Cmd.CommandType = CommandType.Text;
         Cmd.Parameters.AddWithValue("@Id", idTextBox.Text);
         Cmd.Parameters.AddWithValue("@Nombre", nombreTextBox.Text);
         Cmd.Parameters.AddWithValue("@Apellido", apellidoTextBox.Text);
         Cmd.Parameters.AddWithValue("@Departamento", departamentoTextBox.Text);
         Cmd.Parameters.AddWithValue("@Turno", turnoTextBox.Text);
         Cmd.Parameters.AddWithValue("@Contacto", contactoTextBox.Text);
         Cmd.Parameters.AddWithValue("@Imagen", pic_Empleado.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);
     }
     idTextBox.Clear();
     nombreTextBox.Clear();
     apellidoTextBox.Clear();
     departamentoTextBox.Clear();
     turnoTextBox.Clear();
     contactoTextBox.Clear();
     pic_Empleado.ImageLocation = "";
     idTextBox.Focus();
 }
示例#6
0
文件: Form1.cs 项目: jevus696/DBSQL
 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();
 }
示例#7
0
        private void btn_buscar_Click(object sender, EventArgs e)
        {
            string       BUSCAR    = "SELECT * FROM persona WHERE Id=@Id";
            OleDbCommand CmdBuscar = new OleDbCommand(BUSCAR, Cnx);

            CmdBuscar.CommandType = CommandType.Text;
            CmdBuscar.Parameters.AddWithValue("@Id", txt_id.Text);
            Cnx.Open();
            OleDbDataReader Lectura;

            Lectura = CmdBuscar.ExecuteReader();
            if (Lectura.Read() == true)
            {
                txt_nombre.Text            = Lectura[1].ToString();
                txt_apellido.Text          = Lectura[2].ToString();
                txt_domicilio.Text         = Lectura[3].ToString();
                txt_colonia.Text           = Lectura[4].ToString();
                txt_ciudad.Text            = Lectura[5].ToString();
                txt_telcasa.Text           = Lectura[6].ToString();
                txt_telmovil.Text          = Lectura[7].ToString();
                txt_email.Text             = Lectura[8].ToString();
                txt_email_empresarial.Text = Lectura[9].ToString();
                pic_foto.ImageLocation     = Lectura[10].ToString();
            }


            else
            {
                MessageBox.Show("Los Datos a Buscar No Estan Registrados");
                txt_id.Clear();
                txt_id.Focus();
            }
            Cnx.Close();
        }
示例#8
0
 private void btn_eliminar_Click(object sender, EventArgs e)
 {
     try
     {
         string       Eliminar = "DELETE FROM persona WHERE Id=@Id";
         OleDbCommand Cmd      = new OleDbCommand(Eliminar, Cnx);
         Cmd.CommandType = CommandType.Text;
         Cmd.Parameters.AddWithValue("@Id", txt_id.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);
     }
     txt_id.Clear();
     txt_nombre.Clear();
     txt_apellido.Clear();
     txt_domicilio.Clear();
     txt_colonia.Clear();
     txt_ciudad.Clear();
     txt_telcasa.Clear();
     txt_telmovil.Clear();
     txt_email.Clear();
     txt_email_empresarial.Clear();
     pic_foto.ImageLocation = "";
     txt_id.Focus();
 }
示例#9
0
文件: Form1.cs 项目: jevus696/DBSQL
 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();
 }
示例#10
0
文件: Form1.cs 项目: jevus696/DBSQL
 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();
 }
示例#11
0
 private void btn_agregar_Click(object sender, EventArgs e)
 {
     try
     {
         string       Insertar = "Insert Into persona Values (@Id, @Nombre,@Apellido, @CalleYNumero, @Colonia, @Ciudad, @TelCasa, @TelCel, @EmailPersonal,@EmailTrabajo, @Fotografia)";
         OleDbCommand Cmd      = new OleDbCommand(Insertar, Cnx);
         Cmd.CommandType = CommandType.Text;
         Cmd.Parameters.AddWithValue("@Id", txt_id.Text);
         Cmd.Parameters.AddWithValue("@Nombre", txt_nombre.Text);
         Cmd.Parameters.AddWithValue("@Apellido", txt_apellido.Text);
         Cmd.Parameters.AddWithValue("@CalleYNumero", txt_domicilio.Text);
         Cmd.Parameters.AddWithValue("@Colonia", txt_colonia.Text);
         Cmd.Parameters.AddWithValue("@Ciudad", txt_ciudad.Text);
         Cmd.Parameters.AddWithValue("@TelCasa", txt_telcasa.Text);
         Cmd.Parameters.AddWithValue("@TelCel", txt_telmovil.Text);
         Cmd.Parameters.AddWithValue("@EmailPersonal",
                                     txt_email.Text);
         Cmd.Parameters.AddWithValue("@EmailTrabajo", txt_email_empresarial.Text);
         pic_foto.ImageLocation = strFileName;
         Cmd.Parameters.AddWithValue("@Fotografia", pic_foto.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);
     }
     txt_id.Clear();
     txt_nombre.Clear();
     txt_apellido.Clear();
     txt_domicilio.Clear();
     txt_colonia.Clear();
     txt_ciudad.Clear();
     txt_telcasa.Clear();
     txt_telmovil.Clear();
     txt_email.Clear();
     txt_email_empresarial.Clear();
     pic_foto.ImageLocation = "";
     txt_id.Focus();
 }
示例#12
0
 private void btn_modificar_Click(object sender, EventArgs e)
 {
     try
     {
         string       Actualizar = "UPDATE persona SET Id=@Id, Nombre=@Nombre, Apellido=@Apellido, CalleYNumero=@CalleYNumero, Colonia=@Colonia, Ciudad=@Ciudad, TelCasa=@TelCasa, TelCel=@TelCel, EmailPersonal=@EmailPersonal, EmailTrabajo=@EmailTrabajo, Fotografia=@Fotografia WHERE Id=@Id";
         OleDbCommand Cmd        = new OleDbCommand(Actualizar, Cnx);
         Cmd.CommandType = CommandType.Text;
         Cmd.Parameters.AddWithValue("@Id", txt_id.Text);
         Cmd.Parameters.AddWithValue("@Nombre", txt_nombre.Text);
         Cmd.Parameters.AddWithValue("@Apellido", txt_apellido.Text);
         Cmd.Parameters.AddWithValue("@CalleYNumero", txt_domicilio.Text);
         Cmd.Parameters.AddWithValue("@Colonia", txt_colonia.Text);
         Cmd.Parameters.AddWithValue("@Ciudad", txt_ciudad.Text);
         Cmd.Parameters.AddWithValue("@TelCasa", txt_telcasa.Text);
         Cmd.Parameters.AddWithValue("@TelCel", txt_telmovil.Text);
         Cmd.Parameters.AddWithValue("@EmailPersonal",
                                     txt_email.Text);
         Cmd.Parameters.AddWithValue("@EmailTrabajo", txt_email_empresarial.Text);
         Cmd.Parameters.AddWithValue("@Fotografia", pic_foto.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);
     }
     txt_id.Clear();
     txt_nombre.Clear();
     txt_apellido.Clear();
     txt_domicilio.Clear();
     txt_colonia.Clear();
     txt_ciudad.Clear();
     txt_telcasa.Clear();
     txt_telmovil.Clear();
     txt_email.Clear();
     txt_email_empresarial.Clear();
     pic_foto.ImageLocation = "";
     txt_id.Focus();
 }