private void BtnPrintAll_Click(object sender, EventArgs e) { if (LstBadges.SelectedItems.Count == 0) { return; } var badgeType = LstBadges.SelectedItems[0].Text; var startAt = TxtResumeNum.Text.Length > 0 ? Convert.ToInt32(TxtResumeNum.Text) : 0; var badges = Badges.FindAll(b => b.Description == badgeType).Where(b => b.Status == "Paid").ToList(); if (rdoOrderNumber.Checked) { badges = badges.OrderBy(b => b.BadgeNumber).ToList(); } else { badges = badges.OrderBy(b => b.LastName.ToUpper()).ThenBy(b => b.FirstName.ToUpper()).ToList(); } var dialog = new FrmPrinting(badges.Count); dialog.Show(); int count = 0; foreach (var badge in badges) { count++; if (badge.BadgeNumber < startAt) { continue; } Application.DoEvents(); if (!dialog.SetDisplay(count, badge.BadgeNumber + ": " + badge.BadgeName)) { TxtResumeNum.Text = badge.BadgeNumber.ToString(); count = 0; break; } Badge.PrintBadge(badge, chkBackOnly.Checked); } dialog.Close(); if (count == badges.Count) { TxtResumeNum.Text = ""; } }
private void BtnPrintSelected_Click(object sender, EventArgs e) { foreach (ListViewItem item in LstResults.SelectedItems) { var badge = (Badge)item.Tag; if (badge.Status != "Paid") { MessageBox.Show("The badge for " + badge.Name + " (" + badge.BadgeName + ") has a status of '" + badge.Status + "' and cannot be printed.", "Unable to Print Badge", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { Badge.PrintBadge(badge, chkBackOnly.Checked); } } }
public void Print(bool backOnly = false) { Badge.PrintBadge(this, backOnly); }
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, CardNumber = Card.CardNumber, CardMonth = Card.ExpireMonth, CardYear = Card.ExpireYear, CardCVC = txtCVC.Text, Amount = CalculateTotal() }; 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(SaleItem) item.Tag).ToList(); var payload = "action=RecordPurchase&"; if (Purchaser.PeopleID != null) { payload += "purchaser=" + Purchaser.PeopleID; } else { payload += "onetime=" + Purchaser.OneTimeID; } payload += "&reference=" + reference + "&source=" + source; if (TxtCode.TextLength > 0 && !TxtCode.Enabled) { payload += "&code=" + TxtCode.Text; } payload += "&items=" + JsonConvert.SerializeObject(items); var data = Encoding.ASCII.GetBytes(payload); var request = WebRequest.Create(Program.URL + "/functions/salesQuery.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") { if (ChkPrintBadges.Checked && response.ContainsKey("BadgeNumbers")) { var badgeNumbers = JsonConvert.DeserializeObject <Dictionary <string, int> >((string)response["BadgeNumbers"]); foreach (var item in items) { if (item.CategoryID == 1) { var recipient = item.RecipientOneTimeID != null ? OneTimeRecipients[(int)item.RecipientOneTimeID] : Recipients[(int)item.RecipientPeopleID]; var badge = new Badge { BadgeName = item.Details, BadgeNumber = item.RecipientPeopleID != null ? badgeNumbers[item.RecipientPeopleID.ToString()] : badgeNumbers["_" + item.RecipientOneTimeID.ToString()], BadgeTypeID = item.TypeID, Description = item.Description, FirstName = recipient.FirstName, LastName = recipient.LastName, ParentName = recipient.ParentName, ParentContact = recipient.ParentContact }; Badge.PrintBadge(badge); } } } MessageBox.Show("Your purchases have been recorded! Your reference number is \"" + reference + "\".", "Purchase Complete", MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult = DialogResult.OK; } else { MessageBox.Show( "An error occurred entering your purchases into the database: " + (string)response["Message"], "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } Cursor = Cursors.Default; }