public decimal ValidateVoidVoucher(string ticketNumber, int userNo, ref int?nResult) { decimal dAmount = 0; try { // is tis printed ticket if (VoucherHelper.IsTISPrintedTicketPrefix(ticketNumber)) { // if the tis printed ticket available in local db bool isTISTicketAvailable = VoucherHelper.IsTISPrintedTicket(ticketNumber); if (!isTISTicketAvailable) { // wait worst case 10 secs to get the response from TIS int count = 10; string message = "Waiting for receiving data from TIS..."; WPFExtensions.ShowAsyncDialog(null, message, null, 1, count, (o) => { IAsyncProgress2 o2 = o as IAsyncProgress2; // failure case - hit the tis communication interface and get the ticket try { o2.UpdateStatusProgress(5, message); VoucherHelper.SendTISRedeemTicketQuery(ticketNumber, userNo); o2.UpdateStatusProgress(10, message); } catch (Exception ex) { ExceptionManager.Publish(ex); } }); } } // Success/failure case - ok proceed with voiding foreach (var obj in this.ValidateVoidVoucher(ticketNumber, ref nResult)) { dAmount = Convert.ToDecimal(obj.iAmount) / 100; } } catch (Exception ex) { ExceptionManager.Publish(ex); } return(dAmount); }
private void button_Click(object sender, RoutedEventArgs e) { try { int InstallationNumber = 0; int ValidationLength = 0; string _Barcode = this.ucValueCalc.txtDisplay.Text.Trim(); System.Windows.Forms.DialogResult _diagResult; btnVerify.IsEnabled = false; if (isScannerFired) //check done not to fire the verify event twice while verifying a ticket using scanner { isScannerFired = false; return; } if ((sender is System.Windows.Controls.TextBox)) { isScannerFired = true; } else { isScannerFired = false; } if (this.ucValueCalc.txtDisplay.Text.Trim().Length > 0) { //8-digit ticket validation. //Slot ticket cannot be redeemed via cashdesk. if (this.ucValueCalc.txtDisplay.Text.Trim().Length != 18) { LinqDataAccessDataContext linqDBExchange = new LinqDataAccessDataContext(CommonDataAccess.ExchangeConnectionString); IEnumerable <InstallationFromTicket> InstallationTicket = linqDBExchange.GetInstallationNumber(_Barcode); if (InstallationTicket != null) { foreach (var item in InstallationTicket) { InstallationNumber = item.installation_no.Value; _Barcode = item.strbarcode; } DataTable InstallationDetails = (new CommonDataAccess()).GetInstallationDetails(0, InstallationNumber, false, false); if (InstallationDetails.Rows.Count > 0) { int.TryParse(InstallationDetails.Rows[0]["Validation_length"].ToString(), out ValidationLength); if (ValidationLength != _Barcode.Length) { MessageBox.ShowBox("MessageID403", BMC_Icon.Error); return; } } } } TicketsHelper objTicketsHelper = new TicketsHelper(); int? nResult = -1; decimal dAmount = 0; int iTransactionNo = 0; int iSequenceNo = 0; //foreach (var obj in objTicketsHelper.ValidateVoidVoucher(this.ucValueCalc.txtDisplay.Text.Trim(), ref nResult)) //{ // dAmount = Convert.ToDecimal(obj.iAmount)/100; //} dAmount = objTicketsHelper.ValidateVoidVoucher(_Barcode, Security.SecurityHelper.CurrentUser.User_No, ref nResult); switch (nResult) { case 0: { if (Convert.ToBoolean(AppSettings.REDEEM_TICKET_POP_UP_ALERT_VISIBILITY)) { //Message: Are you sure you want to Void the Voucher? _diagResult = MessageBox.ShowBox("MessageID512", BMC_Icon.Question, BMC_Button.YesNo, this.ucValueCalc.txtDisplay.Text.Trim(), Convert.ToString(dAmount)); if (_diagResult == System.Windows.Forms.DialogResult.No) { return; } } else { _diagResult = System.Windows.Forms.DialogResult.Yes; } if (_diagResult == System.Windows.Forms.DialogResult.Yes) { string barcode = this.ucValueCalc.txtDisplay.Text.Trim(); foreach (var obj in objTicketsHelper.UpdateVoidVoucher(barcode, System.Environment.MachineName, Security.SecurityHelper.CurrentUser.User_No, txtNotes.Text)) { iTransactionNo = (int)obj.iTransactionNo; iSequenceNo = obj.TE_ID; } // TIS Printed Tickets if (VoucherHelper.IsTISPrintedTicket(barcode)) { VoucherHelper.SendTISVoidTicket(barcode, Security.SecurityHelper.CurrentUser.User_No); } //Message: "Voucher Voided Successfully." MessageBox.ShowBox("MessageID513", BMC_Icon.Information); //Receipt BMC.Business.CashDeskOperator.Reports objReports = new BMC.Business.CashDeskOperator.Reports(); string sCode = BMC.Transport.Settings.SiteCode; using (CReportViewer objReportViewer = new CReportViewer()) { objReportViewer.PrintVoidVoucherReceipt(System.Environment.MachineName, this.ucValueCalc.txtDisplay.Text.Trim(), dAmount, iTransactionNo, sCode, iSequenceNo); //objReportViewer.ShowDialog(); } Audit(this.ucValueCalc.txtDisplay.Text.Trim(), dAmount, "Voucher Voided Successfully"); lblVoidAmountValue.Visibility = Visibility.Visible; lblVoidAmount.Visibility = Visibility.Visible; lblVoidAmountValue.Text = string.Empty; lblVoidAmountValue.Text = dAmount.ToString("0.00"); } break; } case 1: { //Voucher Not Found //Message: "Voucher is not available in System" MessageBox.ShowBox("MessageID514", BMC_Icon.Error); Audit(this.ucValueCalc.txtDisplay.Text.Trim(), dAmount, "Voucher Not Found"); lblVoidAmount.Visibility = Visibility.Hidden; lblVoidAmountValue.Visibility = Visibility.Hidden; //Audit break; } case 2: { // Invalid for Slots, only CashDesk is allowed. //Message: "Void is applicable only for Cash Desk Vouchers" MessageBox.ShowBox("MessageID515", BMC_Icon.Error); Audit(this.ucValueCalc.txtDisplay.Text.Trim(), dAmount, "Void is applicable only for Cash Desk Vouchers"); //Audit lblVoidAmount.Visibility = Visibility.Hidden; lblVoidAmountValue.Visibility = Visibility.Hidden; break; } case 3: { //PAID Status // Message: "Voucher has already been redeemed." MessageBox.ShowBox("MessageID516", BMC_Icon.Error); Audit(this.ucValueCalc.txtDisplay.Text.Trim(), dAmount, "Voucher has already been redeemed"); lblVoidAmount.Visibility = Visibility.Hidden; lblVoidAmountValue.Visibility = Visibility.Hidden; //Audit break; } case 4: { //Already Voided // Message: "Voucher has already been Voided." MessageBox.ShowBox("MessageID517", BMC_Icon.Error); Audit(this.ucValueCalc.txtDisplay.Text.Trim(), dAmount, "Voucher has already been Voided"); lblVoidAmount.Visibility = Visibility.Hidden; lblVoidAmountValue.Visibility = Visibility.Hidden; //Audit break; } case 5: { //Expired Date // Message: "Voucher has expired." MessageBox.ShowBox("MessageID518", BMC_Icon.Error); Audit(this.ucValueCalc.txtDisplay.Text.Trim(), dAmount, "Voucher has expired"); lblVoidAmount.Visibility = Visibility.Hidden; lblVoidAmountValue.Visibility = Visibility.Hidden; //Audit break; } } } else { //Message: "Please enter or scan a valid Voucher Number MessageBox.ShowBox("MessageID519", BMC_Icon.Warning); this.ucValueCalc.txtDisplay.Focus(); } ClearAll(); } catch (Exception ex) { MessageBox.ShowBox("MessageID520", BMC_Icon.Error); BMC.Common.ExceptionManagement.ExceptionManager.Publish(ex); ClearAll(); } finally { btnVerify.IsEnabled = true; } }