private void KeyDowns(object sender, KeyEventArgs e) { switch (e.KeyCode) { case Keys.Up: GridLista.Focus(); Support.UpDownDataGrid(false, GridLista); e.SuppressKeyPress = true; e.Handled = true; break; case Keys.Down: GridLista.Focus(); Support.UpDownDataGrid(true, GridLista); e.SuppressKeyPress = true; e.Handled = true; break; case Keys.Escape: Close(); e.SuppressKeyPress = true; break; case Keys.F10: SelectItemGrid(); e.SuppressKeyPress = true; break; case Keys.Enter: SelectItemGrid(); e.SuppressKeyPress = true; break; } }
private void Eventos() { Load += (s, e) => { SetTable(); }; btnImportar.Click += (s, e) => workerBackground.RunWorkerAsync(); btnClose.Click += (s, e) => { Application.OpenForms["ImportarNfe"]?.Close(); Application.OpenForms["ImportarProdutos"]?.Close(); Close(); }; workerBackground.DoWork += (s, e) => GridLista.Invoke((MethodInvoker) delegate { Importar(); }); workerBackground.RunWorkerCompleted += (s, e) => { label1.Text = @"Importação Concluída! :)"; btnImportar.Visible = false; btnClose.Visible = true; }; }
private void Eventos() { KeyDown += KeyDowns; KeyPreview = true; Masks.SetToUpper(this); Shown += (s, e) => { Refresh(); if (IdProduto < 0) { Alert.Message("Opps", "Não localizamos o produto.", Alert.AlertType.error); Close(); return; } GridLista.Focus(); LoadAttr(); }; btnContinuar.Click += (s, e) => SelectItemGrid(); }
private void Eventos() { workerBackground.DoWork += (s, e) => GridLista.Invoke((MethodInvoker)LoadProdutos); workerBackground.RunWorkerCompleted += (s, e) => { label2.Visible = false; pictureBox2.Visible = false; GridLista.Visible = true; }; Shown += (s, e) => { Refresh(); AutoCompleteItens(); pictureBox2.Visible = true; var cat = new Categoria().FindAll().Where("tipo", "Produtos").WhereFalse("excluir").OrderByDesc("nome").Get(); if (cat.Any()) { Categorias.DataSource = cat; Categorias.DisplayMember = "NOME"; Categorias.ValueMember = "ID"; } Medidas.DataSource = Support.GetMedidas(); if (ImportarNfe.optionSelected == 1) { BuscarProduto.Visible = false; label10.Visible = false; pictureBox4.Visible = false; btnVincular.Visible = false; label9.Text = @"Edite o produto selecionado abaixo"; } pictureBox2.Visible = true; GridLista.Visible = false; workerBackground.RunWorkerAsync(); }; btnVincular.Click += (s, e) => VincularProduto(); GridLista.CellClick += (s, e) => { BuscarProduto.Enabled = true; if (GridLista.Columns[e.ColumnIndex].Name == "Editar") { VincularProduto(true); GridLista.Enabled = false; } if (GridLista.Columns[e.ColumnIndex].Name == "Importar") { GridLista.SelectedRows[0].Cells["Importar"].Value = (bool)GridLista.SelectedRows[0].Cells["Importar"].Value == false; } }; GridLista.CellMouseEnter += (s, e) => { if (e.ColumnIndex < 0 || e.RowIndex < 0) { return; } var dataGridView = s as DataGridView; if (GridLista.Columns[e.ColumnIndex].Name == "Importar" || GridLista.Columns[e.ColumnIndex].Name == "Editar") { dataGridView.Cursor = Cursors.Hand; } }; GridLista.CellMouseLeave += (s, e) => { if (e.ColumnIndex < 0 || e.RowIndex < 0) { return; } var dataGridView = s as DataGridView; if (GridLista.Columns[e.ColumnIndex].Name == "Importar" || GridLista.Columns[e.ColumnIndex].Name == "Editar") { dataGridView.Cursor = Cursors.Default; } }; btnSalvarVinculacao.Click += (s, e) => { SalvarProduto(); if (ImportarNfe.optionSelected != 1) { label10.Visible = true; pictureBox4.Visible = true; BuscarProduto.Visible = true; btnVincular.Visible = true; label9.Text = @"Vincular a produtos existentes"; panelVinculacao.Location = new Point(34, 517); } panelVinculacao.Visible = false; }; btnImportar.Click += (s, e) => { produtos.Clear(); var i = -1; foreach (DataGridViewRow item in GridLista.Rows) { i++; if ((bool)item.Cells["Importar"].Value) { var id = Validation.ConvertToInt32(item.Cells["IDVINCULO"].Value); double estoque = 0; var codeBarras = item.Cells["Cód. de Barras"].Value.ToString(); var id_sync = 0; if (!string.IsNullOrEmpty(codeBarras)) { var _mItem = new Item(); _mItem = _mItem.Query().Select("*").Where("codebarras", codeBarras).Where("excluir", 0) .FirstOrDefault <Item>(); if (_mItem != null) { id = _mItem.Id; estoque = _mItem.EstoqueAtual; id_sync = _mItem.id_sync; } } //estoque = Validation.ConvertToDouble(item.Cells[6].Value) + estoque; switch (ImportarNfe.optionSelected) { case 1: estoque = 0; break; case 3: //estoque = Validation.ConvertToDouble(item.Cells[6].Value) + estoque; break; } produtos.Add(new { Ordem = i, Id = id, Referencia = item.Cells["Referência"].Value.ToString(), CodeBarras = item.Cells["Cód. de Barras"].Value.ToString(), Nome = item.Cells["Descrição"].Value.ToString(), Medida = item.Cells["Medida"].Value.ToString(), Estoque = estoque, CategoriaId = Validation.ConvertToInt32(item.Cells["CATEGORIAID"].Value), ValorCompra = Validation.ConvertToDouble(item.Cells["Vlr. Compra"].Value), ValorVenda = Validation.ConvertToDouble(item.Cells["Vlr. Venda"].Value), Fornecedor = item.Cells["Fornecedor"].Value.ToString(), NCM = item.Cells["NCM"].Value.ToString(), idSync = id_sync, EstoqueCompra = Validation.ConvertToDouble(item.Cells[6].Value) }); } } if (ImportarNfe.optionSelected == 3) { OpenForm.Show <ImportarPagamentos>(this); } else { OpenForm.Show <ImportarProdutosConcluido>(this); } }; valorcompra.TextChanged += (s, e) => { var txt = (TextBox)s; Masks.MaskPrice(ref txt); }; valorvenda.TextChanged += (s, e) => { var txt = (TextBox)s; Masks.MaskPrice(ref txt); Validation.WarningInput(txt, warning); }; btnMarcarCheckBox.Click += (s, e) => { foreach (DataGridViewRow item in GridLista.Rows) { if (btnMarcarCheckBox.Text == @"Marcar Todos") { if ((bool)item.Cells["Importar"].Value == false) { item.Cells["Importar"].Value = true; } } else { item.Cells["Importar"].Value = false; } } btnMarcarCheckBox.Text = btnMarcarCheckBox.Text == @"Marcar Todos" ? @"Desmarcar Todos" : @"Marcar Todos"; }; BuscarProduto.KeyDown += (s, e) => { if (e.KeyCode != Keys.Enter) { return; } if (!string.IsNullOrEmpty(BuscarProduto.Text)) { var item = _mItem.FindById(collection.Lookup(BuscarProduto.Text)).FirstOrDefault <Item>(); if (item != null) { BuscarProduto.Text = item.Nome; } ModalItens(); return; } if (string.IsNullOrEmpty(BuscarProduto.Text)) { ModalItens(); } else { VincularProduto(); } }; Back.Click += (s, e) => Close(); }
private void Eventos() { KeyDown += KeyDowns; KeyPreview = true; GridLista.Focus(); Shown += (s, e) => { Refresh(); SetHeadersTable(GridLista); SetContentTable(GridLista); }; GridLista.GotFocus += (s, e) => SetContentTable(GridLista); btnHelp.Click += (s, e) => Support.OpenLinkBrowser(Configs.LinkAjuda); btnExit.Click += (s, e) => Close(); btnAdicionar.Click += (s, e) => EditarTaxa(true); btnEditar.Click += (s, e) => EditarTaxa(); btnRemover.Click += (s, e) => { ListTaxas.Clear(); foreach (DataGridViewRow item in GridLista.Rows) { if ((bool)item.Cells["Selecione"].Value) { ListTaxas.Add(Validation.ConvertToInt32(item.Cells["ID"].Value)); } } var result = AlertOptions.Message("Atenção!", "Você está prestes a deletar os itens selecionados, continuar?", AlertBig.AlertType.warning, AlertBig.AlertBtn.YesNo); if (result) { foreach (var item in ListTaxas) { new Model.Taxas().Remove(item); } SetContentTable(GridLista); } btnRemover.Visible = false; btnEditar.Enabled = true; btnAdicionar.Enabled = true; }; GridLista.DoubleClick += (s, e) => EditarTaxa(); GridLista.CellClick += (s, e) => { if (GridLista.Columns[e.ColumnIndex].Name == "Selecione") { if ((bool)GridLista.SelectedRows[0].Cells["Selecione"].Value == false) { GridLista.SelectedRows[0].Cells["Selecione"].Value = true; btnRemover.Visible = true; btnEditar.Visible = false; btnAdicionar.Visible = false; } else { GridLista.SelectedRows[0].Cells["Selecione"].Value = false; var hideBtns = false; var hideBtnsTop = true; foreach (DataGridViewRow item in GridLista.Rows) { if ((bool)item.Cells["Selecione"].Value) { hideBtns = true; hideBtnsTop = false; } } btnRemover.Visible = hideBtns; btnEditar.Visible = hideBtnsTop; btnAdicionar.Visible = hideBtnsTop; } } }; GridLista.CellMouseEnter += (s, e) => { if (e.ColumnIndex < 0 || e.RowIndex < 0) { return; } var dataGridView = s as DataGridView; if (GridLista.Columns[e.ColumnIndex].Name == "Selecione") { dataGridView.Cursor = Cursors.Hand; } }; GridLista.CellMouseLeave += (s, e) => { if (e.ColumnIndex < 0 || e.RowIndex < 0) { return; } var dataGridView = s as DataGridView; if (GridLista.Columns[e.ColumnIndex].Name == "Selecione") { dataGridView.Cursor = Cursors.Default; } }; }