private void EliminarRegistro() { if (this.bs.Current == null) { return; } Traslado documento = (Traslado)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) { FactoryTraslados.InventarioDevolver(documento); } db.Traslados.DeleteObject(documento); db.SaveChanges(); Busqueda(); } catch (Exception x) { MessageBox.Show(x.Message); } }
private void Aceptar_Click(object sender, EventArgs e) { try { trasladoBindingSource.EndEdit(); trasladosIngredienteBindingSource.EndEdit(); registro = (Traslado)trasladoBindingSource.Current; FactoryTraslados.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; } Traslado registro = (Traslado)this.bs.Current; try { if (registro.ActualizadoInventario.GetValueOrDefault(false) == true) { throw new Exception("Esta compra se tiene el inventario actualizado"); } registro.FechaInventario = DateTime.Today; FactoryTraslados.Inventario(registro); this.bs.ResetCurrentItem(); } catch (Exception x) { MessageBox.Show(x.Message); } }