예제 #1
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtNombre.Text) || string.IsNullOrEmpty(txtDireccion.Text) ||
                string.IsNullOrEmpty(txtCelular.Text) || string.IsNullOrEmpty(txtDUI.Text))
            {
                MessageBox.Show("Debe de llenar los campos", "Completar", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            else
            {
                try
                {
                    using (SICOVE1Entities2 db = new SICOVE1Entities2())
                    {
                        string Id = dgvClientes.CurrentRow.Cells[0].Value.ToString();

                        clientes = db.tb_Clientes.Find(int.Parse(Id));
                        db.tb_Clientes.Remove(clientes);
                        db.SaveChanges();
                    }
                    MessageBox.Show("El Cliente se ha Eliminado con éxito");
                    dgvClientes.Rows.Clear();
                    cargardatos();
                    limpiartxt();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Algo salio mal... Intente de nuevo " + ex.ToString());
                }
            }
        }
예제 #2
0
        private void btnEditar_Click(object sender, EventArgs e)
        {
            try
            {
                using (SICOVE1Entities db = new SICOVE1Entities())
                {
                    string Id  = dgvClientes.CurrentRow.Cells[0].Value.ToString();
                    int    IdC = int.Parse(Id);
                    clientes               = db.tb_Clientes.Where(VerificarId => VerificarId.IdCliente == IdC).First();
                    clientes.Nombre        = txtNombre.Text;
                    clientes.Direccion     = txtDireccion.Text;
                    clientes.Celular       = txtCelular.Text;
                    clientes.DUI           = txtDUI.Text;
                    clientes.FechaRegistro = Convert.ToDateTime(dtpFechaReg.Text);

                    db.Entry(clientes).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                }
                MessageBox.Show("El Cliente se ha Actualizado con éxito");
                dgvClientes.Rows.Clear();
                cargardatos();
                limpiartxt();

                btnGuardar.Enabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Algo salio mal... Intente de nuevo " + MessageBoxIcon.Exclamation + ex.ToString());
            }
        }
예제 #3
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            try
            {
                using (SICOVE1Entities db = new SICOVE1Entities())
                {
                    string Id = dgvClientes.CurrentRow.Cells[0].Value.ToString();

                    clientes = db.tb_Clientes.Find(int.Parse(Id));
                    db.tb_Clientes.Remove(clientes);
                    db.SaveChanges();
                }
                MessageBox.Show("El Cliente se ha Eliminado con éxito");
                dgvClientes.Rows.Clear();
                cargardatos();
                limpiartxt();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Algo salio mal... Intente de nuevo " + ex.ToString());
            }
        }
예제 #4
0
        private void btnEditar_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtNombre.Text) || string.IsNullOrEmpty(txtDireccion.Text) ||
                string.IsNullOrEmpty(txtCelular.Text) || string.IsNullOrEmpty(txtDUI.Text))
            {
                MessageBox.Show("Debe de llenar los campos", "Completar", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            else
            {
                try
                {
                    using (SICOVE1Entities2 db = new SICOVE1Entities2())
                    {
                        string Id  = dgvClientes.CurrentRow.Cells[0].Value.ToString();
                        int    IdC = int.Parse(Id);
                        clientes               = db.tb_Clientes.Where(VerificarId => VerificarId.IdCliente == IdC).First();
                        clientes.Nombre        = txtNombre.Text;
                        clientes.Direccion     = txtDireccion.Text;
                        clientes.Celular       = txtCelular.Text;
                        clientes.DUI           = txtDUI.Text;
                        clientes.FechaRegistro = Convert.ToDateTime(dtpFechaReg.Text);

                        db.Entry(clientes).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();
                    }
                    MessageBox.Show("El Cliente se ha Actualizado con éxito");
                    dgvClientes.Rows.Clear();
                    cargardatos();
                    limpiartxt();

                    btnGuardar.Enabled = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Algo salio mal...  " + ex.ToString());
                }
            }
        }