Ejemplo n.º 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(RegionDataContext.WPFMessageAndLabelForList.MessageBoxDeleteConfirm,
                                                      RegionDataContext.WPFMessageAndLabelForList.MessageBoxDeleteConfirmCaption, button, icon);
            string error = null;

            switch (result)
            {
            case MessageBoxResult.Yes:
                ModelNotifiedForRegion itemSelected = (ModelNotifiedForRegion)DataGridRegion.SelectedItem;
                dataConnection.DeleteData(itemSelected, out error);
                if (string.IsNullOrEmpty(error))
                {
                    RegionDataContext.modelNotifiedForRegionMain.Remove(itemSelected);
                }
                break;

            case MessageBoxResult.No:
                return;
            }

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



        public List <ModelNotifiedForRegion> GetAllRegion(out string error)
        {
            error = null;
            try
            {
                RegionBsn                     bsn           = new RegionBsn(wpfConfig);
                List <RegionInfo>             dbItems       = bsn.GetAll();
                List <ModelNotifiedForRegion> notifiedItems = new List <ModelNotifiedForRegion>();

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

                return(notifiedItems);
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(null);
        }
Ejemplo n.º 3
0
        public void DeleteData(ModelNotifiedForRegion modelNotifiedForRegion, out string error)
        {
            RegionBsn  bsn    = new RegionBsn(wpfConfig);
            RegionInfo dbItem = new RegionInfo();

            Cloner.CopyAllTo(typeof(ModelNotifiedForRegion), modelNotifiedForRegion, typeof(RegionInfo), dbItem);
            bsn.DeleteByID(dbItem, out error);
        }
Ejemplo n.º 4
0
        public void DeleteData(ModelNotifiedForRegion modelNotifiedForRegion, out string error)
        {
            RegionGenericREST RegionGenericREST = new RegionGenericREST(wpfConfig);
            DeleteRegionView  deleteRegionView  = new DeleteRegionView();

            Cloner.CopyAllTo(typeof(ModelNotifiedForRegion), modelNotifiedForRegion, typeof(DeleteRegionView), deleteRegionView);
            RegionGenericREST.Delete(deleteRegionView, out error);
        }
Ejemplo n.º 5
0
        public void AddData(ModelNotifiedForRegion modelNotifiedForRegion, out string error)
        {
            RegionGenericREST RegionGenericREST = new RegionGenericREST(wpfConfig);
            CreateRegionView  createRegionView  = new CreateRegionView();

            Cloner.CopyAllTo(typeof(ModelNotifiedForRegion), modelNotifiedForRegion, typeof(CreateRegionView), createRegionView);
            RegionGenericREST.Insert(createRegionView, out error);
        }
Ejemplo n.º 6
0
        public void SaveData(ModelNotifiedForRegion modelNotifiedForRegion, out string error)
        {
            RegionGenericREST RegionGenericREST = new RegionGenericREST(wpfConfig);
            UpdateRegionView  updateRegionView  = new UpdateRegionView();

            Cloner.CopyAllTo(typeof(ModelNotifiedForRegion), modelNotifiedForRegion, typeof(UpdateRegionView), updateRegionView);
            RegionGenericREST.Update(updateRegionView, out error);
        }
Ejemplo n.º 7
0
        public void AddData(ModelNotifiedForRegion modelNotifiedForRegion, out string error)
        {
            RegionBsn  bsn    = new RegionBsn(wpfConfig);
            RegionInfo dbItem = new RegionInfo();

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

            ModelNotifiedForRegion selectedItem = (ModelNotifiedForRegion)DataGridRegion.SelectedItem;

            LoadDetail(selectedItem);
        }
Ejemplo n.º 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(ModelNotifiedForRegion selectedItem)
        {
            if (selectedItem == null)
            {
                return;
            }


            if (DetailListTerritories != null)
            {
                DetailListTerritories.LoadGrid(x => x.RegionID == selectedItem.RegionID);
            }

/* Note: the detail form can load only ONE row from 'Territories'. It's necessary to inform DetailForm primary key here or create a custom Form.Load().
 * if (DetailForm{0} != null)
 * {
 * //DetailFormTerritories.LoadForm(selectedItem.RegionID);
 * }
 */
        }
Ejemplo n.º 10
0
        private void OpenFormClick(object sender, RoutedEventArgs e)
        {
            ModelNotifiedForRegion itemSelected = (ModelNotifiedForRegion)DataGridRegion.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.Region.FormWPFRegion page = new MyApp.WPFForms.Region.FormWPFRegion(config);
            page.LoadForm(itemSelected.RegionID);
            page.Setup_SetLanguage(CurrentLanguage);
            ContainerWindowSimple win = new ContainerWindowSimple(page, "Form Region");

            win.Show();
        }
Ejemplo n.º 11
0
        private void SaveClick(object sender, RoutedEventArgs e)
        {
            ModelNotifiedForRegion itemSelected = (ModelNotifiedForRegion)DataGridRegion.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(RegionDataContext.WPFMessageAndLabelForList.MessageBoxSaveOK);
            }
            else
            {
                //MessageBox.Show(MessageBoxSaveError + error);
                MessageBox.Show(RegionDataContext.WPFMessageAndLabelForList.MessageBoxSaveError + error);
            }
        }