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

            switch (result)
            {
            case MessageBoxResult.Yes:
                ModelNotifiedForOrderDetails itemSelected = (ModelNotifiedForOrderDetails)DataGridOrderDetails.SelectedItem;
                dataConnection.DeleteData(itemSelected, out error);
                if (string.IsNullOrEmpty(error))
                {
                    OrderDetailsDataContext.modelNotifiedForOrderDetailsMain.Remove(itemSelected);
                }
                break;

            case MessageBoxResult.No:
                return;
            }

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



        public List <ModelNotifiedForOrderDetails> GetAllOrderDetails(out string error)
        {
            error = null;
            try
            {
                OrderDetailsBsn                     bsn           = new OrderDetailsBsn(wpfConfig);
                List <OrderDetailsInfo>             dbItems       = bsn.GetAll();
                List <ModelNotifiedForOrderDetails> notifiedItems = new List <ModelNotifiedForOrderDetails>();

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

                return(notifiedItems);
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(null);
        }
示例#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 LoadDetail(ModelNotifiedForOrderDetails selectedItem)
 {
     if (selectedItem == null)
     {
         return;
     }
 }
示例#4
0
        public void DeleteData(ModelNotifiedForOrderDetails modelNotifiedForOrderDetails, out string error)
        {
            OrderDetailsBsn  bsn    = new OrderDetailsBsn(wpfConfig);
            OrderDetailsInfo dbItem = new OrderDetailsInfo();

            Cloner.CopyAllTo(typeof(ModelNotifiedForOrderDetails), modelNotifiedForOrderDetails, typeof(OrderDetailsInfo), dbItem);
            bsn.DeleteByID(dbItem, out error);
        }
示例#5
0
        public void DeleteData(ModelNotifiedForOrderDetails modelNotifiedForOrderDetails, out string error)
        {
            OrderDetailsGenericREST OrderDetailsGenericREST = new OrderDetailsGenericREST(wpfConfig);
            DeleteOrderDetailsView  deleteOrderDetailsView  = new DeleteOrderDetailsView();

            Cloner.CopyAllTo(typeof(ModelNotifiedForOrderDetails), modelNotifiedForOrderDetails, typeof(DeleteOrderDetailsView), deleteOrderDetailsView);
            OrderDetailsGenericREST.Delete(deleteOrderDetailsView, out error);
        }
示例#6
0
        public void AddData(ModelNotifiedForOrderDetails modelNotifiedForOrderDetails, out string error)
        {
            OrderDetailsGenericREST OrderDetailsGenericREST = new OrderDetailsGenericREST(wpfConfig);
            CreateOrderDetailsView  createOrderDetailsView  = new CreateOrderDetailsView();

            Cloner.CopyAllTo(typeof(ModelNotifiedForOrderDetails), modelNotifiedForOrderDetails, typeof(CreateOrderDetailsView), createOrderDetailsView);
            OrderDetailsGenericREST.Insert(createOrderDetailsView, out error);
        }
示例#7
0
        public void SaveData(ModelNotifiedForOrderDetails modelNotifiedForOrderDetails, out string error)
        {
            OrderDetailsGenericREST OrderDetailsGenericREST = new OrderDetailsGenericREST(wpfConfig);
            UpdateOrderDetailsView  updateOrderDetailsView  = new UpdateOrderDetailsView();

            Cloner.CopyAllTo(typeof(ModelNotifiedForOrderDetails), modelNotifiedForOrderDetails, typeof(UpdateOrderDetailsView), updateOrderDetailsView);
            OrderDetailsGenericREST.Update(updateOrderDetailsView, out error);
        }
示例#8
0
        public void AddData(ModelNotifiedForOrderDetails modelNotifiedForOrderDetails, out string error)
        {
            OrderDetailsBsn  bsn    = new OrderDetailsBsn(wpfConfig);
            OrderDetailsInfo dbItem = new OrderDetailsInfo();

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

            ModelNotifiedForOrderDetails selectedItem = (ModelNotifiedForOrderDetails)DataGridOrderDetails.SelectedItem;

            LoadDetail(selectedItem);
        }
示例#10
0
        private void OpenFormClick(object sender, RoutedEventArgs e)
        {
            ModelNotifiedForOrderDetails itemSelected = (ModelNotifiedForOrderDetails)DataGridOrderDetails.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.OrderDetails.FormWPFOrderDetails page = new MyApp.WPFForms.OrderDetails.FormWPFOrderDetails(config);
            page.LoadForm(itemSelected.OrderID, itemSelected.ProductID);
            page.Setup_SetLanguage(CurrentLanguage);
            ContainerWindowSimple win = new ContainerWindowSimple(page, "Form OrderDetails");

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