private void SaveArrangement_Click(object sender, RoutedEventArgs e)
        {
            MainWindow wnd = Application.Current.MainWindow as MainWindow;

            if (wnd.PageIsOnStack(typeof(WorkOrderPage)))
            {
                if (wnd.PageIsOnStack(typeof(InventoryFilter)))
                {
                    wnd.NavigationStack.Pop();
                }

                //save this arangement to the work order in progress
                IEOStackPage workOrderPage = wnd.GetEOStackPage(typeof(WorkOrderPage));

                if (workOrderPage != null)
                {
                    GetArrangementData();

                    WorkOrderMessage msg = new WorkOrderMessage();
                    msg.Arrangement = currentArrangement;
                    workOrderPage.LoadWorkOrderData(msg);
                }

                wnd.OnBackClick(this);
            }
            else
            {
                //AddArrangement();
            }
        }
        public void OnSave(object sender, EventArgs e)
        {
            MainWindow wnd = Application.Current.MainWindow as MainWindow;

            if (wnd.PageIsOnStack(typeof(WorkOrderPage)))
            {
                //save this arangement to the work order in progress
                IEOStackPage workOrderPage = wnd.GetEOStackPage(typeof(WorkOrderPage));

                if (workOrderPage != null)
                {
                    WorkOrderMessage msg = new WorkOrderMessage();
                    //load the currennt object with data from the form
                    GetArrangementData();
                    msg.Arrangement = currentArrangement;
                    workOrderPage.LoadWorkOrderData(new WorkOrderMessage());
                }

                wnd.OnBackClick(this);
            }
            else
            {
                //AddArrangement();
            }
        }
Exemple #3
0
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            MainWindow wnd = Application.Current.MainWindow as MainWindow;

            if (wnd.PageIsOnStack(typeof(CustomerPage)))
            {
                if (basePage != null)
                {
                    basePage.LoadWorkOrderData(new WorkOrderMessage());
                }

                wnd.OnBackClick(this);
            }
        }
        public ArrangementPage(AddArrangementRequest arrangementRequest)
        {
            InitializeComponent();

            currentArrangement = arrangementRequest;

            GetUsers();

            ObservableCollection <KeyValuePair <long, string> > list2 = new ObservableCollection <KeyValuePair <long, string> >();

            list2.Add(new KeyValuePair <long, string>(0, "180"));
            list2.Add(new KeyValuePair <long, string>(1, "360"));

            Style.ItemsSource = list2;

            containers.Add(new KeyValuePair <long, string>(1, "New container"));

            Container.ItemsSource = containers;

            MainWindow wnd = Application.Current.MainWindow as MainWindow;

            if (wnd.PageIsOnStack(typeof(WorkOrderPage)))
            {
                WorkOrderPage wo = (WorkOrderPage)wnd.GetPageFromStack(typeof(WorkOrderPage));

                if (wo != null)
                {
                    currentArrangement.Arrangement.WorkOrderId = wo.CurrentWorkOrderId;

                    Customer = wo.Customer;

                    if (Customer != null && Customer.person_id != 0)
                    {
                        LoadCustomerContainers(Customer.person_id);
                    }
                }
            }

            ObservableCollection <WorkOrderViewModel> list3 = new ObservableCollection <WorkOrderViewModel>();

            arrangementInventoryList = currentArrangement.ArrangementInventory;
            notInInventory           = currentArrangement.NotInInventory;

            ArrangementInventoryListView.ItemsSource = new ObservableCollection <WorkOrderViewModel>();

            ReloadListData();
        }
        //load the type combo on Init
        void LoadProductTypes()
        {
            ObservableCollection <KeyValuePair <long, string> > list1 = new ObservableCollection <KeyValuePair <long, string> >();

            list1.Add(new KeyValuePair <long, string>(1, "Orchids"));
            list1.Add(new KeyValuePair <long, string>(2, "Containers"));

            MainWindow wnd = Application.Current.MainWindow as MainWindow;

            if (!wnd.PageIsOnStack(typeof(ArrangementPage)))
            {
                list1.Add(new KeyValuePair <long, string>(3, "Arrangements"));
            }

            list1.Add(new KeyValuePair <long, string>(4, "Foliage"));
            list1.Add(new KeyValuePair <long, string>(5, "Materials"));

            ProductType.ItemsSource = list1;
        }
        private async void Pay_Click(object sender, RoutedEventArgs e)
        {
            //send record for payment

            //success? show message - go back to Work Order page

            //failure? show message stay on this page

            Pay.IsEnabled = false;

            bool proceedWithSave = true;

            string ccConfirm = String.Empty;

            if (PaymentTypeComboBox.SelectedIndex == 2)
            {
                CreditCard cc = new CreditCard()
                {
                    Cvc        = CVVTextBox.Text,
                    HolderName = NameOnCardTextBox.Text,
                    Numbers    = CardNumberTextBox.Text,
                    Month      = ExpMonthTextBox.Text,
                    Year       = ExpYearTextBox.Text
                };

                List <string> msgs = cc.VerifyCreditCardInfo();

                if (msgs.Count == 0)
                {
                    PaymentResponse paymentResponse = await PayWithCC(cc);

                    ccConfirm = paymentResponse.ccConfirm;

                    proceedWithSave = paymentResponse.success;

                    if (paymentResponse.Messages.Count > 0)
                    {
                        MessageBox.Show(Application.Current.MainWindow, MessageFormatter(paymentResponse.Messages["Stripe"]), "Error", MessageBoxButton.OK);
                    }
                }
                else
                {
                    proceedWithSave = false;
                    MessageBox.Show("Error", MessageFormatter(msgs), MessageBoxButton.OK);
                }
            }

            if (proceedWithSave)
            {
                bool paymentSaved = await SavePaymentRecord(ccConfirm);

                if (paymentSaved)
                {
                    MessageBox.Show(Application.Current.MainWindow, "Payment Successful", "Success", MessageBoxButton.OK);
                    MainWindow wnd = Application.Current.MainWindow as MainWindow;
                    if (wnd.PageIsOnStack(typeof(WorkOrderPage)))
                    {
                        EOStackPage parentPage = wnd.GetEOStackPage(typeof(WorkOrderPage));

                        if (parentPage != null)
                        {
                            WorkOrderMessage msg = new WorkOrderMessage();
                            msg.WorkOrderPaid = true;
                            parentPage.LoadWorkOrderData(msg);
                        }
                    }

                    wnd.OnBackClick(this);
                }
                else
                {
                    MessageBox.Show(Application.Current.MainWindow, "There was a problem saving the payment record", "Error", MessageBoxButton.OK);
                }
            }

            Pay.IsEnabled = true;
        }