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