Example #1
0
        private void textBox1_KeyDown(object sender, KeyEventArgs e)
        {
            //this.textBox1.Text = e.KeyValue.ToString();
            if (e.KeyCode == Keys.Enter)
            {
                if (textBox1.Text != string.Empty)
                    OnScanned(textBox1.Text);

                return;
            }
            if (e.KeyCode == Keys.Escape)
            {
                this.Close();
                return;
            }
            if (e.KeyValue == (int)SpecialButton.RedBtn)
            {
                e.Handled = true;
                return;
            }
            if (e.KeyValue == (int)SpecialButton.BlueBtn)
            {
                e.Handled = true;
                return;
            }
            if (e.KeyValue == (int)SpecialButton.YellowBtn)
            {
                if (!String.IsNullOrEmpty(lastBk))
                {

                    try
                    {
                        enableScan = false;
                        //ScanClass.Scaner.OnScanned = null;
                        using (ViewInventarForm prod =
                            new ViewInventarForm(lastBk,
                                (_currentMode == InventarFormMode.DefaultInventar) ?
                                (byte)TSDUtils.ActionCode.InventoryGlobal :
                                (byte)TSDUtils.ActionCode.SimpleIncome))
                        {
                            prod.ShowDialog();
                        }
                    }
                    finally
                    {
                        enableScan = true;
                        //ScanClass.Scaner.OnScanned += scannedDelegate;
                    }
                }

                return;
            }
            if (e.KeyCode == Keys.Tab)
            {
                if (enableInvent)
                {
                    OnScanned(lastBk);
                }
                return;
            }
        }
Example #2
0
        /*private ProductsDataSet.ProductsTblRow GetProductRow(string barcode)
        {
            ProductsDataSet.ProductsTblRow row = productsTa.GetDataByBarcode(long.Parse(barcode));
            return row;

        }

        private ProductsDataSet.ProductsTblRow GetProductRowByNavCode(string navCode)
        {

            ProductsDataSet.ProductsTblRow[] Rows = ActionsClass.Action.GetDataByNavcode(navCode);
                    //ta.GetDataByNavcode(TSDUtils.CustomEncodingClass.Encoding.GetBytes(navCode));

                if (Rows != null && Rows.Length > 0)
                {
                    return Rows[0]; 
                }
                else
                    return null;

        }*/


        private void navCodeTB_KeyDown(object sender, KeyEventArgs e)
        {
            this.label18.Text = "";
            //label11.Text = e.KeyValue.ToString();
            if (e.KeyCode == Keys.Enter)
            {
                DoAction(ActionsClass.Action.GetProductRowByNavCode(navCodeTB.Text));
                navCodeTB.SelectAll();
                e.Handled = true;
                return;
            }

            if (e.KeyCode == Keys.Escape)
            {
                if (_mode != WorkMode.BoxScan)
                {
                    this.Close();
                    e.Handled = true;
                    return;
                }
                else
                {
                    this.navCodeTB.Text = "";
                    return;
                }
            }
            if (e.KeyCode == Keys.Tab)
            {
                #region GreenBtn
                if (_mode == WorkMode.InventarScan)
                {
                    #region Inventar
                    ScanClass.Scaner.PauseScan();
                    try
                    {
                        int total = 0;
                        int totalBk = 0;

                        ActionsClass.Action.CalculateTotals(
                            _documentId,
                            TSDUtils.ActionCode.InventoryGlobal,
                            out totalBk,
                            out total);

                        //using (DialogForm dlgfrm =
                        //    new DialogForm(
                        DialogResult dr = DialogFrm.ShowMessage(
                                "Вы хотите закрыть просчет?"
                                , ""//string.Format("Посчитано: {0} кодов", totalBk)
                                , string.Format("Итого: {0} штук", total)
                                , "Закрытие просчета");//)
                        //{
                        if (dr == DialogResult.Yes)
                        {
                            ActionsClass.Action.CloseInv(
                                _documentId,
                                TSDUtils.ActionCode.InventoryGlobal);

                            this.Close();
                        }
                        //}

                    }
                    catch (Exception err)
                    {
                        BTPrintClass.PrintClass.SetErrorEvent(err.ToString());
                        //using (DialogForm dlgfrm =
                        //    new DialogForm(
                        DialogResult dr = DialogFrm.ShowMessage(
                                err.Message
                                , err.StackTrace
                                , ""
                                , "Ошибка");//)
                        /*{
                            dlgfrm.ShowDialog();
                        }*/
                    }
                    finally
                    {
                        ScanClass.Scaner.ResumeScan();
                        this.Refresh();
                        e.Handled = true;
                    }
                    #endregion
                    return;
                }
                if (_mode == WorkMode.BoxScan)
                {
                    #region boxScan & green Btn = Exit
                    this.Close();
                    e.Handled = true;
                    return;
                    #endregion
                }
                if (_mode == WorkMode.SimpleIncome)
                {
                    #region Income
                    ScanClass.Scaner.PauseScan();
                    try
                    {
                        int total = 0;
                        int totalBk = 0;

                        ActionsClass.Action.CalculateTotals(
                            _documentId,
                            TSDUtils.ActionCode.SimpleIncome,
                            out totalBk,
                            out total);

                        //using (DialogForm dlgfrm =
                        //    new DialogForm(
                        DialogResult dr = DialogFrm.ShowMessage(
                                "Вы хотите закрыть накладную?"
                                , ""//string.Format("Посчитано: {0} кодов", totalBk)
                                , string.Format("Итого: {0} штук", total)
                                , "Закрытие просчета");//)
                        //{
                        if (dr == DialogResult.Yes)
                        {
                            ActionsClass.Action.CloseInv(
                                _documentId,
                                TSDUtils.ActionCode.SimpleIncome,
                                InventarFormMode.SimpleIncome);

                            this.Close();
                        }
                        //}

                    }
                    catch (Exception err)
                    {
                        BTPrintClass.PrintClass.SetErrorEvent(err.ToString());
                        //using (DialogForm dlgfrm =
                        //    new DialogForm(
                        DialogResult dr = DialogFrm.ShowMessage(
                                err.Message
                                , err.StackTrace
                                , ""
                                , "Ошибка");//)
                        /*{
                            dlgfrm.ShowDialog();
                        }*/
                    }
                    finally
                    {
                        ScanClass.Scaner.ResumeScan();
                        this.Refresh();
                        e.Handled = true;
                    }
                    #endregion
                    return;
                }
                #endregion
            }
            if (e.KeyValue == 18)//RedBtn
            {
                #region redbutton
                if (currentProductRow != null && WorkMode.ProductsScan == _mode)
                {
                    ActionsClass.Action.PrintLabel(currentProductRow, currentDocRow, Program.Default.DefaultRepriceShablon);
                }
                if (currentProductRow != null &&
                    (WorkMode.InventarScan == _mode ||
                    WorkMode.BoxScan == _mode ||
                    WorkMode.SimpleIncome == _mode
                    ))
                {
                    ScannedProductsDataSet.ScannedBarcodesRow scannedRow =
                             ActionsClass.Action.AddScannedRow(
                             currentProductRow.Barcode,
                             inventRow.DocType,
                             inventRow.DocId,
                             inventRow.Quantity,
                             inventRow.Priority);

                    int total = 0;
                    int totalBk = 0;
                    ActionsClass.Action.CalculateTotalsWOPriority(
                        (TSDUtils.ActionCode)scannedRow.DocType,
                        scannedRow.DocId,
                        scannedRow.Barcode.ToString(),
                        out totalBk,
                        out total);

                    if (scannedRow != null && //existing row
                        scannedRow.Priority == 0 //not closed
                        && scannedRow["FactQuantity"] != System.DBNull.Value
                        && total > 0 //scanned already
                        &&
                        (
                           ((Program.СurrentInvId != string.Empty && _mode == WorkMode.InventarScan) || true) ||
                           ((Program.СurrentIncomeId != string.Empty && _mode == WorkMode.SimpleIncome) || true)
                        )
                    )
                    {



                        //using (DialogForm dlgfrm =
                        //        new DialogForm(
                        DialogResult dr = DialogFrm.ShowMessage(
                                    string.Format("Уменьшить по коду {0} ", currentProductRow.NavCode),
                                    string.Format("название {0} ", currentProductRow.ProductName),
                                     string.Format("с количества {0} до количества {1} ?",
                                      total,
                                      total - 1),
                                     "Отмена последнего сканирования");//)
                        //{
                        if (dr == DialogResult.Yes)
                        {
                            inventRow.NavCode = currentProductRow.NavCode;
                            ActionsClass.Action.UndoLastScannedPosition(
                                currentProductRow,
                                inventRow,
                                scannedRow
                                );

                        }
                        //}
                    }
                    else
                    {
                        //using (DialogForm dlgfrm =
                        //        new DialogForm(
                        DialogResult dr = DialogFrm.ShowMessage(
                                    "Дальше уменьшить нельзя!",
                                    "",
                                     "",
                                     "Отмена последнего сканирования");//)
                        //{
                        //    dlgfrm.ShowDialog();
                        //}
                    }


                }
                e.Handled = true;
                return;
                #endregion
            }
            if (e.KeyValue == 16)//BluBtn
            {
                #region ProductsScan
                if (currentProductRow != null && WorkMode.ProductsScan == _mode)
                {
                    ActionsClass.Action.PrintLabel(currentProductRow, currentDocRow, Program.Default.BlueButtonShablon);
                }
                #endregion
                #region BoxScan

                //multyply
                //if (currentProductRow != null && 
                if (_mode == WorkMode.BoxScan && Program.Default.EnableChgMlt == 1)
                {

                    DialogResult dr = FMultiplyForm.MForm.ShowDialog();

                    if (dr == DialogResult.OK)
                    {
                        quantityKoeff = FMultiplyForm.MForm.Quantity;
                        quantityLabel.Text = string.Format("Добавляется {0} шт", quantityKoeff);
                        quantityLabel.Visible = true;
                        this.navCodeTB.SelectAll();
                        this.navCodeTB.Focus();
                        this.Refresh();

                    }
                }
                #endregion
                e.Handled = true;
                return;
            }
            if (e.KeyValue == 115)//YellowBtn
            {
                #region YellowBtn
                try
                {
                    ScanClass.Scaner.PauseScan();
                    if (WorkMode.BoxScan != _mode)
                    {
                        if (WorkMode.SimpleIncome == _mode)
                        {
                            if (!String.IsNullOrEmpty(_documentId))
                            {
                                using (ViewInventarForm prod =
                                    new ViewInventarForm(_documentId,
                                        (byte)TSDUtils.ActionCode.SimpleIncome))
                                {
                                    prod.ShowDialog();
                                    
                                }
                            }
                        }
                        if (currentProductRow != null)
                        {
                            if (WorkMode.ProductsScan == _mode)
                            {
                                using (
                                    ViewDocsForm docsForm =
                                        new ViewDocsForm(currentProductRow, currentdocRows, ActionsClass.Action.ScannedProducts))
                                {
                                    docsForm.ShowDialog();
                                }

                            }
                            else
                            {
                                if (WorkMode.InventarScan == _mode)
                                {
                                    if (!String.IsNullOrEmpty(_documentId))
                                    {
                                        using (ViewInventarForm prod =
                                            new ViewInventarForm(_documentId,
                                                (byte)TSDUtils.ActionCode.InventoryGlobal))
                                        {
                                            prod.ShowDialog();

                                        }
                                    }
                                }

                                /*else
                                    if (WorkMode.BoxScan == _mode)
                                    {
                                        if (!String.IsNullOrEmpty(_documentId))
                                        {
                                            using (ViewBoxForm prod =
                                                new ViewBoxForm(_documentId,
                                                    (byte)TSDUtils.ActionCode.BoxWProducts))
                                            {
                                                prod.ShowDialog();

                                            }
                                        }
                                    }*/
                            }
                        }
                    }
                    else
                    {
                        //BoxScan
                        if (!String.IsNullOrEmpty(_documentId))
                        {
                            using (ViewBoxForm prod =
                                new ViewBoxForm(_documentId,
                                    (byte)TSDUtils.ActionCode.BoxWProducts))
                            {
                                prod.ShowDialog();
                                this.navCodeTB.Text = "";
                            }
                        }
                    }
                }
                catch (Exception err)
                {
                    BTPrintClass.PrintClass.SetErrorEvent(err.ToString());
                }
                finally
                {
                    ScanClass.Scaner.ResumeScan();
                    this.Refresh();
                    e.Handled = true;
                }

                //this.BringToFront();
                //this.Focus();

                return;
                #endregion


            }
            //if (e.KeyValue == 9)
            //{
            //    try
            //    {
            //        BTPrintClass.PrintClass.PartialReconnect();
            //    }
            //    catch (Exception err)
            //    { BTPrintClass.PrintClass.SetErrorEvent(err.ToString()); }
            //    return;
            //}

        }