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

            switch (result)
            {
            case MessageBoxResult.Yes:
                ModelNotifiedForShippers itemSelected = (ModelNotifiedForShippers)DataGridShippers.SelectedItem;
                dataConnection.DeleteData(itemSelected, out error);
                if (string.IsNullOrEmpty(error))
                {
                    ShippersDataContext.modelNotifiedForShippersMain.Remove(itemSelected);
                }
                break;

            case MessageBoxResult.No:
                return;
            }

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



        public List <ModelNotifiedForShippers> GetAllShippers(out string error)
        {
            error = null;
            try
            {
                ShippersBsn                     bsn           = new ShippersBsn(wpfConfig);
                List <ShippersInfo>             dbItems       = bsn.GetAll();
                List <ModelNotifiedForShippers> notifiedItems = new List <ModelNotifiedForShippers>();

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

                return(notifiedItems);
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(null);
        }
示例#3
0
        public void DeleteData(ModelNotifiedForShippers modelNotifiedForShippers, out string error)
        {
            ShippersGenericREST ShippersGenericREST = new ShippersGenericREST(wpfConfig);
            DeleteShippersView  deleteShippersView  = new DeleteShippersView();

            Cloner.CopyAllTo(typeof(ModelNotifiedForShippers), modelNotifiedForShippers, typeof(DeleteShippersView), deleteShippersView);
            ShippersGenericREST.Delete(deleteShippersView, out error);
        }
示例#4
0
        public void AddData(ModelNotifiedForShippers modelNotifiedForShippers, out string error)
        {
            ShippersGenericREST ShippersGenericREST = new ShippersGenericREST(wpfConfig);
            CreateShippersView  createShippersView  = new CreateShippersView();

            Cloner.CopyAllTo(typeof(ModelNotifiedForShippers), modelNotifiedForShippers, typeof(CreateShippersView), createShippersView);
            ShippersGenericREST.Insert(createShippersView, out error);
        }
示例#5
0
        public void SaveData(ModelNotifiedForShippers modelNotifiedForShippers, out string error)
        {
            ShippersGenericREST ShippersGenericREST = new ShippersGenericREST(wpfConfig);
            UpdateShippersView  updateShippersView  = new UpdateShippersView();

            Cloner.CopyAllTo(typeof(ModelNotifiedForShippers), modelNotifiedForShippers, typeof(UpdateShippersView), updateShippersView);
            ShippersGenericREST.Update(updateShippersView, out error);
        }
示例#6
0
        public void DeleteData(ModelNotifiedForShippers modelNotifiedForShippers, out string error)
        {
            ShippersBsn  bsn    = new ShippersBsn(wpfConfig);
            ShippersInfo dbItem = new ShippersInfo();

            Cloner.CopyAllTo(typeof(ModelNotifiedForShippers), modelNotifiedForShippers, typeof(ShippersInfo), dbItem);
            bsn.DeleteByID(dbItem, out error);
        }
示例#7
0
        public void AddData(ModelNotifiedForShippers modelNotifiedForShippers, out string error)
        {
            ShippersBsn  bsn    = new ShippersBsn(wpfConfig);
            ShippersInfo dbItem = new ShippersInfo();

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

            ModelNotifiedForShippers selectedItem = (ModelNotifiedForShippers)DataGridShippers.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(ModelNotifiedForShippers selectedItem)
        {
            if (selectedItem == null)
            {
                return;
            }


            if (DetailListOrders != null)
            {
                DetailListOrders.LoadGrid(x => x.ShipVia == selectedItem.ShipperID);
            }

/* Note: the detail form can load only ONE row from 'Orders'. It's necessary to inform DetailForm primary key here or create a custom Form.Load().
 * if (DetailForm{0} != null)
 * {
 * //DetailFormOrders.LoadForm(selectedItem.ShipperID);
 * }
 */
        }
示例#10
0
        private void OpenFormClick(object sender, RoutedEventArgs e)
        {
            ModelNotifiedForShippers itemSelected = (ModelNotifiedForShippers)DataGridShippers.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.Shippers.FormWPFShippers page = new MyApp.WPFForms.Shippers.FormWPFShippers(config);
            page.LoadForm(itemSelected.ShipperID);
            page.Setup_SetLanguage(CurrentLanguage);
            ContainerWindowSimple win = new ContainerWindowSimple(page, "Form Shippers");

            win.Show();
        }
示例#11
0
        private void SaveClick(object sender, RoutedEventArgs e)
        {
            ModelNotifiedForShippers itemSelected = (ModelNotifiedForShippers)DataGridShippers.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(ShippersDataContext.WPFMessageAndLabelForList.MessageBoxSaveOK);
            }
            else
            {
                //MessageBox.Show(MessageBoxSaveError + error);
                MessageBox.Show(ShippersDataContext.WPFMessageAndLabelForList.MessageBoxSaveError + error);
            }
        }