private void SaveManualHandpay() { if (cmbBarPositions.SelectedIndex <= 0) { return; } Window Owner; double amount = 0; int Auth_User_ID = 0; try { CAuthorize objAuthorize = null; if (txtBox != null && txtBox.Text.Length > 0) { // Issue fix for ->set cultureinfo='en-US', currencyculture='it-IT' double.TryParse(txtBox.Text.ToString(), NumberStyles.Currency, new CultureInfo(ExtensionMethods.CurrentCurrenyCulture), out amount); } Auth_User_ID = Security.SecurityHelper.CurrentUser.User_No; if (Settings.Client != null && Settings.Client.ToLower() == "winchells" && Settings.MaxHandPayAuthRequired && txtBox != null && (amount > Settings.HandpayPayoutCustomer_Max)) { objAuthorize = new CAuthorize("CashdeskOperator.Authorize.cs.MaxHandpay"); Auth_User_ID = Security.SecurityHelper.CurrentUser.User_No; if (!Security.SecurityHelper.HasAccess("CashdeskOperator.Authorize.cs.MaxHandpay")) { objAuthorize.ShowDialogEx(this); if (!objAuthorize.IsAuthorized) { IsProcessed = true; return; } else { Auth_User_ID = handpay.GetUserID(objAuthorize.User.SecurityUserID); } } else { objAuthorize.IsAuthorized = true; } } if (Settings.RegulatoryEnabled == true && Settings.RegulatoryType == "AAMS") { if (txtBox != null) { Custid = 0; ProcessCancelled = false; if (amount >= Settings.HandpayPayoutCustomer_Min && amount <= Settings.HandpayPayoutCustomer_Max) { oCustomerDetails = new BMC.Presentation.POS.Views.CustomerDetails(); oCustomerDetails.delCustomerUpdated += new BMC.Presentation.POS.Views.CustomerDetails.CustomerUpdateHandler(delCustomerUpdated); oCustomerDetails.delCustomerCancelled += new BMC.Presentation.POS.Views.CustomerDetails.CustomerCancelHandler(delCustomerCancelled); Owner = Window.GetWindow(this); oCustomerDetails.ShowDialogEx(this); } else if (amount >= Settings.HandpayPayoutCustomer_BankAccNo) { oCustomerDetails = new BMC.Presentation.POS.Views.CustomerDetails(true); oCustomerDetails.delCustomerUpdated += new BMC.Presentation.POS.Views.CustomerDetails.CustomerUpdateHandler(delCustomerUpdated); oCustomerDetails.delCustomerCancelled += new BMC.Presentation.POS.Views.CustomerDetails.CustomerCancelHandler(delCustomerCancelled); Owner = Window.GetWindow(this); oCustomerDetails.ShowDialogEx(this); } else if (amount >= Settings.HandpayPayoutCustomer_Max && amount <= Settings.HandpayPayoutCustomer_BankAccNo) { oCustomerDetails = new BMC.Presentation.POS.Views.CustomerDetails(); oCustomerDetails.delCustomerUpdated += new BMC.Presentation.POS.Views.CustomerDetails.CustomerUpdateHandler(delCustomerUpdated); oCustomerDetails.delCustomerCancelled += new BMC.Presentation.POS.Views.CustomerDetails.CustomerCancelHandler(delCustomerCancelled); Owner = Window.GetWindow(this); oCustomerDetails.ShowDialogEx(this); } } if (ProcessCancelled) // if the process cancelled from the customer then back to the handpay screen { return; } } List <AssetNumberResult> lstasset = handpay.GetAssetNumber((cmbBarPositions.SelectedItem as BarPositions).Installation_No); string Asset = lstasset[0].Stock_No; treasury = new Treasury { InstallationNumber = (cmbBarPositions.SelectedItem as BarPositions).Installation_No }; if (optHandpay.IsChecked == true) { treasury.TreasuryType = "AttendantPay Credit"; } else if (optJackpot.IsChecked == true) { treasury.TreasuryType = "AttendantPay Jackpot"; } else { treasury.TreasuryType = "PROGRESSIVE"; } treasury.TreasuryAmount = amount; treasury.ActualTreasuryDate = DateTime.Now; // treasury.UserID = Security.SecurityHelper.CurrentUser.User_No; treasury.UserID = Auth_User_ID; treasury.Authorized_Date = DateTime.MinValue.DBMinValue(); if (objAuthorize != null && objAuthorize.IsAuthorized) { treasury.AuthorizedUser_No = Auth_User_ID; treasury.Authorized_Date = DateTime.Now; //Audit for authorization AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History { AuditModuleName = ModuleName.ManualAttendantPay, Audit_Screen_Name = "PositionDetails|ManualAttendantPay", Audit_Desc = "Manual AttendantPay Type-" + treasury.TreasuryType, AuditOperationType = OperationType.ADD, Audit_Field = "AuthorizedUser_No", Audit_New_Vl = Auth_User_ID.ToString(), Audit_Slot = Asset }); } treasury.CustomerID = Custid; // add the customer to the treasury if amt between 1000 & 4000 or >5000 Treasury_No = handpay.ProcessHandPay(treasury, 0); IsProcessed = true; if (Treasury_No > 0) { DateTime dtTreasury = (DateTime)handpay.GetTreasuryDateTime(Treasury_No); TextBlock_11.Text = "#" + (cmbBarPositions.SelectedItem as BarPositions).Bar_Pos_Name + dtTreasury.ToString("ddMMyyyyHHmmss"); txtAmount.Text = Convert.ToDecimal((treasury.TreasuryAmount)).GetUniversalCurrencyFormat(); #region GCD if (Settings.IsGloryCDEnabled && Settings.CashDispenserEnabled) { LoadingWindow ld = new LoadingWindow(Window.GetWindow(this), ModuleName.ManualAttendantPay, Treasury_No.ToString(), (cmbBarPositions.SelectedItem as BarPositions).Bar_Pos_Name, Convert.ToInt32(treasury.TreasuryAmount * 100)); ld.Topmost = true; ld.ShowDialogEx(this); Result res = ld.Result; if (res.IsSuccess && (Treasury_No > 0)) { LogManager.WriteLog(string.Format("Cash Dispensed Successfully - Treasury Amount: {0:0.00}", treasury.TreasuryAmount), LogManager.enumLogLevel.Info); LogManager.WriteLog("Export Manual AttendantPay Details to Enterprise", LogManager.enumLogLevel.Info); handpay.ExportHandPay(Treasury_No); BMC.Presentation.MessageBox.ShowBox(res.error.Message, res.error.MessageType.Equals("Error") ? BMC_Icon.Error : BMC_Icon.Information, true); AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History { AuditModuleName = ModuleName.AttendantPay, Audit_Screen_Name = "PositionDetails|AttendantPay|Manual HandPay", Audit_Desc = "Manual HandPay Succeed", AuditOperationType = OperationType.ADD, Audit_Old_Vl = "Ticket_ExceptionID:0 (Manual Handpay); TreasuryNo:" + Treasury_No + ";", }); } else { BMC.Presentation.MessageBox.ShowBox(res.error.Message, res.error.MessageType.Equals("Error") ? BMC_Icon.Error : BMC_Icon.Information, true); LogManager.WriteLog(string.Format("Unable to Dispense Cash - Treasury Amount: {0:0.00}", treasury.TreasuryAmount), LogManager.enumLogLevel.Info); LogManager.WriteLog("Rollback Manual HandPay Process", LogManager.enumLogLevel.Info); handpay.RollbackHandPay(0, Treasury_No); MessageBox.ShowBox("MessageID117", BMC_Icon.Error); AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History { AuditModuleName = ModuleName.AttendantPay, Audit_Screen_Name = "PositionDetails|AttendantPay", Audit_Desc = treasury.TreasuryType + " processing was not completed.", AuditOperationType = OperationType.ADD, Audit_Slot = Asset }); AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History { AuditModuleName = ModuleName.AttendantPay, Audit_Screen_Name = "PositionDetails|AttendantPay|Manual HandPay Process Failed", Audit_Desc = "Rollback HandPay Process Voucher due to cash dispenser error", AuditOperationType = OperationType.MODIFY, Audit_Old_Vl = "Ticket_ExceptionID:0 (Manual Handpay); TreasuryNo:" + Treasury_No + ";" }); } } else { this.ProcessCashDispense("Manual AttendantPay Type", treasury.TreasuryType, Convert.ToDecimal(amount)); MessageBox.ShowBox("MessageID116", BMC_Icon.Information); } #endregion AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History { AuditModuleName = ModuleName.ManualAttendantPay, Audit_Screen_Name = "PositionDetails|ManualAttendantPay", Audit_Desc = "Manual AttendantPay Type-" + treasury.TreasuryType, AuditOperationType = OperationType.ADD, Audit_Field = "Amount", Audit_New_Vl = String.Format("{0:0.00}", treasury.TreasuryAmount), Audit_Slot = Asset }); if (txtBox != null) { //txtBox.Text = "0.00"; txtBox.Text = this.DefaultAmount(); ucValueCalcComp.s_UnformattedText = ""; } if (objAuthorize != null && objAuthorize.User != null) { (oCommonUtilities.CreateInstance()).PrintCommonReceipt(false, treasury.TreasuryType, Treasury_No.ToString(), objAuthorize.User); } else { (oCommonUtilities.CreateInstance()).PrintCommonReceipt(false, treasury.TreasuryType, Treasury_No.ToString()); } if (((bool)optJackpot.IsChecked) || ((bool)optProgressive.IsChecked))// || ((bool)optHandpay.IsChecked)) { treasury.Asset = Asset; //string installationType = installationPathkey.GetValue("InstallationType").ToString(); //if (installationType.ToUpper().Equals("EXCHANGECLIENT")) //{ // if (Settings.SendPT10FromClient) // PostHandpayEvent(treasury); //} //else PostHandpayEvent(treasury); } } else { if (optHandpay.IsChecked == true) { MessageBox.ShowBox("MessageID119", BMC_Icon.Error); } else if (optJackpot.IsChecked == true) { MessageBox.ShowBox("MessageID1191", BMC_Icon.Error); } else { MessageBox.ShowBox("MessageID1192", BMC_Icon.Error); } AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History { AuditModuleName = ModuleName.ManualAttendantPay, Audit_Screen_Name = "PositionDetails|ManualAttendantPay", Audit_Desc = "Manual AttendantPay Type-" + treasury.TreasuryType + " processing was not completed.", AuditOperationType = OperationType.ADD, Audit_Slot = Asset }); } } catch (Exception Ex) { ExceptionManager.Publish(Ex); MessageBox.ShowBox("MessageID119", BMC_Icon.Error); AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History { AuditModuleName = ModuleName.ManualAttendantPay, Audit_Screen_Name = "PositionDetails|ManualAttendantPay", Audit_Desc = "Manual AttendantPay Type-" + treasury.TreasuryType + " processing was not completed.", AuditOperationType = OperationType.ADD, Audit_Slot = Asset }); } }
private void btnSave_Click(object sender, RoutedEventArgs e) { try { int iReasonID = 0; btnSave.IsEnabled = false; if (!CheckData()) { return; } int iSelectedInstallation = 0; int iSelectedReasoncode = 0; string strExceptionDetails = string.Empty; int iExceptionCode = 0; string strExpectedStatus = string.Empty; string strReason = ""; string strComment = ""; IHandpay IUser_No = HandpayBusinessObject.CreateInstance(); int AuthorizedUserNo = Security.SecurityHelper.CurrentUser.User_No; DataRowView drv = (DataRowView)lstInstallation.SelectedItem; iSelectedInstallation = Convert.ToInt32(drv["Installation_No"]); if (lvReason.SelectedIndex >= 0) { iSelectedReasoncode = 0; drv = (DataRowView)lvReason.SelectedItem; iSelectedReasoncode = Convert.ToInt32(drv[0]); } else { if (lvReason.Items.SourceCollection is System.Data.DataView) { DataView dvReason = (DataView)lvReason.Items.SourceCollection; DataTable dtReason = new DataTable(); dtReason = dvReason.ToTable().Copy(); DataView dvReasonClone = new DataView(dtReason); dvReasonClone.RowFilter = "ReasonDescription='" + txtComments.Text + "'"; if (dvReasonClone.ToTable().Rows.Count > 0) { iSelectedReasoncode = Convert.ToInt32(dvReasonClone.ToTable().Rows[0]["ReasonCode"]); } else { iSelectedReasoncode = lvReason.Items.Count + 1; } } } double dValue = Convert.ToDouble(objValueCalc.txtDisplay.Text); bool blnTicketFoundinException = false; IShortPay objCashDesk = ShortPayBusinessObject.CreateInstance(); BMC.Transport.CashDeskOperatorEntity.Treasury objTreasuries = new BMC.Transport.CashDeskOperatorEntity.Treasury(); objTreasuries.InstallationNumber = iSelectedInstallation; objTreasuries.UserID = Security.SecurityHelper.CurrentUser.User_No; objTreasuries.TreasuryType = "Shortpay"; objTreasuries.TreasuryReasonCode = iSelectedReasoncode; if (lvReason.SelectedIndex >= 0) { DataRowView drvReason = (DataRowView)lvReason.SelectedItem; strReason = drvReason[1].ToString(); strComment = strReason + ". Voucher Number is" + txtTicketNumber.Text; } else { objReasonCode.Reason_Code = iSelectedReasoncode; objReasonCode.ReasonDescription = txtComments.Text; if (!String.IsNullOrEmpty(txtComments.Text)) { if (Settings.AddShortpayCommentstoDefault) { iReasonID = objCashDesk.SaveReasonDetails(objReasonCode); } strComment = txtComments.Text + " . Voucher Number is " + txtTicketNumber.Text; strReason = txtComments.Text; objTreasuries.TreasuryReason = strComment; } } if (strComment.Length > 199) { objTreasuries.TreasuryReason = strComment.Substring(0, 199); } else { objTreasuries.TreasuryReason = strComment; } objTreasuries.TreasuryAmount = dValue; objTreasuries.TreasuryIssuerUserNo = AuthorizedUserNo; int iShortPayID = 0; int UserSecurityId = 0; if (BMC.Transport.Settings.ShortPayAuthorizationRequired && objTreasuries.TreasuryAmount >= BMC.Transport.Settings.ShortPayAuthorizationLimit) { if (objCashDesk.CreateShortPayForApproval(objTreasuries, ref iShortPayID)) { LogManager.WriteLog("Shortpay saved for authorization. Ticketnumber: " + txtTicketNumber.Text, LogManager.enumLogLevel.Info); } else { LogManager.WriteLog("Unable to save Shortpay authorization. Ticketnumber: " + txtTicketNumber.Text, LogManager.enumLogLevel.Info); MessageBox.ShowBox("MessageID198"); return; } CAuthorize oCAuthorize = new CAuthorize("BMC.Presentation.CShortPay.ShortPayApprover"); oCAuthorize.ShowDialog(); if (!oCAuthorize.IsAuthorized) { objCashDesk.CancelShortPayForApproval(iShortPayID); return; } bIsAuthorised = true; AuthorisedUsr = oCAuthorize.User; UserSecurityId = oCAuthorize.User.SecurityUserID; AuthorizedUserNo = IUser_No.GetUserID(UserSecurityId); } //Update user no with authorized user if shortpay is authorised by different user objTreasuries.TreasuryIssuerUserNo = AuthorizedUserNo; objTreasuries.AuthorizedUser_No = AuthorizedUserNo; objTreasuries.Authorized_Date = DateTime.Now; int iTreasuryID = objCashDesk.SaveShortpayDetails(objTreasuries); if (iShortPayID > 0) { objCashDesk.ApproveShortPay(iShortPayID.ToString(), UserSecurityId, iTreasuryID); } if (iTreasuryID > 0) { LogManager.WriteLog("Shortpay saved in treasury. Ticketnumber: " + txtTicketNumber.Text, LogManager.enumLogLevel.Info); if (iReasonID > 0) { LogManager.WriteLog("ReasonCode saved in Reason_Code. ReasonCode: " + objReasonCode.Reason_Code, LogManager.enumLogLevel.Info); } } else { LogManager.WriteLog("Unable to save Shortpay in treasury. Ticketnumber: " + txtTicketNumber.Text, LogManager.enumLogLevel.Info); return; } strExceptionDetails = "Normal Treasury Entry"; iExceptionCode = (int)ShortpayExceptionCodes.NormalTreasuryEntry; IHandpay handpay = HandpayBusinessObject.CreateInstance(); DataTable dtException = handpay.GetTicketingExceptionTable(txtTicketNumber.Text); if (dtException.Rows.Count > 0) { LogManager.WriteLog("Voucher Number :" + txtTicketNumber.Text + " found in Ticket_Exception table.", LogManager.enumLogLevel.Info); strExpectedStatus = dtException.Rows[0]["TE_Status_Create_Expected"].ToString(); blnTicketFoundinException = true; if (objCashDesk.UpdateTicketException(0, txtTicketNumber.Text, "V") == 0) { LogManager.WriteLog("Ticket Exception table updated. Voucher Number:" + txtTicketNumber.Text, LogManager.enumLogLevel.Info); } strExceptionDetails = "House Keeping Void"; iExceptionCode = (int)ShortpayExceptionCodes.HouseKeepingVoid; } if (blnTicketFoundinException && !string.IsNullOrEmpty(strExpectedStatus)) { if (strExpectedStatus == "VOID_SP" || strExpectedStatus == "ACTIVE") { BMC.Transport.CashDeskOperatorEntity.VoidOrExpiredTreasury objVoidTreasury = new BMC.Transport.CashDeskOperatorEntity.VoidOrExpiredTreasury(); objVoidTreasury.TicketNumber = txtTicketNumber.Text; objVoidTreasury.TransactionType = "Shortpay"; objVoidTreasury.TreasuryReason = "Voiding Voucher for ShortPay"; objCashDesk.UpdateVoidorExpiredTreasury(objVoidTreasury); LogManager.WriteLog("Updated void or expired treasury. Ticketnumber: " + txtTicketNumber.Text, LogManager.enumLogLevel.Info); strExceptionDetails = "Voiding Vocuher for ShortPay"; iExceptionCode = (int)ShortpayExceptionCodes.VoidTicketForShortpay; } } if (!blnTicketFoundinException) { strExceptionDetails = "No entry found in ticket_exception table for the Voucher entered"; iExceptionCode = (int)ShortpayExceptionCodes.NoEntryInTicket_Exception; } Transport.CashDeskOperatorEntity.TicketException objException = new BMC.Transport.CashDeskOperatorEntity.TicketException(); objException.InstallationNumber = iSelectedInstallation; objException.ExceptionDetails = strExceptionDetails; objException.ExceptionType = iExceptionCode; objException.Reference = txtTicketNumber.Text; objException.User = AuthorizedUserNo; objCashDesk.InsertException(objException); LogManager.WriteLog("Voucher inserted into Exception. Voucher Number :" + txtTicketNumber.Text, LogManager.enumLogLevel.Info); //MachineDetails.Value = dValue.ToString(); //MachineDetails.TreasuryNo = iTreasuryID.ToString(); string sDesc = "Position: " + ((System.Data.DataRowView)(lstInstallation.SelectedValue)).Row.ItemArray[0].ToString() + " Details: " + strReason + " TicketNo.: " + txtTicketNumber.Text + " Amount: " + dValue; sDesc += bIsAuthorised ? " Approved By : " + AuthorisedUsr.UserName : ""; AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History { AuditModuleName = ModuleName.Shortpay, Audit_Screen_Name = "Shortpay", Audit_Desc = sDesc, AuditOperationType = OperationType.ADD, Audit_Field = "Shortpay ", Audit_New_Vl = "NULL" }); MessageBox.ShowBox("MessageID197"); LoadControls(); lstInstallation.Focus(); if (dtInstallations.Rows.Count > 0) { lstInstallation.SelectedIndex = 0; } //To Print Receipt. if (!bIsAuthorised) { (oCommonUtilities.CreateInstance()).PrintCommonReceipt(false, "Shortpay", iTreasuryID.ToString()); } else { (oCommonUtilities.CreateInstance()).PrintCommonReceipt(false, "Shortpay", iTreasuryID.ToString(), AuthorisedUsr); } AuthorisedUsr = null; bIsAuthorised = false; LogManager.WriteLog("Recipt printed for shortpay. Voucher Number :" + txtTicketNumber.Text, LogManager.enumLogLevel.Info); } catch (Exception ex) { ExceptionManager.Publish(ex); MessageBox.ShowBox("MessageID198"); AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History { AuditModuleName = ModuleName.Shortpay, Audit_Screen_Name = "Shortpay", Audit_Desc = "Exception Occured while saving the Data", AuditOperationType = OperationType.ADD, Audit_Field = "Shortpay ", Audit_New_Vl = "NULL" }); } finally { btnSave.IsEnabled = true; } }