void fsfiLookupBarcode_FormClosing(object sender, FormClosingEventArgs e) { string sResult = fsfiFindBarcode.GetItemBarcode(); string[] sItemDetails = tEngine.GetItemDetailsForLookup(sResult); if (sItemDetails != null) { tbRefundDetails[0].BackColor = cFrmBackColour; tbRefundDetails[0].ForeColor = cFrmForeColour; tbRefundDetails[0].Font = new Font(sFontName, 11.0f); tbRefundDetails[0].Text = sItemDetails[0]; tbRefundDetails[1].Text = TillEngine.TillEngine.FormatMoneyForDisplay(TillEngine.TillEngine.fFormattedMoneyString(sItemDetails[1])); tbRefundDetails[1].KeyDown += new KeyEventHandler(frmRefund_KeyDown); tbRefundDetails[1].Tag = "1"; tbRefundDetails[1].Focus(); } else { tbRefundDetails[0].Text = ""; } }
void frmLookupTransactionsV2_KeyDown(object sender, KeyEventArgs e) { if (e.KeyValue >= 65 && e.KeyValue <= 90 && !e.Shift) { sSearchTerm += e.KeyCode.ToString(); bTextBoxHasFocus = true; } else if (e.KeyValue >= 47 && e.KeyValue <= 57) { sSearchTerm += (e.KeyValue - 48).ToString(); bTextBoxHasFocus = true; } else if (e.KeyValue >= 96 && e.KeyValue <= 106) { sSearchTerm += (e.KeyValue - 96).ToString(); bTextBoxHasFocus = true; } else if (e.KeyValue == 8) { string sNewSearchTerm = ""; for (int i = 0; i < sSearchTerm.Length - 1; i++) { sNewSearchTerm += sSearchTerm[i].ToString(); } if (sSearchTerm == "CAT:") { sSearchTerm = ""; } else { sSearchTerm = sNewSearchTerm; } bTextBoxHasFocus = true; } else if (e.KeyValue == 32) { sSearchTerm += " "; bTextBoxHasFocus = true; } else if (e.KeyValue == 13 && bTextBoxHasFocus) { // Do search if (sSearchTerm.Length > 1) { this.CreateGraphics().DrawString("Searching by code, please wait.", new Font(GTill.Properties.Settings.Default.sFontName, 12.0f), new SolidBrush(Color.Red), new PointF(10, 107)); SearchForItems(); bTextBoxHasFocus = false; } } else if (e.KeyValue == 9) { bHideNoStockItems = !bHideNoStockItems; CountNumberOfResultsToShow(); nCurrentItemSelected = 0; nScrolledDown = 0; if (nOfSearchResultsBeingDisplayed == 0) { bTextBoxHasFocus = true; } } else if (e.KeyValue == 40) { // Move Down if (bTextBoxHasFocus) { bTextBoxHasFocus = false; nCurrentItemSelected = 0; nScrolledDown = 0; } else { if (nCurrentItemSelected + 1 < nOfSearchResultsBeingDisplayed) { nCurrentItemSelected++; } else if (!bTextBoxHasFocus) { // Prevent it from going to the top when going too far down //bTextBoxHasFocus = true; } if (nCurrentItemSelected > nScrolledDown + nOfResultsDrawnToScreen && nCurrentItemSelected < nOfSearchResultsBeingDisplayed) { nScrolledDown++; } } } else if (e.KeyValue == 38) { // Move up if (nCurrentItemSelected > 0) { nCurrentItemSelected -= 1; } else if (nCurrentItemSelected == 0 && bTextBoxHasFocus) { /*bTextBoxHasFocus = false; * nCurrentItemSelected = nOfSearchResultsBeingDisplayed - 1; * nScrolledDown = nOfSearchResultsBeingDisplayed - nOfResultsDrawnToScreen - 1; * if (nScrolledDown < 0) * nScrolledDown = 0;*/ // Prevent it from going to the bottom when going too far up } else if (nCurrentItemSelected == 0 && !bTextBoxHasFocus) { bTextBoxHasFocus = true; } if (nCurrentItemSelected < nScrolledDown) { nScrolledDown -= 1; } } else if (e.KeyValue == 27) { if (bTextBoxHasFocus) { this.Close(); } else { bTextBoxHasFocus = true; nScrolledDown = 0; nCurrentItemSelected = 0; } } else if (e.KeyCode == Keys.Subtract || e.KeyCode == Keys.OemMinus) { if (bTextBoxHasFocus) { sSearchTerm += "-"; bTextBoxHasFocus = true; } } else if (e.KeyCode == Keys.Enter) { sSelectedBarcode = getSelectedBarcode(); this.Close(); } else if (e.Shift && e.KeyCode == Keys.P) { // Print out a barcode string sCode = getSelectedBarcode(); if (sCode != "") { tEngine.PrintBarcode(sCode, false); } } else if (e.KeyCode == Keys.F5) { fcSelect = new frmCategorySelect(ref tEngine); fcSelect.ShowDialog(); if (fcSelect.SelectedCategory != "NONE_SELECTED") { sSearchTerm = "CAT:" + fcSelect.SelectedCategory; SearchForItems(); if (nOfSearchResultsBeingDisplayed > 0) { nScrolledDown = 0; nCurrentItemSelected = 0; bTextBoxHasFocus = false; } } fcSelect.Dispose(); } else if (e.KeyCode == Keys.F6) { this.Hide(); frmSearchForItem fsi = new frmSearchForItem(ref tEngine); fsi.ShowDialog(); sSelectedBarcode = fsi.GetItemBarcode(); this.Close(); } else if (e.KeyCode == Keys.Oem1) { sSearchTerm += ":"; } else if (e.KeyCode == Keys.PageDown) { nScrolledDown += nOfResultsDrawnToScreen; if (nScrolledDown + nOfResultsDrawnToScreen >= nOfSearchResultsBeingDisplayed) { nScrolledDown = nOfSearchResultsBeingDisplayed - nOfResultsDrawnToScreen; } nCurrentItemSelected = nScrolledDown; } else if (e.Shift) { // Do nothing - wait for the next key ; } else { bTextBoxHasFocus = true; } this.Refresh(); }