private void btnDeleteOut_Click(object sender, EventArgs e) { VOut vOut = this.GetFirstSelectedVOut(); InOut inOut = DAL.GetInOutByVOut(vOut); if (vOut != null) { if (DAL.DeleteInOut(inOut)) { this.ViewAll(); } } }
private void btnEditOut_Click(object sender, EventArgs e) { VOut vOut = this.GetFirstSelectedVOut(); if (vOut != null) { InOut inOut = DAL.GetInOutByVOut(vOut); int oldId = inOut.ID; frmInOut editor = new frmInOut(inOut); if (editor.ShowDialog() == DialogResult.OK) { if (DAL.EditInOut(oldId, inOut)) { this.ViewAll(); } } } }
public static InOut GetInOutByVOut(VOut vOut) { try { using (WareHouseEntities en = new WareHouseEntities()) { return(en.InOuts.Include(p => p.Material).First(x => !x.IsIn && x.Material.Name == vOut.Name && x.Quantity == vOut.Quantity && x.Date == vOut.Date)); } } catch (Exception ex) { MessageBox.Show(ex.Message); return(null); } }