Ejemplo n.º 1
0
        private void UpdateCharge(Charge auxcharge, AppDbContext context)
        {
            using (context)
            {
                ReferencesCharge referCharge = new ReferencesCharge
                {
                    chargeId  = auxcharge.chargeId,
                    amount    = Math.Round(double.Parse(TextBoxAmount.Text, CultureInfo.InvariantCulture), 2),
                    date      = DateTime.Now,
                    reference = TextBoxReference.Text,
                    image     = imageaux,
                };

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


                auxcharge.ReferencesCharge = new EntitySet <ReferencesCharge>()
                {
                    referCharge
                };
                context.ReferencesCharges.InsertOnSubmit(referCharge);
                context.SubmitChanges();
            }
        }
Ejemplo n.º 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));
             }
         }
     }
 }
Ejemplo n.º 3
0
        private void newCharge(AppDbContext context)
        {
            ReferencesCharge referCharge = new ReferencesCharge
            {
                amount    = Math.Round(double.Parse(TextBoxAmount.Text, CultureInfo.InvariantCulture), 2),
                date      = DateTime.Now,
                reference = TextBoxReference.Text,
                image     = imageaux,
            };


            Charge chargeObj = new Charge
            {
                amount = Math.Round(double.Parse(TextBoxAmount.Text, CultureInfo.InvariantCulture), 2),

                phone            = TextBlockPersonChoosenPhone.Text.ToString(),
                person           = TextBlockPersonChoosen.Text,
                NumberReferences = 1,
                ReferencesCharge = new EntitySet <ReferencesCharge>()
                {
                    referCharge
                },
            };

            referCharge.chargeId = chargeObj.chargeId;

            UpdateTileCharge(chargeObj);

            context.Charges.InsertOnSubmit(chargeObj);
            context.SubmitChanges();

            referCharge.chargeId = chargeObj.chargeId;
            context.SubmitChanges();
        }
Ejemplo n.º 4
0
        //DELETE REFERENCE OF A CHARGE
        private int ListBoxDeleteItemContextMenuCharge(object sender)
        {
            using (AppDbContext context = new AppDbContext("Data Source='isostore:/AccountAssistantDb.sdf'"))
            {
                //Charge
                ReferencesCharge selectedListBoxItem     = ((sender as MenuItem).DataContext) as ReferencesCharge;
                ReferencesCharge ReferenceChargeToDelete = (from rc in context.ReferencesCharges
                                                            where rc.date.Equals(selectedListBoxItem.date)
                                                            select rc).FirstOrDefault();

                int    idcharge       = ReferenceChargeToDelete.chargeId;
                double amountToDelete = ReferenceChargeToDelete.amount;

                Charge chargeToUpdate = (from c in context.Charges
                                         where c.chargeId.Equals(idcharge)
                                         select c).FirstOrDefault();

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


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

                if (chargeToUpdate.amount.Equals(0))
                {
                    context.Charges.DeleteOnSubmit(chargeToUpdate);

                    UpdateTileCharge(chargeToUpdate);
                }


                context.ReferencesCharges.DeleteOnSubmit(ReferenceChargeToDelete);
                context.SubmitChanges();

                return(idcharge);
            }
        }