/// <summary> /// /// </summary> /// <returns></returns> public bool Setup() { //Processing message var pMesg = new ProcessingMessage("* AUDIT QUERY APP SETUP *"); pMesg.Show(); //Initialize database connection, LDAP connection, and ShopTime var confRef = SecurityAccessor.Instance.EncryptConfig; if (confRef == null) { return(false); } this.userState = UserDesktopState.NOTLOGGEDIN; this.UserName = string.Empty; GlobalDataAccessor.Instance.Init( this, confRef, "AuditQueryApp", auditLogEnabledChangeHandlerBase, auditLogMessageHandlerBase, false); pMesg.Close(); pMesg.Dispose(); return(true); }
private static void RunApplication() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); try { // decrypt pawnsec information from config file var pMesg = new ProcessingMessage("** AUDIT QUERY APP INIT **", 4000); pMesg.Show(); string key = Resources.PrivateKey; string dbHost = StringUtilities.Decrypt(Settings.Default.PawnSecDBHost, key, true); string dbPassword = StringUtilities.Decrypt(Settings.Default.PawnSecDBPassword, key, true); string dbPort = StringUtilities.Decrypt(Settings.Default.PawnSecDBPort, key, true); string dbSchema = StringUtilities.Decrypt(Settings.Default.PawnSecDBSchema, key, true); string dbService = StringUtilities.Decrypt(Settings.Default.PawnSecDBService, key, true); string dbUser = StringUtilities.Decrypt(Settings.Default.PawnSecDBUser, key, true); if (!(string.IsNullOrEmpty(dbHost) || string.IsNullOrEmpty(dbPassword) || string.IsNullOrEmpty(dbPort) || string.IsNullOrEmpty(dbSchema) || string.IsNullOrEmpty(dbService) || string.IsNullOrEmpty(dbUser))) { //Update message pMesg.Message = "** AUDIT QUERY APP SECURITY INIT **"; // create connection with PawnSec SecurityAccessor.Instance.InitializeConnection(dbHost, dbPassword, dbPort, dbSchema, dbService, dbUser); // retrieve data from PawnSec if (!SecurityAccessor.Instance.RetrieveSecurityData(key, ComputeAppHash(), true, PawnSecApplication.AuditQueries)) { pMesg.Close(); pMesg.Dispose(); //TODO: Log error and report exception //No security data means this machine is not allowed to access Cashlinx //Fail immediately. } //Otherwise, the machine is now authenticated to run AuditQueries, proceed with execution else { pMesg.Close(); pMesg.Dispose(); Application.Run(new AuditQueriesForm()); } } else { pMesg.Close(); pMesg.Dispose(); } } catch (Exception eX) { MessageBox.Show("Exception caught in CashlinxDesktop.Program during Application.Run: " + "\nMessage : " + eX.Message + "\nStack Trace: " + eX.StackTrace + "\nTarget Site: " + eX.TargetSite + "\nSource : " + eX.Source + "\nData : " + eX.Data + "\nTerminating Application!", "Application Exception", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); } }
private void btnContinue_Click(object sender, EventArgs e) { if (gvAudits.SelectedRows.Count != 1) { return; } InventoryAuditVO audit = gvAudits.SelectedRows[0].Tag as InventoryAuditVO; if (audit == null) { return; } panelButtons.Enabled = false; ProcessingMessage = new ProcessingMessage("Loading Audit Information", 0); ProcessingMessage.Show(); CommonDatabaseContext dataContext = CreateCommonDatabaseContext(); InventoryAuditProcedures.GetSummaryInfo(audit, dataContext); InventoryAuditProcedures.GetAdditionalAuditInfo(audit, dataContext); ProcessingMessage.Close(); if (!dataContext.Result) { MessageBox.Show("Error loading CACC information"); panelButtons.Enabled = true; return; } ADS.ActiveAudit = audit; switch (audit.Status) { case AuditStatus.ACTIVE: panelButtons.Enabled = true; NavControlBox.IsCustom = true; NavControlBox.CustomDetail = "VIEWACTIVEAUDIT"; NavControlBox.Action = NavBox.NavAction.SUBMIT; break; case AuditStatus.CLOSED: panelButtons.Enabled = true; NavControlBox.IsCustom = true; NavControlBox.CustomDetail = "VIEWCLOSEDAUDIT"; NavControlBox.Action = NavBox.NavAction.SUBMIT; break; default: MessageBox.Show("Status not implemented: " + audit.Status.ToString()); panelButtons.Enabled = true; break; } }
private void Print_PfiChargeOffList_Load(object sender, EventArgs e) { if (_Records.Count > 0) { ProcessingMessage myForm = new ProcessingMessage("Please wait while we generate report."); myForm.Show(); PrintQueue(); myForm.Close(); myForm.Dispose(); MessageBox.Show("Printing Complete", "PFI Charge Off Report", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("No records available to print", "PFI Charge Off Report", MessageBoxButtons.OK, MessageBoxIcon.Warning); } Close(); }
private void Print_AssignPhysicalLocation_Load(object sender, EventArgs e) { if (_Records.Count > 0) { ProcessingMessage myForm = new ProcessingMessage("Please wait while we generate report."); myForm.Show(); PrintQueue(); myForm.Close(); myForm.Dispose(); MessageBox.Show("Printing Complete", "Merchandise Location Assignment", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("No records available to print", "Merchandise Location Assignment", MessageBoxButtons.OK, MessageBoxIcon.Warning); } Close(); }
private void PrintGunBook_Load(object sender, EventArgs e) { if (records.Count > 0) { ProcessingMessage myForm = new ProcessingMessage("Please wait while we generate report."); myForm.TopMost = true; this.rpttitle.Text = this.reportTitle; Point p = new Point((ClientRectangle.Width - rpttitle.Width) / 2, this.rpttitle.Location.Y); this.rpttitle.Location = p; myForm.Show(); PrintQueue(); FileLogger.Instance.logMessage(LogLevel.DEBUG, this, "********** Print Queue Compelted :" + DateTime.Now); myForm.Close(); myForm.Dispose(); MessageBox.Show("Printing Complete", "Gun Book Reports", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("No records available to print", "Gun Book Reports", MessageBoxButtons.OK, MessageBoxIcon.Warning); } Close(); }
private void loginButton_Click(object sender, RoutedEventArgs e) { //Ensure the user name / password are valid strings if (string.IsNullOrEmpty(this.curUserName)) { MessageBox.Show("Please enter a valid employee number (cannot be empty)."); return; } //Ensure the user name contains only digits var isDigits = true; foreach (var c in this.curUserName) { if (!Char.IsDigit(c)) { isDigits = false; break; } } if (!isDigits) { MessageBox.Show("Please enter a valid user name (must contain only digits [0-9])"); return; } var procMsg = new ProcessingMessage("*** VALIDATING LOGIN ***"); procMsg.Show(); //Load pawn security data and authenticate string errTxt; if (!setupInternalData(out errTxt)) { procMsg.Hide(); MessageBox.Show(string.Format("Could not log in to the environment chosen. Error: {0}", errTxt)); if (Application.Current != null) { Application.Current.Shutdown(3); } this.Close(); return; } //Set some more key fields //Log audit message var auditLogData = new Dictionary <string, object>(); auditLogData.Add(DesktopSession.AUDIT_OVERRIDE_COMMENT, string.Format("Employee #{0} logging in to Cashlinx {1} with DSTRViewer", this.curUserName, curEnvString)); AuditLogger.Instance.LogAuditMessage(AuditLogType.OVERRIDE, auditLogData); //Set and show the viewer window procMsg.Hide(); var viewer = new DSTRViewerWindow(this.curEnvString, this.curUserName); viewer.PawnSecData = this.pawnSecData; viewer.EncryptedConfig = this.encConfig; viewer.CouchServer = this.couchServer; viewer.DatabaseServer = this.databaseServer; viewer.CshLnxCred = this.cshLnxCred; viewer.CshLnxDataTools = this.cshLnxDataTools; viewer.PwnSecCred = this.pwnSecCred; viewer.PwnSecDataTools = this.pwnSecDataTools; var res = viewer.ShowDialog(); if (res == false) { this.cleanup(); if (Application.Current != null) { Application.Current.Shutdown(4); } this.Close(); } }
public void Print(string totalCost, string totalTags, bool showMsg = true) { if (ReportData == null || ReportData.Rows.Count == 0) { if (showMsg) { MessageBox.Show("No records available to print", ReportTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); } return; } ControllerForm.Cursor = Cursors.WaitCursor; ProcessingMessage processingForm = new ProcessingMessage("Please wait while we generate report."); processingForm.Show(); ReportObject reportObject = new ReportObject(); reportObject.ReportTitle = ReportTitle; reportObject.ReportStore = GlobalDataAccessor.Instance.CurrentSiteId.StoreNumber; reportObject.ReportTempFile = SecurityAccessor.Instance.EncryptConfig.ClientConfig.GlobalConfiguration.BaseLogPath; reportObject.CreateTemporaryFullName(); PfiPostReport report = new PfiPostReport(ReportData, totalCost, totalTags, ShopDateTime.Instance.ShopDate.ToShortDateString(), Convert.ToDateTime(ShopDateTime.Instance.ShopTime.ToString()), reportObject, PdfLauncher.Instance); if (!report.CreateReport()) { processingForm.Close(); processingForm.Dispose(); ControllerForm.Cursor = Cursors.Default; MessageBox.Show("Failed to generate report", "PFI POST", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //Dictionary<string, string> eDeviceData = GetPrintDeviceData(); if (SecurityAccessor.Instance.EncryptConfig.ClientConfig.ClientConfiguration.PrintEnabled && GlobalDataAccessor.Instance.DesktopSession.LaserPrinter.IsValid) { if (FileLogger.Instance.IsLogInfo) { FileLogger.Instance.logMessage(LogLevel.INFO, "PrintPFIUtilities", "Printing {0} on {1}", ReportTitle, GlobalDataAccessor.Instance.DesktopSession.LaserPrinter); } string strReturnMessage = PrintingUtilities.printDocument( reportObject.ReportTempFileFullName, GlobalDataAccessor.Instance.DesktopSession.LaserPrinter.IPAddress, GlobalDataAccessor.Instance.DesktopSession.LaserPrinter.Port, 1); if (strReturnMessage.IndexOf("SUCCESS", StringComparison.OrdinalIgnoreCase) == -1) { if (FileLogger.Instance.IsLogError) { FileLogger.Instance.logMessage(LogLevel.ERROR, this, "Cannot print " + ReportTitle + " report " + strReturnMessage); } } } processingForm.Close(); processingForm.Dispose(); ControllerForm.Cursor = Cursors.Default; if (showMsg) { MessageBox.Show("Printing Complete", ReportTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/*__________________________________________________________________________________________*/ private void Setup() { IH_CategoryComboBox.SelectedText = "Pawn"; IH_CategoryComboBox.Enabled = false; _ActiveTicketNumber = 0; DataView theData = new DataView(); theData.Table = new DataTable("ItemHistory"); theData.Table.Columns.Add(IH_History_TransactionNumberColumn.Name); theData.Table.Columns.Add(IH_History_StatusDateColumn.Name); theData.Table.Columns.Add(IH_History_ItemStatusColumn.Name); theData.Table.Columns.Add(IH_History_ItemDescriptionColumn.Name); theData.Table.Columns.Add(IH_History_DocType.Name); theData.Table.Columns.Add(IH_History_TktNo.Name); IH_ItemHistoryDataGridView.DataSource = theData; //Get all the customer loans if (GlobalDataAccessor.Instance.DesktopSession.CustomerHistoryLoans == null || GlobalDataAccessor.Instance.DesktopSession.CustomerHistoryLoans.Count == 0) { if (GlobalDataAccessor.Instance.DesktopSession.ActiveCustomer != null) { custNumber = GlobalDataAccessor.Instance.DesktopSession.ActiveCustomer.CustomerNumber; } if (!string.IsNullOrEmpty(custNumber)) { Cursor = Cursors.WaitCursor; procMsgForm = new ProcessingMessage("Retrieving Customer Loan History"); SetButtonState(false); procMsgForm.Show(this); if (!_Setup[0]) { CustomerProcedures.GetCustomerLoanData(GlobalDataAccessor.Instance.DesktopSession, custNumber); } //CustomerProcedures.GetCustomerLoanData(custNumber); /* * bgControl[0] = new AutoResetEvent(false); * bg_tasks[0] = new BackgroundWorker(); * bg_tasks[0].DoWork += bw_getSales; * bg_tasks[0].RunWorkerAsync(); * * bgControl[1] = new AutoResetEvent(false); * bg_tasks[1] = new BackgroundWorker(); * bg_tasks[1].DoWork += bw_getBuys; * bg_tasks[1].RunWorkerAsync(); * * bgControl[2] = new AutoResetEvent(false); * bg_tasks[2] = new BackgroundWorker(); * bg_tasks[2].DoWork += bw_getLayaways; * bg_tasks[2].RunWorkerAsync(); */ //procMsgForm.Dispose(); } } if (GlobalDataAccessor.Instance.DesktopSession.CustomerHistoryLoans != null) { sync_populateGrid(0, GlobalDataAccessor.Instance.DesktopSession.CustomerHistoryLoans, o => o.Items.Count); //addData(theData, (List<CustomerProductDataVO>) CashlinxDesktopSession.Instance.CustomerHistorySales.Cast<CustomerProductDataVO>()); theData.Sort = IH_History_ItemStatusColumn.Name; sortHistoryData(); _Setup[0] = true; IH_AddItemToNewPawnLoan.Enabled = false; if (GlobalDataAccessor.Instance.DesktopSession.ShowOnlyHistoryTabs) { this.customButtonExit.Text = "Exit"; } else { this.customButtonExit.Text = "Cancel"; } } SetButtonState(true); if (procMsgForm != null) { procMsgForm.Close(); } this.Cursor = Cursors.Default; }
private void DownloadFiles() { ProcessingMessage = new ProcessingMessage("Retrieving upload files", 0); ProcessingMessage.Show(); try { string tmpPath = Path.Combine(Application.StartupPath, "tmp"); string trakkerPath = Path.Combine(tmpPath, "uptrak"); string trakkerIdPath = Path.Combine(tmpPath, "trakker.id"); if (!Directory.Exists(tmpPath)) { Directory.CreateDirectory(tmpPath); } FtpHelper ftpHelper = new FtpHelper(FtpHost, FtpUser, FtpPassword); ftpHelper.DownloadFile("tmp_" + ADS.ActiveAudit.StoreNumber + "/uptrak", trakkerPath, false); ftpHelper.DownloadFile("tmp_" + ADS.ActiveAudit.StoreNumber + "/trakker.id", trakkerIdPath, false); string[] fileContents = File.ReadAllLines(trakkerIdPath); if (fileContents.Length == 0 || string.IsNullOrWhiteSpace(fileContents[0])) { ProcessingMessage.Close(); throw new ApplicationException("trakker.id file is empty"); } int trakkerId = Utilities.GetIntegerValue(fileContents[0].Substring(fileContents[0].IndexOf('|') + 1), 0); ProcessingMessage.Hide(); ConfirmTrakker confirmTrakker = new ConfirmTrakker(trakkerId); if (confirmTrakker.ShowDialog() == DialogResult.Cancel) { ProcessingMessage.Close(); return; } ProcessingMessage.Show(); TrakkerFileReader trakkerFileReader = new TrakkerFileReader(trakkerPath); List <TrakkerItem> uploadedItems = trakkerFileReader.ReadFile(); int count = 0; if (uploadedItems.Count > 0) { ADS.beginTransactionBlock(); foreach (TrakkerItem item in uploadedItems) { count++; ProcessingMessage.Message = string.Format("Uploading record {0} of {1}", count, uploadedItems.Count); CommonDatabaseContext dataContext = new CommonDatabaseContext(); InventoryAuditProcedures.UploadTrakkerItem(item, ADS.ActiveAudit.AuditId, trakkerId, ADS.ActiveAudit.StoreNumber, dataContext); if (!dataContext.Result) { ADS.endTransactionBlock(EndTransactionType.ROLLBACK); MessageBox.Show(dataContext.ErrorText); return; } } ADS.endTransactionBlock(EndTransactionType.COMMIT); } ProcessingMessage.Close(); ChangeStatusMessage2("Records Uploaded from Trakker " + trakkerId); ChangeStatusValue2(uploadedItems.Count.ToString()); Uploaded = true; } catch (Exception exc) { ProcessingMessage.Close(); BasicExceptionHandler.Instance.AddException("Failed to upload trakker files", exc); MessageBox.Show(exc.Message); } }
/*__________________________________________________________________________________________*/ private void IH_ProductComboBox_SelectedIndexChanged(object sender, EventArgs e) { if (_Setup[0]) { Cursor = Cursors.WaitCursor; string filter = string.Empty; string docType = null; IH_ItemHistoryDataGridView.ClearSelection(); IH_ItemHistoryDataGridView.CurrentCell = null; var test = GlobalDataAccessor.Instance.DesktopSession.CustomerHistoryPurchases; SetButtonState(false); switch (IH_ProductComboBox.SelectedItem.ToString()) { case "Pawn": docType = "1"; filter = IH_History_DocType.Name + "=" + 1; break; case "Buy": docType = "2"; filter = IH_History_DocType.Name + "=" + 2; procMsgForm = new ProcessingMessage("Retrieving Customer Purchase History"); procMsgForm.Show(this); //async_populateGrid(1, "Retrieving Customer Purchase History", CashlinxDesktopSession.Instance.CustomerHistoryPurchases); if (!_Setup[2]) { PurchaseProcedures.GetCustomerPurchases(custNumber); sync_populateGrid <PurchaseVO>(2, GlobalDataAccessor.Instance.DesktopSession.CustomerHistoryPurchases, o => o.Items.Count); } break; case "Sale": docType = null; //CashlinxDesktopSession.Instance.CustomerHistorySales procMsgForm = new ProcessingMessage("Retrieving Customer Sales History"); procMsgForm.Show(this); filter = IH_History_ItemStatusColumn.Name + "= 'SOLD'"; //async_populateGrid(0, "Retrieving Customer Sales History", CashlinxDesktopSession.Instance.CustomerHistorySales); if (!_Setup[1]) { RetailProcedures.GetCustomerSales(GlobalDataAccessor.Instance.DesktopSession, custNumber); sync_populateGrid <SaleVO>(1, GlobalDataAccessor.Instance.DesktopSession.CustomerHistorySales, o => ((SaleVO)o).RetailItems.Count); } break; case "Layaway": docType = null; filter = IH_History_ItemStatusColumn.Name + "= 'On Layaway'"; procMsgForm = new ProcessingMessage("Retrieving Customer Layaway History"); procMsgForm.Show(this); //async_populateGrid(2, "Retrieving Customer Layaway History", CashlinxDesktopSession.Instance.CustomerHistoryLayaways); if (!_Setup[3]) { RetailProcedures.GetCustomerLayaways(GlobalDataAccessor.Instance.DesktopSession, custNumber); sync_populateGrid <LayawayVO>(3, GlobalDataAccessor.Instance.DesktopSession.CustomerHistoryLayaways, o => ((LayawayVO)o).RetailItems.Count); } break; case "Refund": docType = null; filter = IH_History_ItemStatusColumn.Name + "= 'REF'"; break; case "All": procMsgForm = new ProcessingMessage("Retrieving Customer Item History"); procMsgForm.Show(this); if (!_Setup[1]) { RetailProcedures.GetCustomerSales(GlobalDataAccessor.Instance.DesktopSession, custNumber); sync_populateGrid <SaleVO>(1, GlobalDataAccessor.Instance.DesktopSession.CustomerHistorySales, o => ((SaleVO)o).RetailItems.Count); } if (!_Setup[2]) { PurchaseProcedures.GetCustomerPurchases(custNumber); sync_populateGrid <PurchaseVO>(2, GlobalDataAccessor.Instance.DesktopSession.CustomerHistoryPurchases, o => o.Items.Count); } if (!_Setup[3]) { RetailProcedures.GetCustomerLayaways(GlobalDataAccessor.Instance.DesktopSession, custNumber); sync_populateGrid <LayawayVO>(3, GlobalDataAccessor.Instance.DesktopSession.CustomerHistoryLayaways, o => ((LayawayVO)o).RetailItems.Count); } //async_populateGrid(0, "Retrieving Customer Sales History", CashlinxDesktopSession.Instance.CustomerHistorySales); //async_populateGrid(1, "Retrieving Customer Purchase History", CashlinxDesktopSession.Instance.CustomerHistoryPurchases); //async_populateGrid(2, "Retrieving Customer Layaway History", CashlinxDesktopSession.Instance.CustomerHistoryLayaways); break; } //-- The filter doesn't seem to handle the very last row ((DataView)IH_ItemHistoryDataGridView.DataSource).RowFilter = filter; IH_ItemHistoryDataGridView.ClearSelection(); IH_ItemHistoryDataGridView.CurrentCell = null; if (IH_ItemHistoryDataGridView.Rows.Count > 0 && docType != null && IH_ItemHistoryDataGridView.Rows[IH_ItemHistoryDataGridView.Rows.Count - 1].Cells[IH_History_DocType.Name].Value != null) { if ((string)IH_ItemHistoryDataGridView.Rows[IH_ItemHistoryDataGridView.Rows.Count - 1].Cells[IH_History_DocType.Name].Value != docType) { IH_ItemHistoryDataGridView.Rows[IH_ItemHistoryDataGridView.Rows.Count - 1].Visible = false; } else { IH_ItemHistoryDataGridView.Rows[IH_ItemHistoryDataGridView.Rows.Count - 1].Visible = true; } } else if (IH_ItemHistoryDataGridView.Rows.Count > 0) { IH_ItemHistoryDataGridView.Rows[IH_ItemHistoryDataGridView.Rows.Count - 1].Visible = true; switch (IH_ProductComboBox.SelectedItem.ToString()) { case "Sale": if ((string)IH_ItemHistoryDataGridView.Rows[IH_ItemHistoryDataGridView.Rows.Count - 1].Cells[this.IH_History_ItemStatusColumn.Name].Value != "SOLD") { IH_ItemHistoryDataGridView.Rows[IH_ItemHistoryDataGridView.Rows.Count - 1].Visible = false; } break; case "Layaway": if ((string)IH_ItemHistoryDataGridView.Rows[IH_ItemHistoryDataGridView.Rows.Count - 1].Cells[this.IH_History_ItemStatusColumn.Name].Value != "On Layaway") { IH_ItemHistoryDataGridView.Rows[IH_ItemHistoryDataGridView.Rows.Count - 1].Visible = false; } break; case "Refund": if ((string)IH_ItemHistoryDataGridView.Rows[IH_ItemHistoryDataGridView.Rows.Count - 1].Cells[this.IH_History_ItemStatusColumn.Name].Value != "REF") { IH_ItemHistoryDataGridView.Rows[IH_ItemHistoryDataGridView.Rows.Count - 1].Visible = false; } break; } } sortHistoryData(); if (procMsgForm != null) { procMsgForm.Close(); } Cursor = Cursors.Default; SetButtonState(true); } }
public static void RunApplication() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); try { var pwnSecMsg = new ProcessingMessage("* PAWN SECURITY LOADING *"); pwnSecMsg.Show(); // decrypt pawnsec information from config file string key = Common.Properties.Resources.PrivateKey; string dbHost = StringUtilities.Decrypt( Properties.Settings.Default.PawnSecDBHost, key, true); string dbPassword = StringUtilities.Decrypt( Properties.Settings.Default.PawnSecDBPassword, key, true); string dbPort = StringUtilities.Decrypt( Properties.Settings.Default.PawnSecDBPort, key, true); string dbSchema = StringUtilities.Decrypt( Properties.Settings.Default.PawnSecDBSchema, key, true); string dbService = StringUtilities.Decrypt( Properties.Settings.Default.PawnSecDBService, key, true); string dbUser = StringUtilities.Decrypt( Properties.Settings.Default.PawnSecDBUser, key, true); if (!(string.IsNullOrEmpty(dbHost) || string.IsNullOrEmpty(dbPassword) || string.IsNullOrEmpty(dbPort) || string.IsNullOrEmpty(dbSchema) || string.IsNullOrEmpty(dbService) || string.IsNullOrEmpty(dbUser))) { // create connection with PawnSec SecurityAccessor.Instance.InitializeConnection( dbHost, dbPassword, dbPort, dbSchema, dbService, dbUser); pwnSecMsg.Message = "* PAWN SECURITY PROCESSING *"; // retrieve data from PawnSec if (!SecurityAccessor.Instance.RetrieveSecurityData(Resources.PrivateKey, ComputeAppHash(), true, PawnSecApplication.Cashlinx)) { //SecurityAccessor.Instance.Close(); //Application.Exit(); pwnSecMsg.Close(); pwnSecMsg.Dispose(); } else { pwnSecMsg.Close(); pwnSecMsg.Dispose(); //DO NOT REMOVE THE LINE OF CODE BELOW GlobalDataAccessor.Instance.DesktopSession = CashlinxDesktopSession.Instance; //DO NOT REMOVE THE LINE OF CODE ABOVE Application.Run(new Pawn.Forms.NewDesktop()); } } } catch (Exception eX) { MessageBox.Show("Exception caught in CashlinxDesktop.Program during Application.Run: " + "\nMessage : " + eX.Message + "\nStack Trace: " + eX.StackTrace + "\nTarget Site: " + eX.TargetSite + "\nSource : " + eX.Source + "\nData : " + eX.Data + "\nTerminating Application!", "Application Exception", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); } }
private void printButton_Click(object sender, EventArgs e) { // Have extra enumeration to go ProKnow with only ONE call List <CustomerProductDataVO> productObjects = new List <CustomerProductDataVO>(); List <String> customerNames = new List <String>(); List <int> tickets = new List <int>(gvLoans.Rows.Count); Cursor = Cursors.WaitCursor; try { // improve efficiency -- only return new numbers if these have been previously loaded foreach (DataGridViewRow myRow in gvLoans.Rows) { if (Convert.ToBoolean(myRow.Cells[colSelect.Name].Value) && !myRow.Cells[colSelect.Name].ReadOnly) { int iTktNumber = Utilities.GetIntegerValue(myRow.Cells[colNumber.Name].Value, 0); if (iTktNumber != 0) { tickets.Add(iTktNumber); } } } string errorCode; string errorTxt; DateTime dt = Convert.ToDateTime(dateCalendarSearchDate.SelectedDate); StoreLoans.Get_PFI_Details(CashlinxDesktopSession.Instance.CurrentSiteId.StoreNumber, dt, tickets, out _PawnLoans, out _PawnApplications, out _CustomerVOs, out _Purchases, out errorCode, out errorTxt); foreach (DataGridViewRow myRow in gvLoans.Rows) { if (Convert.ToBoolean(myRow.Cells[colSelect.Name].Value) && !myRow.Cells[colSelect.Name].ReadOnly) { int iTktNumber = Utilities.GetIntegerValue(myRow.Cells[colNumber.Name].Value, 0); string customer = (string)myRow.Cells[4].Value; PawnLoan pawnLoan = null; if (myRow.Cells[colType.Name].Value.Equals("LOAN")) { if (_PawnLoans != null) { pawnLoan = (from ploan in _PawnLoans where ploan.TicketNumber == iTktNumber && ploan.ProductType == ProductType.PAWN.ToString() select ploan).FirstOrDefault(); } if (pawnLoan != null) { LoanPrinted loanPrinted = _PrintedLoans.Find( l => l.LoanNumber == iTktNumber && l.RefType == 1); loanPrinted.bPrinted = true; _PrintedLoans.RemoveAll( l => l.LoanNumber == iTktNumber && l.RefType == 1); _PrintedLoans.Add(loanPrinted); productObjects.Add(pawnLoan); customerNames.Add(customer); } } else { PurchaseVO purchaseObj = null; if (_Purchases != null) { purchaseObj = (from purchase in _Purchases where purchase.TicketNumber == iTktNumber select purchase).FirstOrDefault(); } if (purchaseObj != null) { LoanPrinted loanPrinted = _PrintedLoans.Find(l => l.LoanNumber == iTktNumber && l.RefType == 2); loanPrinted.bPrinted = true; _PrintedLoans.RemoveAll(l => l.LoanNumber == iTktNumber && l.RefType == 2); _PrintedLoans.Add(loanPrinted); productObjects.Add(purchaseObj); customerNames.Add(customer); } } } } if (productObjects.Count() > 0) { ProcessingMessage processingForm = new ProcessingMessage("Please wait while we generate report."); try { processingForm.Show(); this.Cursor = Cursors.WaitCursor; //----- Tracy 12/15/2010 List <int> lstTicketNumbers = new List <int>(); List <string> lstRefTypes = new List <string>(); string sErrorCode; string sErrorText; foreach (CustomerProductDataVO o in productObjects) { lstTicketNumbers.Add(o.TicketNumber); lstRefTypes.Add(o.ProductType == "PAWN" ? "1" : "2"); } if (lstTicketNumbers.Count > 0 && !StoreLoans.UpdateTempStatus( lstTicketNumbers, StateStatus.PFIW, CashlinxDesktopSession.Instance.CurrentSiteId.StoreNumber, true, lstRefTypes, out sErrorCode, out sErrorText)) { MessageBox.Show("Error updating PFI Verify. " + sErrorText, "PFI Verification Update", MessageBoxButtons.OK, MessageBoxIcon.Warning); } //------- Tracy 12/15/2010 var context = new PickingSlipHelper().GetPickingSlipReportContext(productObjects, customerNames, true); var reportObject = new ReportObject(); reportObject.ReportTempFile = SecurityAccessor.Instance.EncryptConfig.ClientConfig.GlobalConfiguration.BaseLogPath; reportObject.CreateTemporaryFullName(); context.ReportObject = reportObject; var pickingSlip = new PickingSlip(context); if (!pickingSlip.CreateReport()) { processingForm.Close(); processingForm.Dispose(); this.Cursor = Cursors.Default; MessageBox.Show("Failed to generate report", "Picking Slip", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //Dictionary<string, string> eDeviceData = new PrintUtilities().GetPrintDeviceData("pfipickslip"); if (SecurityAccessor.Instance.EncryptConfig.ClientConfig.ClientConfiguration.PrintEnabled && GlobalDataAccessor.Instance.DesktopSession.LaserPrinter.IsValid) { if (FileLogger.Instance.IsLogInfo) { FileLogger.Instance.logMessage(LogLevel.INFO, "PFI_SelectLoan", "Printing PFI picking slip on {0}", GlobalDataAccessor.Instance.DesktopSession.LaserPrinter); } string strReturnMessage = PrintingUtilities.printDocument(reportObject.ReportTempFileFullName, GlobalDataAccessor.Instance.DesktopSession.LaserPrinter.IPAddress, GlobalDataAccessor.Instance.DesktopSession.LaserPrinter.Port, 1); if (!strReturnMessage.Contains("SUCCESS")) { FileLogger.Instance.logMessage(LogLevel.ERROR, this, "Cannot print picking slip : " + strReturnMessage); } } processingForm.Close(); processingForm.Dispose(); this.Cursor = Cursors.Default; MessageBox.Show("Printing Complete", "Picking Slip", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception exc) { FileLogger.Instance.logMessage(LogLevel.ERROR, this, exc.Message); processingForm.Close(); processingForm.Dispose(); this.Cursor = Cursors.Default; MessageBox.Show(exc.Message); } } //else //{ // continueButton.Enabled = false; //} continueButton.Enabled = true; } catch (Exception exp) { MessageBox.Show("Error in printing. Retry. (" + exp.Message + ")", "PFI Printing"); } Cursor = Cursors.Default; }
/* * select storenumber, storage_id, storage_date, storage_time from ccsowner.pawndocumentregistry pdr * where PDR.STORENUMBER = '02030' * and PDR.DOC_TYPE = 'PDF' * and PDR.RECEIPTDETAIL_NUMBER = 0 * and PDR.TICKET_NUMBER = 0 * and PDR.CUSTOMERNUMBER is null * and PDR.STORAGE_DATE > (sysdate-90); * */ private void submitStoreButton_Click(object sender, RoutedEventArgs e) { if (this.storeCalendar != null) { this.storeCalendar.IsEnabled = false; } //Check file time - we do not want to hit production if the time limit is still in effect TupleType <long, long, string> timeData; if (TimeFileExists() && WithinTimeLimit(out timeData)) { var diffTime = timeData.Right; MessageBox.Show("You are still within the time restriction limit. " + Environment.NewLine + " The application will now close.", "*** TIME LIMIT WARNING ***"); Application.Current.Shutdown(); this.Close(); return; } if (!string.IsNullOrEmpty(this.selectedStore)) { //Check to see if the store is in the list if (this.storeList.BinarySearch(this.selectedStore) < 0) { MessageBox.Show("That store has not yet been converted to Cashlinx. Please enter a different store number."); return; } string errTxt; var dTools = this.CshLnxDataTools; this.submitStoreButton.IsEnabled = false; var ninetyDaysAgo = DateTime.Now.Date.Subtract(new TimeSpan(90, 0, 0, 0)); var toDateConstruct = string.Format( "to_date('{0}/{1}/{2}', 'MM/DD/YYYY')", ninetyDaysAgo.Date.Month.ToString().PadLeft(2, '0'), ninetyDaysAgo.Date.Day.ToString().PadLeft(2, '0'), ninetyDaysAgo.Date.Year.ToString().PadLeft(4, '0')); if (!InitCouchDB()) { MessageBox.Show("Cannot connect to couch server! Exiting...", "Exit Warning"); Application.Current.Shutdown(); this.DialogResult = false; this.Close(); } var procMsg = new ProcessingMessage("*** PLEASE WAIT - FINDING DOCUMENTS ***"); procMsg.Show(); if (!DataAccessService.ExecuteQuery( false, string.Format( "select storage_id, storage_time from ccsowner.pawndocumentregistry where storenumber = '{0}' " + "and receiptdetail_number = 0 and ticket_number = 0 and doc_type = 'PDF' " + "and customernumber is null and storage_date > {1} order by storage_time desc", this.selectedStore, toDateConstruct), "ccsowner.pawndocumentregistry", PawnStoreProcedures.CCSOWNER, out dstrStorageData, ref dTools)) { procMsg.Hide(); errTxt = string.Format( "Could not find any DSTR documents for that store"); showError(errTxt); this.submitStoreButton.IsEnabled = true; return; } if (dstrStorageData == null || dstrStorageData.NumberRows <= 0) { procMsg.Hide(); errTxt = string.Format( "Could not find any DSTR documents to view"); showError(errTxt); this.submitStoreButton.IsEnabled = true; return; } //Collect dates into a temporary map this.dateStorageMap.Clear(); bool foundValidDoc = false; for (var j = 0; j < dstrStorageData.NumberRows; ++j) { DataReturnSetRow dRow; if (!dstrStorageData.GetRow(j, out dRow)) { continue; } var dRowDate = Utilities.GetDateTimeValue(dRow.GetData("STORAGE_TIME"), DateTime.Now.Date); List <PairType <string, Document> > storageIds; var ticksKey = dRowDate.Date.Ticks; if (CollectionUtilities.isNotEmptyContainsKey(this.dateStorageMap, ticksKey)) { storageIds = this.dateStorageMap[ticksKey]; } else { storageIds = new List <PairType <string, Document> >(); this.dateStorageMap.Add(ticksKey, storageIds); } //Get the storage id first var storageId = Utilities.GetStringValue(dRow.GetData("STORAGE_ID"), string.Empty); Document doc; if (IsDocumentDSTR(storageId, out doc)) { storageIds.Add(new PairType <string, Document>(storageId, doc)); foundValidDoc = true; } } procMsg.Hide(); if (!foundValidDoc) { procMsg.Hide(); errTxt = string.Format( "Could not find any DSTR documents to view for this store"); showError(errTxt); this.submitStoreButton.IsEnabled = true; return; } //Update calendar var today = DateTime.Now.Date; var tomorrowDate = DateTime.Now.Date.Add(new TimeSpan(1, 0, 0, 0)); //Clear calendar black out dates this.storeCalendar.BlackoutDates.Clear(); //Black out calendar from start of time to 90 days ago this.storeCalendar.BlackoutDates.Add(new CalendarDateRange(DateTime.MinValue.Date, ninetyDaysAgo.Date)); //Black out calendar from tomorrow to the end of time this.storeCalendar.BlackoutDates.Add(new CalendarDateRange(tomorrowDate.Date, DateTime.MaxValue.Date)); //Ensure store calendar is set to single date mode this.storeCalendar.SelectionMode = CalendarSelectionMode.SingleDate; //Ensure calendar is on today's date this.storeCalendar.SelectedDate = null; //Go through the ninety day range to today and black out dates we do not have storage ids for... var curDay = ninetyDaysAgo.Date; while (curDay.Date.CompareTo(today.Date) < 0) { if (!CollectionUtilities.isNotEmptyContainsKey(this.dateStorageMap, curDay.Date.Ticks)) { this.storeCalendar.BlackoutDates.Add(new CalendarDateRange(curDay.Date)); if (FileLogger.Instance.IsLogDebug) { FileLogger.Instance.logMessage(LogLevel.DEBUG, this, "Blackout date found = " + curDay.Date.ToLongDateString() + ", Ticks = " + curDay.Date.Ticks); } } else { var idList = this.dateStorageMap[curDay.Date.Ticks]; if (CollectionUtilities.isEmpty(idList)) { this.storeCalendar.BlackoutDates.Add(new CalendarDateRange(curDay.Date)); if (FileLogger.Instance.IsLogWarn) { FileLogger.Instance.logMessage(LogLevel.WARN, this, "Date with no DSTR found = " + curDay.Date.ToLongDateString() + ", Ticks = " + curDay.Date.Ticks); } } else { if (FileLogger.Instance.IsLogDebug) { FileLogger.Instance.logMessage(LogLevel.DEBUG, this, "Valid date found = " + curDay.Date.ToLongDateString() + ", Ticks = " + curDay.Date.Ticks); } } } //Increment date curDay = curDay.Date.Add(new TimeSpan(1, 0, 0, 0)); } //Enable calendar this.storeCalendar.IsEnabled = true; } }
private void executeQueryButton_Click(object sender, EventArgs e) { this.saveButton.Enabled = false; if (!GlobalDataAccessor.Instance.IsDataAccessorValid()) { MessageBox.Show("There is no valid database connection available at this time. Please exit and try again"); return; } var qStore = AuditQueriesSession.Instance.GetQueryStorage(); var selQ = AuditQueriesSession.Instance.SelectedQueryId; if (qStore == null) { MessageBox.Show("There are no valid queries defined for this audit query session. Please exit and try again."); return; } //Update the parameters for this query bool flagInvalid = false; foreach (var p in this.auditParameters) { if (!qStore.UpdateQueryParameter(selQ, p.ParameterName, p.ParameterValue)) { flagInvalid = true; break; } } if (flagInvalid) { MessageBox.Show("Could not execute the query due to an invalid parameter."); return; } try { //Extract the populated query to execute var qExec = qStore.GetPopulatedQuery(selQ); if (!string.IsNullOrEmpty(qExec) && qExec.Contains("?") == false) { var pMesg = new ProcessingMessage("* QUERY PROCESSING - PLEASE WAIT *", 100000); pMesg.Show(); if (!GlobalDataAccessor.Instance.OracleDA.issueSqlTextSelectCommand(qExec, string.Empty, CommandBehavior.Default, null, out this.resultTable)) { pMesg.Close(); pMesg.Dispose(); MessageBox.Show("Failed to execute query! Please try again"); } else { //Check the number of rows and columns returned, if nothing, query was empty if (this.resultTable != null && this.resultTable.Rows.Count > 0 && this.resultTable.Columns.Count > 0) { pMesg.Close(); pMesg.Dispose(); MessageBox.Show("Query was successful!"); //Put the datatable in the view this.queryResultDataGridView.DataSource = this.resultBindingSource; this.resultBindingSource.DataSource = this.resultTable; this.queryResultDataGridView.Update(); this.saveButton.Enabled = true; } else { pMesg.Close(); pMesg.Dispose(); MessageBox.Show("Query returned zero rows. Please try again with different parameters!"); } } } else { MessageBox.Show("The query parameters are not specified properly. Please try again"); } } catch (SystemException rEx) { MessageBox.Show("Query was not successful and/or returned zero rows. Please try again." + Environment.NewLine + "Error Details: " + rEx, "AuditQueryApp Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (ApplicationException aEx) { MessageBox.Show("Query was not successful and/or returned zero rows. Please try again." + Environment.NewLine + "Error Details: " + aEx, "AuditQueryApp Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception eX) { MessageBox.Show("Query was not successful and/or returned zero rows. Please try again." + Environment.NewLine + "Error Details: " + eX, "AuditQueryApp Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } }