コード例 #1
0
        private void BtnSubmit_Click(object sender, EventArgs e)
        {
            string reference;
            string source;

            if (TabMethods.SelectedTab == TabCredit)
            {
                source = "Stripe";
                var dialog = new FrmProcessing
                {
                    Description = "Hanging Fees",
                    FirstTry    = StripeFirstTry,
                    PayeeName   = CmbPayee.SelectedItem.ToString(),
                    CardNumber  = Card.CardNumber,
                    CardMonth   = Card.ExpireMonth,
                    CardYear    = Card.ExpireYear,
                    CardCVC     = txtCVC.Text,
                    Amount      = FeesDue
                };

                dialog.ShowDialog();

                if (dialog.Charge != null)
                {
                    reference = dialog.Charge.Id;
                }
                else
                {
                    StripeFirstTry = false;
                    MessageBox.Show("The transaction was declined: " + dialog.Error.Message, "Charge Failed",
                                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
            else
            {
                reference = GetRandomHexNumber(13);
                if (TabMethods.SelectedTab == TabCash)
                {
                    source = "Cash";
                }
                else if (TabMethods.SelectedTab == TabCheck)
                {
                    source     = "Check";
                    reference += "_#" + TxtCheckNumber.Text;
                }
                else
                {
                    source = "Waived";
                }
            }

            var payload = "action=PayHangingFees&fees=" + FeesDue + "&id=" + Presence.ArtistAttendingID + "&year=" +
                          Program.Year.ToString() + "&source=" + source + "&reference=" + reference;

            if (source == "Waived")
            {
                payload += "&reason" + TxtWaiverReason.Text;
            }

            var data    = Encoding.ASCII.GetBytes(payload);
            var request = WebRequest.Create(Program.URL + "/functions/artQuery.php");

            request.ContentLength = data.Length;
            request.ContentType   = "application/x-www-form-urlencoded";
            request.Method        = "POST";
            using (var stream = request.GetRequestStream())
                stream.Write(data, 0, data.Length);

            var webResponse = (HttpWebResponse)request.GetResponse();
            var results     = new StreamReader(webResponse.GetResponseStream()).ReadToEnd();
            var response    = JsonConvert.DeserializeObject <Dictionary <string, dynamic> >(results);

            if ((string)response["Result"] == "Success")
            {
                MessageBox.Show("All hanging fees have been settled.", "Success", MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
                DialogResult = DialogResult.OK;
            }
            else
            {
                MessageBox.Show(
                    "An error occurred processing your hanging fees with the database: " + (string)response["Message"],
                    "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                DialogResult = DialogResult.None;
            }
        }
コード例 #2
0
        private void BtnPurchase_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;
            string reference;
            string source;

            if (TabPaymentMethods.SelectedTab == TabCredit)
            {
                source = "Stripe";
                var dialog = new FrmProcessing
                {
                    FirstTry    = StripeFirstTry,
                    Person      = Purchaser,
                    Description = "Print Shop Purchases",
                    CardNumber  = Card.CardNumber,
                    CardMonth   = Card.ExpireMonth,
                    CardYear    = Card.ExpireYear,
                    CardCVC     = txtCVC.Text,
                    Amount      = TotalDue
                };

                dialog.ShowDialog();

                if (dialog.Charge != null)
                {
                    reference = dialog.Charge.Id;
                }
                else
                {
                    StripeFirstTry = false;
                    Cursor         = Cursors.Default;
                    MessageBox.Show("The transaction was declined: " + dialog.Error.Message, "Charge Failed",
                                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
            else
            {
                source    = TabPaymentMethods.SelectedTab == TabCash ? "Cash" : "Check";
                reference = GetRandomHexNumber(13);
                if (TabPaymentMethods.SelectedTab == TabCheck)
                {
                    reference += "_#" + TxtCheckNumber.Text;
                }
            }

            var items   = (from ListViewItem item in LstCart.Items select(PrintShopItem) item.Tag).ToList();
            var payload = "action=RecordPrintShopSales&year=" + Program.Year.ToString() + "&price=" + TotalPrice + "&tax=" + TotalTax + "&total=" + TotalDue;

            if (Purchaser.PeopleID != null)
            {
                payload += "&purchaser=" + Purchaser.PeopleID;
            }
            else
            {
                payload += "&onetime=" + Purchaser.OneTimeID;
            }
            payload += "&reference=" + reference + "&source=" + source;
            payload += "&items=" + HttpUtility.UrlEncode(JsonConvert.SerializeObject(items));

            var data    = Encoding.ASCII.GetBytes(payload);
            var request = WebRequest.Create(Program.URL + "/functions/artQuery.php");

            request.ContentLength = data.Length;
            request.ContentType   = "application/x-www-form-urlencoded";
            request.Method        = "POST";
            using (var stream = request.GetRequestStream())
                stream.Write(data, 0, data.Length);

            var webResponse = (HttpWebResponse)request.GetResponse();
            var results     = new StreamReader(webResponse.GetResponseStream()).ReadToEnd();
            var response    = JsonConvert.DeserializeObject <Dictionary <string, dynamic> >(results);

            if ((string)response["Result"] == "Success")
            {
                MessageBox.Show("Your purchases have been recorded! Your reference number is \"" + reference + "\".",
                                "Purchase Complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
                var receipt = new FrmShopReceipt(Purchaser, items, source, reference);
                receipt.ShowDialog();
                DialogResult = DialogResult.OK;
            }
            else
            {
                MessageBox.Show(
                    "An error occurred entering your purchases into the database: " + (string)response["Message"],
                    "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #3
0
        private void BtnPurchase_Click(object sender, EventArgs e)
        {
            string reference;
            string source;

            if (TabPaymentMethods.SelectedTab == TabCredit)
            {
                source = "Stripe";
                var dialog = new FrmProcessing
                {
                    Description = "Auction Pieces",
                    FirstTry    = StripeFirstTry,
                    PayeeName   = Person.Name,
                    CardNumber  = Card.CardNumber,
                    CardMonth   = Card.ExpireMonth,
                    CardYear    = Card.ExpireYear,
                    CardCVC     = txtCVC.Text,
                    Amount      = TotalDue
                };

                dialog.ShowDialog();

                if (dialog.Charge != null)
                {
                    reference = dialog.Charge.Id;
                }
                else
                {
                    StripeFirstTry = false;
                    MessageBox.Show("The transaction was declined: " + dialog.Error.Message, "Charge Failed",
                                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
            else
            {
                reference = GetRandomHexNumber(13);
                if (TabPaymentMethods.SelectedTab == TabCash)
                {
                    source = "Cash";
                }
                else if (TabPaymentMethods.SelectedTab == TabCheck)
                {
                    source     = "Check";
                    reference += "_#" + TxtCheckNumber.Text;
                }
                else
                {
                    source = "Waived";
                }
            }

            var payload = "action=SellAuctionItems&year=" + Program.Year.ToString() + "&price=" + TotalPrice + "&tax=" + TotalTax + "&total=" + TotalDue + "&id=" +
                          Person.BadgeID + "&pieces=" + Items.Count + "&source=" + source + "&reference=" + reference;

            var data    = Encoding.ASCII.GetBytes(payload);
            var request = WebRequest.Create(Program.URL + "/functions/artQuery.php");

            request.ContentLength = data.Length;
            request.ContentType   = "application/x-www-form-urlencoded";
            request.Method        = "POST";
            using (var stream = request.GetRequestStream())
                stream.Write(data, 0, data.Length);

            var webResponse = (HttpWebResponse)request.GetResponse();
            var results     = new StreamReader(webResponse.GetResponseStream()).ReadToEnd();
            var response    = JsonConvert.DeserializeObject <Dictionary <string, dynamic> >(results);

            if ((string)response["Result"] == "Success")
            {
                MessageBox.Show("Your purchases have been recorded! Your reference number is \"" + reference + "\".",
                                "Purchase Complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
                var receipt = new FrmAuctionReceipt(Person, Items, source, reference);
                receipt.ShowDialog();
                DialogResult = DialogResult.OK;
            }
            else
            {
                MessageBox.Show(
                    "An error occurred processing your auction sales with the database: " + (string)response["Message"],
                    "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                DialogResult = DialogResult.None;
            }
        }