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(); } }
void OnIncomeScanned(string barcode) { if (_mevt.WaitOne(5000, false) == false) return; if (!enableScan) return; this.label3.Visible = false; this.label4.Visible = false; this.label2.Visible = false; this.textBox1.Text = barcode; this.textBox1.SelectAll(); //if (barcode.StartsWith("660") && barcode.Length == 13) { lastBk = barcode; ScannedProductsDataSet.ScannedBarcodesRow[] row = ActionsClass.Action.FindByDocIdAndDocType ( barcode, (byte)TSDUtils.ActionCode.CloseIncome); if (row == null || row.Length == 0) { this.label3.Visible = true; this.label4.Text = string.Format("№ {0}?", barcode); this.label4.Visible = true; //lastBk = barcode; //using (DialogForm frm = // new DialogForm( DialogResult dr = DialogFrm.ShowMessage("Вы хотите начать накладную?", string.Format(" № {0}", barcode), "ДА – продолжить. Нет – выйти", "Новая накладная");//) { if (dr == DialogResult.Yes) { try { ActionsClass.Action.OpenInv( barcode, TSDUtils.ActionCode.SimpleIncome , InventarFormMode.SimpleIncome ); 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.SimpleIncome, barcode)) { prodfrm.ShowDialog(); } } catch (Exception err) { //using (DialogForm frmErr = // new DialogForm( DialogResult dr1 = DialogFrm.ShowMessage("Ошибка накл-ой", err.Message, "ДА – продолжить. Нет – выйти", "Ошибка");//) { if (dr1 == 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); } //this.Close(); } else this.Close(); } this.Refresh(); enableInvent = true; } else { if (ActionsClass.Action.CheckInv(barcode, InventarFormMode.SimpleIncome)) { //using (DialogForm frm = //new DialogForm( DialogResult dr = DialogFrm.ShowMessage( string.Format("Накладная № {0}", barcode), "Продолжить накладную?", "ДА – продолжить. Нет – выйти", "Накладная уже существует!");//) { if (dr == DialogResult.Yes) { enableScan = false; enableInvent = true; try { ScanClass.Scaner.OnScanned -= scannedDelegate; ScanClass.Scaner.StopScan(); using (ViewProductForm prodfrm = new ViewProductForm( WorkMode.SimpleIncome, barcode)) { prodfrm.ShowDialog(); } } finally { ScanClass.Scaner.InitScan(); ScanClass.Scaner.OnScanned += scannedDelegate; enableScan = true; } } else this.Close(); //this.Refresh(); } } else { label2.Text = string.Format("Накладная {0} завершена!", barcode); label2.Visible = true; enableInvent = false; //this.Refresh(); } } } //else //{ // ActionsClass.Action.InvokeAction(TSDUtils.ActionCode.NotFound, null, null); // enableInvent = false; // label2.Text = string.Format("Штрихкод {0} неверный адрес!", barcode); // label2.Visible = true; //} this.Refresh(); }
void MenuEvents(int menuId) { try { switch (menuId) { case (int)MenuItems.ExitMenu: { if (Program.Default.EnableExit == 1) Application.Exit(); break; } case (int)MenuItems.ViewProductMenu: { BTPrintClass.PrintClass.CheckForClear(); ActionsClass.Action.OpenProducts(); ActionsClass.Action.OpenScanned(); using (ViewProductForm frm = new ViewProductForm()) { //this.Visible = false; frm.ShowDialog(); } ActionsClass.Action.CloseProducts(); ActionsClass.Action.ClosedScanned(); ActionsClass.Action.ClearCache(); // this.Visible = true; //this.Activate(); break; } case (int)MenuItems.InventarMenu: { BTPrintClass.PrintClass.CheckForClear(); ActionsClass.Action.OpenProducts(); ActionsClass.Action.OpenScanned(); using (InventarForm frm = new InventarForm()) { //this.Visible = false; frm.ShowDialog(); } ActionsClass.Action.CloseProducts(); ActionsClass.Action.ClosedScanned(); ActionsClass.Action.ClearCache(); //this.Visible = true; //this.Activate(); break; } case (int)MenuItems.SimpleIncome: { BTPrintClass.PrintClass.CheckForClear(); ActionsClass.Action.OpenProducts(); ActionsClass.Action.OpenScanned(); using (InventarForm frm = new InventarForm(InventarFormMode.SimpleIncome)) { //this.Visible = false; frm.ShowDialog(); } ActionsClass.Action.CloseProducts(); ActionsClass.Action.ClosedScanned(); ActionsClass.Action.ClearCache(); //this.Visible = true; //this.Activate(); break; } case (int)MenuItems.IncomeMenu: { //this.Visible = false; BTPrintClass.PrintClass.CheckForClear(); ActionsClass.Action.OpenProducts(); ActionsClass.Action.OpenScanned(); using ( IncomeForm frm = new IncomeForm()) { frm.ShowDialog(); } ActionsClass.Action.CloseProducts(); ActionsClass.Action.ClosedScanned(); ActionsClass.Action.ClearCache(); //this.Visible = true; //this.Activate(); //BTPrintClass.PrintClass.SetStatusEvent("Form Closed"); break; } case (int)MenuItems.TTNForm: { //this.Visible = false; //thread = new System.Threading.Thread( // new System.Threading.ThreadStart( // frm_onBeginLoad)); //thread.IsBackground = false; //thread.Start(); using (TtnForm frm = new TtnForm()) { frm.onEndLoad += new EndLoadDelegate(frm_onEndLoad); BTPrintClass.PrintClass.CheckForClear(); ActionsClass.Action.OpenProducts(); ActionsClass.Action.OpenScanned(); //this.Visible = false; frm.ShowDialog(); //this.Visible = true; } ActionsClass.Action.CloseProducts(); ActionsClass.Action.ClosedScanned(); ActionsClass.Action.ClearCache(); //this.Visible = true; //this.Activate(); break; } case (int)MenuItems.ReturnBoxes: { //this.Visible = false; //thread = new System.Threading.Thread( // new System.Threading.ThreadStart( // frm_onBeginLoad)); //thread.IsBackground = false; //thread.Start(); using (ReturnForm frm = new ReturnForm()) { frm.onEndLoad += new EndLoadDelegate(frm_onEndLoad); BTPrintClass.PrintClass.CheckForClear(); ActionsClass.Action.OpenProducts(); ActionsClass.Action.OpenScanned(); //this.Visible = false; frm.ShowDialog(); //this.Visible = true; } ActionsClass.Action.CloseProducts(); ActionsClass.Action.ClosedScanned(); ActionsClass.Action.ClearCache(); //this.Visible = true; //this.Activate(); break; } case (int)MenuItems.ViewSettingMenu: { BTPrintClass.PrintClass.CheckForClear(); using (SettingsForm frm = new SettingsForm()) { //this.Visible = false; frm.ShowDialog(); } // this.Visible = true; //this.Activate(); break; } default: { break; } } } catch (Exception err) { MessageBox.Show(err.Message , "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } this.Refresh(); BTPrintClass.PrintClass.SetStatusEvent("Main Form Refreshed"); }
private void ProcessKeyDoun(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.Focused) { if (textBox1.Text != string.Empty) OnScanned(textBox1.Text); } else { try { enableScan = false; //int selected = listBox1.SelectedIndex; string[] selectObj = listBox1.Items[listBox1.SelectedIndex].ToString().Split('|'); ScanClass.Scaner.OnScanned -= scannedDelegate; ScanClass.Scaner.StopScan(); //ActionsClass.Action.CreateNewReturnBox( //проверить есть ли открытый короб //если есть - перейти в него //если нет - создать новый string returnBox = ActionsClass.Action.CheckOpenedReturnBoxAndGo(selectObj[0]); using (ViewProductForm prodfrm = new ViewProductForm( WorkMode.ReturnBoxWProducts, returnBox, //selectObj[0], textBox1.Text)) { prodfrm.ShowDialog(); } } catch (Exception err) { BTPrintClass.PrintClass.SetErrorEvent(err.Message); } finally { ScanClass.Scaner.InitScan(); ScanClass.Scaner.OnScanned += scannedDelegate; enableScan = true; } } return; } if (e.KeyCode == Keys.Escape) { this.Close(); return; } if (e.KeyValue == (int)SpecialButton.RedBtn) { if (listBox1.Items[listBox1.SelectedIndex] != null) { string[] selectObj = listBox1.Items[listBox1.SelectedIndex].ToString().Split('|'); //string[] selectObj = listBox1.SelectedValue.ToString().Split('|'); BTPrintClass.PrintClass.SetStatusEvent(selectObj[0]); BTPrintClass.PrintClass.SetStatusEvent(textBox1.Text); enableScan = false; try { ScanClass.Scaner.OnScanned -= scannedDelegate; ScanClass.Scaner.StopScan(); using (ViewProductForm prodfrm = new ViewProductForm( WorkMode.ReturnBoxWProducts, selectObj[0], textBox1.Text)) { prodfrm.ShowDialog(); } } finally { ScanClass.Scaner.InitScan(); ScanClass.Scaner.OnScanned += scannedDelegate; enableScan = true; } } //if (!closedCar && currentTtnBarcode != string.Empty) //{ // enableScan = false; // ScanClass.Scaner.OnScanned -= scannedDelegate; // try // { // using (IncomeForm income = // new IncomeForm(TtnStruct, currentTtnBarcode)) // { // income.ShowDialog(); // } // } // finally // { // enableScan = true; // ScanClass.Scaner.InitScan(); // ScanClass.Scaner.OnScanned += scannedDelegate; // } // CheckStatus(currentTtnBarcode); //} return; } if (e.KeyValue == (int)SpecialButton.BlueBtn) { return; } if (e.KeyValue == (int)SpecialButton.YellowBtn) { //enableScan = false; //try //{ // if (currentTtnBarcode != string.Empty && // Boxrows != null && // Boxrows.Count > 0) // { // using (ViewTtnForm vFrm = new ViewTtnForm(TtnStruct)) // { // vFrm.ShowDialog(); // } // } //} //finally //{ // enableScan = true; //} return; } if (e.KeyValue == (int)SpecialButton.GreenBtn) //GreenBtn { return; } } finally { this.Refresh(); } }