Пример #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}");
            }
        }
Пример #2
0
        void fiGetAmount_FormClosing(object sender, FormClosingEventArgs e)
        {
            string sToReturn = fiGetAmount.sGetDataToReturn();

            if (sToReturn != "CANCELLED")
            {
                fAmountToReceive    = TillEngine.TillEngine.fFormattedMoneyString(sToReturn);
                fAmountToReceive    = TillEngine.TillEngine.FixFloatError(fAmountToReceive);
                fpiGetPaymentMethod = new frmPaymentInput(pLocation, new Size(sSize.Width, sSize.Height), tEngine.GetCreditCards(), fAmountToReceive, false, false, false);
                fpiGetPaymentMethod.Show();
                fpiGetPaymentMethod.GetAmountFromUser = false;
                fpiGetPaymentMethod.FormClosing      += new FormClosingEventHandler(fpiGetPaymentMethod_FormClosing);
            }
        }