Esempio n. 1
0
        private void insertData(Product p)
        {
            using (NpvDataContext context = new NpvDataContext())
            {
                if (p != null)
                {
                    NetPresValue npv = new NetPresValue();
                    npv.InitialCost = p.InitialCost;
                    npv.Name = p.Name;
                    npv.AnnualProfit = p.AnnualProfit;
                    npv.Marr = p.Marr;
                    npv.LifetimeProject = p.LifetimeProject;
                    npv.Npv = p.Npv;
                    npv.Status = p.Status;
                    npv.Irr = p.Irr;
                    try
                    {

                        context.Npv.InsertOnSubmit(npv);
                        context.SubmitChanges();
                        this.targetSaved.ItemsSource = (List<NetPresValue>)this.GetNpv();
                    }
                    catch
                    {
                        MessageBox.Show("P : " + p.Name + " NPV : " + npv.Name);
                        if (!context.DatabaseExists())
                        {
                            context.CreateDatabase();
                        }
                    }

                }
                else
                {
                    MessageBox.Show("NOTHING");
                }

            }
        }
Esempio n. 2
0
        private void StackPanel_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            if (MessageBox.Show("Are you sure?", "Save this plan?", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
            {
                Product p = new Product();
                p = (Product)targetOn.SelectedItem;
                this.insertData(p);
                this.targetSaved.ItemsSource = (List<NetPresValue>)this.GetNpv();

            }
        }
Esempio n. 3
0
        private void insertData()
        {
            Product prod = new Product();
            try
            {
                prod.Name = name.Text;
                double varInitialCost = Convert.ToDouble(initialCost.Text);
                double varAnnualProfit = Convert.ToDouble(annualProfit.Text);
                prod.LifetimeProject = Convert.ToInt64(lifetimeProject.Text);
                prod.Marr = Convert.ToDouble(marr.Text);
                double counter = 0;
                double temp2 = (1 + (prod.Marr / (double)100));

                for (int i = 1; i <= prod.LifetimeProject; i++)
                {
                    double temp = varAnnualProfit / (double)Math.Pow(temp2, i);
                    counter += temp;
                }
                double varNpv = counter - varInitialCost;
                prod.Status = "";
                if (varNpv <= -1)
                {
                    prod.Status = "NPV Not Qualified";
                }
                else
                {
                    prod.Status = "NPV Qualified";
                }
                prod.countIRR(varInitialCost, varAnnualProfit, prod.LifetimeProject);
                if (prod.Irr < 0.001)
                {
                    prod.Status += " and will run at loss";
                }
                else if(prod.Irr >=0.001)
                {
                    prod.Status += " and positive return";
                }
                prod.InitialCost = string.Format(CultureInfo.CurrentCulture, "{0:C}", varInitialCost);
                prod.AnnualProfit = string.Format(CultureInfo.CurrentCulture, "{0:C}", varAnnualProfit);
                prod.Npv = string.Format(CultureInfo.CurrentCulture, "{0:C}", varNpv);
                productList.Add(prod);
                check = true;
            }
            catch
            {
                MessageBox.Show("Data invalid");
                check = false;
            }
        }
Esempio n. 4
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");
                }

            }
        }
Esempio n. 5
0
 //memasukkan data ke List
 private void insertData()
 {
     Product prod = new Product();
     try
     {
         prod.Name = name.Text;
         double varInitialCost = Convert.ToDouble(initialCost.Text);
         prod.LifetimeProject = Convert.ToInt64(lifetimeProject.Text);
         prod.Marr = Convert.ToDouble(interest.Text);
         double varFutureValue = varInitialCost * (Math.Pow((1 + (prod.Marr / (double)100)), prod.LifetimeProject));
         prod.InitialCost = string.Format(CultureInfo.CurrentCulture, "{0:C}", varInitialCost);
         prod.FutureValue = string.Format(CultureInfo.CurrentCulture, "{0:C}", varFutureValue);
         productList.Add(prod);
         check = true;
     }
     catch
     {
         MessageBox.Show("Data invalid");
         check = false;
     }
 }