private void btnGuardar_Click(object sender, EventArgs e) { try { using (SICOVE1Entities db = new SICOVE1Entities()) { 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("Usuario registrado con éxito"); dgvProductos.Rows.Clear(); cargarGridview(); limpiardatos(); CargarCombo(); } catch (Exception ex) { MessageBox.Show("Algo salio mal... " + ex.ToString()); } }
private void btnGuardar_Click(object sender, EventArgs e) { try { using (SICOVE1Entities db = new SICOVE1Entities()) { 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... Intente de nuevo"); } }
private void btnGuardar_Click(object sender, EventArgs e) { try { using (SICOVE1Entities db = new SICOVE1Entities()) { 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) { try { using (SICOVE1Entities db = new SICOVE1Entities()) { string Id = dgvProveedores.CurrentRow.Cells[0].Value.ToString(); int IdC = int.Parse(Id); proveedores = db.tb_Proveedores.Where(VerificarId => VerificarId.IdProveedor == IdC).First(); proveedores.Nombre = txtNombre.Text; proveedores.Direccion = txtDireccion.Text; proveedores.Celular = txtCelular.Text; proveedores.DUI = txtDUI.Text; proveedores.FechaRegistro = Convert.ToDateTime(dtpFechaReg.Text); db.Entry(proveedores).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } MessageBox.Show("El Proveedor se ha Actualizado con éxito"); dgvProveedores.Rows.Clear(); cargardatos(); limpiartxt(); btnGuardar.Enabled = true; } catch (Exception ex) { MessageBox.Show("Algo salio mal... Intente de nuevo"); } }
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()); } }
private void btnEditar_Click(object sender, EventArgs e) { try { using (SICOVE1Entities db = new SICOVE1Entities()) { string Id = dgvRoles.CurrentRow.Cells[0].Value.ToString(); int IdC = int.Parse(Id); roles = db.tb_Roles.Where(VerificarId => VerificarId.IdRol == IdC).First(); roles.Nombre = txtRol.Text; db.Entry(roles).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } MessageBox.Show("El Rol se ha Actuliazado con éxito"); dgvRoles.Rows.Clear(); cargardatos(); txtRol.Clear(); txtRol.Focus(); btnGuardar.Enabled = true; btnNuevo.Enabled = false; } catch (Exception ex) { MessageBox.Show("Algo salio mal " + ex.ToString()); } }
private void btnEditar_Click(object sender, EventArgs e) { try { using (SICOVE1Entities db = new SICOVE1Entities()) { string Id = dgvProductos.CurrentRow.Cells[0].Value.ToString(); int IdC = int.Parse(Id); productos = db.tb_Productos.Where(VerificarId => VerificarId.IdProducto == IdC).First(); 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.Entry(productos).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } MessageBox.Show("Se Actualizo con éxito"); dgvProductos.Rows.Clear(); cargarGridview(); limpiardatos(); CargarCombo(); btnGuardar.Enabled = true; btnNuevo.Enabled = true; } catch (Exception ex) { MessageBox.Show("Algo Salio Mal, intente de nuevo. "); } }
private void btnEditar_Click(object sender, EventArgs e) { try { using (SICOVE1Entities db = new SICOVE1Entities()) { 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! "); } }
private void btnGuardar_Click(object sender, EventArgs e) { try { using (SICOVE1Entities db = new SICOVE1Entities()) { 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! "); } }
private void btnEminiar_Click(object sender, EventArgs e) { try { using (SICOVE1Entities db = new SICOVE1Entities()) { 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) { try { using (SICOVE1Entities db = new SICOVE1Entities()) { 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("Algo salio mal... Intente de nuevo"); } }
private void btnGuardar_Click(object sender, EventArgs e) { try { using (SICOVE1Entities db = new SICOVE1Entities()) { 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()); } }
private void btnEliminar_Click(object sender, EventArgs e) { try { using (SICOVE1Entities db = new SICOVE1Entities()) { string Id = dgvProductos.CurrentRow.Cells[0].Value.ToString(); productos = db.tb_Productos.Find(int.Parse(Id)); db.tb_Productos.Remove(productos); db.SaveChanges(); } MessageBox.Show("El registro se eliminó con éxito"); dgvProductos.Rows.Clear(); cargarGridview(); limpiardatos(); CargarCombo(); } catch (Exception ex) { MessageBox.Show("Algo salio mal, intente de nuevo"); } }
private void btnGuardar_Click(object sender, EventArgs e) { try { using (SICOVE1Entities db = new SICOVE1Entities()) { 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 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()); } }
private void btnEditar_Click(object sender, EventArgs e) { try { using (SICOVE1Entities db = new SICOVE1Entities()) { 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, intente de nuevo. " + ex.ToString()); } }
private void btnEminiar_Click(object sender, EventArgs e) { try { using (SICOVE1Entities db = new SICOVE1Entities()) { string Id = dgvRoles.CurrentRow.Cells[0].Value.ToString(); roles = db.tb_Roles.Find(int.Parse(Id)); db.tb_Roles.Remove(roles); db.SaveChanges(); } MessageBox.Show("El Rol se ha Eliminado con éxito"); dgvRoles.Rows.Clear(); cargardatos(); txtRol.Clear(); txtRol.Focus(); btnNuevo.Enabled = true; } catch (Exception ex) { MessageBox.Show("Algo salio mal " + ex.ToString()); } }
private void btnGuardar_Click(object sender, EventArgs e) { try { using (SICOVE1Entities db = new SICOVE1Entities()) { // 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; db.tb_DetalleCompras.Add(detalleCompra); db.SaveChanges(); } MessageBox.Show("La venta se registro con exito"); dgvCompras.Rows.Clear(); limpiarVenta(); Limpiar(); CargarCombos(); } } catch (Exception ex) { MessageBox.Show("Algo salio mal... " + ex.ToString()); } }