private async void deletesubmit()
        {
            var mySettings = new MetroDialogSettings()
            {
                AffirmativeButtonText = "Delete",
                NegativeButtonText    = "Cancel"
            };
            MainWindow          mainWindow = (MainWindow)Application.Current.MainWindow;
            MessageDialogResult result     = await mainWindow.ShowMessageAsync("Are you Sure want to Delete ?", "",
                                                                               MessageDialogStyle.AffirmativeAndNegative, mySettings);

            if (result == MessageDialogResult.Affirmative)
            {
                Log.Info("Before: going to Delete customer record");
                var controller = await mainWindow.ShowProgressAsync("Please wait...", "Process is Going on..!");

                controller.SetIndeterminate();
                await TaskEx.Delay(1000);

                DatabaseAndQueries.Queries.Delete <Customer>(Customer);
                Log.Info("After: to Delete customer record,Successfully");
                await TaskEx.Delay(2000);

                await controller.CloseAsync();

                await mainWindow.ShowMessageAsync("Customer Record Deleted Successfully", "");

                Helpful.CloseAllFlyouts(mainWindow.Flyouts);
            }
        }
        private async void updatesubmit()
        {
            var mySettings = new MetroDialogSettings()
            {
                AffirmativeButtonText = "Update",
                NegativeButtonText    = "Cancel"
            };
            MainWindow mainWindow = (MainWindow)Application.Current.MainWindow;

            MessageDialogResult result = await mainWindow.ShowMessageAsync("Are you Sure want to Update ?", "",
                                                                           MessageDialogStyle.AffirmativeAndNegative, mySettings);

            if (result == MessageDialogResult.Affirmative)
            {
                if (!string.IsNullOrEmpty(_customer.Address) && !string.IsNullOrEmpty(_customer.Cname) &&
                    !string.IsNullOrEmpty(_customer.ContactNo))
                {
                    if (string.IsNullOrEmpty(_customer.Email))
                    {
                        _customer.Email = "not available";
                    }
                    else
                    {
                        var controller = await mainWindow.ShowProgressAsync("Please wait...", "Process is Going on..!");

                        if (!DatabaseAndQueries.Queries.IsExists <Customer>(x => x.ContactNo == _customer.ContactNo && x.Cid != _customer.Cid))
                        {
                            Log.Info("Before: going to update customer record");
                            controller.SetIndeterminate();
                            await TaskEx.Delay(1000);

                            DatabaseAndQueries.Queries.Update <Customer>(_customer);
                            Log.Info("After: going to update customer record");
                            await TaskEx.Delay(2000);

                            await controller.CloseAsync();

                            await mainWindow.ShowMessageAsync("Customer Record Updated Successfully", "");

                            Helpful.CloseAllFlyouts(mainWindow.Flyouts);
                        }
                        else
                        {
                            await TaskEx.Delay(2000);

                            await controller.CloseAsync();

                            await mainWindow.ShowMessageAsync("Customer Contact number already exist", "");
                        }
                    }
                }
                else
                {
                    await mainWindow.ShowMessageAsync("Please Fill the Complete Details", "");
                }
            }
        }
Example #3
0
        private async void SubmitAddSales()
        {
            Log.Info("Before: Process to add new sales record");

            MainWindow mainWindow = (MainWindow)Application.Current.MainWindow;
            var        controller = await mainWindow.ShowProgressAsync("Please wait...", "Process is Going on..!");

            controller.SetIndeterminate();
            await TaskEx.Delay(1000);

            _sale.Type = true;              // for sale record............


            if (!string.IsNullOrEmpty(_sale.Product.Pid.ToString()) && !string.IsNullOrEmpty(_sale.Customer.Cid.ToString()) &&
                !string.IsNullOrEmpty(_sale.Advance.ToString()) && !string.IsNullOrEmpty(_sale.Price.ToString()) &&
                !string.IsNullOrEmpty(_sale.Quantity.ToString()) && !string.IsNullOrEmpty(_sale.SaleDate.ToString()))
            {
                _sale.RemainingBalance = _sale.TotalAmount - _sale.Advance;

                Log.Info("Before: get list of available stock");
                Products _chk = Queries.GetDataByCondition <Products>(x => x.Pid == _sale.Product.Pid);
                Log.Info("After: get list of available stock");
                if (_chk.StockQty >= _sale.Quantity)
                {
                    _chk.StockQty = _chk.StockQty - _sale.Quantity;
                    DatabaseAndQueries.Queries.Add <Sale>(_sale);

                    Sales.Add(_sale);
                    Sale = new Sale();
                    await TaskEx.Delay(2000);

                    await controller.CloseAsync();

                    await mainWindow.ShowMessageAsync("Sales Record Added Successfully", "");
                }
                else
                {
                    await TaskEx.Delay(2000);

                    await controller.CloseAsync();

                    await mainWindow.ShowMessageAsync("You have Insufficient Stock : " + _chk.StockQty, "");
                }
                Helpful.CloseAllFlyouts(mainWindow.Flyouts);
            }
            else
            {
                await TaskEx.Delay(2000);

                await controller.CloseAsync();

                await mainWindow.ShowMessageAsync("Please Fill all the fields", "");
            }
            Log.Info("After: Process to add new sales record, successfully");
        }
Example #4
0
        private async void SubmitUpdate()
        {
            Log.Info("Before: EditProduct record");

            var mySettings = new MetroDialogSettings()
            {
                AffirmativeButtonText = "Submit",
                NegativeButtonText    = "Cancel"
            };
            MainWindow          mainWindow = (MainWindow)Application.Current.MainWindow;
            MessageDialogResult result     = await mainWindow.ShowMessageAsync("Are you Sure want to Update ?", "",
                                                                               MessageDialogStyle.AffirmativeAndNegative, mySettings);

            if (result == MessageDialogResult.Affirmative)
            {
                if (!string.IsNullOrEmpty(product.Pname) && !string.IsNullOrEmpty(product.Description) && !string.IsNullOrEmpty(product.Mrp.ToString()))
                {
                    var controller = await mainWindow.ShowProgressAsync("Please wait...", "Process is Going on..!");

                    controller.SetIndeterminate();
                    await TaskEx.Delay(1000);

                    Log.Info("Before: check product is exist or not in DB");
                    if (Queries.IsExists <Products>(x => x.Pname.Contains(Product.Pname)))
                    {
                        Log.Info("After: check product is exist or not in DB, successfully");
                        await TaskEx.Delay(2000);

                        await controller.CloseAsync();

                        await mainWindow.ShowMessageAsync("Product Record Already Exist", "");
                    }
                    else
                    {
                        Queries.Update <Products>(product);
                        await TaskEx.Delay(2000);

                        await controller.CloseAsync();

                        await mainWindow.ShowMessageAsync("Product Record Updated Successfully", "");

                        Helpful.CloseAllFlyouts(mainWindow.Flyouts);
                        Log.Info("After: Edit Product record successfully inside the model name: Product");
                    }
                }
                else
                {
                    await mainWindow.ShowMessageAsync("Please Fill the Complete Details", "");
                }
            }
        }
Example #5
0
        private async void Submit()
        {
            MainWindow mainWindow = (MainWindow)Application.Current.MainWindow;
            var        controller = await mainWindow.ShowProgressAsync("Please wait...", "Process is Going on..!");

            if (!string.IsNullOrEmpty(product.Pname) && !string.IsNullOrEmpty(product.Description))
            {
                Log.Info("Before: going to add new product into stock");

                controller.SetIndeterminate();
                await TaskEx.Delay(1000);

                Log.Info("Before: check product is exist or not in DB");
                if (Queries.IsExists <Products>(x => x.Pname.Contains(Product.Pname)))
                {
                    Log.Info("After: check product is exist or not in DB, successfully");
                    await TaskEx.Delay(2000);

                    await controller.CloseAsync();

                    await mainWindow.ShowMessageAsync("Product Record Already Exist", "");
                }
                else
                {
                    Log.Info("Before: To add new Product record");
                    DatabaseAndQueries.Queries.Add <Products>(product);
                    Products.Add(product);
                    Product = new Products();
                    Log.Info("After: To add new Product record ,successfully");
                    await TaskEx.Delay(2000);

                    await controller.CloseAsync();

                    await mainWindow.ShowMessageAsync("Product Record Added Successfully", "");

                    Helpful.CloseAllFlyouts(mainWindow.Flyouts);
                    Log.Info("After: going to add new product into stock");
                }
            }
            else
            {
                await TaskEx.Delay(2000);

                await controller.CloseAsync();

                await mainWindow.ShowMessageAsync("Please Fill the Complete Details", "");
            }
        }
Example #6
0
        private async void SubmitAddPurchase()
        {
            Log.Info("Before: Process to add new Purchase record");
            MainWindow mainWindow = (MainWindow)Application.Current.MainWindow;

            if (!string.IsNullOrEmpty(_sale.Product.Pid.ToString()) && !string.IsNullOrEmpty(_sale.Customer.Cid.ToString()) &&
                !string.IsNullOrEmpty(_sale.Advance.ToString()) && !string.IsNullOrEmpty(_sale.Price.ToString()) &&
                !string.IsNullOrEmpty(_sale.Quantity.ToString()) && !string.IsNullOrEmpty(_sale.SaleDate.ToString()))
            {
                var controller = await mainWindow.ShowProgressAsync("Please wait...", "Process is Going on..!");

                controller.SetIndeterminate();
                await TaskEx.Delay(1000);

                if (_sale != null)
                {
                    _sale.RemainingBalance = _sale.TotalAmount - _sale.Advance;
                    DatabaseAndQueries.Queries.Add <Sale>(_sale);

                    Log.Info("Before: get list of available stock");
                    Products _chk = Queries.GetDataByCondition <Products>(x => x.Pid == _sale.Product.Pid);
                    _chk.StockQty = _chk.StockQty + _sale.Quantity;
                    Log.Info("After: get list of available stock");
                    Queries.Update <Products>(_chk);
                    Log.Info("After: updation of product stock, successfully");
                    Sales.Add(_sale);
                    Sale = new Sale();
                    await TaskEx.Delay(2000);

                    await controller.CloseAsync();

                    await mainWindow.ShowMessageAsync("Sales Record Added Successfully", "");

                    Log.Info("After: Process to add new Purchase record");
                }

                Helpful.CloseAllFlyouts(mainWindow.Flyouts);
            }
            else
            {
                await mainWindow.ShowMessageAsync("Please Fill the Complete Details", "");
            }
        }