コード例 #1
0
ファイル: ReturnBoxForm.cs プロジェクト: ramilexe/tsdfamilia
        private void textBox1_KeyDown(object sender, KeyEventArgs e)
        {
            try
            {
                //BTPrintClass.PrintClass.SetStatusEvent("KeyDown pressed");
                //this.textBox1.Text = e.KeyValue.ToString();
                //this.textBox1.Text = e.KeyCode.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)
                {

                    if (_mode == CarScanMode.BoxScan && fullAcceptEnabled && !fullAccepted)
                    {
                        
                        //using (DialogForm dlgfrm =
                                //new DialogForm(
                        DialogResult dr = DialogFrm.ShowMessage(
                                   lblQtySku.Text,
                                    lblQtyTotal.Text,
                                     "Вы уверены?",
                                     "Принять полностью");//)
                        //{
                            if (dr == DialogResult.Yes)
                            {
                                ActionsClass.Action.AcceptFullBoxWProductsActionProc(_currentBoxBarcode);
                                RefreshData(_currentBoxBarcode);
    
                            }
                        //}

                    }

                    return;
                }
                if (e.KeyValue == (int)SpecialButton.BlueBtn)
                {

                    return;
                }
                if (e.KeyValue == (int)SpecialButton.YellowBtn)
                {
                    if (_mode == CarScanMode.BoxScan)
                    {
                        /*int totals = 0;
                        int totalBk = 0;
                        ActionsClass.Action.CalculateTotalsWOPriority(
                            TSDUtils.ActionCode.IncomeBox,
                            DateTime.Today,
                            out totalBk,
                            out totals);*/
                        try
                        {
                            /*ScanClass.Scaner.OnScanned -= scannedDelegate;
                            using (DialogForm dlgfrm =
                                        new DialogForm(
                                            string.Format("За {0} отсканировано",
                                            DateTime.Today.ToString("dd.MM.yyyy"))
                                            , string.Format(" {0} правильных коробов", totalBk)
                                            , ""
                                            , "Подсчет коробов"))
                            {
                                dlgfrm.ShowDialog();
                            }
                            */
                            using (ViewBoxForm boxFrm =
                                new ViewBoxForm(_currentBoxBarcode, (byte)TSDUtils.ActionCode.BoxWProducts))
                            {
                                boxFrm.ShowDialog();
                            }
                            RefreshData(_currentBoxBarcode);

                        }
                        finally
                        {
                            //ScanClass.Scaner.OnScanned += scannedDelegate;

                        }
                    }
                    else
                    {
                        using (ViewTtnForm vFrm = new ViewTtnForm(TtnStruct))
                        {
                            vFrm.ShowDialog();
                        }
                    }
                    

                    return;
                }
                if (e.KeyValue == (int)SpecialButton.GreenBtn) //GreenBtn
                {
                    if (_mode == CarScanMode.CarsScan)
                    {
                        int total = 0;

                        foreach (string incomeDoc in TtnStruct[_currentTTNBarcode].Keys)
                        {//цикл по всем накладным
                            foreach (string navCodeBox in TtnStruct[_currentTTNBarcode][incomeDoc].Keys)
                            {
                                if (TtnStruct[_currentTTNBarcode][incomeDoc][navCodeBox].Accepted)
                                    total++;
                            }
                        }


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

                                ActionsClass.Action.CloseDoc(
                                    _currentTTNBarcode,
                                    TSDUtils.ActionCode.Cars,
                                    total);

                                this.Close();
                            }
                        //}

                    }
                    else
                    {
                        if (!fullAccepted)
                        {
                            try
                            {


                                enableScan = false;
                                ScanClass.Scaner.StopScan();
                                ScanClass.Scaner.OnScanned -= scannedDelegate;
                                //ScanClass.Scaner.OnScanned =null;
                                //this.Visible = false;
                                //this.Enabled = false;
                                ScanClass.Scaner.StopScan();
                                using (ViewProductForm prodfrm =
                                    new ViewProductForm(
                                        WorkMode.BoxScan,
                                        _currentBoxBarcode))
                                {
                                    prodfrm.ShowDialog();
                                }
                                RefreshData(_currentBoxBarcode);

                            }
                            catch (Exception err)
                            {
                                //using (DialogForm frmErr =
                                //    new DialogForm("Ошибка инв-ции",
                                //        err.Message,
                                //        "ДА – продолжить. Нет – выйти",
                                //         "Ошибка"))
                                //{
                                //    if (frmErr.ShowDialog() == DialogResult.No)
                                //        return;
                                //}
                            }
                            finally
                            {
                                ScanClass.Scaner.OnScanned += scannedDelegate;
                                ScanClass.Scaner.InitScan();
                                enableScan = true;
                                //this.Visible = true;
                                //this.Enabled = true;
                                //ScanClass.Scaner.InitScan();
                                //ScanClass.Scaner.OnScanned += new Scanned(OnScanned);
                            }
                        }
                    }
                    return;
                }
            }
            finally
            {
                this.Refresh();
            }
             
        }
コード例 #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;
            //}

        }