示例#1
0
        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
                {

                }
            }
        }
示例#2
0
 public IList<FutValue> GetFv()
 {
     IList<FutValue> fvList = null;
     using (FutureValueDataContext context = new FutureValueDataContext())
     {
         try
         {
             IQueryable<FutValue> query = from f in context.Futurevalue select f;
             fvList = query.ToList();
         }
         catch
         {
         }
     }
     return fvList;
 }
示例#3
0
        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");
                }

            }
        }