Ejemplo n.º 1
0
        private void btnActualizar_Click(object sender, EventArgs e)
        {
            if (dgClientes.SelectedCells.Count > 0)
            {
                int    id       = Convert.ToInt16(this.txtID.Text);
                string empresa  = txtEmpresa.Text;
                string contacto = txtContacto.Text;
                string telefono = txtTelefono.Text;
                string correo   = txtCorreo.Text;

                using (GrupoIDAIIEntities1 contexto = new GrupoIDAIIEntities1())
                {
                    ClientesIDAII clientesIDAII = contexto.ClientesIDAII.FirstOrDefault(x => x.id == id);
                    clientesIDAII.nomEmpresa  = empresa;
                    clientesIDAII.nomContacto = contacto;
                    clientesIDAII.telefono    = telefono;
                    clientesIDAII.correo      = correo;
                    contexto.SaveChanges();
                    cargarClientes();
                    Limpiar();
                    Desactivar();
                }
                MessageBox.Show("Los datos han sido modificados");
            }
        }
Ejemplo n.º 2
0
 private void btnEliminar_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("¿Seguro que desea borrarlo?", "", MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         if (dgClientes.SelectedCells.Count == 1)
         {
             int id = Convert.ToInt16(this.txtID.Text);
             using (GrupoIDAIIEntities1 contexto = new GrupoIDAIIEntities1())
             {
                 ClientesIDAII clientes = contexto.ClientesIDAII.FirstOrDefault(x => x.id == id);
                 contexto.ClientesIDAII.Remove(clientes);
                 contexto.SaveChanges();
                 cargarClientes();
                 Desactivar();
                 Limpiar();
             }
         }
         else
         {
             if (MessageBox.Show("Seleccione", "Advertencia",
                                 MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
             {
                 ;
             }
         }
     }
 }
Ejemplo n.º 3
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (txtEmpresa.Text.Length == 0 | txtContacto.Text.Length == 0 | txtTelefono.Text.Length == 0 | txtCorreo.Text.Length == 0)
            {
                MessageBox.Show("Existen campos vacíos");
            }
            else if (ComprobarFormatoEmail(txtCorreo.Text) == false)
            {
                MessageBox.Show("La dirección de correo electrónico no es valida");
            }
            else if (ComprobarFormatoEmail(txtCorreo.Text) == true)
            {
                cargarClientes();
                string empresa  = txtEmpresa.Text;
                string contacto = txtContacto.Text;
                string telefono = txtTelefono.Text;
                string correo   = txtCorreo.Text;

                using (GrupoIDAIIEntities1 contexto = new GrupoIDAIIEntities1())
                {
                    ClientesIDAII clientesIDAII = new ClientesIDAII
                    {
                        nomEmpresa  = empresa,
                        nomContacto = contacto,
                        telefono    = telefono,
                        correo      = correo,
                    };
                    Desactivar();
                    contexto.ClientesIDAII.Add(clientesIDAII);
                    contexto.SaveChanges();
                    cargarClientes();
                    Limpiar();
                }
            }
        }