コード例 #1
0
        private void UpdateLoan(Loan auxloan, AppDbContext context)
        {
            using (context)
            {
                ReferencesLoan referLoan = new ReferencesLoan
                {
                    loanId    = auxloan.loanId,
                    amount    = Math.Round(double.Parse(TextBoxAmount.Text, CultureInfo.InvariantCulture), 2),
                    date      = DateTime.Now,
                    reference = TextBoxReference.Text,
                    image     = imageaux,
                };

                auxloan.amount           = auxloan.amount + Math.Round(double.Parse(TextBoxAmount.Text, CultureInfo.InvariantCulture), 2);
                auxloan.NumberReferences = auxloan.NumberReferences + 1;


                auxloan.ReferencesLoan = new EntitySet <ReferencesLoan>()
                {
                    referLoan,
                };
                context.ReferencesLoans.InsertOnSubmit(referLoan);
                context.SubmitChanges();
            }
        }
コード例 #2
0
 private void TapItemListBox2(object sender, System.Windows.Input.GestureEventArgs e)
 {
     if (IsolatedStorageSettings.ApplicationSettings.Contains("situation"))
     {
         if (IsolatedStorageSettings.ApplicationSettings["situation"].Equals(false))
         {
             selectedReferenceCharge = (sender as ListBox).SelectedItem as ReferencesCharge;
             if (selectedReferenceCharge == null)
             {
                 e.Handled = true;
             }
             else
             {
                 NavigationService.Navigate(new Uri("/DetailsReference.xaml", UriKind.Relative));
             }
         }
         else
         {
             selectedReferenceLoan = (sender as ListBox).SelectedItem as ReferencesLoan;
             if (selectedReferenceLoan == null)
             {
                 e.Handled = true;
             }
             else
             {
                 NavigationService.Navigate(new Uri("/DetailsReference.xaml", UriKind.Relative));
             }
         }
     }
 }
コード例 #3
0
        private void newLoan(AppDbContext context)
        {
            ReferencesLoan referLoan = new ReferencesLoan
            {
                amount    = Math.Round(double.Parse(TextBoxAmount.Text, CultureInfo.InvariantCulture), 2),
                date      = DateTime.Now,
                reference = TextBoxReference.Text,
                image     = imageaux,
            };

            Loan loanObj = new Loan
            {
                amount           = Math.Round(double.Parse(TextBoxAmount.Text, CultureInfo.InvariantCulture), 2),
                phone            = TextBlockPersonChoosenPhone.Text.ToString(),
                person           = TextBlockPersonChoosen.Text,
                NumberReferences = 1,
                ReferencesLoan   = new EntitySet <ReferencesLoan>()
                {
                    referLoan,
                },
            };

            referLoan.loanId = loanObj.loanId;

            UpdateTileLoan(loanObj);

            context.Loans.InsertOnSubmit(loanObj);
            context.SubmitChanges();

            referLoan.loanId = loanObj.loanId;
            context.SubmitChanges();
        }
コード例 #4
0
        //DELETE REFERENCE OF A LOAN
        private int ListBoxDeleteItemContextMenuLoan(object sender)
        {
            using (AppDbContext context = new AppDbContext("Data Source='isostore:/AccountAssistantDb.sdf'"))
            {
                //Loan
                ReferencesLoan selectedListBoxItem   = ((sender as MenuItem).DataContext) as ReferencesLoan;
                ReferencesLoan ReferenceLoanToDelete = (from rl in context.ReferencesLoans
                                                        where rl.date.Equals(selectedListBoxItem.date)
                                                        select rl).FirstOrDefault();

                int    idloan         = ReferenceLoanToDelete.loanId;
                double amountToDelete = ReferenceLoanToDelete.amount;

                Loan loanToUpdate = (from l in context.Loans
                                     where l.loanId.Equals(idloan)
                                     select l).FirstOrDefault();

                loanToUpdate.NumberReferences = loanToUpdate.NumberReferences - 1;
                loanToUpdate.amount           = Math.Round(loanToUpdate.amount - amountToDelete, 2);


                if (IsolatedStorageSettings.ApplicationSettings["situation"].Equals(false))
                {
                    TextBlockAmount.Text     = loanToUpdate.amount.ToString();
                    TextBlockReferences.Text = loanToUpdate.NumberReferences.ToString();
                }

                if (loanToUpdate.amount.Equals(0))
                {
                    context.Loans.DeleteOnSubmit(loanToUpdate);


                    UpdateTileLoan(loanToUpdate);
                }


                context.ReferencesLoans.DeleteOnSubmit(ReferenceLoanToDelete);
                context.SubmitChanges();

                return(idloan);
            }
        }