Пример #1
0
        //private void CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        //{
        //Notify("IncludeFolders");
        //}



        public List <ModelNotifiedForSuppliers> GetAllSuppliers(out string error)
        {
            error = null;
            try
            {
                SuppliersBsn                     bsn           = new SuppliersBsn(wpfConfig);
                List <SuppliersInfo>             dbItems       = bsn.GetAll();
                List <ModelNotifiedForSuppliers> notifiedItems = new List <ModelNotifiedForSuppliers>();

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

                return(notifiedItems);
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(null);
        }
Пример #2
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(SuppliersDataContext.WPFMessageAndLabelForList.MessageBoxDeleteConfirm,
                                                      SuppliersDataContext.WPFMessageAndLabelForList.MessageBoxDeleteConfirmCaption, button, icon);
            string error = null;

            switch (result)
            {
            case MessageBoxResult.Yes:
                ModelNotifiedForSuppliers itemSelected = (ModelNotifiedForSuppliers)DataGridSuppliers.SelectedItem;
                dataConnection.DeleteData(itemSelected, out error);
                if (string.IsNullOrEmpty(error))
                {
                    SuppliersDataContext.modelNotifiedForSuppliersMain.Remove(itemSelected);
                }
                break;

            case MessageBoxResult.No:
                return;
            }

            if (error != null)
            {
                MessageBox.Show(error);
            }
            else
            {
                //MessageBox.Show(MessageBoxDeleteOK);
                MessageBox.Show(SuppliersDataContext.WPFMessageAndLabelForList.MessageBoxDeleteOK);
                btnReload_Click(null, null);
            }
        }
Пример #3
0
        public void DeleteData(ModelNotifiedForSuppliers modelNotifiedForSuppliers, out string error)
        {
            SuppliersGenericREST SuppliersGenericREST = new SuppliersGenericREST(wpfConfig);
            DeleteSuppliersView  deleteSuppliersView  = new DeleteSuppliersView();

            Cloner.CopyAllTo(typeof(ModelNotifiedForSuppliers), modelNotifiedForSuppliers, typeof(DeleteSuppliersView), deleteSuppliersView);
            SuppliersGenericREST.Delete(deleteSuppliersView, out error);
        }
Пример #4
0
        public void AddData(ModelNotifiedForSuppliers modelNotifiedForSuppliers, out string error)
        {
            SuppliersGenericREST SuppliersGenericREST = new SuppliersGenericREST(wpfConfig);
            CreateSuppliersView  createSuppliersView  = new CreateSuppliersView();

            Cloner.CopyAllTo(typeof(ModelNotifiedForSuppliers), modelNotifiedForSuppliers, typeof(CreateSuppliersView), createSuppliersView);
            SuppliersGenericREST.Insert(createSuppliersView, out error);
        }
Пример #5
0
        public void SaveData(ModelNotifiedForSuppliers modelNotifiedForSuppliers, out string error)
        {
            SuppliersGenericREST SuppliersGenericREST = new SuppliersGenericREST(wpfConfig);
            UpdateSuppliersView  updateSuppliersView  = new UpdateSuppliersView();

            Cloner.CopyAllTo(typeof(ModelNotifiedForSuppliers), modelNotifiedForSuppliers, typeof(UpdateSuppliersView), updateSuppliersView);
            SuppliersGenericREST.Update(updateSuppliersView, out error);
        }
Пример #6
0
        public void DeleteData(ModelNotifiedForSuppliers modelNotifiedForSuppliers, out string error)
        {
            SuppliersBsn  bsn    = new SuppliersBsn(wpfConfig);
            SuppliersInfo dbItem = new SuppliersInfo();

            Cloner.CopyAllTo(typeof(ModelNotifiedForSuppliers), modelNotifiedForSuppliers, typeof(SuppliersInfo), dbItem);
            bsn.DeleteByID(dbItem, out error);
        }
Пример #7
0
        public void AddData(ModelNotifiedForSuppliers modelNotifiedForSuppliers, out string error)
        {
            SuppliersBsn  bsn    = new SuppliersBsn(wpfConfig);
            SuppliersInfo dbItem = new SuppliersInfo();

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

            ModelNotifiedForSuppliers selectedItem = (ModelNotifiedForSuppliers)DataGridSuppliers.SelectedItem;

            LoadDetail(selectedItem);
        }
Пример #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(ModelNotifiedForSuppliers selectedItem)
        {
            if (selectedItem == null)
            {
                return;
            }


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

/* 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.SupplierID);
 * }
 */
        }
Пример #10
0
        private void OpenFormClick(object sender, RoutedEventArgs e)
        {
            ModelNotifiedForSuppliers itemSelected = (ModelNotifiedForSuppliers)DataGridSuppliers.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.Suppliers.FormWPFSuppliers page = new MyApp.WPFForms.Suppliers.FormWPFSuppliers(config);
            page.LoadForm(itemSelected.SupplierID);
            page.Setup_SetLanguage(CurrentLanguage);
            ContainerWindowSimple win = new ContainerWindowSimple(page, "Form Suppliers");

            win.Show();
        }
Пример #11
0
        private void SaveClick(object sender, RoutedEventArgs e)
        {
            ModelNotifiedForSuppliers itemSelected = (ModelNotifiedForSuppliers)DataGridSuppliers.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(SuppliersDataContext.WPFMessageAndLabelForList.MessageBoxSaveOK);
            }
            else
            {
                //MessageBox.Show(MessageBoxSaveError + error);
                MessageBox.Show(SuppliersDataContext.WPFMessageAndLabelForList.MessageBoxSaveError + error);
            }
        }