Ejemplo n.º 1
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            Log.Info("Before: Process to add Product record in AddProduct");
            if (!string.IsNullOrEmpty(pname.Text) && !string.IsNullOrEmpty(description.Text))
            {
                MainWindow mainWindow = (MainWindow)Application.Current.MainWindow;

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

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

                Products _p = new Inventory.Model.Products();
                _p.Pname       = pname.Text;
                _p.Description = description.Text;
                _p.Date        = DateTime.Now;

                Log.Info("Before: check to add Product record in AddProduct");

                if (Queries.IsExists <Products>(x => x.Pname == (pname.Text)))
                {
                    await mainWindow.ShowMessageAsync("Product Record Already Exist", "");
                }
                else
                {
                    DatabaseAndQueries.Queries.Add <Products>(_p);
                    await TaskEx.Delay(2000);

                    await controller.CloseAsync();

                    Helpful.CloseAllFlyouts(mainWindow.Flyouts);
                    var flyout = mainWindow.Flyouts.Items[8] as ShowProduct;


                    if (flyout == null)
                    {
                        return;
                    }
                    Log.Info("Before: To add Product record in AddProduct");

                    flyout.datalist.ItemsSource = DatabaseAndQueries.Queries.GetAllData <Products>();
                    pname.Text       = string.Empty;
                    description.Text = string.Empty;
                    await mainWindow.ShowMessageAsync("Product Record Inserted Successfully", "");

                    Log.Info("After: To add Product record in AddProduct");
                }
                Log.Info("After: check to add Product record in AddProduct");
            }
            else
            {
                MainWindow mainWindow = (MainWindow)Application.Current.MainWindow;
                await mainWindow.ShowMessageAsync("Please Enter the Complete Details", "");
            }
        }