Exemple #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(CategoriesDataContext.WPFMessageAndLabelForList.MessageBoxDeleteConfirm,
                                                      CategoriesDataContext.WPFMessageAndLabelForList.MessageBoxDeleteConfirmCaption, button, icon);
            string error = null;

            switch (result)
            {
            case MessageBoxResult.Yes:
                ModelNotifiedForCategories itemSelected = (ModelNotifiedForCategories)DataGridCategories.SelectedItem;
                dataConnection.DeleteData(itemSelected, out error);
                if (string.IsNullOrEmpty(error))
                {
                    CategoriesDataContext.modelNotifiedForCategoriesMain.Remove(itemSelected);
                }
                break;

            case MessageBoxResult.No:
                return;
            }

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



        public List <ModelNotifiedForCategories> GetAllCategories(out string error)
        {
            error = null;
            try
            {
                CategoriesBsn                     bsn           = new CategoriesBsn(wpfConfig);
                List <CategoriesInfo>             dbItems       = bsn.GetAll();
                List <ModelNotifiedForCategories> notifiedItems = new List <ModelNotifiedForCategories>();

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

                return(notifiedItems);
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(null);
        }
Exemple #3
0
        private void btnExcludePicture_Click(object sender, RoutedEventArgs e)
        {
            ModelNotifiedForCategories itemSelected = (ModelNotifiedForCategories)DataGridCategories.SelectedItem;

            itemSelected.Picture = null;
            itemSelected.BtnAddPictureVisibility     = Visibility.Visible;
            itemSelected.BtnExcludePictureVisibility = Visibility.Collapsed;
        }
Exemple #4
0
        public void DeleteData(ModelNotifiedForCategories modelNotifiedForCategories, out string error)
        {
            CategoriesGenericREST CategoriesGenericREST = new CategoriesGenericREST(wpfConfig);
            DeleteCategoriesView  deleteCategoriesView  = new DeleteCategoriesView();

            Cloner.CopyAllTo(typeof(ModelNotifiedForCategories), modelNotifiedForCategories, typeof(DeleteCategoriesView), deleteCategoriesView);
            CategoriesGenericREST.Delete(deleteCategoriesView, out error);
        }
Exemple #5
0
        public void AddData(ModelNotifiedForCategories modelNotifiedForCategories, out string error)
        {
            CategoriesGenericREST CategoriesGenericREST = new CategoriesGenericREST(wpfConfig);
            CreateCategoriesView  createCategoriesView  = new CreateCategoriesView();

            Cloner.CopyAllTo(typeof(ModelNotifiedForCategories), modelNotifiedForCategories, typeof(CreateCategoriesView), createCategoriesView);
            CategoriesGenericREST.Insert(createCategoriesView, out error);
        }
Exemple #6
0
        public void SaveData(ModelNotifiedForCategories modelNotifiedForCategories, out string error)
        {
            CategoriesGenericREST CategoriesGenericREST = new CategoriesGenericREST(wpfConfig);
            UpdateCategoriesView  updateCategoriesView  = new UpdateCategoriesView();

            Cloner.CopyAllTo(typeof(ModelNotifiedForCategories), modelNotifiedForCategories, typeof(UpdateCategoriesView), updateCategoriesView);
            CategoriesGenericREST.Update(updateCategoriesView, out error);
        }
Exemple #7
0
        public void DeleteData(ModelNotifiedForCategories modelNotifiedForCategories, out string error)
        {
            CategoriesBsn  bsn    = new CategoriesBsn(wpfConfig);
            CategoriesInfo dbItem = new CategoriesInfo();

            Cloner.CopyAllTo(typeof(ModelNotifiedForCategories), modelNotifiedForCategories, typeof(CategoriesInfo), dbItem);
            bsn.DeleteByID(dbItem, out error);
        }
Exemple #8
0
        public void AddData(ModelNotifiedForCategories modelNotifiedForCategories, out string error)
        {
            CategoriesBsn  bsn    = new CategoriesBsn(wpfConfig);
            CategoriesInfo dbItem = new CategoriesInfo();

            Cloner.CopyAllTo(typeof(ModelNotifiedForCategories), modelNotifiedForCategories, typeof(CategoriesInfo), dbItem);
            bsn.InsertOne(dbItem, out error);
            modelNotifiedForCategories.NewItem = false;
            Cloner.CopyAllTo(typeof(CategoriesInfo), dbItem, typeof(ModelNotifiedForCategories), modelNotifiedForCategories);
        }
Exemple #9
0
        private void btnAddPicture_Click(object sender, RoutedEventArgs e)
        {
            ModelNotifiedForCategories itemSelected         = (ModelNotifiedForCategories)DataGridCategories.SelectedItem;
            frmDisplayBinaryData       frmDisplayBinaryData = new frmDisplayBinaryData(itemSelected.Picture, GlobalEnums.MimeTypes.Image);

            frmDisplayBinaryData.ShowDialog();
            //frmDisplayBinaryData.Owner = ToDo. Without owner, alt tab can bug
            itemSelected.Picture = frmDisplayBinaryData.myViewModel.BinData;
            itemSelected.BtnAddPictureVisibility     = Visibility.Collapsed;
            itemSelected.BtnExcludePictureVisibility = Visibility.Visible;
        }
Exemple #10
0
        /// <summary>
        /// Triggered by change in grid's row.
        /// </summary>
        private void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if ((DataGridCategories.SelectedItem == null) || DataGridCategories.SelectedItem.GetType() != typeof(ModelNotifiedForCategories))
            {
                //New row on grid's bottom. By default do nothing when new row is included
                return;
            }

            ModelNotifiedForCategories selectedItem = (ModelNotifiedForCategories)DataGridCategories.SelectedItem;

            LoadDetail(selectedItem);
        }
Exemple #11
0
        private void OnMouseUpBinary(object sender, MouseButtonEventArgs e)
        {
            Image image = sender as Image;
            ModelNotifiedForCategories itemSelected = (ModelNotifiedForCategories)DataGridCategories.SelectedItem;

            if (image.Tag.ToString().ToLower() == "Picture".ToLower())
            {
                frmDisplayBinaryData frmDisplayBinaryData = new frmDisplayBinaryData(itemSelected.Picture, GlobalEnums.MimeTypes.Image);
                frmDisplayBinaryData.ShowDialog();
                //frmDisplayBinaryData.Owner = ToDo. Without owner, alt tab can bug
                itemSelected.Picture = frmDisplayBinaryData.myViewModel.BinData;
                return;
            }
            MessageBox.Show("Error: 'btnSaveBinAs' does not contains the tag reference to target binary column.");
        }
Exemple #12
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(ModelNotifiedForCategories selectedItem)
        {
            if (selectedItem == null)
            {
                return;
            }


            if (DetailListProducts != null)
            {
                DetailListProducts.LoadGrid(x => x.CategoryID == selectedItem.CategoryID);
            }

/* Note: the detail form can load only ONE row from 'Products'. It's necessary to inform DetailForm primary key here or create a custom Form.Load().
 * if (DetailForm{0} != null)
 * {
 * //DetailFormProducts.LoadForm(selectedItem.CategoryID);
 * }
 */
        }
Exemple #13
0
        private void OpenFormClick(object sender, RoutedEventArgs e)
        {
            ModelNotifiedForCategories itemSelected = (ModelNotifiedForCategories)DataGridCategories.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.Categories.FormWPFCategories page = new MyApp.WPFForms.Categories.FormWPFCategories(config);
            page.LoadForm(itemSelected.CategoryID);
            page.Setup_SetLanguage(CurrentLanguage);
            ContainerWindowSimple win = new ContainerWindowSimple(page, "Form Categories");

            win.Show();
        }
Exemple #14
0
        private void SaveClick(object sender, RoutedEventArgs e)
        {
            ModelNotifiedForCategories itemSelected = (ModelNotifiedForCategories)DataGridCategories.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(CategoriesDataContext.WPFMessageAndLabelForList.MessageBoxSaveOK);
            }
            else
            {
                //MessageBox.Show(MessageBoxSaveError + error);
                MessageBox.Show(CategoriesDataContext.WPFMessageAndLabelForList.MessageBoxSaveError + error);
            }
        }