private async void PaymentDetail_Clicked(object sender, EventArgs e)
        {
            Button b = sender as Button;

            if (b != null)
            {
                try
                {
                    WorkOrderResponse workOrder = (WorkOrderResponse)b.CommandParameter;

                    if (workOrder != null)
                    {
                        if (!PageExists(typeof(PaymentPage)))
                        {
                            WorkOrderPaymentDTO payment = await((App)App.Current).GetWorkOrderPayment(workOrder.WorkOrder.WorkOrderId);

                            if (payment.WorkOrderPaymentId > 0)
                            {
                                Navigation.PushAsync(new PaymentPage(workOrder, payment));
                            }
                            else
                            {
                                DisplayAlert("Unpaid", "This work order has not been paid.", "Ok");
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }
Exemplo n.º 2
0
        public ApiResponse AddWorkOrderPayment(WorkOrderPaymentDTO workOrderPayment)
        {
            ApiResponse response = new ApiResponse();

            response.Id = inventoryManager.AddWorkOrderPayment(workOrderPayment);
            return(response);
        }
Exemplo n.º 3
0
        private async void EmailReceipt(WorkOrderPaymentDTO workOrderPayment)
        {
            try
            {
                if (Customer.Person.person_id > 0)
                {
                    EmailHelpers emailHelper = new EmailHelpers();

                    EOMailMessage mailMessage = new EOMailMessage();

                    string emailHtml = String.Empty;

                    if (!String.IsNullOrEmpty(Customer.Person.email))
                    {
                        GenericGetRequest         request         = new GenericGetRequest("GetWorkOrderPrices", "workOrderId", workOrderPayment.WorkOrderId);
                        GetWorkOrderPriceResponse workOrderPrices = await((App)App.Current).GetRequest <GetWorkOrderPriceResponse>(request);

                        emailHtml = emailHelper.ComposeReceipt(currentWorkOrder, workOrderPayment, workOrderPrices);

                        mailMessage = new EOMailMessage("*****@*****.**", Customer.Person.email, "Elegant Orchids Receipt", emailHtml, "Orchids@5185");
                    }
                    else //let EO know the customer needs to add an email address
                    {
                        emailHtml = emailHelper.ComposeMissingEmail(Customer);

                        mailMessage = new EOMailMessage("*****@*****.**", "*****@*****.**", "Missing Customer Email", emailHtml, "Orchids@5185");
                    }

                    Email.SendEmail(mailMessage);
                }
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 4
0
        public async Task <WorkOrderPaymentDTO> GetWorkOrderPayment(long workOrderId)
        {
            GenericGetRequest   request  = new GenericGetRequest("GetWorkOrderPayment", "workOrderId", workOrderId);
            WorkOrderPaymentDTO response = await GetRequest <WorkOrderPaymentDTO>(request);

            return(response);
        }
Exemplo n.º 5
0
        private WorkOrderPaymentDTO GetWorkOrderPaymentDTO()
        {
            WorkOrderPaymentDTO workOrderPayment = new WorkOrderPaymentDTO();
            decimal             workValue        = 0;

            workOrderPayment.WorkOrderId = workOrderId;
            decimal.TryParse(Total.Text, NumberStyles.Currency, CultureInfo.CurrentCulture.NumberFormat, out workValue);
            workOrderPayment.WorkOrderPaymentAmount = workValue;
            workValue = 0;
            workOrderPayment.WorkOrderPaymentType = (int)payTypeList[PaymentType.SelectedIndex].Key;
            workOrderPayment.WorkOrderPaymentCreditCardConfirmation = ccConfirm;
            decimal.TryParse(Tax.Text, NumberStyles.Currency, CultureInfo.CurrentCulture.NumberFormat, out workValue);
            workOrderPayment.WorkOrderPaymentTax = workValue;
            workOrderPayment.DiscountType        = DiscountType.SelectedIndex;

            if (workOrderPayment.DiscountType > 0)
            {
                workValue = 0;
                decimal.TryParse(DiscountAmount.Text, out workValue);
                workOrderPayment.DiscountAmount = workValue;
            }

            workValue = 0;
            decimal.TryParse(GiftCardAmount.Text, out workValue);

            if (workValue > 0)
            {
                workOrderPayment.GiftCardAmount = workValue;
                workOrderPayment.GiftCardNumber = GiftCardNumber.Text;
            }

            return(workOrderPayment);
        }
Exemplo n.º 6
0
        private void WorkOrderPricesLoaded(WorkOrderResponse workOrder, WorkOrderPaymentDTO payment, GetWorkOrderPriceResponse workOrderPriceResponse)
        {
            EmailHelpers emailHelper = new EmailHelpers();

            EOMailMessage mailMessage = new EOMailMessage();

            string emailHtml = emailHelper.ComposeReceipt(workOrder, payment, workOrderPriceResponse);

            mailMessage = new EOMailMessage("*****@*****.**", buyer[0].Person.email, "Elegant Orchids Receipt", emailHtml, "Orchids@5185");

            Email.SendEmail(mailMessage);
        }
Exemplo n.º 7
0
        private async Task <bool> SavePaymentRecord(string ccConfirm)
        {
            WorkOrderPaymentDTO workOrderPayment = GetWorkOrderPaymentDTO(ccConfirm);

            ApiResponse response = await((App)App.Current).PostRequest <WorkOrderPaymentDTO, ApiResponse>("AddWorkOrderPayment", workOrderPayment);

            if (response.Success)
            {
                EmailReceipt(workOrderPayment);
            }

            return(response.Success);
        }
Exemplo n.º 8
0
        private void SetPaymentData(WorkOrderPaymentDTO payment)
        {
            Pay.IsEnabled = false;

            PaymentType.SelectedIndex = payment.WorkOrderPaymentType;
            PaymentType.IsEnabled     = false;

            CCFrame.IsVisible = false;

            if (payment.WorkOrderPaymentType == 2)
            {
                ccConfirmLabel.IsVisible = true;
                ccConfirmPaid.IsVisible  = true;
                ccConfirmPaid.Text       = payment.WorkOrderPaymentCreditCardConfirmation;
            }

            DiscountType.SelectedIndex = payment.DiscountType;
            DiscountType.IsEnabled     = false;

            DiscountAmount.IsEnabled = false;

            if (payment.DiscountType > 0)
            {
                DiscountAmount.Text = payment.DiscountAmount.ToString("N2");
            }

            if (!String.IsNullOrEmpty(payment.GiftCardNumber))
            {
                GiftCardNumber.Text      = payment.GiftCardNumber;
                GiftCardNumber.IsEnabled = false;
            }


            if (payment.GiftCardAmount > 0)
            {
                GiftCard.IsChecked = true;
                GiftCard_PropertyChanged(GiftCard, null);
                GiftCard.IsEnabled       = false;
                GiftCardAmount.Text      = payment.GiftCardAmount.ToString("N2");
                GiftCardAmount.IsEnabled = false;
            }

            SubTotal.Text      = "";
            SubTotal.IsEnabled = false;

            Tax.Text      = payment.WorkOrderPaymentTax.ToString("N2");
            Tax.IsEnabled = false;

            Total.Text      = payment.WorkOrderPaymentAmount.ToString("N2");
            Total.IsEnabled = false;
        }
Exemplo n.º 9
0
        void SetWorkOrderDetail(WorkOrderPaymentDTO payment)
        {
            Pay.IsEnabled = false;

            PaymentTypeComboBox.SelectedIndex = payment.WorkOrderPaymentType;
            PaymentTypeComboBox.IsEnabled     = false;

            if (payment.WorkOrderPaymentType == 2)
            {
                ccConfirmLabel.Visibility   = Visibility.Visible;
                ccConfirmTextBox.Visibility = Visibility.Visible;
                ccConfirmTextBox.Text       = payment.WorkOrderPaymentCreditCardConfirmation;
                CCGrid.Visibility           = Visibility.Hidden;
            }

            DiscountTypeComboBox.SelectedIndex = payment.DiscountType;
            DiscountTypeComboBox.IsEnabled     = false;

            DiscountAmountTextBox.IsEnabled = false;

            if (payment.DiscountType > 0)
            {
                DiscountAmountTextBox.Text = payment.DiscountAmount.ToString("N2");
            }

            if (!String.IsNullOrEmpty(payment.GiftCardNumber))
            {
                GiftCardNumberTextBox.Text      = payment.GiftCardNumber;
                GiftCardNumberTextBox.IsEnabled = false;
            }


            if (payment.GiftCardAmount > 0)
            {
                GiftCardCheckBox.IsChecked = true;
                GiftCardCheckBox_Click(GiftCardCheckBox, new RoutedEventArgs());
                GiftCardCheckBox.IsEnabled      = false;
                GiftCardAmountTextBox.Text      = payment.GiftCardAmount.ToString("N2");
                GiftCardAmountTextBox.IsEnabled = false;
            }

            SubTotalTextBox.Text = "";

            TaxTextBox.Text = payment.WorkOrderPaymentTax.ToString("N2");

            TotalTextBox.Text = payment.WorkOrderPaymentAmount.ToString("N2");
        }
        private async void PaymentDetail_Click(object sender, RoutedEventArgs e)
        {
            //if paid - load payment page with detail
            Button b = sender as Button;

            if (b != null)
            {
                WorkOrderResponse workOrder = (WorkOrderResponse)b.CommandParameter;
                if (workOrder != null && workOrder.WorkOrder != null && workOrder.WorkOrder.WorkOrderId > 0)
                {
                    GenericGetRequest   request = new GenericGetRequest("GetWorkOrderPayment", "workOrderId", workOrder.WorkOrder.WorkOrderId);
                    WorkOrderPaymentDTO payment = await((App)App.Current).GetRequest <WorkOrderPaymentDTO>(request);

                    PaymentDetailLoaded(payment, workOrder);
                }
            }
        }
Exemplo n.º 11
0
        private async Task <bool> SavePaymentRecord(string ccConfirm)
        {
            bool success = false;

            WorkOrderPaymentDTO workOrderPayment = GetWorkOrderPaymentDTO();

            workOrderPayment.WorkOrderPaymentCreditCardConfirmation = ccConfirm;

            workOrderPaymentId = ((App)App.Current).AddWorkOrderPayment(workOrderPayment);

            if (workOrderPaymentId > 0)
            {
                MarkWorkOrderPaidRequest request = new MarkWorkOrderPaidRequest(workOrderPayment.WorkOrderId);

                success = ((App)App.Current).MarkWorkOrderPaid(request);
            }

            return(success);
        }
 void PaymentDetailLoaded(WorkOrderPaymentDTO payment, WorkOrderResponse workOrder)
 {
     Dispatcher.Invoke(() =>
     {
         if (payment != null && payment.WorkOrderPaymentId > 0)
         {
             MainWindow wnd          = Application.Current.MainWindow as MainWindow;
             PaymentPage paymentPage = new PaymentPage(workOrder, payment);
             wnd.NavigationStack.Push(paymentPage);
             wnd.MainContent.Content = new Frame()
             {
                 Content = paymentPage
             };
         }
         else
         {
             MessageBox.Show(Application.Current.MainWindow, "Work Order has not been paid.", "OK", MessageBoxButton.OK);
         }
     });
 }
Exemplo n.º 13
0
        private WorkOrderPaymentDTO GetWorkOrderPaymentDTO(string ccConfirm)
        {
            WorkOrderPaymentDTO workOrderPayment = new WorkOrderPaymentDTO();
            decimal             workValue        = 0;

            workOrderPayment.WorkOrderId = currentWorkOrder.WorkOrder.WorkOrderId;
            decimal.TryParse(TotalTextBox.Text, NumberStyles.Currency, CultureInfo.CurrentCulture.NumberFormat, out workValue);
            workOrderPayment.WorkOrderPaymentAmount = workValue;
            workValue = 0;
            workOrderPayment.WorkOrderPaymentType = PaymentTypeComboBox.SelectedIndex;
            workOrderPayment.WorkOrderPaymentCreditCardConfirmation = ccConfirm;
            decimal.TryParse(TaxTextBox.Text, NumberStyles.Currency, CultureInfo.CurrentCulture.NumberFormat, out workValue);
            workOrderPayment.WorkOrderPaymentTax = workValue;
            workOrderPayment.DiscountType        = DiscountTypeComboBox.SelectedIndex;

            if (workOrderPayment.DiscountType > 0)
            {
                workValue = 0;
                decimal.TryParse(DiscountAmountTextBox.Text, out workValue);
                workOrderPayment.DiscountAmount = workValue;
            }

            if (!String.IsNullOrEmpty(GiftCardNumberTextBox.Text))
            {
                workOrderPayment.GiftCardNumber = GiftCardNumberTextBox.Text;
            }

            if (!string.IsNullOrEmpty(GiftCardAmountTextBox.Text))
            {
                workValue = 0;
                decimal.TryParse(GiftCardAmountTextBox.Text, out workValue);
                workOrderPayment.GiftCardAmount = workValue;
            }

            return(workOrderPayment);
        }
Exemplo n.º 14
0
        public long AddWorkOrderPayment(WorkOrderPaymentDTO request)
        {
            long newWorkOrderPaymentId = 0;

            try
            {
                HttpClient client = new HttpClient();
                client.BaseAddress = new Uri(LAN_Address);
                //client.DefaultRequestHeaders.Add("appkey", "myapp_key");
                client.DefaultRequestHeaders.Accept.Add(
                    new MediaTypeWithQualityHeaderValue("application/json"));

                client.DefaultRequestHeaders.Add("EO-Header", User + " : " + Pwd);

                string jsonData = JsonConvert.SerializeObject(request);
                var    content  = new StringContent(jsonData, Encoding.UTF8, "application/json");
                HttpResponseMessage httpResponse = client.PostAsync("api/Login/AddWorkOrderPayment", content).Result;
                if (httpResponse.IsSuccessStatusCode)
                {
                    string      strData  = httpResponse.Content.ReadAsStringAsync().Result;
                    ApiResponse response = JsonConvert.DeserializeObject <ApiResponse>(strData);
                    newWorkOrderPaymentId = response.Id;
                }
                else
                {
                    //MessageBox.Show("Error adding Work Order");
                }
            }
            catch (Exception ex)
            {
                Exception ex2 = new Exception("AddWorkOrderPayment", ex);
                LogError(ex2.Message, JsonConvert.SerializeObject(request));
            }

            return(newWorkOrderPaymentId);
        }
Exemplo n.º 15
0
 public PaymentPage(WorkOrderResponse workOrder, WorkOrderPaymentDTO payment) : this()
 {
     SetPaymentData(payment);
 }
Exemplo n.º 16
0
        public CCPaymentPage(WorkOrderPaymentDTO workOrderPayment)
        {
            InitializeComponent();

            this.workOrderPayment = workOrderPayment;
        }
Exemplo n.º 17
0
        //Load and possibly convert data into relevant data lists
        private void WorkOrderPaymentLoaded(WorkOrderResponse workOrder, WorkOrderPaymentDTO payment)
        {
            Device.BeginInvokeOnMainThread(() =>
            {
                currentWorkOrderId = workOrder.WorkOrder.WorkOrderId;

                searchedForPerson = new PersonAndAddressDTO();
                searchedForPerson.Person.person_id = workOrder.WorkOrder.CustomerId;
                customerId = searchedForPerson.Person.person_id;

                currentWorkOrderPaymentId = payment.WorkOrderPaymentId;

                if (currentWorkOrderPaymentId == 0)
                {
                    Save.IsEnabled    = true;
                    Payment.IsEnabled = true;
                }
                else
                {
                    if (workOrder.WorkOrder.Paid)
                    {
                        InventoryItemsListView.IsEnabled = false;
                        Save.IsEnabled         = false;
                        Payment.IsEnabled      = false;
                        AddInventory.IsEnabled = false;
                    }
                    else
                    {
                        Save.IsEnabled = true;
                        if (workOrder.WorkOrderList.Count == 0)
                        {
                            Payment.IsEnabled = false;
                        }
                        else
                        {
                            Payment.IsEnabled = true;
                        }
                    }
                }

                Buyer.Text = workOrder.WorkOrder.Buyer;

                sellerId             = workOrder.WorkOrder.SellerId;
                Seller.SelectedIndex = ((App)App.Current).GetPickerIndex(Seller, workOrder.WorkOrder.SellerId);

                DeliveryType.SelectedIndex = workOrder.WorkOrder.DeliveryType;

                deliveryUserId = workOrder.WorkOrder.DeliveryUserId;
                DeliveryPerson.SelectedIndex = ((App)App.Current).GetPickerIndex(DeliveryPerson, workOrder.WorkOrder.DeliveryUserId);

                DeliveryDate.Date = workOrder.WorkOrder.DeliveryDate;

                deliveryRecipientId = workOrder.WorkOrder.DeliveryRecipientId;

                DeliverTo.Text = workOrder.WorkOrder.DeliverTo;

                WorkOrderDate.Date = workOrder.WorkOrder.CreateDate;

                workOrderList.Clear();

                notInInventory = workOrder.NotInInventory;

                //convert between duplicate types - refactor
                foreach (var x in workOrder.WorkOrderList)
                {
                    WorkOrderInventoryItemDTO dto =
                        new WorkOrderInventoryItemDTO()
                    {
                        WorkOrderId   = x.WorkOrderId,
                        InventoryId   = x.InventoryId,
                        InventoryName = x.InventoryName,
                        Quantity      = x.Quantity,
                        Size          = x.Size,
                        GroupId       = x.GroupId
                    };

                    workOrderInventoryList.Add(dto);
                }

                foreach (GetArrangementResponse ar in workOrder.Arrangements)
                {
                    AddArrangementRequest aaReq = new AddArrangementRequest();

                    aaReq.Arrangement          = ar.Arrangement;
                    aaReq.Inventory            = ar.Inventory;
                    aaReq.ArrangementInventory = ar.ArrangementList;
                    aaReq.GroupId        = ar.Arrangement.ArrangementId;
                    aaReq.NotInInventory = ar.NotInInventory;

                    arrangementList.Add(aaReq);
                }

                RedrawInventoryList();
            });
        }
Exemplo n.º 18
0
 public PaymentPage(WorkOrderResponse workOrder, WorkOrderPaymentDTO payment) : this()
 {
     currentWorkOrder = workOrder;
     Customer.Person  = new PersonDTO();
     SetWorkOrderDetail(payment);
 }
Exemplo n.º 19
0
        private async void WorkOrderPaymentLoaded(WorkOrderPaymentDTO payment)
        {
            GenericGetRequest request = new GenericGetRequest("GetWorkOrderPrices", "workOrderId", payment.WorkOrderId);

            ((App)App.Current).GetRequest <GetWorkOrderPriceResponse>(request).ContinueWith(a => WorkOrderPricesLoaded(workOrder, payment, a.Result));
        }
Exemplo n.º 20
0
        public string ComposeReceipt(WorkOrderResponse workOrder, WorkOrderPaymentDTO payment)
        {
            string receiptHtml = String.Empty;

            receiptHtml =
                "<div>" +
                "<h2><center>Elegant Orchids </center></h2> <br>" +
                "<center> 5185 Conklin Drive Delray Beach fl 33484 </center> <br><br>" +
                "Order Placed: " + workOrder.WorkOrder.CreateDate.ToShortDateString() + "<br>" +
                "Order # " + workOrder.WorkOrder.WorkOrderId.ToString() + "<br>" +
                "Order Total: " + String.Format("Order Total: {0:C}", payment.WorkOrderPaymentAmount) + "<br>" + "<br>" +
                "<div style='border:1px; solid; black'>" +
                "<div style='display: inline-block'> Order Detail</div>" +
                "<div style='border:1px solid; black; text-align: center'>";


            receiptHtml += "<div style = 'display: inline-block'>";

            foreach (WorkOrderInventoryMapDTO inventoryMap in workOrder.WorkOrderList)
            {
                receiptHtml += inventoryMap.Quantity.ToString() + " " + inventoryMap.InventoryName + "  " + inventoryMap.Size + "<br>";
            }

            foreach (NotInInventoryDTO notInInventory in workOrder.NotInInventory)
            {
                receiptHtml += notInInventory.NotInInventoryQuantity.ToString() + " " + notInInventory.NotInInventoryName + "  " + notInInventory.NotInInventorySize + "<br>";
            }

            foreach (GetArrangementResponse a in workOrder.Arrangements)
            {
                receiptHtml += "<br> Arrangement <br>";
                foreach (ArrangementInventoryItemDTO b in a.ArrangementList)
                {
                    receiptHtml += b.Quantity.ToString() + " " + b.InventoryName + "  " + b.Size + "<br>";
                }

                foreach (NotInInventoryDTO notInInventory in a.NotInInventory)
                {
                    receiptHtml += notInInventory.NotInInventoryQuantity.ToString() + " " + notInInventory.NotInInventoryName + "  " + notInInventory.NotInInventorySize + "<br>";
                }

                receiptHtml += "<br>";
            }

            receiptHtml += "</div>";

            receiptHtml +=

                "<div style='border:1px solid; black;'>" +
                "<div>" + "</div>" +
                "<div>" + "</div>" +
                "</div> <br>";

            if (workOrder.WorkOrder.DeliveryType == 2)
            {
                receiptHtml += "<br>" +
                               "<div style='border:1px; solid; black'>" +
                               "<div style='border:1px solid; black; text-align: center'>" +
                               "<div style='display: inline-block'> Delivery Detail</div>" +
                               "</div>" +
                               "<div style='border:1px solid; black;'>" +
                               "<div>" + "</div>" +
                               "<div>" + "</div>" +
                               "</div>" +
                               "</div> <br>";
            }

            receiptHtml += "<br>" +
                           "<div style='border:1px; solid; black'>" +
                           "<div style='border:1px solid; black; text-align: center'>" +
                           "<div style='display: inline-block'> Payment Detail</div>" +
                           "</div>" +
                           "<div style='border:1px solid; black;'>" +
                           "<div>" + "</div>" +
                           "<div>" + "</div>" +
                           "</div>" +
                           "</div>";

            if (payment.WorkOrderPaymentType == 2)
            {
                receiptHtml +=
                    "<div style='border:1px; solid; black'>" +
                    "<div style='border:1px solid; black; text-align: center'>" +
                    "<div style='display: inline-block'> Credit Card Payment Detail</div>" +
                    "</div>" +
                    "<div style='border:1px solid; black;'>" +
                    "<div>" + "</div>" +
                    "<div>" + "</div>" +
                    "</div>" +
                    "</div>";
            }

            receiptHtml += "</div>";

            receiptHtml += "<h2><center> Thank you for your business </center></h2>";

            return(receiptHtml);
        }
Exemplo n.º 21
0
 public long AddWorkOrderPayment(WorkOrderPaymentDTO workOrderPayment)
 {
     return(persistence.AddWorkOrderPayment(workOrderPayment));
 }