public static string StaffWithBiggestTransaction(ref TillEngine.TillEngine tEngine) { string[] sTransactionNumbers = tEngine.GetListOfTransactionNumbers(); float fHighest = 0.0f; string sStaffWithHighest = ""; for (int i = 0; i < sTransactionNumbers.Length; i++) { string[,] sTransactionInfo = tEngine.GetTransactionInfo(sTransactionNumbers[i]); int nItemsInTransaction = Convert.ToInt32(sTransactionInfo[0, 0]); if (sTransactionInfo[0, 3] == "SALE") { float fAmount = 0.0f; for (int x = 1; x <= nItemsInTransaction; x++) { fAmount += (float)Convert.ToDecimal(sTransactionInfo[x, 2]); fAmount = tEngine.fFixFloatError(fAmount); } if (fAmount > fHighest) { fHighest = fAmount; sStaffWithHighest = tEngine.ReturnSensibleDateTimeString(sTransactionInfo[0, 2])[1]; } } } if (fHighest == 0.0f) { return("No transactions"); } else { return(sStaffWithHighest + " - " + tEngine.GetCurrencySymbol() + TillEngine.TillEngine.FormatMoneyForDisplay(fHighest)); } }
/// <summary> /// Initialises the form /// </summary> /// <param name="s">The size of the form</param> /// <param name="tE">A reference to the TillEngine</param> /// <param name="pStartLocation">The start location of the form</param> /// <param name="sInstruction">The purpose of this form (to look at transactions, void transactions etc)</param> public frmLookupTransactions(Size s, ref TillEngine.TillEngine tE, Point pStartLocation, string sInstruction) { cFrmBackColour = Properties.Settings.Default.cFrmBackColour; cFrmForeColour = Properties.Settings.Default.cFrmForeColour; this.ForeColor = cFrmForeColour; this.BackColor = cFrmBackColour; this.FormBorderStyle = FormBorderStyle.None; this.Size = s; this.StartPosition = FormStartPosition.Manual; this.Location = pStartLocation; tillEngine = tE; sFontName = Properties.Settings.Default.sFontName; if (sInstruction != null) { if (sInstruction == "REMOVE_TRANSACTION") { sWindowTitle = "REMOVE TRANSACTION"; bVoidTransactions = false; } else if (sInstruction == "VOID_TRANSACTION") { sWindowTitle = "Void Transaction"; bVoidTransactions = true; } else if (sInstruction == "REPRINT_RECEIPT") { sWindowTitle = "Reprint Receipt"; bVoidTransactions = false; } } SetupForm(); GetListOfTransactions(); }
public static float[] GetAmountsThatStaffHaveSold(ref TillEngine.TillEngine te) { float[] fAmounts = new float[100]; for (int i = 0; i < 100; i++) { fAmounts[i] = WorkOutHowMuchStaffMemberHasSold(i, ref te); } return(fAmounts); }
/// <summary> /// Initialises the Account Selection form /// </summary> /// <param name="te"></param> public frmAccSel(ref TillEngine.TillEngine te) { this.BackColor = Properties.Settings.Default.cFrmForeColour; this.ForeColor = Properties.Settings.Default.cFrmBackColour; cFrmBackColour = Properties.Settings.Default.cFrmForeColour; cFrmForeColour = Properties.Settings.Default.cFrmBackColour; this.FormBorderStyle = FormBorderStyle.None; this.Size = new Size(640, 480); this.StartPosition = FormStartPosition.CenterScreen; tEngine = te; sFontName = Properties.Settings.Default.sFontName; DrawForm(); GetAccountsAndDisplay(); }
// End of Description Search public frmSearchForItem(ref TillEngine.TillEngine te) { this.FormBorderStyle = FormBorderStyle.None; cFrmBackColour = Properties.Settings.Default.cFrmForeColour; cFrmForeColour = Properties.Settings.Default.cFrmBackColour; this.BackColor = cFrmBackColour; this.ForeColor = cFrmForeColour; this.StartPosition = FormStartPosition.CenterScreen; this.Size = new Size(640, 480); sFontName = Properties.Settings.Default.sFontName; tTillCat = new Table("TILLCAT.DBF"); DrawForm(FormState.CategoryLookup); fsCurrentFormState = FormState.CategoryLookup; tEngine = te; this.KeyDown += new KeyEventHandler(frm_KeyDown); }
/// <summary> /// Initialises the form /// </summary> /// <param name="te">A reference to the TillEngine</param> /// <param name="pLoc">The location on screen to place the form</param> /// <param name="s">The size of the form</param> public frmMoneyInTill(ref TillEngine.TillEngine te, Point pLoc, Size s) { cFrmBackColour = Properties.Settings.Default.cFrmBackColour; cFrmForeColour = Properties.Settings.Default.cFrmForeColour; this.BackColor = cFrmBackColour; this.ForeColor = cFrmForeColour; this.StartPosition = FormStartPosition.Manual; this.Location = pLoc; this.Size = s; this.FormBorderStyle = FormBorderStyle.None; this.Paint += new PaintEventHandler(frmMoneyInTill_Paint); this.KeyDown += new KeyEventHandler(frmMoneyInTill_KeyDown); sFontName = Properties.Settings.Default.sFontName; tEngine = te; SetupFormLayout(); DisplayMoneyInTill(); }
public frmSearchForItemV2(ref TillEngine.TillEngine te) { this.FormBorderStyle = FormBorderStyle.None; this.BackColor = GTill.Properties.Settings.Default.cFrmForeColour; this.ForeColor = GTill.Properties.Settings.Default.cFrmBackColour; this.Size = new Size(1024, 700); this.StartPosition = FormStartPosition.CenterScreen; this.DoubleBuffered = true; iResults = new TillEngine.Item[0]; tEngine = te; pItems = new ParentItems[0]; this.Paint += new PaintEventHandler(frmLookupTransactionsV2_Paint); this.KeyDown += new KeyEventHandler(frmLookupTransactionsV2_KeyDown); this.FormClosed += new FormClosedEventHandler(frmSearchForItemV2_FormClosed); tmrCursorBlink = new Timer(); tmrCursorBlink.Interval = 500; tmrCursorBlink.Tick += new EventHandler(tmrCursorBlink_Tick); tmrCursorBlink.Enabled = true; }
public frmCategorySelect(ref TillEngine.TillEngine te) { tEngine = te; this.FormBorderStyle = FormBorderStyle.None; this.StartPosition = FormStartPosition.CenterScreen; this.BackColor = GTill.Properties.Settings.Default.cFrmBackColour; this.ForeColor = GTill.Properties.Settings.Default.cFrmForeColour; this.Size = new Size(640, 480); lbCategories = new ListBox(); lbCategories.Location = new Point(15, 15); lbCategories.Size = new Size(this.Width - 30, this.Height - 30); lbCategories.Font = new Font(GTill.Properties.Settings.Default.sFontName, 16.0f); lbCategories.BorderStyle = BorderStyle.None; lbCategories.KeyDown += new KeyEventHandler(lbCategories_KeyDown); this.Controls.Add(lbCategories); UpdateListBoxWithCategories(); }
/// <summary> /// Initialises the form /// </summary> /// <param name="s">The size of the form</param> /// <param name="tE">A reference to the TillEngine</param> /// <param name="pStartLocation">The start location of the form</param> /// <param name="sInstruction">The purpose of this form (to look at transactions, void transactions etc)</param> public frmLookupTransactions(Size s, ref TillEngine.TillEngine tE, Point pStartLocation, string sInstruction) { cFrmBackColour = Properties.Settings.Default.cFrmBackColour; cFrmForeColour = Properties.Settings.Default.cFrmForeColour; this.ForeColor = cFrmForeColour; this.BackColor = cFrmBackColour; this.FormBorderStyle = FormBorderStyle.None; this.Size = s; this.StartPosition = FormStartPosition.Manual; this.Location = pStartLocation; tillEngine = tE; sFontName = Properties.Settings.Default.sFontName; if (sInstruction != null) { if (sInstruction == "REMOVE_TRANSACTION") { if (MessageBox.Show("WARNING: Once you select a transaction in this window (by pressing enter), the transaction will be totally removed.\n\nThe bytes are deleted from the dBase files, not just hidden.\n\nIf you wish to continue with the delete, select no. Selecing yes cancels this operation", "Remove Transaction", MessageBoxButtons.YesNo) == DialogResult.Yes) { this.Close(); } else { sWindowTitle = "REMOVE TRANSACTION"; bVoidTransactions = false; } } else if (sInstruction == "VOID_TRANSACTION") { sWindowTitle = "Void Transaction"; bVoidTransactions = true; } else if (sInstruction == "REPRINT_RECEIPT") { sWindowTitle = "Reprint Receipt"; bVoidTransactions = false; } } SetupForm(); GetListOfTransactions(); }
public static string StaffThatHasSoldTheMost(ref TillEngine.TillEngine tEngine) { float fTotal = 0.0f; float[] fAmountSold = new float[10]; for (int i = 0; i < fAmountSold.Length; i++) { fAmountSold[i] = WorkOutHowMuchStaffMemberHasSold(i, ref tEngine); fTotal += fAmountSold[i]; fTotal = tEngine.fFixFloatError(fTotal); } int nMaxSlot = 0; for (int i = 0; i < fAmountSold.Length; i++) { if (fAmountSold[i] > fAmountSold[nMaxSlot]) { nMaxSlot = i; } } try { if (fTotal != 0.0f) { float fPercentage = (100 / fTotal) * fAmountSold[nMaxSlot]; fPercentage = tEngine.fFixFloatError(fPercentage); return(tEngine.GetStaffName(nMaxSlot) + " - " + tEngine.GetCurrencySymbol() + TillEngine.TillEngine.FormatMoneyForDisplay(fAmountSold[nMaxSlot]) + " (" + TillEngine.TillEngine.FormatMoneyForDisplay(fPercentage) + "% of total)"); } else { return("No transactions"); } } catch { return("No transactions"); } }
public static string StaffThatHasSoldHighestQuantityOfItem(ref TillEngine.TillEngine tEngine) { int[] nQuantitySold = new int[10]; int nTotalSold = 0; for (int i = 0; i < nQuantitySold.Length; i++) { nQuantitySold[i] = WorkOutQuantityOfItemStaffMemberHasSold(i, ref tEngine); nTotalSold += nQuantitySold[i]; } int nHighest = 0; for (int i = 0; i < nQuantitySold.Length; i++) { if (nQuantitySold[nHighest] < nQuantitySold[i]) { nHighest = i; } } try { if (nTotalSold != 0) { float fPercentage = (100 / (float)nTotalSold) * nQuantitySold[nHighest]; fPercentage = TillEngine.TillEngine.FixFloatError(fPercentage); return(tEngine.GetStaffName(nHighest) + " - " + nQuantitySold[nHighest].ToString() + " item(s) (" + TillEngine.TillEngine.FormatMoneyForDisplay(fPercentage) + "% of total)"); } else { return("No transactions"); } } catch { return("No transactions"); } }
public void UpdateTransaction(ref TillEngine.TillEngine te, string[] sNonItems) { tEngine = te; sNonItemDisplayArray = sNonItems; }
private static float WorkOutHowMuchStaffMemberHasSold(int nStaffMemberNumber, ref TillEngine.TillEngine tEngine) { string[] sTransactionNumbers = tEngine.GetListOfTransactionNumbers(); float fHighest = 0.0f; string sStaffWithHighest = ""; for (int i = 0; i < sTransactionNumbers.Length; i++) { string[,] sTransactionInfo = tEngine.GetTransactionInfo(sTransactionNumbers[i]); int nItemsInTransaction = Convert.ToInt32(sTransactionInfo[0, 0]); if (sTransactionInfo[0, 3] == "SALE") { float fAmount = 0.0f; for (int x = 1; x <= nItemsInTransaction; x++) { fAmount += (float)Convert.ToDecimal(sTransactionInfo[x, 2]); fAmount = tEngine.fFixFloatError(fAmount); } sStaffWithHighest = tEngine.ReturnSensibleDateTimeString(sTransactionInfo[0, 2])[1]; if (tEngine.GetStaffName(nStaffMemberNumber).ToUpper() == sStaffWithHighest.ToUpper()) { fHighest += fAmount; } } } return(tEngine.fFixFloatError(fHighest)); }
private static int WorkOutQuantityOfItemStaffMemberHasSold(int nStaffMemberNumber, ref TillEngine.TillEngine tEngine) { string[] sTransactionNumbers = tEngine.GetListOfTransactionNumbers(); int nHighest = 0; string sStaffWithHighest = ""; for (int i = 0; i < sTransactionNumbers.Length; i++) { string[,] sTransactionInfo = tEngine.GetTransactionInfo(sTransactionNumbers[i]); int nItemsInTransaction = Convert.ToInt32(sTransactionInfo[0, 0]); if (sTransactionInfo[0, 3] == "SALE") { int nCurrentItems = 0; for (int x = 1; x <= nItemsInTransaction; x++) { nCurrentItems += Convert.ToInt32(sTransactionInfo[x, 4]); } sStaffWithHighest = tEngine.ReturnSensibleDateTimeString(sTransactionInfo[0, 2])[1]; if (tEngine.GetStaffName(nStaffMemberNumber).ToUpper() == sStaffWithHighest.ToUpper()) { nHighest += nCurrentItems; } } } return(nHighest); }
/// <summary> /// Cashes up the till /// </summary> public void CashUp() { try { // Open till drawer OpenTillDrawer(false); //ApplyCreditCardDiscs(); // Check what to do if it's a Sunday if (IsItSunday && System.Windows.Forms.MessageBox.Show("Today is Sunday. Should I skip cashing up? (If you're unsure, choose yes)", "Sunday", System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { return; } string sDateToday = tRepData.GetRecordFrom(0)[1].TrimEnd('\0'); tRepData.EditRecordData(0, 2, "2"); // Change the date REPQTY to 2 // Sort out START and END Records string[] sEnd = tRepData.GetRecordFrom("END", 1); float fStartValue = FixFloatError((float)Convert.ToDecimal(sEnd[3].TrimEnd('\0')) + 0.01f); // Add SALES Record /* * string[] sNoTran = tRepData.GetRecordFrom("NOTRAN", 1); * string[] sSales = new string[sNoTran.Length]; * Array.Copy(sNoTran, sSales, sNoTran.Length); * sSales[1] = "SALES"; * sSales[4] = ""; * tRepData.AddRecord(sSales); * // Sales record added * tRepData.SaveToFile(sRepDataFileLoc);*/ // Fixed SALES record code int nOfSalesRecords = 0; string[,] sSales = tTHDR.SearchAndGetAllMatchingRecords(4, "SALE", ref nOfSalesRecords); float fSalesAmount = 0.0f; for (int i = 0; i < nOfSalesRecords; i++) { fSalesAmount += (float)Convert.ToDecimal(sSales[i, 3]); fSalesAmount = TillEngine.FixFloatError(fSalesAmount); } string[] sToAdd = { "CR", "SALES", nOfSalesRecords.ToString(), fSalesAmount.ToString(), "" }; tRepData.AddRecord(sToAdd); // Remove removed transactions records int nTranNum = 0; do { nTranNum = 0; tRepData.SearchForRecord("RE", 0, ref nTranNum); if (nTranNum != 0) { tRepData.DeleteRecord(nTranNum); } }while (nTranNum != 0); tRepData.SaveToFile(sRepDataFileLoc); if (!Directory.Exists(sOutGNGFolderLocation)) { try { Directory.CreateDirectory(sOutGNGFolderLocation); } catch { GTill.ErrorHandler.LogError("The directory " + sOutGNGFolderLocation + " was not found, and could not be created. Please create this folder, or run this program with administrator priviliges (Windows Vista & 7)"); throw new NotSupportedException("The directory " + sOutGNGFolderLocation + " was not found, and could not be created. Please create this folder, or run this program with administrator priviliges (Windows Vista & 7)"); } } File.Copy(sRepDataFileLoc, sOutGNGFolderLocation + "\\" + sRepDataFileLoc.Replace(".DBF", "") + DayNumber(sDateToday).ToString() + ".DBF", true); File.Copy(sOutGNGFolderLocation + "\\" + sRepDataFileLoc.Replace(".DBF", "") + DayNumber(sDateToday).ToString() + ".DBF", sOutGNGFolderLocation + "\\" + sRepDataFileLoc, true); File.Copy(sTDataFileLoc, sOutGNGFolderLocation + "\\" + sTDataFileLoc.Replace(".DBF", "") + DayNumber(sDateToday).ToString() + ".DBF", true); File.Copy(sTHdrFileLoc, sOutGNGFolderLocation + "\\" + sTHdrFileLoc.Replace(".DBF", "") + DayNumber(sDateToday).ToString() + ".DBF", true); // Write the blank files FileStream fsWriter = new FileStream(sRepDataFileLoc, FileMode.Create); fsWriter.Write(GTill.Properties.Resources.BLANK_REPDATA, 0, GTill.Properties.Resources.BLANK_REPDATA.Length); fsWriter.Close(); fsWriter = new FileStream(sTDataFileLoc, FileMode.Create); fsWriter.Write(GTill.Properties.Resources.BLANK_TDATA, 0, GTill.Properties.Resources.BLANK_TDATA.Length); fsWriter.Close(); fsWriter = new FileStream(sTHdrFileLoc, FileMode.Create); fsWriter.Write(GTill.Properties.Resources.BLANK_THDR, 0, GTill.Properties.Resources.BLANK_THDR.Length); fsWriter.Close(); // Reload the blank files tRepData = new Table(sRepDataFileLoc); tTData = new Table(sTDataFileLoc); tTHDR = new Table(sTHdrFileLoc); tRepData.EditRecordData(0, 2, "4"); // Change the REPQTY to 4, to show that the till has been cashed up tRepData.EditRecordData(0, 1, sDateToday); int nStartRecordLocation = 0; tRepData.SearchForRecord("START", 1, ref nStartRecordLocation); tRepData.EditRecordData(nStartRecordLocation, 3, FormatMoneyForDisplay(fStartValue)); tRepData.SearchForRecord("END", 1, ref nStartRecordLocation); tRepData.EditRecordData(nStartRecordLocation, 3, FormatMoneyForDisplay(FixFloatError(fStartValue - 0.01f))); // Change the IDENT record. Default is MODELS, but only Models uses that tRepData.SearchForRecord("IDENT MODELS", 1, ref nStartRecordLocation); string[] sIdent = tRepData.GetRecordFrom("IDENT MODELS", 1); sIdent[1] = "IDENT " + TillName.ToUpper(); tRepData.EditRecordData(nStartRecordLocation, 1, sIdent[1]); tRepData.SaveToFile(sRepDataFileLoc); tTData.SaveToFile(sTDataFileLoc); tTHDR.SaveToFile(sTHdrFileLoc); } catch (Exception ex) { GTill.ErrorHandler.LogError(ex.ToString()); System.Windows.Forms.MessageBox.Show("Error caught! Please try cashing up again"); } }
static void Main(string[] args) { // Ensure that the compression dll exists if (!File.Exists("Ionic.Zip.dll")) { FileStream fs = new FileStream("Ionic.Zip.dll", FileMode.Create); fs.Write(Properties.Resources.Ionic_Zip, 0, Properties.Resources.Ionic_Zip.Length); fs.Close(); } bool bFatalErrors = false; if (args.Length > 0) { if (args[0] == "config") { frmConfig c = new frmConfig(); c.ShowDialog(); } else if (args[0] == "regreport") { try { // Print a register report and exit TillEngine.TillEngine tEngine = new TillEngine.TillEngine(); tEngine.LoadTablesForJustRegisterReport(); tEngine.PrintRegisterReport(); } catch (Exception ex) { MessageBox.Show("Error. Unable to print the selected register report:" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } Application.Exit(); return; } } // Checks for fatal errors with the configuration file if (PreRunChecks(ref bFatalErrors)) { // If no errors, then continue to start the program Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //try //{ Application.Run(new frmMain()); //} /*catch (Exception ex) * { * ErrorHandler.LogError(ex.ToString()); * if (MessageBox.Show("Sorry, an error has occured with GTill. GTill will restart automatically when you select OK. Press Cancel to not restart", "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error) == DialogResult.OK) * { * Application.Restart(); * } * }*/ } else { if (bFatalErrors) { System.Windows.Forms.MessageBox.Show("One or more fatal errors occured whilst trying to load the till. Please see the log for more information."); } else { // Not a serious error System.Windows.Forms.MessageBox.Show("One or more errors occured whilst trying to load the till. Please see the log for more information"); } } /* * TillEngine.TillEngine tEngine = new TillEngine.TillEngine(); * tEngine.LoadTable("STOCK"); * tEngine.LoadTable("STKLEVEL"); * tEngine.LoadTable("TILLCAT"); * //Application.Run(new frmSearchForItemV2(ref tEngine)); * //Application.Run(new frmCategorySelect(ref tEngine)); */ }
public frmEmailInput(ref TillEngine.TillEngine te) { tEngine = te; this.BackColor = GTill.Properties.Settings.Default.cFrmForeColour; this.ForeColor = GTill.Properties.Settings.Default.cFrmBackColour; lblInsts = new Label[6]; for (int i = 0; i < lblInsts.Length; i++) { lblInsts[i] = new Label(); lblInsts[i].Location = new Point(10, 10 + (i * 35)); lblInsts[i].BackColor = this.BackColor; lblInsts[i].ForeColor = this.ForeColor; lblInsts[i].Font = new Font(GTill.Properties.Settings.Default.sFontName, 16.0f); lblInsts[i].AutoSize = true; this.Controls.Add(lblInsts[i]); } this.FormBorderStyle = FormBorderStyle.None; this.Size = new Size(630, 240); this.StartPosition = FormStartPosition.CenterScreen; lblInsts[0].Text = "Title : "; lblInsts[1].Text = "Forename : "; lblInsts[2].Text = "Surname : "; lblInsts[3].Text = "E-Mail Address : "; lblInsts[4].Text = "Home Address : "; lblInsts[5].Text = "Item Barcode : "; tbTitle = new TextBox(); tbTitle.Location = new Point(200, lblInsts[0].Top); tbTitle.Size = new Size(100, lblInsts[0].Height); tbTitle.Font = lblInsts[0].Font; tbTitle.KeyDown += new KeyEventHandler(tbTitle_KeyDown); this.Controls.Add(tbTitle); tbForeName = new TextBox(); tbForeName.Location = new Point(200, lblInsts[1].Top); tbForeName.Size = new Size(300, lblInsts[1].Height); tbForeName.Font = lblInsts[1].Font; tbForeName.KeyDown += new KeyEventHandler(tbForeName_KeyDown); this.Controls.Add(tbForeName); tbSurname = new TextBox(); tbSurname.Location = new Point(200, lblInsts[2].Top); tbSurname.Size = new Size(300, lblInsts[2].Height); tbSurname.Font = lblInsts[2].Font; tbSurname.KeyDown += new KeyEventHandler(tbSurname_KeyDown); this.Controls.Add(tbSurname); tbEMail = new TextBox(); tbEMail.Location = new Point(200, lblInsts[3].Top); tbEMail.Size = new Size(400, lblInsts[3].Height); tbEMail.Font = lblInsts[3].Font; tbEMail.KeyDown += new KeyEventHandler(tbEMail_KeyDown); this.Controls.Add(tbEMail); tbAddress = new TextBox(); tbAddress.Location = new Point(200, lblInsts[4].Top); tbAddress.Size = new Size(400, lblInsts[4].Height); tbAddress.Font = lblInsts[4].Font; tbAddress.KeyDown += new KeyEventHandler(tbAddress_KeyDown); this.Controls.Add(tbAddress); tbItem = new TextBox(); tbItem.Location = new Point(200, lblInsts[5].Top); tbItem.Size = new Size(400, lblInsts[5].Height); tbItem.Font = lblInsts[5].Font; tbItem.KeyDown += new KeyEventHandler(tbItem_KeyDown); this.Controls.Add(tbItem); }