public ActionResult Edit(string id, string GID, string Amount, string Note, string Fund, string Org, string Program, string Date) { AuleaseEntities db = new AuleaseEntities(); int Id = Convert.ToInt32(id); SingleCharge charge = db.SingleCharges.Where(n => n.Id == Id).Single(); charge.GID = GID; charge.Price = Convert.ToDecimal(Amount); charge.Note = Note; charge.Date = Convert.ToDateTime(Date); if (db.Departments.Any(n => n.Fund == Fund && n.Org == Org && n.Program == Program)) { charge.Department = db.Departments.Where(n => n.Fund == Fund && n.Org == Org && n.Program == Program).Single(); } else { Department dept = new Department(); dept.Fund = Fund; dept.Org = Org; dept.Program = Program; dept.Name = ""; db.Departments.Add(dept); db.SaveChanges(); charge.Department = dept; } db.SaveChanges(); return(View()); }
public ActionResult Delete(string id) { AuleaseEntities db = new AuleaseEntities(); int Id = Convert.ToInt32(id); SingleCharge charge = db.SingleCharges.Where(n => n.Id == Id).Single(); db.SingleCharges.Remove(charge); db.SaveChanges(); return(View()); }