private void deleteDataFV(FutValue fv) { using (FutureValueDataContext context = new FutureValueDataContext()) { // find a city to update IQueryable<FutValue> fvQuery = from f in context.Futurevalue where f.Name == fv.Name select f; FutValue fvTODelete = new FutValue(); fvTODelete = fvQuery.FirstOrDefault(); MessageBox.Show(fvQuery.FirstOrDefault().Name); //hapus data yang diseleksi try { context.Futurevalue.DeleteOnSubmit(fvQuery.FirstOrDefault()); // save changes to the database context.SubmitChanges(); } catch { } } }
private void insertData(Product p) { using (FutureValueDataContext context = new FutureValueDataContext()) { if (p != null) { FutValue fv = new FutValue(); fv.InitialCost = p.InitialCost; fv.Name = p.Name; fv.InitialCost = p.InitialCost; fv.Marr = p.Marr; fv.LifetimeProject = p.LifetimeProject; fv.FutureValue = p.FutureValue; try { context.Futurevalue.InsertOnSubmit(fv); context.SubmitChanges(); this.targetSaved.ItemsSource = (List<FutValue>)this.GetFv(); } catch { if (!context.DatabaseExists()) { context.CreateDatabase(); } } } else { MessageBox.Show("NOTHING"); } } }