Example #1
0
        private void DeleteClick(object sender, RoutedEventArgs e)
        {
            MessageBoxButton button = MessageBoxButton.YesNo;
            MessageBoxImage  icon   = MessageBoxImage.Warning;
            //MessageBoxResult result = MessageBox.Show(MessageBoxDeleteConfirm, MessageBoxDeleteConfirmCaption, button, icon);
            MessageBoxResult result = MessageBox.Show(ProductsDataContext.WPFMessageAndLabelForList.MessageBoxDeleteConfirm,
                                                      ProductsDataContext.WPFMessageAndLabelForList.MessageBoxDeleteConfirmCaption, button, icon);
            string error = null;

            switch (result)
            {
            case MessageBoxResult.Yes:
                ModelNotifiedForProducts itemSelected = (ModelNotifiedForProducts)DataGridProducts.SelectedItem;
                dataConnection.DeleteData(itemSelected, out error);
                if (string.IsNullOrEmpty(error))
                {
                    ProductsDataContext.modelNotifiedForProductsMain.Remove(itemSelected);
                }
                break;

            case MessageBoxResult.No:
                return;
            }

            if (error != null)
            {
                MessageBox.Show(error);
            }
            else
            {
                //MessageBox.Show(MessageBoxDeleteOK);
                MessageBox.Show(ProductsDataContext.WPFMessageAndLabelForList.MessageBoxDeleteOK);
                btnReload_Click(null, null);
            }
        }
Example #2
0
        //private void CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        //{
        //Notify("IncludeFolders");
        //}



        public List <ModelNotifiedForProducts> GetAllProducts(out string error)
        {
            error = null;
            try
            {
                ProductsBsn                     bsn           = new ProductsBsn(wpfConfig);
                List <ProductsInfo>             dbItems       = bsn.GetAll();
                List <ModelNotifiedForProducts> notifiedItems = new List <ModelNotifiedForProducts>();

                foreach (ProductsInfo dbItem in dbItems)
                {
                    ModelNotifiedForProducts itemToAdd = new ModelNotifiedForProducts();
                    Cloner.CopyAllTo(typeof(ProductsInfo), dbItem, typeof(ModelNotifiedForProducts), itemToAdd);
                    itemToAdd.ItemChanged = false;
                    itemToAdd.NewItem     = false;
                    notifiedItems.Add(itemToAdd);
                }

                return(notifiedItems);
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(null);
        }
Example #3
0
        public void DeleteData(ModelNotifiedForProducts modelNotifiedForProducts, out string error)
        {
            ProductsBsn  bsn    = new ProductsBsn(wpfConfig);
            ProductsInfo dbItem = new ProductsInfo();

            Cloner.CopyAllTo(typeof(ModelNotifiedForProducts), modelNotifiedForProducts, typeof(ProductsInfo), dbItem);
            bsn.DeleteByID(dbItem, out error);
        }
Example #4
0
        public void DeleteData(ModelNotifiedForProducts modelNotifiedForProducts, out string error)
        {
            ProductsGenericREST ProductsGenericREST = new ProductsGenericREST(wpfConfig);
            DeleteProductsView  deleteProductsView  = new DeleteProductsView();

            Cloner.CopyAllTo(typeof(ModelNotifiedForProducts), modelNotifiedForProducts, typeof(DeleteProductsView), deleteProductsView);
            ProductsGenericREST.Delete(deleteProductsView, out error);
        }
Example #5
0
        public void AddData(ModelNotifiedForProducts modelNotifiedForProducts, out string error)
        {
            ProductsGenericREST ProductsGenericREST = new ProductsGenericREST(wpfConfig);
            CreateProductsView  createProductsView  = new CreateProductsView();

            Cloner.CopyAllTo(typeof(ModelNotifiedForProducts), modelNotifiedForProducts, typeof(CreateProductsView), createProductsView);
            ProductsGenericREST.Insert(createProductsView, out error);
        }
Example #6
0
        public void SaveData(ModelNotifiedForProducts modelNotifiedForProducts, out string error)
        {
            ProductsGenericREST ProductsGenericREST = new ProductsGenericREST(wpfConfig);
            UpdateProductsView  updateProductsView  = new UpdateProductsView();

            Cloner.CopyAllTo(typeof(ModelNotifiedForProducts), modelNotifiedForProducts, typeof(UpdateProductsView), updateProductsView);
            ProductsGenericREST.Update(updateProductsView, out error);
        }
Example #7
0
        public void AddData(ModelNotifiedForProducts modelNotifiedForProducts, out string error)
        {
            ProductsBsn  bsn    = new ProductsBsn(wpfConfig);
            ProductsInfo dbItem = new ProductsInfo();

            Cloner.CopyAllTo(typeof(ModelNotifiedForProducts), modelNotifiedForProducts, typeof(ProductsInfo), dbItem);
            bsn.InsertOne(dbItem, out error);
            modelNotifiedForProducts.NewItem = false;
            Cloner.CopyAllTo(typeof(ProductsInfo), dbItem, typeof(ModelNotifiedForProducts), modelNotifiedForProducts);
        }
Example #8
0
        /// <summary>
        /// Triggered by change in grid's row.
        /// </summary>
        private void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if ((DataGridProducts.SelectedItem == null) || DataGridProducts.SelectedItem.GetType() != typeof(ModelNotifiedForProducts))
            {
                //New row on grid's bottom. By default do nothing when new row is included
                return;
            }

            ModelNotifiedForProducts selectedItem = (ModelNotifiedForProducts)DataGridProducts.SelectedItem;

            LoadDetail(selectedItem);
        }
Example #9
0
        /// <summary>
        /// Load Detail form/list in master detail. Triggered by user's change in Grid's Row.
        /// When row change, load "DetailForm" or "Detail List" (need to be configured)
        /// </summary>
        /// <param name="selectedItem"></param>
        private void LoadDetail(ModelNotifiedForProducts selectedItem)
        {
            if (selectedItem == null)
            {
                return;
            }


            if (DetailListOrderDetails != null)
            {
                DetailListOrderDetails.LoadGrid(x => x.ProductID == selectedItem.ProductID);
            }

/* Note: the detail form can load only ONE row from 'OrderDetails'. It's necessary to inform DetailForm primary key here or create a custom Form.Load().
 * if (DetailForm{0} != null)
 * {
 * //DetailFormOrderDetails.LoadForm(selectedItem.ProductID);
 * }
 */
        }
Example #10
0
        private void OpenFormClick(object sender, RoutedEventArgs e)
        {
            ModelNotifiedForProducts itemSelected = (ModelNotifiedForProducts)DataGridProducts.SelectedItem;

            if (itemSelected == null)
            {
                return;
            }

            //Uncomment this line to allow navigation
            //this.FrameMainWindow.Navigate(this.DetailListGeoCities);

            /* COMPILE ERROR WARNING!!! If this line crash:
             * a) Generate the FORM version of this list.
             * b) Re-generate the LIST without the "OpenForm" feature.#
             * c) Remove this chunk of code*/

            MyApp.WPFForms.Products.FormWPFProducts page = new MyApp.WPFForms.Products.FormWPFProducts(config);
            page.LoadForm(itemSelected.ProductID);
            page.Setup_SetLanguage(CurrentLanguage);
            ContainerWindowSimple win = new ContainerWindowSimple(page, "Form Products");

            win.Show();
        }
Example #11
0
        private void SaveClick(object sender, RoutedEventArgs e)
        {
            ModelNotifiedForProducts itemSelected = (ModelNotifiedForProducts)DataGridProducts.SelectedItem;

            if (itemSelected == null)
            {
                return;
            }

            string error = null;

            if (itemSelected.NewItem)
            {
                dataConnection.AddData(itemSelected, out error);

                if (error == null)
                {
                    btnReload_Click(null, null);
                }
            }
            else
            {
                dataConnection.SaveData(itemSelected, out error);
            }

            if (error == null)
            {
                //MessageBox.Show(MessageBoxSaveOK);
                MessageBox.Show(ProductsDataContext.WPFMessageAndLabelForList.MessageBoxSaveOK);
            }
            else
            {
                //MessageBox.Show(MessageBoxSaveError + error);
                MessageBox.Show(ProductsDataContext.WPFMessageAndLabelForList.MessageBoxSaveError + error);
            }
        }