Example #1
0
        //private void CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        //{
        //Notify("IncludeFolders");
        //}



        public List <ModelNotifiedForEmployeeTerritories> GetAllEmployeeTerritories(out string error)
        {
            error = null;
            try
            {
                EmployeeTerritoriesBsn                     bsn           = new EmployeeTerritoriesBsn(wpfConfig);
                List <EmployeeTerritoriesInfo>             dbItems       = bsn.GetAll();
                List <ModelNotifiedForEmployeeTerritories> notifiedItems = new List <ModelNotifiedForEmployeeTerritories>();

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

                return(notifiedItems);
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(null);
        }
Example #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(EmployeeTerritoriesDataContext.WPFMessageAndLabelForList.MessageBoxDeleteConfirm,
                                                      EmployeeTerritoriesDataContext.WPFMessageAndLabelForList.MessageBoxDeleteConfirmCaption, button, icon);
            string error = null;

            switch (result)
            {
            case MessageBoxResult.Yes:
                ModelNotifiedForEmployeeTerritories itemSelected = (ModelNotifiedForEmployeeTerritories)DataGridEmployeeTerritories.SelectedItem;
                dataConnection.DeleteData(itemSelected, out error);
                if (string.IsNullOrEmpty(error))
                {
                    EmployeeTerritoriesDataContext.modelNotifiedForEmployeeTerritoriesMain.Remove(itemSelected);
                }
                break;

            case MessageBoxResult.No:
                return;
            }

            if (error != null)
            {
                MessageBox.Show(error);
            }
            else
            {
                //MessageBox.Show(MessageBoxDeleteOK);
                MessageBox.Show(EmployeeTerritoriesDataContext.WPFMessageAndLabelForList.MessageBoxDeleteOK);
                btnReload_Click(null, null);
            }
        }
Example #3
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 xLoadDetail(ModelNotifiedForEmployeeTerritories selectedItem)
 {
     if (selectedItem == null)
     {
         return;
     }
 }
Example #4
0
        public void DeleteData(ModelNotifiedForEmployeeTerritories modelNotifiedForEmployeeTerritories, out string error)
        {
            EmployeeTerritoriesGenericREST EmployeeTerritoriesGenericREST = new EmployeeTerritoriesGenericREST(wpfConfig);
            DeleteEmployeeTerritoriesView  deleteEmployeeTerritoriesView  = new DeleteEmployeeTerritoriesView();

            Cloner.CopyAllTo(typeof(ModelNotifiedForEmployeeTerritories), modelNotifiedForEmployeeTerritories, typeof(DeleteEmployeeTerritoriesView), deleteEmployeeTerritoriesView);
            EmployeeTerritoriesGenericREST.Delete(deleteEmployeeTerritoriesView, out error);
        }
Example #5
0
        public void AddData(ModelNotifiedForEmployeeTerritories modelNotifiedForEmployeeTerritories, out string error)
        {
            EmployeeTerritoriesGenericREST EmployeeTerritoriesGenericREST = new EmployeeTerritoriesGenericREST(wpfConfig);
            CreateEmployeeTerritoriesView  createEmployeeTerritoriesView  = new CreateEmployeeTerritoriesView();

            Cloner.CopyAllTo(typeof(ModelNotifiedForEmployeeTerritories), modelNotifiedForEmployeeTerritories, typeof(CreateEmployeeTerritoriesView), createEmployeeTerritoriesView);
            EmployeeTerritoriesGenericREST.Insert(createEmployeeTerritoriesView, out error);
        }
Example #6
0
        public void SaveData(ModelNotifiedForEmployeeTerritories modelNotifiedForEmployeeTerritories, out string error)
        {
            EmployeeTerritoriesGenericREST EmployeeTerritoriesGenericREST = new EmployeeTerritoriesGenericREST(wpfConfig);
            UpdateEmployeeTerritoriesView  updateEmployeeTerritoriesView  = new UpdateEmployeeTerritoriesView();

            Cloner.CopyAllTo(typeof(ModelNotifiedForEmployeeTerritories), modelNotifiedForEmployeeTerritories, typeof(UpdateEmployeeTerritoriesView), updateEmployeeTerritoriesView);
            EmployeeTerritoriesGenericREST.Update(updateEmployeeTerritoriesView, out error);
        }
Example #7
0
        public void DeleteData(ModelNotifiedForEmployeeTerritories modelNotifiedForEmployeeTerritories, out string error)
        {
            EmployeeTerritoriesBsn  bsn    = new EmployeeTerritoriesBsn(wpfConfig);
            EmployeeTerritoriesInfo dbItem = new EmployeeTerritoriesInfo();

            Cloner.CopyAllTo(typeof(ModelNotifiedForEmployeeTerritories), modelNotifiedForEmployeeTerritories, typeof(EmployeeTerritoriesInfo), dbItem);
            bsn.DeleteByID(dbItem, out error);
        }
Example #8
0
        public void AddData(ModelNotifiedForEmployeeTerritories modelNotifiedForEmployeeTerritories, out string error)
        {
            EmployeeTerritoriesBsn  bsn    = new EmployeeTerritoriesBsn(wpfConfig);
            EmployeeTerritoriesInfo dbItem = new EmployeeTerritoriesInfo();

            Cloner.CopyAllTo(typeof(ModelNotifiedForEmployeeTerritories), modelNotifiedForEmployeeTerritories, typeof(EmployeeTerritoriesInfo), dbItem);
            bsn.InsertOne(dbItem, out error);
            modelNotifiedForEmployeeTerritories.NewItem = false;
            Cloner.CopyAllTo(typeof(EmployeeTerritoriesInfo), dbItem, typeof(ModelNotifiedForEmployeeTerritories), modelNotifiedForEmployeeTerritories);
        }
Example #9
0
        private void LoadDetail(ModelNotifiedForEmployeeTerritories selectedItem)
        {
            if (selectedItem == null)
            {
                return;
            }

            if (DetailListTerritories != null)
            {
                DetailListTerritories.LoadGrid(x => x.TerritoryID == selectedItem.TerritoryID);
            }
        }
Example #10
0
        /// <summary>
        /// Triggered by change in grid's row.
        /// </summary>
        private void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if ((DataGridEmployeeTerritories.SelectedItem == null) || DataGridEmployeeTerritories.SelectedItem.GetType() != typeof(ModelNotifiedForEmployeeTerritories))
            {
                //New row on grid's bottom. By default do nothing when new row is included
                return;
            }

            ModelNotifiedForEmployeeTerritories selectedItem = (ModelNotifiedForEmployeeTerritories)DataGridEmployeeTerritories.SelectedItem;

            LoadDetail(selectedItem);
        }
Example #11
0
        private void OpenFormClick(object sender, RoutedEventArgs e)
        {
            ModelNotifiedForEmployeeTerritories itemSelected = (ModelNotifiedForEmployeeTerritories)DataGridEmployeeTerritories.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.EmployeeTerritories.FormWPFEmployeeTerritories page = new MyApp.WPFForms.EmployeeTerritories.FormWPFEmployeeTerritories(config);
            page.LoadForm(itemSelected.EmployeeID, itemSelected.TerritoryID);
            page.Setup_SetLanguage(CurrentLanguage);
            ContainerWindowSimple win = new ContainerWindowSimple(page, "Form EmployeeTerritories");

            win.Show();
        }
Example #12
0
        private void SaveClick(object sender, RoutedEventArgs e)
        {
            ModelNotifiedForEmployeeTerritories itemSelected = (ModelNotifiedForEmployeeTerritories)DataGridEmployeeTerritories.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(EmployeeTerritoriesDataContext.WPFMessageAndLabelForList.MessageBoxSaveOK);
            }
            else
            {
                //MessageBox.Show(MessageBoxSaveError + error);
                MessageBox.Show(EmployeeTerritoriesDataContext.WPFMessageAndLabelForList.MessageBoxSaveError + error);
            }
        }