public int NewExpanse(Expanse expanse) { using (db = new ApartmentAutomationEntities()) { db.Expanse.Add(expanse); return(db.SaveChanges()); } }
public void RemoveExpanse(int expanseID) { using (db = new ApartmentAutomationEntities()) { Expanse expanseToRemove = db.Expanse.FirstOrDefault(e => e.ExpenseID == expanseID); db.Expanse.Remove(expanseToRemove); db.SaveChanges(); } }
public void UpdateExpanse(Expanse expanse) { using (db = new ApartmentAutomationEntities()) { Expanse expanseToUpdate = db.Expanse.FirstOrDefault(e => e.ExpenseID == expanse.ExpenseID); expanseToUpdate.ExpenseName = expanse.ExpenseName; expanseToUpdate.ExpanseDescription = expanse.ExpanseDescription; expanseToUpdate.ExpansePrice = expanse.ExpansePrice; expanseToUpdate.ExpanseDate = expanse.ExpanseDate; db.SaveChanges(); } }
private void GetExpanseFromListView() { if (lvExpanses.FocusedItem == null) { throw new Exception("Bir Gider Seçmelisiniz."); } int expanseID = int.Parse(lvExpanses.FocusedItem.Tag.ToString()); Expanse expanse = expanseAccess.GetExpanseByID(expanseID); if (expanse == null) { throw new Exception("Kayıt veritabanından silinmiş."); } pbExpanse.Visible = false; txtExpanseName.Tag = expanse.ExpenseID; txtExpanseName.Text = expanse.ExpenseName; txtExpanseDescription.Text = expanse.ExpanseDescription; txtExpansePrice.Text = expanse.ExpansePrice.ToString(); dtpExpanseDate.Value = (DateTime)expanse.ExpanseDate; }