Ejemplo n.º 1
0
        //private void CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        //{
        //Notify("IncludeFolders");
        //}



        public List <ModelNotifiedForOrders> GetAllOrders(out string error)
        {
            error = null;
            try
            {
                OrdersBsn                     bsn           = new OrdersBsn(wpfConfig);
                List <OrdersInfo>             dbItems       = bsn.GetAll();
                List <ModelNotifiedForOrders> notifiedItems = new List <ModelNotifiedForOrders>();

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

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

            switch (result)
            {
            case MessageBoxResult.Yes:
                ModelNotifiedForOrders itemSelected = (ModelNotifiedForOrders)DataGridOrders.SelectedItem;
                dataConnection.DeleteData(itemSelected, out error);
                if (string.IsNullOrEmpty(error))
                {
                    OrdersDataContext.modelNotifiedForOrdersMain.Remove(itemSelected);
                }
                break;

            case MessageBoxResult.No:
                return;
            }

            if (error != null)
            {
                MessageBox.Show(error);
            }
            else
            {
                //MessageBox.Show(MessageBoxDeleteOK);
                MessageBox.Show(OrdersDataContext.WPFMessageAndLabelForList.MessageBoxDeleteOK);
                btnReload_Click(null, null);
            }
        }
Ejemplo n.º 3
0
        public void DeleteData(ModelNotifiedForOrders modelNotifiedForOrders, out string error)
        {
            OrdersGenericREST OrdersGenericREST = new OrdersGenericREST(wpfConfig);
            DeleteOrdersView  deleteOrdersView  = new DeleteOrdersView();

            Cloner.CopyAllTo(typeof(ModelNotifiedForOrders), modelNotifiedForOrders, typeof(DeleteOrdersView), deleteOrdersView);
            OrdersGenericREST.Delete(deleteOrdersView, out error);
        }
Ejemplo n.º 4
0
        public void AddData(ModelNotifiedForOrders modelNotifiedForOrders, out string error)
        {
            OrdersGenericREST OrdersGenericREST = new OrdersGenericREST(wpfConfig);
            CreateOrdersView  createOrdersView  = new CreateOrdersView();

            Cloner.CopyAllTo(typeof(ModelNotifiedForOrders), modelNotifiedForOrders, typeof(CreateOrdersView), createOrdersView);
            OrdersGenericREST.Insert(createOrdersView, out error);
        }
Ejemplo n.º 5
0
        public void SaveData(ModelNotifiedForOrders modelNotifiedForOrders, out string error)
        {
            OrdersGenericREST OrdersGenericREST = new OrdersGenericREST(wpfConfig);
            UpdateOrdersView  updateOrdersView  = new UpdateOrdersView();

            Cloner.CopyAllTo(typeof(ModelNotifiedForOrders), modelNotifiedForOrders, typeof(UpdateOrdersView), updateOrdersView);
            OrdersGenericREST.Update(updateOrdersView, out error);
        }
Ejemplo n.º 6
0
        public void DeleteData(ModelNotifiedForOrders modelNotifiedForOrders, out string error)
        {
            OrdersBsn  bsn    = new OrdersBsn(wpfConfig);
            OrdersInfo dbItem = new OrdersInfo();

            Cloner.CopyAllTo(typeof(ModelNotifiedForOrders), modelNotifiedForOrders, typeof(OrdersInfo), dbItem);
            bsn.DeleteByID(dbItem, out error);
        }
Ejemplo n.º 7
0
        public void AddData(ModelNotifiedForOrders modelNotifiedForOrders, out string error)
        {
            OrdersBsn  bsn    = new OrdersBsn(wpfConfig);
            OrdersInfo dbItem = new OrdersInfo();

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

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


            if (DetailListOrderDetails != null)
            {
                DetailListOrderDetails.LoadGrid(x => x.OrderID == selectedItem.OrderID);
            }

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

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