private void EliminarRegistro() { if (this.bs.Current == null) { return; } Compra documento = (Compra)this.bs.Current; if (MessageBox.Show("Esta seguro de eliminar esta compra", "Atencion", MessageBoxButtons.YesNo) != System.Windows.Forms.DialogResult.Yes) { return; } try { FactoryLibroCompras.BorrarItem(documento); FactoryLibroInventarios.RevertirCompra(documento); FactoryCompras.InventarioDevolver(documento); db.Compras.DeleteObject(documento); db.SaveChanges(); Busqueda(); } catch (Exception x) { Basicas.ManejarError(x); } }
private void EliminarRegistro() { if (this.bs.Current == null) { return; } Compra documento = (Compra)this.bs.Current; if (MessageBox.Show("Esta seguro de eliminar esta compra", "Atencion", MessageBoxButtons.YesNo) != System.Windows.Forms.DialogResult.Yes) { return; } try { if (documento.ActualizadoInventario.GetValueOrDefault(false) == true) { FactoryCompras.InventarioDevolver(documento); } db.Compras.DeleteObject(documento); db.SaveChanges(); Busqueda(); } catch (Exception x) { MessageBox.Show(x.Message); } }
private bool Guardar() { try { registro.IdUsuario = FactoryUsuarios.UsuarioActivo.IdUsuario; proveedor = FactoryProveedores.Item(db, registro.CedulaRif); if (proveedor == null) { using (var newDb = new DatosEntities()) { proveedor = new Proveedore(); proveedor.CedulaRif = registro.CedulaRif; proveedor.RazonSocial = registro.RazonSocial; proveedor.Direccion = registro.Direccion; proveedor.IdProveedor = FactoryContadores.GetMax("IdProveedor"); newDb.Proveedores.AddObject(proveedor); newDb.SaveChanges(); } } else { proveedor.CedulaRif = registro.CedulaRif; proveedor.RazonSocial = registro.RazonSocial; proveedor.Direccion = registro.Direccion; } registro.Totalizar(); if (registro.Errores().Count > 0) { MessageBox.Show(registro.ErroresStr(), "Atencion", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } if (esNuevo) { registro.IdCompra = FactoryContadores.GetMax("IdCompra"); db.Compras.AddObject(registro); } foreach (HK.ComprasIngrediente p in registro.ComprasIngredientes) { if (p.IdCompraIngrediente == null) { p.IdCompraIngrediente = FactoryContadores.GetMax("IdCompraIngrediente"); } } db.SaveChanges(); if (registro.Estatus == "CERRADA") { FactoryLibroCompras.EscribirItem(registro); FactoryLibroInventarios.RegistrarCompra(registro); FactoryCompras.Inventario(registro); } return(true); } catch (Exception x) { Basicas.ManejarError(x); return(false); } }
private void Busqueda() { dc = new RestaurantEntities(); Texto = this.txtBuscar.Text; switch (myLayout.ToUpper()) { case "CLIENTES": this.bindingSource.DataSource = FactoryClientes.getItems(dc, Texto); break; case "MESONEROS": this.bindingSource.DataSource = FactoryUsuarios.getItems(dc, Texto, "MESONERO"); break; case "ADMINISTRADORES": this.bindingSource.DataSource = FactoryUsuarios.getItems(dc, Texto, "ADMINISTRADOR"); break; case "CAJEROS": this.bindingSource.DataSource = FactoryUsuarios.getItems(dc, Texto, "CAJERO"); break; case "MESAS": this.bindingSource.DataSource = FactoryMesas.getItems(dc, Texto); break; case "PLATOS": this.bindingSource.DataSource = FactoryPlatos.getItems(dc, Texto); break; case "COMPRAS": this.bindingSource.DataSource = FactoryCompras.getComprasEspera(dc, Texto); break; case "FACTURAS": this.bindingSource.DataSource = FactoryFacturas.getFacturasPendientes(dc, Texto); break; case "INGREDIENTES": this.bindingSource.DataSource = FactoryIngredientes.getItems(dc, Texto); break; case "PROVEEDORES": this.bindingSource.DataSource = FactoryProveedores.getItems(dc, Texto); break; case "MESAS DISPONIBLES": this.bindingSource.DataSource = FactoryMesas.getMesasDisponibles(dc); break; } this.gridControl1.DataSource = this.bindingSource; gridControl1.ForceInitialize(); gridView1.OptionsLayout.Columns.Reset(); this.gridControl1.DefaultView.RestoreLayoutFromXml(Application.StartupPath + "\\Layouts\\" + myLayout + ".XML", DevExpress.Utils.OptionsLayoutGrid.FullLayout); }
private void WorkerMethod(object sender, Jacksonsoft.WaitWindowEventArgs e) { e.Window.Message = "Registrando Compras"; FactoryCompras.PasarComprasLibro(); if (e.Arguments.Count > 0) { e.Result = e.Arguments[0].ToString(); } else { e.Result = "Ok"; } }
private void Aceptar_Click(object sender, EventArgs e) { try { compraBindingSource.EndEdit(); comprasIngredienteBindingSource.EndEdit(); registro = (Compra)compraBindingSource.Current; FactoryCompras.Validar(registro); this.Guadar(); this.DialogResult = DialogResult.OK; this.Close(); } catch (Exception ex) { MessageBox.Show("Error al validar los datos \n" + ex.Message, "Atencion", MessageBoxButtons.OK); } }
void btnActualizarInventario_Click(object sender, EventArgs e) { if (this.bs.Current == null) { return; } Compra registro = (Compra)this.bs.Current; try { if (registro.ActualizadoInventario.GetValueOrDefault(false) == true) { throw new Exception("Esta compra se tiene el inventario actualizado"); } registro.FechaInventario = DateTime.Today; FactoryCompras.Inventario(registro); this.bs.ResetCurrentItem(); } catch (Exception x) { MessageBox.Show(x.Message); } }
void toolRecuperar_Click(object sender, EventArgs e) { FrmBuscarEntidades f = new FrmBuscarEntidades(); f.BuscarCompras(""); if (f.DialogResult == System.Windows.Forms.DialogResult.Abort) { using (var db = new DatosEntities()) { var x = (from item in db.Compras where item.IdCompra == ((Compra)(f.registro)).IdCompra select item).FirstOrDefault(); if (x != null) { db.Compras.DeleteObject(x); db.SaveChanges(); return; } } } if (f.DialogResult == System.Windows.Forms.DialogResult.OK) { if (f.registro != null) { Limpiar(); registro = FactoryCompras.Item(db, ((Compra)f.registro).IdCompra); compraBindingSource.DataSource = registro; compraBindingSource.ResetBindings(true); comprasIngredienteBindingSource.DataSource = registro.ComprasIngredientes; comprasIngredienteBindingSource.ResetBindings(true); proveedor = FactoryProveedores.Item(registro.CedulaRif); esNuevo = false; // registro.Estatus = "ABIERTA"; } } }