Exemple #1
0
        private void btnGuardar_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())
                    {
                        categorias.Nombre        = txtCategoria.Text;
                        categorias.FechaRegistro = Convert.ToDateTime(dtpFechaReg.Text);

                        db.tb_Categorias.Add(categorias);
                        db.SaveChanges();
                    }
                    MessageBox.Show("La categoría se ha Registrado con éxito");
                    dgvCategoria.Rows.Clear();
                    cargardatos();
                    txtCategoria.Clear();
                    txtCategoria.Focus();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Algo salio mal " + ex.ToString());
                }
            }
        }
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtUsuario.Text) || string.IsNullOrEmpty(txtClave.Text) ||
                string.IsNullOrEmpty(cmbEmpleado.Text) || string.IsNullOrEmpty(cmbRol.Text))
            {
                MessageBox.Show("Debe de llenar los campos", "Completar", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            else
            {
                try
                {
                    using (SICOVE1Entities2 db = new SICOVE1Entities2())
                    {
                        string Id = dgvUsuarios.CurrentRow.Cells[0].Value.ToString();

                        user = db.tb_Usuarios.Find(int.Parse(Id));
                        db.tb_Usuarios.Remove(user);
                        db.SaveChanges();
                    }
                    MessageBox.Show("El registro se eliminó con éxito");
                    dgvUsuarios.Rows.Clear();
                    cargarGridview();
                    limpiardatos();
                    CargarCombo();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Algo salio mal, intente de nuevo");
                }
            }
        }
        private void btnGuardar_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())
                    {
                        proveedores.Nombre        = txtNombre.Text;
                        proveedores.Direccion     = txtDireccion.Text;
                        proveedores.Celular       = txtCelular.Text;
                        proveedores.DUI           = txtDUI.Text;
                        proveedores.FechaRegistro = Convert.ToDateTime(dtpFechaReg.Text);

                        db.tb_Proveedores.Add(proveedores);
                        db.SaveChanges();
                    }
                    MessageBox.Show("El Proveedor se ha Registrado con éxito");
                    dgvProveedores.Rows.Clear();
                    cargardatos();
                    limpiartxt();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Algo salio mal... " + ex.ToString());
                }
            }
        }
Exemple #4
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());
                }
            }
        }
Exemple #5
0
        private void btnEminiar_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtFPago.Text))
            {
                MessageBox.Show("Debe de llenar los campos", "Completar", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            else
            {
                try
                {
                    using (SICOVE1Entities2 db = new SICOVE1Entities2())
                    {
                        string Id = dgvFPagos.CurrentRow.Cells[0].Value.ToString();

                        formaPago = db.tb_FormaPago.Find(int.Parse(Id));
                        db.tb_FormaPago.Remove(formaPago);
                        db.SaveChanges();
                    }
                    MessageBox.Show("La Forma de Pago se ha Eliminado con éxito");
                    dgvFPagos.Rows.Clear();
                    cargardatos();
                    txtFPago.Clear();
                    txtFPago.Focus();

                    btnGuardar.Enabled = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(" Algo salio mal...  ¡Intente de nuevo! ");
                }
            }
        }
        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 = dgvProveedores.CurrentRow.Cells[0].Value.ToString();

                        proveedores = db.tb_Proveedores.Find(int.Parse(Id));
                        db.tb_Proveedores.Remove(proveedores);
                        db.SaveChanges();
                    }
                    MessageBox.Show("El Proveedor se ha Eliminado con éxito");
                    dgvProveedores.Rows.Clear();
                    cargardatos();
                    limpiartxt();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("El proveedor no se puede eliminar porque tiene registros... ");
                }
            }
        }
Exemple #7
0
        private void btnEditar_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtFPago.Text))
            {
                MessageBox.Show("Debe de llenar los campos", "Completar", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            else
            {
                try
                {
                    using (SICOVE1Entities2 db = new SICOVE1Entities2())
                    {
                        string Id  = dgvFPagos.CurrentRow.Cells[0].Value.ToString();
                        int    IdC = int.Parse(Id);
                        formaPago                 = db.tb_FormaPago.Where(VerificarId => VerificarId.IdFormaPago == IdC).First();
                        formaPago.Nombre          = txtFPago.Text;
                        db.Entry(formaPago).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();
                    }
                    MessageBox.Show("La Forma de Pago se ha Actualizado con éxito");
                    dgvFPagos.Rows.Clear();
                    cargardatos();
                    txtFPago.Clear();
                    txtFPago.Focus();

                    btnGuardar.Enabled = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(" Algo salio mal...  ¡Intente de nuevo! ");
                }
            }
        }
Exemple #8
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtRol.Text))
            {
                MessageBox.Show("Debe de llenar los campos", "Completar", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            else
            {
                try
                {
                    using (SICOVE1Entities2 db = new SICOVE1Entities2())
                    {
                        roles.Nombre = txtRol.Text;

                        db.tb_Roles.Add(roles);
                        db.SaveChanges();
                    }
                    MessageBox.Show("El Rol se ha Registrado con éxito");
                    dgvRoles.Rows.Clear();
                    cargardatos();
                    txtRol.Clear();
                    txtRol.Focus();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Algo salio mal " + ex.ToString());
                }
            }
        }
Exemple #9
0
        private void btnEliminar_Click_1(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 = dgvEmpleados.CurrentRow.Cells[0].Value.ToString();

                        empleados = db.tb_Empleados.Find(int.Parse(Id));
                        db.tb_Empleados.Remove(empleados);
                        db.SaveChanges();
                    }
                    MessageBox.Show("El Empleado se ha Eliminado con éxito");
                    dgvEmpleados.Rows.Clear();
                    cargardatos();
                    limpiartxt();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Algo salio mal... Intente de nuevo " + ex.ToString());
                }
            }
        }
        private void btnEditar_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtUsuario.Text) || string.IsNullOrEmpty(txtClave.Text) ||
                string.IsNullOrEmpty(cmbEmpleado.Text) || string.IsNullOrEmpty(cmbRol.Text))
            {
                MessageBox.Show("Debe de llenar los campos", "Completar", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            else
            {
                try
                {
                    using (SICOVE1Entities2 db = new SICOVE1Entities2())
                    {
                        string Id  = dgvUsuarios.CurrentRow.Cells[0].Value.ToString();
                        int    IdC = int.Parse(Id);
                        user         = db.tb_Usuarios.Where(VerificarId => VerificarId.IdUsuario == IdC).First();
                        user.Usuario = txtUsuario.Text;
                        user.Clave   = txtClave.Text;

                        String comboRol = cmbRol.SelectedValue.ToString();
                        user.IdRol = Convert.ToInt32(comboRol);

                        String comboEmpleado = cmbEmpleado.SelectedValue.ToString();
                        user.IdEmpleado = Convert.ToInt32(comboEmpleado);

                        user.FechaRegistro = Convert.ToDateTime(dtpFechaReg.Text);

                        db.Entry(user).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();
                    }
                    MessageBox.Show("Se Actualizo con éxito");
                    dgvUsuarios.Rows.Clear();
                    cargarGridview();
                    limpiardatos();
                    CargarCombo();

                    btnGuardar.Enabled = true;
                    btnNuevo.Enabled   = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Algo Salio Mal... " + ex.ToString());
                }
            }
        }
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtUsuario.Text) || string.IsNullOrEmpty(txtClave.Text) ||
                string.IsNullOrEmpty(cmbEmpleado.Text) || string.IsNullOrEmpty(cmbRol.Text))
            {
                MessageBox.Show("Debe de llenar los campos", "Completar", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            else
            {
                try
                {
                    using (SICOVE1Entities2 db = new SICOVE1Entities2())
                    {
                        user.Usuario = txtUsuario.Text;
                        user.Clave   = txtClave.Text;

                        user.FechaRegistro = Convert.ToDateTime(dtpFechaReg.Text);

                        String comboRol = cmbRol.SelectedValue.ToString();
                        user.IdRol = Convert.ToInt32(comboRol);

                        String comboEmpleado = cmbEmpleado.SelectedValue.ToString();
                        user.IdEmpleado = Convert.ToInt32(comboEmpleado);


                        db.tb_Usuarios.Add(user);
                        db.SaveChanges();
                    }
                    MessageBox.Show("Usuario registrado con éxito");
                    dgvUsuarios.Rows.Clear();
                    cargarGridview();
                    limpiardatos();
                    CargarCombo();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Algo salio mal " + ex.ToString());
                }
            }
        }
        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());
                }
            }
        }
Exemple #13
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtFPago.Text))
            {
                MessageBox.Show("Debe de llenar los campos", "Completar", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            else
            {
                try
                {
                    using (SICOVE1Entities2 db = new SICOVE1Entities2())
                    {
                        if (txtFPago.Text == "")
                        {
                            MessageBox.Show("Debe dijitar una forma de pago");
                        }
                        else
                        {
                            formaPago.Nombre = txtFPago.Text;

                            db.tb_FormaPago.Add(formaPago);
                            db.SaveChanges();
                        }
                    }
                    MessageBox.Show("La Forma de Pago se ha registrado con éxito");
                    dgvFPagos.Rows.Clear();
                    cargardatos();
                    txtFPago.Clear();
                    txtFPago.Focus();
                }
                catch (Exception ex)
                {
                    //System.Windows.Forms.MessageBox.Show("Error: " + ex.Message, "FormaPago");
                    MessageBox.Show(" Algo salio mal...  ¡Intente de nuevo! ");
                }
            }
        }
Exemple #14
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtNombre.Text) || string.IsNullOrEmpty(cmbCategoria.Text))
            {
                MessageBox.Show("Debe de llenar los campos", "Completar", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            else
            {
                try
                {
                    using (SICOVE1Entities2 db = new SICOVE1Entities2())
                    {
                        productos.Nombre  = txtNombre.Text;
                        productos.Detalle = txtDetalle.Text;

                        productos.FechaRegistro = Convert.ToDateTime(dtpFechaReg.Text);

                        String comboCategoria = cmbCategoria.SelectedValue.ToString();
                        productos.IdCategoria = Convert.ToInt32(comboCategoria);


                        db.tb_Productos.Add(productos);
                        db.SaveChanges();
                    }
                    MessageBox.Show("Producto registrado con éxito");
                    dgvProductos.Rows.Clear();
                    cargarGridview();
                    limpiardatos();
                    CargarCombo();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Algo salio mal... " + ex.ToString());
                }
            }
        }
Exemple #15
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(cmbProveedor.Text) || string.IsNullOrEmpty(cmbFormaPago.Text) || string.IsNullOrEmpty(txtTotalFinal.Text))
            {
                MessageBox.Show("Debe de llenar los campos de la compra", "Completar", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            else
            {
                try
                {
                    using (SICOVE1Entities2 db = new SICOVE1Entities2())
                    {
                        // se hacer el insert de la compra en la tabla de compras
                        String comboProveedor = cmbProveedor.SelectedValue.ToString();
                        compras.IdProveedor = Convert.ToInt32(comboProveedor);

                        String comboFPago = cmbFormaPago.SelectedValue.ToString();
                        compras.IdFormaPago = Convert.ToInt32(comboFPago);

                        compras.IdEmpleado    = 1;
                        compras.NumFac        = Convert.ToInt32(txtNunFac.Text);
                        compras.DetalleCompra = txtDetalleCompra.Text;
                        compras.TotalCompra   = Convert.ToDecimal(txtTotalFinal.Text);
                        compras.FechaRegistro = Convert.ToDateTime(dtpFechaReg.Text);


                        db.tb_Compras.Add(compras);
                        db.SaveChanges();


                        ///////////////////////////////////////////////////////////////////// Lilian Bonilla.
                        //se hace el insert para la tabla detalle de la compra

                        tb_DetalleCompras detalleCompra = new tb_DetalleCompras();
                        for (int i = 0; i < dgvCompras.RowCount; i++)
                        {
                            String idProducto            = dgvCompras.Rows[i].Cells[0].Value.ToString();
                            int    IdProductoConvertidos = Convert.ToInt32(idProducto);

                            String idCategoria           = dgvCompras.Rows[i].Cells[1].Value.ToString();
                            int    IdCategoriaConvertida = Convert.ToInt32(idCategoria);

                            String  precio            = dgvCompras.Rows[i].Cells[4].Value.ToString();
                            decimal precioConvertidos = Convert.ToDecimal(precio);

                            String cantidad            = dgvCompras.Rows[i].Cells[5].Value.ToString();
                            int    cantidadConvertidos = Convert.ToInt32(cantidad);

                            String  SubTotal            = dgvCompras.Rows[i].Cells[6].Value.ToString();
                            decimal SubTotalConvertidos = Convert.ToDecimal(SubTotal);

                            String  IVA            = dgvCompras.Rows[i].Cells[7].Value.ToString();
                            decimal IVAConvertidos = Convert.ToDecimal(IVA);

                            String  total            = dgvCompras.Rows[i].Cells[8].Value.ToString();
                            decimal totalConvertidos = Convert.ToDecimal(total);


                            detalleCompra.IdCompra = Convert.ToInt32(txtNunFac.Text);

                            detalleCompra.IdProducto   = IdProductoConvertidos;
                            detalleCompra.IdCategoria  = IdCategoriaConvertida;
                            detalleCompra.PrecioCompra = precioConvertidos;
                            detalleCompra.Cantidad     = cantidadConvertidos;
                            detalleCompra.SubTotal     = SubTotalConvertidos;
                            detalleCompra.IVA          = IVAConvertidos;
                            detalleCompra.Total        = totalConvertidos;


                            var listaInventario = db.tb_Inventarios;
                            try
                            {
                                inventarios = db.tb_Inventarios.Where(VerificarId => VerificarId.IdProducto == IdProductoConvertidos).First();
                                foreach (var iterardatostbventa in listaInventario)
                                {
                                    int idCompra = inventarios.Existencia;

                                    inventarios.Existencia      = inventarios.Existencia + cantidadConvertidos;
                                    db.Entry(inventarios).State = System.Data.Entity.EntityState.Modified;
                                }
                            }
                            catch (Exception ex)
                            {
                                inventarios.Existencia = inventarios.Existencia + cantidadConvertidos;
                                inventarios.IdProducto = IdProductoConvertidos;
                                db.tb_Inventarios.Add(inventarios);
                            }


                            db.tb_DetalleCompras.Add(detalleCompra);
                            db.SaveChanges();
                        }
                        MessageBox.Show("La Compra se registro con exito ");
                        dgvCompras.Rows.Clear();
                        limpiarVenta();
                        Limpiar();
                        CargarCombos();
                        retornoId();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Algo salio mal... " + ex.ToString());
                }
            }
        }