Beispiel #1
0
 private void MetroWindow_Loaded(object sender, RoutedEventArgs e)
 {
     billProductModel = new BillProductModel();
     new TaskFactory().StartNew(() =>
     {
         if (selectedCustomer != null)
         {
             if (DFS > DateTime.MinValue && DTS > DateTime.MinValue)
             {
                 return(POS_Customer_Ledger(selectedCustomer, DFS, DTS));
             }
             else
             {
                 return(POS_Customer_Ledger(selectedCustomer));
             }
         }
         return(null);
     })
     .ContinueWith(x =>
     {
         if (x.Result == null)
         {
             Dispatcher.Invoke(new Action(() => { error(); }), DispatcherPriority.ContextIdle);
             return;
         }
         Dispatcher.Invoke(new Action(() => { aftermost(); }), DispatcherPriority.ContextIdle);
     });
 }
Beispiel #2
0
 private void Button_Click_delete(object sender, RoutedEventArgs e)
 {
     try
     {
         BillProductModel row = (BillProductModel)dataTable1DataGrid.SelectedItems[0];
         ObservableCollection <BillProductModel> data = (ObservableCollection <BillProductModel>)dataTable1DataGrid.ItemsSource;
         data.Remove(row);
     }
     catch (Exception)
     {
         //billProductModel.BillCollection.RemoveAt(dataTable1DataGrid.SelectedIndex);
     }
 }
Beispiel #3
0
 private void AddBillProduct(BillProductModel product)
 {
     if (product == null)
     {
         return;
     }
     if (_billSource.DataSource is List <BillProductModel> b)
     {
         var bill = b.Find(x => x.Barcode.Equals(product.Barcode) && x.Unit == product.Unit);
         if (bill == null)
         {
             b.Add(product);
         }
         else
         {
             bill.Quantity += 1;
         }
         _billSource.ResetBindings(false);
         _billSource.DataSource = b;
     }
 }
Beispiel #4
0
        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);
                }
            };
        }
Beispiel #5
0
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            bill             = new BillModel();
            billProductModel = new BillProductModel();
            billProductModel.BillCollection = new ObservableCollection <BillProductModel>();
            POS_GET_CUSTOMER();
            POS_Start_Bill();
            gridSource.DataContext              = billProductModel;
            webHandler.POS_Start_BillCompleted += (x, y) =>
            {
                var result = y.Result;
                resultout = y.got;
                if (resultout == 1)
                {
                    string[] arr = result.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (var item in arr)
                    {
                        string[] arg = item.Split(new string[] { "---" }, StringSplitOptions.None);
                        bill = new BillModel()
                        {
                            Billid     = int.Parse(arg[0]),
                            Current    = DateTime.ParseExact(arg[1], "M/d/yyyy h:mm:ss tt", CultureInfo.InvariantCulture),
                            EmployeeId = int.Parse(arg[2]),
                            Total      = Decimal.Parse(arg[3]),
                        };
                    }
                }
                invoiceno.Content       = new BillModel().Billid.ToString();
                Date.Content            = new BillModel().Current;
                billProductModel.Billid = new BillModel().Billid;
            };
            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)
                    {
                        //Grid DynamicGrid = new Grid();

                        //ColumnDefinition gridCol1 = new ColumnDefinition();
                        //gridCol1.Width = new GridLength(7, GridUnitType.Star);
                        //ColumnDefinition gridCol2 = new ColumnDefinition();
                        //gridCol2.Width = new GridLength(30, GridUnitType.Star);
                        //ColumnDefinition gridCol3 = new ColumnDefinition();
                        //gridCol3.Width = new GridLength(60, GridUnitType.Star);
                        //DynamicGrid.ColumnDefinitions.Add(gridCol1);
                        //DynamicGrid.ColumnDefinitions.Add(gridCol2);
                        //DynamicGrid.ColumnDefinitions.Add(gridCol3);

                        //// Create Rows
                        //RowDefinition gridRow1 = new RowDefinition();
                        //gridRow1.Height = new GridLength(8, GridUnitType.Star);
                        //RowDefinition gridRow2 = new RowDefinition();
                        //gridRow2.Height = new GridLength(50, GridUnitType.Star);
                        //RowDefinition gridRow3 = new RowDefinition();
                        //gridRow3.Height = new GridLength(25, GridUnitType.Star);
                        //DynamicGrid.RowDefinitions.Add(gridRow1);
                        //DynamicGrid.RowDefinitions.Add(gridRow2);
                        //DynamicGrid.RowDefinitions.Add(gridRow3);

                        //Grid fields = fieldGrid;
                        //Grid.SetRow(fields, 0);
                        //Grid.SetColumn(fields, 0);
                        //Grid.SetColumnSpan(fields, 3);

                        //DynamicGrid.Children.Add(fields);

                        //Border border = griddataTable1DataGrid;
                        //Grid.SetRow(border, 1);
                        //Grid.SetColumn(border, 0);
                        //Grid.SetColumnSpan(border, 3);

                        //DynamicGrid.Children.Add(border);

                        //Grid cash = gridCash;
                        //Grid.SetRow(cash, 2);
                        //Grid.SetColumn(cash, 0);
                        //Grid.SetColumnSpan(cash, 3);

                        //DynamicGrid.Children.Add(cash);

                        //StackPanel stack = new StackPanel();
                        //stack.Children.Add(gridPrint);
                        //stack.Children.Add(gridPrint1);
                        gridPrint.SetValue(Grid.RowSpanProperty, 3);
                        gridPrint1.Visibility = Visibility.Visible;
                        PrintCharts(finalprint);
                        NavigationService navigation = NavigationService.GetNavigationService(this);
                        navigation.Navigate(new Uri("Dashboard.xaml", UriKind.Relative));
                    }
                }
                if (resultout1 == 0)
                {
                    var res1 = await win.ShowMessageAsync("Something is wrong...", " " +
                                                          MessageDialogStyle.Affirmative);

                    webHandler.POS_delete_billAsync(new BillModel().Billid);
                    webHandler.POS_delete_billCompleted += (x1, y1) =>
                    {
                        NavigationService navigation = NavigationService.GetNavigationService(this);
                        navigation.Navigate(new Uri("Dashboard.xaml", UriKind.Relative));
                    };
                }
            };
            webHandler.POS_Add_Bill_Product_ShipmentCompleted += 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)
                    {
                        NavigationService navigation = NavigationService.GetNavigationService(this);
                        navigation.Navigate(new Uri("Dashboard.xaml", UriKind.Relative));
                    }
                }
                if (resultout1 == 0)
                {
                    var res1 = await win.ShowMessageAsync("Something is wrong...", " " +
                                                          MessageDialogStyle.Affirmative);

                    webHandler.POS_delete_billAsync(new BillModel().Billid);
                    webHandler.POS_delete_billCompleted += (x1, y1) =>
                    {
                        NavigationService navigation = NavigationService.GetNavigationService(this);
                        navigation.Navigate(new Uri("Dashboard.xaml", UriKind.Relative));
                    };
                }
            };
        }
Beispiel #6
0
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            billProductModel = new BillProductModel();
            dateModel        = new DateModel();
            POS_GET_CUSTOMER();
            flyout.DataContext = dateModel;

            ///---///
            #region Completed
            webHandler.POS_Get_Customer_LedgerCompleted += (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]),
                    });
                }
                dataTable1DataGrid.ItemsSource = billProductModel.BillCollection;
            };
            webHandler.POS_Get_Customer_Ledger_FilterDateCompleted += (x, y) =>
            {
                var result = y.Result;
                billProductModel.BillCollection.Clear();
                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]),
                    });
                }
            };
            webHandler.POS_Get_CustomerCompleted += (x, y) =>
            {
                var result = y.Result;
                customer.CustomerCollection = new ObservableCollection <CustomerModel>();
                string[] arr = result.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                foreach (var item in arr)
                {
                    string[] arg = item.Split(new string[] { "|||" }, StringSplitOptions.None);
                    customer.CustomerCollection.Add(new CustomerModel()
                    {
                        Customerid        = arg[0],
                        CustomerName      = arg[1],
                        Customerbalance   = arg[2],
                        Customerphone     = arg[3],
                        Customeraddress   = arg[4],
                        CustomerLocation  = arg[5],
                        CustomerLastTally = arg[6],
                    });
                }
                combo.ItemsSource = customer.CustomerCollection;
            };
            #endregion End
        }