private void combo_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { SelectedBill = (GetBillModel)combo.SelectedItem; BALANCE = SelectedBill.TotalBalance; BALANCE = BALANCE - SelectedBill.Total; BALANCE = BALANCE + Decimal.Parse(SelectedBill.PaidAmount); if (SelectedBill != null) { webHandler.POS_Get_Bill_ProductAsync(SelectedBill.Billid); } } catch (Exception) { } }
private void Page_Loaded(object sender, RoutedEventArgs e) { if (new LoggedInEmployeeModel().Rank > 2) { dataTable1DataGrid.IsEnabled = false; rightStackPanel.IsEnabled = false; flyout.IsEnabled = false; combo.IsEnabled = true; } bill = new GetBillModel(); billProductModel = new BillProductModel(); POS_Get_Bills(); webHandler.POS_Get_BillCompleted += (x, y) => { var result = y.Result; bill.GetBillCollection = new ObservableCollection <GetBillModel>(); string[] arr = result.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); foreach (var item in arr) { string[] arg = item.Split(new string[] { "---" }, StringSplitOptions.None); bill.GetBillCollection.Add(new GetBillModel() { Billid = int.Parse(arg[0]), Current = (DateTime.ParseExact(arg[1], "M/d/yyyy h:mm:ss tt", CultureInfo.InvariantCulture)), Total = Decimal.Parse(arg[2]), PaidAmount = arg[3], PaymentMethod = arg[4], CustomerName = arg[5], Customerid = int.Parse(arg[6]), TotalBalance = decimal.Parse(arg[7]), EmployeeId = int.Parse(arg[8]), EmployeeName = arg[9], }); } combo.ItemsSource = bill.GetBillCollection; }; webHandler.POS_Get_Bill_ProductCompleted += (x, y) => { var result = y.Result; billProductModel.BillCollection = new ObservableCollection <BillProductModel>(); string[] arr = result.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); foreach (var item in arr) { string[] arg = item.Split(new string[] { "---" }, StringSplitOptions.None); billProductModel.BillCollection.Add(new BillProductModel() { DateTime = (DateTime.ParseExact(arg[0], "M/d/yyyy h:mm:ss tt", CultureInfo.InvariantCulture)), Billid = int.Parse(arg[1]), Quantity = int.Parse(arg[2]), ProductName = arg[3], Rate = Decimal.Parse(arg[4]), TotalAmount = Decimal.Parse(arg[5]), Status = arg[6], Balance = Decimal.Parse(arg[7]), }); } try { total.Content = SelectedBill.Total; var a = billProductModel.BillCollection.SingleOrDefault(x1 => x1.Status == "Cr"); if (a != null) { billProductModel.BillCollection.Remove(a); rightcheck.IsChecked = true; paymentamount.Text = a.TotalAmount.ToString(); List <RadioButton> radioButtons = new List <RadioButton>(); WalkLogicalTree(radioButtons, rootpanel); foreach (RadioButton rb in radioButtons) { if (rb.GroupName == "ready" && (string)rb.Content == a.ProductName) { rb.IsChecked = true; } } } else { rightcheck.IsChecked = false; paymentamount.Text = null; bill.PaymentMethod = null; } } catch (Exception ex) { Debug.WriteLine(ex.Message); } dataTable1DataGrid.ItemsSource = billProductModel.BillCollection; }; webHandler.POS_Add_Bill_ProductCompleted += async(x, y) => { var win = (MetroWindow)Application.Current.MainWindow; resultout1 = y.result1; if (resultout1 == 1) { var res1 = await win.ShowMessageAsync("All done...", " " + MessageDialogStyle.Affirmative); if (res1 == MessageDialogResult.Affirmative) { InvalidateVisual(); } } if (resultout1 == 0) { var res1 = await win.ShowMessageAsync("Something is wrong...", "Please try again " + MessageDialogStyle.Affirmative); NavigationService navigation = NavigationService.GetNavigationService(this); navigation.Navigate(new Uri("Dashboard.xaml", UriKind.Relative)); } }; webHandler.POS_delete_billCompleted += async(x, y) => { var win = (MetroWindow)Application.Current.MainWindow; resultout1 = y.Result; if (resultout1 == 1) { var res1 = await win.ShowMessageAsync("Bill Deleted...", " " + MessageDialogStyle.Affirmative); if (res1 == MessageDialogResult.Affirmative) { InvalidateVisual(); NavigationService navigation = NavigationService.GetNavigationService(this); navigation.Navigate(new Uri("Dashboard.xaml", UriKind.Relative)); } } if (resultout1 == 0) { var res1 = await win.ShowMessageAsync("Something is wrong...", "Please try again " + MessageDialogStyle.Affirmative); } }; }