示例#1
0
        private void btnEminiar_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtCategoria.Text))
            {
                MessageBox.Show("Debe de llenar los campos", "Completar", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            else
            {
                try
                {
                    using (SICOVE1Entities2 db = new SICOVE1Entities2())
                    {
                        string Id = dgvCategoria.CurrentRow.Cells[0].Value.ToString();

                        categorias = db.tb_Categorias.Find(int.Parse(Id));
                        db.tb_Categorias.Remove(categorias);
                        db.SaveChanges();
                    }
                    MessageBox.Show("La categoría se ha Eliminado con éxito");
                    dgvCategoria.Rows.Clear();
                    cargardatos();
                    txtCategoria.Clear();
                    txtCategoria.Focus();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Algo salio mal " + ex.ToString());
                }
            }
        }
示例#2
0
        //llamdo por medio de codigo de barras el producto
        private void txtBuscarProducto_KeyUp(object sender, KeyEventArgs e)
        {
            //cuando entra el numero y se acciona el evento de enter
            if (txtBuscarProducto.Text == "")
            {
                if (e.KeyCode == Keys.Enter)
                {
                    btnBuscarProducto.PerformClick();
                }
            }
            else if (e.KeyCode == Keys.Enter)
            {
                using (SICOVE1Entities2 db = new SICOVE1Entities2())
                {
                    tb_Productos  producto   = new tb_Productos();
                    tb_Categorias categorias = new tb_Categorias();
                    int           buscar     = int.Parse(txtBuscarProducto.Text);

                    producto   = db.tb_Productos.Where(idBuscar => idBuscar.IdProducto == buscar).First();
                    categorias = db.tb_Categorias.Where(idBuscar => idBuscar.IdCategoria == buscar).First();

                    txtCodProducto.Text    = Convert.ToString(producto.IdProducto);
                    txtNombreProducto.Text = Convert.ToString(producto.Nombre);
                    txtIdCategoria.Text    = Convert.ToString(categorias.IdCategoria);
                    txtCategoriaProd.Text  = Convert.ToString(categorias.Nombre);

                    txtPrecio.Focus();
                    txtBuscarProducto.Text = "";
                    intentos = 2;
                }
            }
        }
示例#3
0
        private void btnEditar_Click(object sender, EventArgs e)
        {
            try
            {
                using (SICOVE1Entities db = new SICOVE1Entities())
                {
                    string Id  = dgvCategoria.CurrentRow.Cells[0].Value.ToString();
                    int    IdC = int.Parse(Id);
                    categorias                 = db.tb_Categorias.Where(VerificarId => VerificarId.IdCategoria == IdC).First();
                    categorias.Nombre          = txtCategoria.Text;
                    categorias.FechaRegistro   = Convert.ToDateTime(dtpFechaReg.Text);
                    db.Entry(categorias).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                }
                MessageBox.Show("La categoría se ha Actualizo con éxito");
                dgvCategoria.Rows.Clear();
                cargardatos();
                txtCategoria.Clear();
                txtCategoria.Focus();

                btnGuardar.Enabled = true;
                btnNuevo.Enabled   = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Algo salio mal " + ex.ToString());
            }
        }
示例#4
0
        private void btnEminiar_Click(object sender, EventArgs e)
        {
            try
            {
                using (SICOVE1Entities db = new SICOVE1Entities())
                {
                    string Id = dgvCategoria.CurrentRow.Cells[0].Value.ToString();

                    categorias = db.tb_Categorias.Find(int.Parse(Id));
                    db.tb_Categorias.Remove(categorias);
                    db.SaveChanges();
                }
                MessageBox.Show("La categoría se ha Eliminado con éxito");
                dgvCategoria.Rows.Clear();
                cargardatos();
                txtCategoria.Clear();
                txtCategoria.Focus();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Algo salio mal " + ex.ToString());
            }
        }