예제 #1
0
        private void UpdateWeeklyReport(Transaction dailytransaction)
        {
            using (EnkuDesignDBContext context = new EnkuDesignDBContext())
            {
                String date = dailytransaction.Date.ToString();
                Console.WriteLine($"The date passed is : {date}");
                try
                {
                    TransactionReport treport = context.TransactionReports.Where(tr => tr.Date.ToString().Equals(date)).Single();

                    Console.WriteLine($"The date extracted is : {treport.Date.ToString()}");
                    if (dailytransaction.Type == "SALE")
                    {
                        Console.WriteLine($"Inside the if");
                        treport.Sale = treport.Sale + dailytransaction.Price;
                        treport.Net  = treport.Net + dailytransaction.Price;
                        context.SaveChanges();
                        LoadWeeklyReportsTable();
                    }
                    else if (dailytransaction.Type == "EXPENSE")
                    {
                        treport.Expense = treport.Expense + dailytransaction.Price;
                        treport.Net     = treport.Net - dailytransaction.Price;
                        context.SaveChanges();
                        LoadWeeklyReportsTable();
                    }
                }
                catch (Exception)
                {
                    if (dailytransaction.Type == "SALE")
                    {
                        Console.WriteLine($"Inside the exception if ");
                        context.TransactionReports.Add(new TransactionReport()
                        {
                            Date    = dailytransaction.Date,
                            Sale    = dailytransaction.Price,
                            Expense = 0.0,
                            Net     = dailytransaction.Price
                        });
                        context.SaveChanges();
                        LoadWeeklyReportsTable();
                    }
                    else if (dailytransaction.Type == "EXPENSE")
                    {
                        context.TransactionReports.Add(new TransactionReport()
                        {
                            Date    = dailytransaction.Date,
                            Sale    = 0.0,
                            Expense = dailytransaction.Price,
                            Net     = -1 * dailytransaction.Price
                        });
                        context.SaveChanges();
                        LoadWeeklyReportsTable();
                    }
                }
            }
        }
예제 #2
0
        private void AddSalesButtonClicked(object sender, RoutedEventArgs e)
        {
            try
            {
                Transaction dailysaletransaction = new Transaction
                {
                    Id      = 111,
                    Item    = solddress.Text.ToString(),
                    Price   = Double.Parse(sellprice.Text.ToString()),
                    Cashier = cashiersell.Text.ToString(),
                    Date    = string.Format("{0:D}", (DateTime)Selldate.SelectedDate),
                    Type    = "SALE"
                };

                mydb.Transactions.Add(dailysaletransaction);
                mydb.SaveChanges();
                LoadDailyReportsTable();
                UpdateWeeklyReport(dailysaletransaction);
                String dressid = dailysaletransaction.Item;
                UpdateDressAmount(dressid);
            }
            catch (Exception) { }
        }
 private void DressDelivered(object sender, RoutedEventArgs e)
 {
     using (EnkuDesignDBContext context = new EnkuDesignDBContext())
     {
         try
         {
             Console.WriteLine("this is in the deliver dress function * before manipulation");
             string      IdMemeber      = ((AppointmentsDataGrid.SelectedItem as Appointment).Name).ToString();
             Appointment delivereddress = (from r in context.Appointments where (r.Name.ToString()) == IdMemeber select r).SingleOrDefault();
             context.Appointments.Remove(delivereddress);
             context.SaveChanges();
             AppointmentsDataGrid.ItemsSource = context.Appointments.ToList();
             Console.WriteLine("this is in the deliver dress function");
         }
         catch (Exception) { }
     }
 }
예제 #4
0
 private void AddDressButtonClicked(object sender, RoutedEventArgs e)
 {
     try
     {
         Dress dress = new Dress
         {
             Id          = Int32.Parse(dresscode.Text.ToString()),
             Price       = Double.Parse(price.Text.ToString()),
             Amount      = Int32.Parse(Amount.Text.ToString()),
             Description = Description.Text.ToString(),
             PicLocation = picturelocation.ToString()
         };
         mydb.Dresses.Add(dress);
         mydb.SaveChanges();
         LoadData();
     }
     catch (Exception) { }
 }
 private void AppointButtonClick(object sender, RoutedEventArgs e)
 {
     try {
         Appointment appointmentgiven = new Appointment
         {
             Name            = customername.Text.ToString(),
             Phone           = customerphone.Text.ToString(),
             Id              = 12,
             Price           = Double.Parse(appointmentprice.Text.ToString()),
             PaidAmount      = Double.Parse(appointmentpaidamount.Text.ToString()),
             RemainingAmount = (Double)(Double.Parse(appointmentprice.Text.ToString()) - Double.Parse(appointmentpaidamount.Text.ToString())),
             AppointmentDate = string.Format("{0:D}", (DateTime)appointmentdate.SelectedDate)
         };
         mydb.Appointments.Add(appointmentgiven);
         mydb.SaveChanges();
         LoadAppointmentsTable();
         //AppAddedSnackbar.Visibility = Visibility.Visible;
     }
     catch (Exception) { }
 }
 private void SaveChanges(object sender, RoutedEventArgs e)
 {
     try
     {
         using (EnkuDesignDBContext context = new EnkuDesignDBContext())
         {
             Appointment item = AppointmentsDataGrid.SelectedItem as Appointment;
             Appointment mem  = context.Appointments.Where(b => b.Id == item.Id).Single();
             mem.Name  = (AppointmentsDataGrid.SelectedCells[0].Column.GetCellContent(item) as TextBlock).Text;
             mem.Phone = (AppointmentsDataGrid.SelectedCells[1].Column.GetCellContent(item) as TextBlock).Text;
             //mem.LastName = (AppointmentsDataGrid.SelectedCells[3].Column.GetCellContent(item) as TextBlock).Text;
             mem.Price           = double.Parse((AppointmentsDataGrid.SelectedCells[2].Column.GetCellContent(item) as TextBlock).Text);
             mem.PaidAmount      = double.Parse((AppointmentsDataGrid.SelectedCells[3].Column.GetCellContent(item) as TextBlock).Text);
             mem.RemainingAmount = double.Parse((AppointmentsDataGrid.SelectedCells[4].Column.GetCellContent(item) as TextBlock).Text);
             context.SaveChanges();
             AppointmentsDataGrid.ItemsSource = context.Appointments.ToList();
         };
         TableUpdateSnackbar.Visibility = Visibility.Visible;
     }
     catch (Exception) { }
 }
예제 #7
0
        private void UpdateDressAmount(string dressid)
        {
            try
            {
                using (EnkuDesignDBContext context = new EnkuDesignDBContext())
                {
                    Dress dress = context.Dresses.Where(dd => dd.Id.ToString().Equals(dressid)).Single();
                    if (dress.Amount == 1)
                    {
                        Dress dresstoremove = context.Dresses.Where(dd => dd.Id.ToString().Equals(dressid)).Single();
                        context.Dresses.Remove(dresstoremove);
                    }
                    else
                    {
                        dress.Amount = dress.Amount - 1;
                    }

                    context.SaveChanges();
                }
            }
            catch (Exception) { }
        }