Exemple #1
0
        void tbRefund_KeyDown(object sender, KeyEventArgs e)
        {
            TextBox tbCurrent   = (TextBox)sender;
            int     nCurrentBox = Convert.ToInt32(tbCurrent.Tag.ToString()[0].ToString());

            if (e.Shift && nCurrentBox == 0)
            {
                bShiftFunctionKeys = !bShiftFunctionKeys;
            }
            if (e.KeyCode == Keys.Enter)
            {
                if (nCurrentBox < 2)
                {
                    tbRefundDetails[nCurrentBox + 1].Focus();
                    switch (nCurrentBox + 1)
                    {
                    case 0:
                        lblInstruction.Text = "Enter the barcode of the item to refund.";
                        break;

                    case 1:
                        lblInstruction.Text = "Enter the price that was paid for the item.";
                        break;

                    case 2:
                        lblInstruction.Text = "Enter the quantity of the item to refund";
                        break;
                    }
                }
                if (nCurrentBox == 0)
                {
                    string[] sItemDetails = tEngine.GetItemDetailsForLookup(tbRefundDetails[0].Text);
                    if (sItemDetails == null)
                    {
                        if (tbRefundDetails[0].Text.Length > 1)
                        {
                            fsfiFindBarcode              = new frmSearchForItem(ref tEngine);
                            fsfiFindBarcode.FormClosing += new FormClosingEventHandler(fsfiFindBarcode_FormClosing);
                            fsfiFindBarcode.Show();
                            fsfiFindBarcode.CheckForPartialBarcodeFromScanner(tbRefundDetails[0].Text);
                        }
                        else
                        {
                            lblInstruction.Text = "The barcode that was entered was invalid. Please try again.";
                            tbRefundDetails[0].Focus();
                        }
                    }
                    else
                    {
                        sBarcodeToRefund             = tbRefundDetails[0].Text.ToUpper();
                        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";
                    }
                }
                else if (nCurrentBox == 2)
                {
                    for (int i = 0; i < tbRefundDetails.Length; i++)
                    {
                        tbRefundDetails[i].BackColor = cFrmBackColour;
                        tbRefundDetails[i].ForeColor = cFrmForeColour;
                        tbRefundDetails[i].Font      = new Font(sFontName, 11.0f);
                        tbRefundDetails[i].Enabled   = false;
                    }
                    try
                    {
                        nQuantityToRefund = Convert.ToInt32(tbRefundDetails[2].Text);
                    }
                    catch
                    {
                        nQuantityToRefund       = 1;
                        tbRefundDetails[2].Text = "1";
                    }
                    fAmountToRefund         = TillEngine.TillEngine.FixFloatError((float)Convert.ToDecimal(tbRefundDetails[1].Text));
                    fAmountToRefund        *= nQuantityToRefund;
                    fAmountToRefund         = TillEngine.TillEngine.FixFloatError(fAmountToRefund);
                    tbRefundDetails[3].Text = TillEngine.TillEngine.FormatMoneyForDisplay(fAmountToRefund);
                    fpiGetPaymentType       = new frmPaymentInput(new Point(this.Left, lblRefundDetails[3].Top + 200), new Size(this.Width, this.Height - 70 - (lblRefundDetails[0].Top + 250)), tEngine.GetCreditCards(), fAmountToRefund, false, false, true);
                    fpiGetPaymentType.Show();
                    fpiGetPaymentType.GetAmountFromUser = false;
                    fpiGetPaymentType.FormClosed       += new FormClosedEventHandler(fpiGetPaymentType_FormClosing);
                }
                else if (nCurrentBox == 1)
                {
                    try
                    {
                        fAmountToRefund              = (float)Convert.ToDecimal(TillEngine.TillEngine.fFormattedMoneyString(tbRefundDetails[1].Text));
                        fAmountToRefund              = tEngine.fFixFloatError(fAmountToRefund);
                        tbRefundDetails[1].Text      = TillEngine.TillEngine.FormatMoneyForDisplay(fAmountToRefund);
                        tbRefundDetails[1].BackColor = cFrmBackColour;
                        tbRefundDetails[1].ForeColor = cFrmForeColour;
                        tbRefundDetails[1].Font      = new Font(sFontName, 11.0f);
                        if (sBarcodeToRefund == "$GENERAL_REFUND")
                        {
                            tbRefundDetails[1].Enabled = false;
                            tbRefundDetails[3].Text    = tbRefundDetails[1].Text;
                            tbRefundDetails[3].Font    = new Font(sFontName, 11.0f);
                            fpiGetPaymentType          = new frmPaymentInput(new Point(this.Left, lblRefundDetails[3].Top + 200), new Size(this.Width, this.Height - 70 - (lblRefundDetails[0].Top + 250)), tEngine.GetCreditCards(), fAmountToRefund, false, false, true);
                            fpiGetPaymentType.Show();
                            fpiGetPaymentType.GetAmountFromUser = false;
                            fpiGetPaymentType.FormClosed       += new FormClosedEventHandler(fpiGetPaymentType_FormClosing);
                        }
                        else
                        {
                            tbRefundDetails[2].Text = "1";
                            tbRefundDetails[2].SelectAll();
                        }
                    }
                    catch
                    {
                        tbRefundDetails[1].Text = "";
                        tbRefundDetails[1].Focus();
                        lblInstruction.Text = "The price that was entered was invalid, please try again.";
                    }
                }
            }
            else if (e.KeyCode == Keys.Escape)
            {
                if (nCurrentBox > 0)
                {
                    tbRefundDetails[nCurrentBox].Text = "";
                    tbRefundDetails[nCurrentBox - 1].Focus();
                }
                else if (nCurrentBox == 0)
                {
                    this.Close();
                }
                if (nCurrentBox == 1)
                {
                    if (sBarcodeToRefund != "$GENERAL_REFUND")
                    {
                        tbRefundDetails[0].BackColor = cFrmForeColour;
                        tbRefundDetails[0].ForeColor = cFrmBackColour;
                        tbRefundDetails[0].Text      = "";
                        tbRefundDetails[0].Font      = new Font(sFontName, 16.0f);
                        tbRefundDetails[0].Enabled   = true;
                        tbRefundDetails[0].Focus();
                        tbRefundDetails[1].Tag = "0";
                    }
                    else
                    {
                        this.Close();
                    }
                }
                else if (nCurrentBox == 2)
                {
                    tbRefundDetails[1].BackColor = cFrmForeColour;
                    tbRefundDetails[1].ForeColor = cFrmBackColour;
                    tbRefundDetails[1].Text      = "";
                    tbRefundDetails[1].Font      = new Font(sFontName, 16.0f);
                    tbRefundDetails[1].Enabled   = true;
                    tbRefundDetails[1].Focus();
                }
            }
            else if (e.KeyCode == Keys.OemQuestion && nCurrentBox == 0)
            {
                fsfiFindBarcode = new frmSearchForItem(ref tEngine);
                fsfiFindBarcode.Show();
                fsfiFindBarcode.FormClosing += new FormClosingEventHandler(fsfiLookupBarcode_FormClosing);
            }
            else if (e.KeyCode == Keys.Tab)
            {
                MessageBox.Show("orite luv");
                tbCurrent.Focus();
                e.Handled = true;
            }
            else if (e.KeyCode == Keys.F1)
            {
                if (!bShiftFunctionKeys)
                {
                    tbCurrent.Text = tEngine.sBarcodeFromFunctionKey("F1");
                }
                else
                {
                    tbCurrent.Text = tEngine.sBarcodeFromFunctionKey("SF1");
                }
                bShiftFunctionKeys = false;
                tbCurrent.Focus();
                SendKeys.Send("{ENTER}");
            }
            else if (e.KeyCode == Keys.F2)
            {
                if (!bShiftFunctionKeys)
                {
                    tbCurrent.Text = tEngine.sBarcodeFromFunctionKey("F2");
                }
                else
                {
                    tbCurrent.Text = tEngine.sBarcodeFromFunctionKey("SF2");
                }
                bShiftFunctionKeys = false;
                tbCurrent.Focus();
                SendKeys.Send("{ENTER}");
            }
            else if (e.KeyCode == Keys.F3)
            {
                if (!bShiftFunctionKeys)
                {
                    tbCurrent.Text = tEngine.sBarcodeFromFunctionKey("F3");
                }
                else
                {
                    tbCurrent.Text = tEngine.sBarcodeFromFunctionKey("SF3");
                }
                bShiftFunctionKeys = false;
                tbCurrent.Focus();
                SendKeys.Send("{ENTER}");
            }
            else if (e.KeyCode == Keys.F4)
            {
                if (!bShiftFunctionKeys)
                {
                    tbCurrent.Text = tEngine.sBarcodeFromFunctionKey("F4");
                }
                else
                {
                    tbCurrent.Text = tEngine.sBarcodeFromFunctionKey("SF4");
                }
                bShiftFunctionKeys = false;
                tbCurrent.Focus();
                SendKeys.Send("{ENTER}");
            }
            else if (e.KeyCode == Keys.F5)
            {
                if (!bShiftFunctionKeys)
                {
                    tbCurrent.Text = tEngine.sBarcodeFromFunctionKey("F5");
                }
                else
                {
                    tbCurrent.Text = tEngine.sBarcodeFromFunctionKey("SF5");
                }
                bShiftFunctionKeys = false;
                tbCurrent.Focus();
                SendKeys.Send("{ENTER}");
            }
            else if (e.KeyCode == Keys.F6)
            {
                if (!bShiftFunctionKeys)
                {
                    tbCurrent.Text = tEngine.sBarcodeFromFunctionKey("F6");
                }
                else
                {
                    tbCurrent.Text = tEngine.sBarcodeFromFunctionKey("SF6");
                }
                bShiftFunctionKeys = false;
                tbCurrent.Focus();
                SendKeys.Send("{ENTER}");
            }
            else if (e.KeyCode == Keys.F7)
            {
                if (!bShiftFunctionKeys)
                {
                    tbCurrent.Text = tEngine.sBarcodeFromFunctionKey("F7");
                }
                else
                {
                    tbCurrent.Text = tEngine.sBarcodeFromFunctionKey("SF7");
                }
                bShiftFunctionKeys = false;
                tbCurrent.Focus();
                SendKeys.Send("{ENTER}");
            }
            else if (e.KeyCode == Keys.F8)
            {
                if (!bShiftFunctionKeys)
                {
                    tbCurrent.Text = tEngine.sBarcodeFromFunctionKey("F8");
                }
                else
                {
                    tbCurrent.Text = tEngine.sBarcodeFromFunctionKey("SF8");
                }
                bShiftFunctionKeys = false;
                tbCurrent.Focus();
                SendKeys.Send("{ENTER}");
            }
            else if (e.KeyCode == Keys.F9)
            {
                if (!bShiftFunctionKeys)
                {
                    tbCurrent.Text = tEngine.sBarcodeFromFunctionKey("F9");
                }
                else
                {
                    tbCurrent.Text = tEngine.sBarcodeFromFunctionKey("SF9");
                }
                bShiftFunctionKeys = false;
                tbCurrent.Focus();
                SendKeys.Send("{ENTER}");
            }
            else if (e.KeyCode == Keys.F10)
            {
                if (!bShiftFunctionKeys)
                {
                    tbCurrent.Text = tEngine.sBarcodeFromFunctionKey("F10");
                }
                else
                {
                    tbCurrent.Text = tEngine.sBarcodeFromFunctionKey("SF10");
                }
                bShiftFunctionKeys = false;
                tbCurrent.Focus();
                SendKeys.Send("{ENTER}");
            }
            else if (e.KeyCode == Keys.F11)
            {
                if (!bShiftFunctionKeys)
                {
                    tbCurrent.Text = tEngine.sBarcodeFromFunctionKey("F11");
                }
                else
                {
                    tbCurrent.Text = tEngine.sBarcodeFromFunctionKey("SF11");
                }
                bShiftFunctionKeys = false;
                tbCurrent.Focus();
                SendKeys.Send("{ENTER}");
            }
            else if (e.KeyCode == Keys.F12)
            {
                if (!bShiftFunctionKeys)
                {
                    tbCurrent.Text = tEngine.sBarcodeFromFunctionKey("F12");
                }
                else
                {
                    tbCurrent.Text = tEngine.sBarcodeFromFunctionKey("SF12");
                }
                bShiftFunctionKeys = false;
                tbCurrent.Focus();
                SendKeys.Send("{ENTER}");
            }
        }
Exemple #2
0
 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();
 }