Example #1
0
        public void GenerateBill(object sender, RoutedEventArgs e)
        {
            Button b    = sender as Button;
            Sale   sale = b.CommandParameter as Sale;

            Log.Info("Before: generate bill call from ShowSales");
            Log.Info("Request to salesbill for report");
            SalesBill rpt = new SalesBill(Convert.ToInt32(sale.Billing));

            rpt.ShowDialog();
            Log.Info("After: generate bill call, from ShowSales");
        }
Example #2
0
        private async void Button_Click_1(object sender, RoutedEventArgs e)
        {
            MainWindow mainWindow = (MainWindow)Application.Current.MainWindow;

            showCustomer.IsEnabled = false;
            List <Sale> lstsale = new List <Sale>();
            Sale        _S      = null;

            if (datalist.Items.Count > 0)
            {
                Log.Info("Before: To insert data in sales ItemSalesAdd");
                foreach (DataView item in datalist.Items)
                {
                    DataRowView ssss = item[0];
                    var         kk   = ssss.Row.ItemArray;
                    _S = new Sale();

                    _S.Product.Pid = Convert.ToInt32(kk[0]);
                    _S.Customer    = (Customer)showCustomer.SelectedItem;
                    _S.Price       = float.Parse(kk[3].ToString());
                    _S.Quantity    = float.Parse(kk[4].ToString());
                    _S.Discount    = float.Parse(kk[5].ToString());
                    _S.Vat         = float.Parse(kk[6].ToString());
                    _S.TotalAmount = float.Parse(kk[7].ToString());
                    _S.SaleDate    = (DateTime)SalesDate.SelectedDate;
                    _S.Type        = true;
                    datalist.SelectedIndex++;

                    if (string.IsNullOrEmpty(Advanced.Text))
                    {
                        float p = 0;
                        Advanced.Text = p.ToString();
                        _S.Advance    = float.Parse(Advanced.Text);
                    }
                    if (datalist.SelectedIndex == datalist.Items.Count - 1)
                    {
                        _S.Advance = float.Parse(Advanced.Text);
                    }
                    Log.Info("Before: Create Linq to get record of selected product ItemSalesAdd");
                    _S.RemainingBalance = _S.TotalAmount - _S.Advance;
                    Products _chk = (from P in lst
                                     where P.Pid == Convert.ToInt32(kk[0])
                                     select P).First <Products>();
                    Log.Info("After: Create Linq to get record of selected product ItemSalesAdd");
                    if (_chk.StockQty >= float.Parse(kk[4].ToString()))
                    {
                        float aq;
                        aq            = _chk.StockQty - float.Parse(kk[4].ToString());
                        _chk.StockQty = aq;
                        _S.Billing    = billnumber;
                        Log.Info("Before: To update product stock in product Db ItemSalesAdd");
                        Queries.Update <Products>(_chk);
                        Log.Info("After: To update product stock in product Db, Successfully ItemSalesAdd");
                        Queries.Add <Sale>(_S);
                        Log.Info("After: To insert data in sales, Successfully ItemSalesAdd");
                    }
                    else
                    {
                        await mainWindow.ShowMessageAsync("You have Insufficient Stock", "");
                    }
                    _S = null;
                }
                Billing obje = new Billing();
                obje.BillNo = billnumber;
                Queries.Add <Billing>(obje);

                var mySettings = new MetroDialogSettings()
                {
                    AffirmativeButtonText = "Generate Bill",
                    NegativeButtonText    = "Cancel",
                };
                MessageDialogResult result1 = await mainWindow.ShowMessageAsync("Sales Record Inserted Successfully", "",
                                                                                MessageDialogStyle.AffirmativeAndNegative, mySettings);

                if (result1 != MessageDialogResult.Negative)
                {
                    Log.Info("Before: generate bill call from ItemSalesAdd");
                    Log.Info("Request to salesbill for report in ItemSalesAdd");
                    SalesBill rpt = new SalesBill(billnumber);
                    rpt.ShowDialog();
                    Log.Info("After: generate bill call, from ItemSalesAdd");
                }
                Helpful.CloseAllFlyouts(mainWindow.Flyouts);
            }
            else
            {
                await mainWindow.ShowMessageAsync("Item not Available in list ", "");
            }
        }