Beispiel #1
0
        private void Eventos()
        {
            KeyDown   += KeyDowns;
            KeyPreview = true;

            Load += (s, e) =>
            {
                var data = _mPedido.Query().Select("desconto").Where("id", idPedido).FirstOrDefault <Model.Pedido>();
                if (data == null)
                {
                    return;
                }

                if (data.Desconto > 0)
                {
                    dinheiro.Text = Validation.FormatPrice(data.Desconto);
                }
            };

            btnSalvar.Click         += (s, e) => Save();
            porcentagem.TextChanged += (s, e) =>
            {
                if (string.IsNullOrEmpty(porcentagem.Text))
                {
                    return;
                }

                var dataPedido = _mPedido.Query().Select("id", "total").Where("id", idPedido).First <Model.Pedido>();
                var dP         = Validation.ConvertToDouble(porcentagem.Text) / 100 * dataPedido.Total;
                valorPorcentagem.Text = Validation.FormatPrice(dP);
            };

            porcentagem.KeyPress += (s, e) => Masks.MaskDouble(s, e);
            dinheiro.KeyPress    += (s, e) => Masks.MaskDouble(s, e);
        }
Beispiel #2
0
        private void Eventos()
        {
            KeyDown   += KeyDowns;
            KeyPreview = true;

            Load += (s, e) =>
            {
                var data = _mPedido.Query().Select("frete").Where("id", idPedido).FirstOrDefault <Model.Pedido>();
                if (data == null)
                {
                    return;
                }

                if (data.Desconto > 0)
                {
                    Frete.Text = Validation.FormatPrice(data.Frete);
                }
            };

            btnSalvar.Click += (s, e) => Save();

            Frete.KeyPress += (s, e) => Masks.MaskDouble(s, e);
        }
Beispiel #3
0
        private void Eventos()
        {
            KeyDown   += KeyDowns;
            KeyPreview = true;
            Masks.SetToUpper(this);

            Shown += (s, e) =>
            {
                Refresh();

                BeginInvoke((MethodInvoker) delegate
                {
                    IdPdtSelecionado = Produtos.IdPdtSelecionado;
                    backOn.RunWorkerAsync();
                });

                SetHeadersAdicionais(GridAdicionais);
                SetHeadersCombo(GridCombos);
                nome.Focus();
            };

            menuEstoque.Click  += (s, e) => Support.DynamicPanel(flowLayoutPanel, panelEstoque, menuEstoque);
            label27.Click      += (s, e) => Support.DynamicPanel(flowLayoutPanel, panelEstoque, menuEstoque);
            pictureBox12.Click += (s, e) => Support.DynamicPanel(flowLayoutPanel, panelEstoque, menuEstoque);

            menuImpostos.Click += (s, e) => Support.DynamicPanel(flowLayoutPanel, panelImpostos, menuImpostos);
            label35.Click      += (s, e) => Support.DynamicPanel(flowLayoutPanel, panelImpostos, menuImpostos);
            pictureBox16.Click += (s, e) => Support.DynamicPanel(flowLayoutPanel, panelImpostos, menuImpostos);

            menuAdicionais.Click += (s, e) => Support.DynamicPanel(flowLayoutPanel, panelAdicionais, menuAdicionais);
            label30.Click        += (s, e) => Support.DynamicPanel(flowLayoutPanel, panelAdicionais, menuAdicionais);
            pictureBox13.Click   += (s, e) => Support.DynamicPanel(flowLayoutPanel, panelAdicionais, menuAdicionais);

            menuCombo.Click    += (s, e) => Support.DynamicPanel(flowLayoutPanel, panelCombo, menuCombo);
            label33.Click      += (s, e) => Support.DynamicPanel(flowLayoutPanel, panelCombo, menuCombo);
            pictureBox17.Click += (s, e) => Support.DynamicPanel(flowLayoutPanel, panelCombo, menuCombo);

            menuInfoAdicionais.Click += (s, e) => Support.DynamicPanel(flowLayoutPanel, panelInfoAdicionais, menuInfoAdicionais);
            label31.Click            += (s, e) => Support.DynamicPanel(flowLayoutPanel, panelInfoAdicionais, menuInfoAdicionais);
            pictureBox15.Click       += (s, e) => Support.DynamicPanel(flowLayoutPanel, panelInfoAdicionais, menuInfoAdicionais);

            btnExit.Click += (s, e) =>
            {
                var dataProd = _modelItem.Query().Where("id", IdPdtSelecionado)
                               .Where("atualizado", "01.01.0001, 00:00:00.000").WhereNull("codebarras").FirstOrDefault();
                if (dataProd != null)
                {
                    var result = AlertOptions.Message("Atenção!", "Esse produto não foi editado, deseja deletar?",
                                                      AlertBig.AlertType.info, AlertBig.AlertBtn.YesNo);
                    if (result)
                    {
                        var data = _modelItem.Remove(IdPdtSelecionado, false);
                        if (data)
                        {
                            Close();
                        }
                    }

                    nome.Focus();
                    return;
                }

                Close();
            };

            btnSalvar.Click += (s, e) => Save();

            btnRemover.Click += (s, e) =>
            {
                var result = AlertOptions.Message("Atenção!", "Você está prestes a deletar um produto, continuar?",
                                                  AlertBig.AlertType.warning, AlertBig.AlertBtn.YesNo);
                if (result)
                {
                    var data = _modelItem.Remove(IdPdtSelecionado);
                    if (data)
                    {
                        Close();
                    }
                }
            };

            btnEstoque.Click += (s, e) =>
            {
                _modelItem.Nome = nome.Text;
                if (new Model.Item().ValidarDados(_modelItem))
                {
                    return;
                }

                var f = new AddEstoque {
                    TopMost = true
                };
                if (f.ShowDialog() == DialogResult.OK)
                {
                    LoadEstoque();

                    estoqueminimo.Focus();
                    DataTableEstoque();
                }
            };

            valorcompra.TextChanged += (s, e) =>
            {
                var txt = (TextBox)s;
                Masks.MaskPrice(ref txt);
            };

            valorvenda.TextChanged += (s, e) =>
            {
                var txt = (TextBox)s;
                Masks.MaskPrice(ref txt);
            };

            txtLimiteDesconto.TextChanged += (s, e) =>
            {
                var txt = (TextBox)s;
                Masks.MaskPrice(ref txt);
            };

            btnAddCategoria.Click += (s, e) =>
            {
                Home.CategoriaPage = "Produtos";
                var f = new AddCategorias
                {
                    FormBorderStyle = FormBorderStyle.FixedSingle,
                    StartPosition   = FormStartPosition.CenterScreen,
                    TopMost         = true
                };
                if (f.ShowDialog() == DialogResult.OK)
                {
                    Categorias.DataSource = new Categoria().GetAll("Produtos");
                    Categorias.Refresh();
                }
            };

            btnAddFornecedor.Click += (s, e) =>
            {
                Home.pessoaPage = "Fornecedores";
                AddClientes.Id  = 0;
                var f = new AddClientes
                {
                    FormBorderStyle = FormBorderStyle.FixedSingle,
                    StartPosition   = FormStartPosition.CenterScreen,
                    TopMost         = true
                };
                if (f.ShowDialog() == DialogResult.OK)
                {
                    LoadFornecedores();
                }
            };

            btnAddImpostoOne.Click += (s, e) =>
            {
                View.Produtos.Impostos.idImpSelected = 0;
                var f = new AddImpostos
                {
                    FormBorderStyle = FormBorderStyle.FixedSingle,
                    StartPosition   = FormStartPosition.CenterScreen,
                    TopMost         = true
                };
                if (f.ShowDialog() == DialogResult.OK)
                {
                    LoadImpostoOne();
                    LoadImpostoTwo();
                }
            };

            btnAddImpostoTwo.Click += (s, e) =>
            {
                View.Produtos.Impostos.idImpSelected = 0;
                var f = new AddImpostos
                {
                    FormBorderStyle = FormBorderStyle.FixedSingle,
                    StartPosition   = FormStartPosition.CenterScreen,
                    TopMost         = true
                };
                if (f.ShowDialog() == DialogResult.OK)
                {
                    LoadImpostoOne();
                    LoadImpostoTwo();
                }
            };

            valorvenda.TextChanged += (s, e) =>
            {
                if (Validation.ConvertToDouble(valorcompra.Text) == 0)
                {
                    return;
                }

                if (Validation.ConvertToDouble(valorvenda.Text) == 0)
                {
                    return;
                }

                var media =
                    (Validation.ConvertToDouble(valorvenda.Text) - Validation.ConvertToDouble(valorcompra.Text)) * 100 /
                    Validation.ConvertToDouble(valorcompra.Text);
                precoMedio.Text = $"{Validation.ConvertToDouble(Validation.RoundTwo(media))}%";
            };

            valorcompra.TextChanged += (s, e) =>
            {
                if (Validation.ConvertToDouble(valorcompra.Text) == 0)
                {
                    return;
                }

                if (Validation.ConvertToDouble(valorvenda.Text) == 0)
                {
                    return;
                }

                var media =
                    (Validation.ConvertToDouble(valorvenda.Text) - Validation.ConvertToDouble(valorcompra.Text)) * 100 /
                    Validation.ConvertToDouble(valorcompra.Text);
                precoMedio.Text = Validation.Price(media);
            };

            estoqueminimo.KeyPress += (s, e) => Masks.MaskDouble(s, e);
            codebarras.KeyPress    += (s, e) => Masks.MaskOnlyNumbers(s, e, 20);
            referencia.KeyPress    += (s, e) => Masks.MaskOnlyNumberAndChar(s, e, 50);
            ncm.KeyPress           += (s, e) => Masks.MaskOnlyNumbers(s, e, 8);
            cest.KeyPress          += (s, e) => Masks.MaskOnlyNumbers(s, e, 7);

            nome.TextChanged += (s, e) => { btnEstoque.Visible = nome.Text.Length >= 2; };

            nome.KeyPress += (s, e) => { Masks.MaskMaxLength(s, e, 100); };

            btnHelp.Click += (s, e) => Support.OpenLinkBrowser(Configs.LinkAjuda);

            chkImpostoNFE.Click += (s, e) =>
            {
                if (chkImpostoNFE.Checked)
                {
                    ImpostoNFE.Enabled = true;
                }
                else
                {
                    ImpostoNFE.Enabled       = false;
                    ImpostoNFE.SelectedValue = 0;
                }
            };

            chkImpostoCFE.Click += (s, e) =>
            {
                if (chkImpostoCFE.Checked)
                {
                    ImpostoCFE.Enabled = true;
                }
                else
                {
                    ImpostoCFE.Enabled       = false;
                    ImpostoCFE.SelectedValue = 0;
                }
            };

            btnRemoverImage.Click += (s, e) =>
            {
                _modelItem.Id = IdPdtSelecionado;

                if (File.Exists($@"{Program.PATH_IMAGE}\Imagens\{_modelItem.Image}"))
                {
                    File.Delete($@"{Program.PATH_IMAGE}\Imagens\{_modelItem.Image}");
                }

                _modelItem.Image = "";
                _modelItem.Save(_modelItem, false);

                imageProduct.Image      = Resources.sem_imagem;
                pathImage.Text          = "";
                btnRemoverImage.Visible = false;
                Alert.Message("Pronto!", "Imagem removida com sucesso.", Alert.AlertType.success);
            };

            btnImage.Click += (s, e) =>
            {
                ofd.RestoreDirectory = true;
                ofd.Filter           = @"Image files (*.jpg, *.jpeg, *.png) | *.jpg; *.jpeg; *.png";
                ofd.CheckFileExists  = true;
                ofd.CheckPathExists  = true;
                ofd.Multiselect      = false;
                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    if (!ofd.CheckFileExists)
                    {
                        Alert.Message("Opps", "Não encontramos a imagem selecionada. Tente Novamente!",
                                      Alert.AlertType.error);
                        return;
                    }

                    var path = ofd.InitialDirectory + ofd.FileName;
                    var ext  = Path.GetExtension(ofd.FileName);

                    if (File.Exists(path))
                    {
                        if (!Directory.Exists(Program.PATH_IMAGE + @"\Imagens"))
                        {
                            Directory.CreateDirectory(Program.PATH_IMAGE + @"\Imagens");
                        }

                        var nameImage = $"{Validation.CleanString(nome.Text).Replace(" ", "-")}{ext}";

                        if (File.Exists($@"{Program.PATH_IMAGE}\Imagens\{nameImage}"))
                        {
                            File.Delete($@"{Program.PATH_IMAGE}\Imagens\{nameImage}");
                        }

                        File.Copy(path, $@"{Program.PATH_IMAGE}\Imagens\{nameImage}");

                        _modelItem.Id    = IdPdtSelecionado;
                        _modelItem.Image = nameImage;
                        _modelItem.Save(_modelItem, false);

                        var imageAsByteArray = File.ReadAllBytes($@"{Program.PATH_IMAGE}\Imagens\{nameImage}");
                        imageProduct.Image      = Support.ByteArrayToImage(imageAsByteArray);
                        pathImage.Text          = $@"{Program.PATH_IMAGE}\Imagens\{nameImage}";
                        btnRemoverImage.Visible = true;
                        Alert.Message("Pronto!", "Imagem atualizada com sucesso.", Alert.AlertType.success);
                    }
                    else
                    {
                        Alert.Message("Opps", "Não foi possível copiar a imagem. Tente novamente.",
                                      Alert.AlertType.error);
                    }
                }
            };

            filterTodos.Click        += (s, e) => DataTableEstoque();
            filterMaisRecentes.Click += (s, e) => DataTableEstoque();

            selecionarNCM.Click += (s, e) =>
            {
                var f = new ModalNCM {
                    TopMost = true
                };
                if (f.ShowDialog() == DialogResult.OK)
                {
                    ncm.Text = ModalNCM.NCM;
                }
            };

            backOn.DoWork += (s, e) =>
            {
                _modelItem       = _modelItem.FindById(IdPdtSelecionado).FirstOrDefault <Model.Item>();
                ListCategorias   = new Categoria().GetAll("Produtos");
                ListFornecedores = new Pessoa().GetAll("Fornecedores");
                Impostos         = new Model.Imposto().FindAll().WhereFalse("excluir").OrderByDesc("nome").Get();
                Impostos2        = new Model.Imposto().FindAll().WhereFalse("excluir").OrderByDesc("nome").Get();
            };

            backOn.RunWorkerCompleted += (s, e) =>
            {
                Start();

                if (IdPdtSelecionado > 0)
                {
                    LoadData();
                }
                else
                {
                    _modelItem = new Item {
                        Tipo = "Produtos", Id = IdPdtSelecionado
                    };
                    if (_modelItem.Save(_modelItem, false))
                    {
                        IdPdtSelecionado = _modelItem.GetLastId();
                        LoadData();
                    }
                    else
                    {
                        Alert.Message("Opss", "Erro ao criar.", Alert.AlertType.error);
                        Close();
                    }
                }
            };

            workerBackEstoque.DoWork += (s, e) =>
            {
                var query = new ItemEstoqueMovimentacao().Query()
                            .LeftJoin("USUARIOS", "USUARIOS.id_user", "ITEM_MOV_ESTOQUE.id_usuario")
                            .Select("ITEM_MOV_ESTOQUE.*", "USUARIOS.id_user", "USUARIOS.nome as nome_user")
                            .Where("id_item", IdPdtSelecionado)
                            .OrderByDesc("criado");

                if (LimitShowStock > 0)
                {
                    query.Limit(LimitShowStock);
                }

                ListEstoque = query.Get();
            };

            workerBackEstoque.RunWorkerCompleted += (s, e) =>
            {
                GetDataTableEstoque(listaEstoque);
            };

            btnVariacao.Click += (s, e) =>
            {
                ModalVariacao.idProduto = IdPdtSelecionado;
                var form = new ModalVariacao();
                form.ShowDialog();
            };

            GridAdicionais.CellContentClick += (s, e) =>
            {
                if (GridAdicionais.Columns[e.ColumnIndex].Name == "Selecione")
                {
                    GridAdicionais.SelectedRows[0].Cells["Selecione"].Value = (bool)GridAdicionais.SelectedRows[0].Cells["Selecione"].Value == false;
                }
            };

            GridAdicionais.CellMouseEnter += (s, e) =>
            {
                if (e.ColumnIndex < 0 || e.RowIndex < 0)
                {
                    return;
                }

                var dataGridView = s as DataGridView;
                if (GridAdicionais.Columns[e.ColumnIndex].Name == "Selecione")
                {
                    dataGridView.Cursor = Cursors.Hand;
                }
            };

            GridAdicionais.CellMouseLeave += (s, e) =>
            {
                if (e.ColumnIndex < 0 || e.RowIndex < 0)
                {
                    return;
                }

                var dataGridView = s as DataGridView;
                if (GridAdicionais.Columns[e.ColumnIndex].Name == "Selecione")
                {
                    dataGridView.Cursor = Cursors.Default;
                }
            };

            GridCombos.CellContentClick += (s, e) =>
            {
                if (GridCombos.Columns[e.ColumnIndex].Name == "Selecione")
                {
                    GridCombos.SelectedRows[0].Cells["Selecione"].Value = (bool)GridCombos.SelectedRows[0].Cells["Selecione"].Value == false;
                }
            };

            GridCombos.CellMouseEnter += (s, e) =>
            {
                if (e.ColumnIndex < 0 || e.RowIndex < 0)
                {
                    return;
                }

                var dataGridView = s as DataGridView;
                if (GridCombos.Columns[e.ColumnIndex].Name == "Selecione")
                {
                    dataGridView.Cursor = Cursors.Hand;
                }
            };

            GridCombos.CellMouseLeave += (s, e) =>
            {
                if (e.ColumnIndex < 0 || e.RowIndex < 0)
                {
                    return;
                }

                var dataGridView = s as DataGridView;
                if (GridCombos.Columns[e.ColumnIndex].Name == "Selecione")
                {
                    dataGridView.Cursor = Cursors.Default;
                }
            };
        }
Beispiel #4
0
        private void Eventos()
        {
            KeyDown   += KeyDowns;
            KeyPreview = true;
            Masks.SetToUpper(this);

            Shown += (s, e) =>
            {
                if (idItem > 0)
                {
                    var item = _modelItem.FindById(idItem).First <Item>();

                    tituloProduto.Text = item.Nome;
                    estoqueAtual.Text  = Validation.FormatMedidas(item.Medida, Validation.ConvertToDouble(item.EstoqueAtual));
                    custoAtual.Text    = Validation.FormatPrice(item.ValorCompra);
                }
            };

            btnSalvar.Click += (s, e) =>
            {
                var item = _modelItem.FindById(idItem).FirstOrDefault <Item>();
                if (item == null)
                {
                    return;
                }

                var tipo = btnRadioAddItem.Checked ? "A" : btnRadioRemoveItem.Checked ? "R" : "A";

                var data = _modelItemEstoque
                           .SetUsuario(Settings.Default.user_id)
                           .SetQuantidade(Validation.ConvertToDouble(quantidade.Text))
                           .SetTipo(tipo)
                           .SetLocal("Cadastro de Produto")
                           .SetObs(obs.Text)
                           .SetItem(item)
                           .Save(_modelItemEstoque);

                if (data)
                {
                    DialogResult = DialogResult.OK;
                    Close();
                }
            };

            quantidade.KeyPress += (s, e) => Masks.MaskDouble(s, e);
            obs.KeyPress        += (s, e) => Masks.MaskOnlyNumberAndCharAndMore(s, e);

            quantidade.TextChanged += (s, e) =>
            {
                var item = _modelItem.FindById(idItem).First <Item>();
                if (btnRadioAddItem.Checked)
                {
                    novaQtd.Text = Validation.FormatMedidas(item.Medida,
                                                            item.EstoqueAtual + Validation.ConvertToDouble(quantidade.Text));
                }

                if (btnRadioRemoveItem.Checked)
                {
                    novaQtd.Text = Validation.FormatMedidas(item.Medida,
                                                            item.EstoqueAtual - Validation.ConvertToDouble(quantidade.Text));
                }
            };

            btnRadioAddItem.Click += (s, e) =>
            {
                var item = _modelItem.FindById(idItem).First <Item>();
                if (!string.IsNullOrEmpty(quantidade.Text))
                {
                    novaQtd.Text = Validation.FormatMedidas(item.Medida,
                                                            item.EstoqueAtual + Validation.ConvertToDouble(quantidade.Text));
                }
            };

            btnRadioRemoveItem.Click += (s, e) =>
            {
                var item = _modelItem.FindById(idItem).First <Item>();
                if (!string.IsNullOrEmpty(quantidade.Text))
                {
                    novaQtd.Text = Validation.FormatMedidas(item.Medida,
                                                            item.EstoqueAtual - Validation.ConvertToDouble(quantidade.Text));
                }
            };
        }
Beispiel #5
0
        /// <summary>
        ///     Eventos do form
        /// </summary>
        public void Eventos()
        {
            Load += (s, e) =>
            {
                PayVerify = true;

                if (AddPedidos.PDV)
                {
                    // btn NF-e
                    btnNfe.Visible      = false;
                    button21.Visible    = false;
                    pictureBox6.Visible = false;
                }
            };

            Shown += (s, e) =>
            {
                Resolution.SetScreenMaximized(this);

                AddPedidos.BtnFinalizado = false;
                TelaReceber.Visible      = false;

                switch (Home.pedidoPage)
                {
                case "Orçamentos":
                    label13.Text = $@"Dados do Orçamento: {idPedido}";
                    label10.Text = @"Siga as etapas abaixo para criar um orçamento!";
                    break;

                case "Consignações":
                    label13.Text = $@"Dados da Consignação: {idPedido}";
                    label10.Text = @"Siga as etapas abaixo para criar uma consignãção!";
                    break;

                case "Devoluções":
                    label13.Text = $@"Dados da Devolução: {idPedido}";
                    label10.Text = @"Siga as etapas abaixo para criar uma devolução!";
                    break;

                case "Compras":
                    label13.Text = $@"Dados da Compra: {idPedido}";
                    label10.Text = @"Siga as etapas abaixo para adicionar uma compra!";

                    label15.Text = @"Á Pagar";
                    label1.Text  = @"Pagamentos";
                    //enviarEmail.Visible = false;
                    btnNfe.Visible    = false;
                    button21.Visible  = false;
                    btnCFeSat.Visible = false;
                    button22.Visible  = false;
                    break;

                default:
                    label13.Text = $@"Dados da Venda: {idPedido}";
                    label10.Text = @"Siga as etapas abaixo para adicionar uma venda!";
                    break;
                }

                if (HideFinalizar)
                {
                    btnCFeSat.Visible = false;
                    button22.Visible  = false;

                    btnNfe.Visible   = false;
                    button21.Visible = false;

                    btnConcluir.Visible = false;
                    button19.Visible    = false;

                    //btnImprimir.Left = 835;
                    //button20.Left = 830;
                    btnImprimir.Visible = false;
                    button20.Visible    = false;
                }

                if (IniFile.Read("Alimentacao", "Comercial") == "True")
                {
                    btnDividir.Visible = true;
                }

                mtxt.Visible  = false;
                mtxt2.Visible = false;

                GridListaFormaPgtos.Controls.Add(mtxt);
                GridListaFormaPgtos.Controls.Add(mtxt2);

                AtualizarDados();

                AddPedidos.BtnFinalizado = false;

                Dinheiro.Focus();
                Dinheiro.Select();

                var taxasSource = new ArrayList();
                var dataTaxa    = new Taxas().FindAll(new[] { "id", "nome" }).WhereFalse("excluir").Get <Taxas>();
                taxasSource.Add(new { Id = 0, Nome = "SELECIONE" });
                if (dataTaxa.Any())
                {
                    foreach (var item in dataTaxa)
                    {
                        taxasSource.Add(new { item.Id, item.Nome });
                    }
                }

                taxas.DataSource    = taxasSource;
                taxas.DisplayMember = "Nome";
                taxas.ValueMember   = "Id";
            };

            FormClosing += (s, e) =>
            {
                if (AddPedidos.BtnFinalizado)
                {
                    Application.OpenForms["AddPedidos"]?.Close();
                }
            };

            KeyDown                     += KeyDowns;
            Dinheiro.KeyDown            += KeyDowns;
            Cheque.KeyDown              += KeyDowns;
            Debito.KeyDown              += KeyDowns;
            Credito.KeyDown             += KeyDowns;
            Crediario.KeyDown           += KeyDowns;
            Boleto.KeyDown              += KeyDowns;
            Desconto.KeyDown            += KeyDowns;
            Acrescimo.KeyDown           += KeyDowns;
            GridListaFormaPgtos.KeyDown += KeyDowns;

            btnCFeSat.KeyDown += (s, e) =>
            {
                if (UserPermission.SetControl(btnCFeSat, pictureBox1, "fiscal_emissaocfe"))
                {
                    return;
                }

                KeyDowns(s, e);
            };

            btnNfe.KeyDown += (s, e) =>
            {
                if (!Support.CheckForInternetConnection())
                {
                    Alert.Message("Opps", "Você está sem conexão com a internet.", Alert.AlertType.warning);
                    return;
                }

                if (UserPermission.SetControl(btnNfe, pictureBox6, "fiscal_emissaonfe"))
                {
                    return;
                }

                KeyDowns(s, e);
            };

            btnImprimir.KeyDown += KeyDowns;
            btnConcluir.KeyDown += KeyDowns;
            btnSalvar.KeyDown   += KeyDowns;
            btnCancelar.KeyDown += KeyDowns;
            valor.KeyDown       += KeyDowns;
            parcelas.KeyDown    += KeyDowns;
            iniciar.KeyDown     += KeyDowns;

            btnImprimir.Click += (s, e) => { new Controller.Pedido().Imprimir(idPedido); };

            Debito.Click    += (s, e) => JanelasRecebimento("Cartão de Débito");
            Credito.Click   += (s, e) => JanelasRecebimento("Cartão de Crédito");
            Dinheiro.Click  += (s, e) => JanelasRecebimento("Dinheiro");
            Boleto.Click    += (s, e) => JanelasRecebimento("Boleto");
            Crediario.Click += (s, e) => JanelasRecebimento("Crediário");
            Cheque.Click    += (s, e) => JanelasRecebimento("Cheque");

            Desconto.Click  += (s, e) => JanelaDesconto();
            Acrescimo.Click += (s, e) => JanelaAcrescimo();
            Devolucao.Click += (s, e) => JanelaDevolucao();

            btnSalvar.Click   += (s, e) => BSalvar();
            btnCancelar.Click += (s, e) =>
            {
                PayVerify           = true;
                TelaReceber.Visible = false;
            };

            btnClose.Click += (s, e) =>
            {
                if (_controllerTitulo.GetLancados(idPedido) > 0)
                {
                    var text    = Home.pedidoPage == "Compras" ? "pagamentos" : "recebimentos";
                    var message = AlertOptions.Message("Atenção",
                                                       $"Os {text} lançados serão apagados,\n deseja continuar?", AlertBig.AlertType.warning,
                                                       AlertBig.AlertBtn.YesNo);
                    if (message)
                    {
                        foreach (DataGridViewRow row in GridListaFormaPgtos.Rows)
                        {
                            if (Convert.ToString(row.Cells[0].Value) != "")
                            {
                                _mTitulo.Remove(Validation.ConvertToInt32(row.Cells[0].Value), "ID", false);
                            }
                        }

                        AtualizarDados();

                        _mPedido        = _mPedido.FindById(idPedido).FirstOrDefault <Model.Pedido>();
                        _mPedido.status = 2;
                        _mPedido.Save(_mPedido);

                        Close();
                    }
                    else
                    {
                        return;
                    }
                }

                AddPedidos.BtnVoltar = true;
                Close();
            };

            btnDividir.Click += (s, e) =>
            {
                var itens = new ArrayList();
                if (PayVerify)
                {
                    var dataItens = _mPedidoItens.FindAll().Where("pedido", idPedido).WhereFalse("excluir")
                                    .Get <PedidoItem>();
                    if (dataItens.Any())
                    {
                        foreach (var item in dataItens)
                        {
                            itens.Add(new
                            {
                                item.Id,
                                item.Item,
                                item.xProd,
                                item.CEan,
                                item.CProd,
                                item.Quantidade,
                                item.Total
                            });
                        }
                    }

                    PedidoModalDividirConta.Itens = itens;
                }

                var form = new PedidoModalDividirConta {
                    TopMost = true
                };
                if (form.ShowDialog() == DialogResult.OK)
                {
                    valor.Text = Validation.FormatPrice(PedidoModalDividirConta.ValorDividido);
                }
            };

            btnConcluir.Click += (s, e) => { Concluir(); };

            iniciar.KeyPress += Masks.MaskBirthday;
            iniciar.KeyPress += Masks.MaskBirthday;
            valor.KeyPress   += (s, e) => Masks.MaskDouble(s, e);

            valor.TextChanged += (s, e) =>
            {
                var txt = (TextBox)s;
                Masks.MaskPrice(ref txt);
            };

            mtxt2.TextChanged += (s, e) =>
            {
                var txt = (TextBox)s;
                Masks.MaskPrice(ref txt);
            };

            GridListaFormaPgtos.CellDoubleClick += (s, e) =>
            {
                if (GridListaFormaPgtos.Columns[e.ColumnIndex].Name == "colExcluir")
                {
                    if (Convert.ToString(GridListaFormaPgtos.CurrentRow.Cells[4].Value) != "")
                    {
                        var id = Validation.ConvertToInt32(GridListaFormaPgtos.CurrentRow.Cells[0].Value);
                        _mTitulo.Remove(id);
                        AtualizarDados();
                    }
                }
            };

            GridListaFormaPgtos.CellBeginEdit += (s, e) =>
            {
                if (e.ColumnIndex == 2)
                {
                    //-----mtxt

                    mtxt.Mask = @"##/##/####";

                    var rec = GridListaFormaPgtos.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true);
                    mtxt.Location = rec.Location;
                    mtxt.Size     = rec.Size;
                    mtxt.Text     = "";

                    if (GridListaFormaPgtos[e.ColumnIndex, e.RowIndex].Value != null)
                    {
                        mtxt.Text = GridListaFormaPgtos[e.ColumnIndex, e.RowIndex].Value.ToString();
                    }

                    mtxt.Visible = true;
                }

                if (e.ColumnIndex == 3)
                {
                    //-----mtxt2

                    var rec = GridListaFormaPgtos.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true);
                    mtxt2.Location = rec.Location;
                    mtxt2.Size     = rec.Size;
                    mtxt2.Text     = "";

                    if (GridListaFormaPgtos[e.ColumnIndex, e.RowIndex].Value != null)
                    {
                        mtxt2.Text = GridListaFormaPgtos[e.ColumnIndex, e.RowIndex].Value.ToString();
                    }

                    mtxt2.Visible = true;
                }
            };

            GridListaFormaPgtos.CellEndEdit += (s, e) =>
            {
                if (mtxt.Visible)
                {
                    GridListaFormaPgtos.CurrentCell.Value = mtxt.Text;
                    mtxt.Visible = false;
                }

                if (mtxt2.Visible)
                {
                    GridListaFormaPgtos.CurrentCell.Value = mtxt2.Text;
                    mtxt2.Visible = false;
                }

                var ID = Validation.ConvertToInt32(GridListaFormaPgtos.Rows[e.RowIndex].Cells["colID"].Value);
                if (ID == 0)
                {
                    return;
                }

                var titulo = new Model.Titulo().FindById(ID).FirstOrDefault <Model.Titulo>();

                if (titulo == null)
                {
                    return;
                }

                DateTime parsed;
                if (DateTime.TryParse(GridListaFormaPgtos.Rows[e.RowIndex].Cells["Column1"].Value.ToString(),
                                      out parsed))
                {
                    titulo.Vencimento =
                        Validation.ConvertDateToSql(GridListaFormaPgtos.Rows[e.RowIndex].Cells["Column1"].Value);
                }
                else
                {
                    GridListaFormaPgtos.Rows[e.RowIndex].Cells["Column1"].Value =
                        Validation.ConvertDateToForm(titulo.Vencimento);
                }

                titulo.Total    = Validation.ConvertToDouble(GridListaFormaPgtos.Rows[e.RowIndex].Cells["Column3"].Value);
                titulo.Recebido =
                    Validation.ConvertToDouble(GridListaFormaPgtos.Rows[e.RowIndex].Cells["Column3"].Value);

                if (titulo.Save(titulo, false))
                {
                    //_controllerTitulo.GetDataTableTitulos(GridListaFormaPgtos, IdPedido);
                    Alert.Message("Pronto!", "Recebimento atualizado com sucesso.", Alert.AlertType.success);
                    AtualizarDados(false);
                }
                else
                {
                    Alert.Message("Opsss!", "Algo deu errado ao atualizar o recebimento.", Alert.AlertType.error);
                }
            };

            GridListaFormaPgtos.Scroll += (s, e) =>
            {
                if (mtxt.Visible)
                {
                    var rec = GridListaFormaPgtos.GetCellDisplayRectangle(GridListaFormaPgtos.CurrentCell.ColumnIndex,
                                                                          GridListaFormaPgtos.CurrentCell.RowIndex, true);
                    mtxt.Location = rec.Location;
                }

                if (mtxt2.Visible)
                {
                    var rec = GridListaFormaPgtos.GetCellDisplayRectangle(GridListaFormaPgtos.CurrentCell.ColumnIndex,
                                                                          GridListaFormaPgtos.CurrentCell.RowIndex, true);
                    mtxt2.Location = rec.Location;
                }
            };

            btnClearRecebimentos.Click += (s, e) =>
            {
                foreach (DataGridViewRow row in GridListaFormaPgtos.Rows)
                {
                    if (Convert.ToString(row.Cells[0].Value) != "")
                    {
                        _mTitulo.Remove(Validation.ConvertToInt32(row.Cells[0].Value), "ID", false);
                    }
                }

                AtualizarDados();

                _mPedido        = _mPedido.FindById(idPedido).FirstOrDefault <Model.Pedido>();
                _mPedido.status = 2;
                _mPedido.Save(_mPedido);
            };

            btnNfe.Click += (s, e) =>
            {
                if (!Support.CheckForInternetConnection())
                {
                    Alert.Message("Opps", "Você está sem conexão com a internet.", Alert.AlertType.warning);
                    return;
                }

                if (UserPermission.SetControl(btnNfe, pictureBox6, "fiscal_emissaonfe"))
                {
                    return;
                }

                Nfe();
            };

            btnCFeSat.Click += (s, e) =>
            {
                if (UserPermission.SetControl(btnCFeSat, pictureBox1, "fiscal_emissaocfe"))
                {
                    return;
                }

                Cfe();
            };
        }
Beispiel #6
0
        /// <summary>
        /// Eventos do form
        /// </summary>
        public void Eventos()
        {
            KeyDown           += KeyDowns;
            Dinheiro.KeyDown  += KeyDowns;
            Cheque.KeyDown    += KeyDowns;
            Debito.KeyDown    += KeyDowns;
            Credito.KeyDown   += KeyDowns;
            Crediario.KeyDown += KeyDowns;
            Boleto.KeyDown    += KeyDowns;
            Desconto.KeyDown  += KeyDowns;
            Acrescimo.KeyDown += KeyDowns;

            btnSalvar.KeyDown   += KeyDowns;
            btnCancelar.KeyDown += KeyDowns;
            valor.KeyDown       += KeyDowns;
            parcelas.KeyDown    += KeyDowns;
            iniciar.KeyDown     += KeyDowns;

            Load += (s, e) =>
            {
                mtxt.Visible  = false;
                mtxt2.Visible = false;

                GridListaFormaPgtos.Controls.Add(mtxt);
                GridListaFormaPgtos.Controls.Add(mtxt2);

                AtualizarDados();

                if (_mNota.Status != "Pendente")
                {
                    progress5.Visible   = false;
                    pictureBox1.Visible = false;
                    label13.Visible     = false;
                    Next.Visible        = false;
                }
            };

            Debito.Click    += (s, e) => JanelasRecebimento("Cartão de Débito");
            Credito.Click   += (s, e) => JanelasRecebimento("Cartão de Crédito");
            Dinheiro.Click  += (s, e) => JanelasRecebimento("Dinheiro");
            Boleto.Click    += (s, e) => JanelasRecebimento("Boleto");
            Crediario.Click += (s, e) => JanelasRecebimento("Crediário");
            Cheque.Click    += (s, e) => JanelasRecebimento("Cheque");

            Desconto.Click  += (s, e) => JanelaDesconto();
            Acrescimo.Click += (s, e) => JanelaAcrescimo();

            btnSalvar.Click   += (s, e) => bSalvar();
            btnCancelar.Click += (s, e) => TelaReceber.Visible = false;

            iniciar.KeyPress += (s, e) => Masks.MaskBirthday(s, e);
            iniciar.KeyPress += (s, e) => Masks.MaskBirthday(s, e);
            valor.KeyPress   += (s, e) => Masks.MaskDouble(s, e);

            valor.TextChanged += (s, e) =>
            {
                TextBox txt = (TextBox)s;
                Masks.MaskPrice(ref txt);
            };

            GridListaFormaPgtos.CellDoubleClick += (s, e) =>
            {
                if (GridListaFormaPgtos.Columns[e.ColumnIndex].Name == "colExcluir")
                {
                    Console.WriteLine(GridListaFormaPgtos.CurrentRow.Cells[4].Value);
                    if (Convert.ToString(GridListaFormaPgtos.CurrentRow.Cells[4].Value) != "")
                    {
                        int id = Validation.ConvertToInt32(GridListaFormaPgtos.CurrentRow.Cells[0].Value);
                        _mTitulo.Remove(id);
                        AtualizarDados();
                    }
                }
            };

            btnClearRecebimentos.Click += (s, e) =>
            {
                foreach (DataGridViewRow row in GridListaFormaPgtos.Rows)
                {
                    if (Convert.ToString(row.Cells[0].Value) != "")
                    {
                        _mTitulo.Remove(Validation.ConvertToInt32(row.Cells[0].Value), "ID", false);
                    }
                }

                AtualizarDados();
            };

            Next.Click += (s, e) => OpenForm.Show <TelaFinal>(this);

            Back.Click += (s, e) => Close();

            mtxt2.TextChanged += (s, e) =>
            {
                TextBox txt = (TextBox)s;
                Masks.MaskPrice(ref txt);
            };

            GridListaFormaPgtos.CellBeginEdit += (s, e) =>
            {
                if (e.ColumnIndex == 2)
                {
                    //-----mtxt

                    mtxt.Mask = "##/##/####";

                    Rectangle rec = GridListaFormaPgtos.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true);
                    mtxt.Location = rec.Location;
                    mtxt.Size     = rec.Size;
                    mtxt.Text     = "";

                    if (GridListaFormaPgtos[e.ColumnIndex, e.RowIndex].Value != null)
                    {
                        mtxt.Text = GridListaFormaPgtos[e.ColumnIndex, e.RowIndex].Value.ToString();
                    }

                    mtxt.Visible = true;
                }

                if (e.ColumnIndex == 3)
                {
                    //-----mtxt2

                    Rectangle rec = GridListaFormaPgtos.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true);
                    mtxt2.Location = rec.Location;
                    mtxt2.Size     = rec.Size;
                    mtxt2.Text     = "";

                    if (GridListaFormaPgtos[e.ColumnIndex, e.RowIndex].Value != null)
                    {
                        mtxt2.Text = GridListaFormaPgtos[e.ColumnIndex, e.RowIndex].Value.ToString();
                    }

                    mtxt2.Visible = true;
                }
            };

            GridListaFormaPgtos.CellEndEdit += (s, e) =>
            {
                if (mtxt.Visible)
                {
                    GridListaFormaPgtos.CurrentCell.Value = mtxt.Text;
                    mtxt.Visible = false;
                }

                if (mtxt2.Visible)
                {
                    GridListaFormaPgtos.CurrentCell.Value = mtxt2.Text;
                    mtxt2.Visible = false;
                }

                int ID = Validation.ConvertToInt32(GridListaFormaPgtos.Rows[e.RowIndex].Cells["colID"].Value);

                if (ID == 0)
                {
                    return;
                }

                var titulo = new Model.Titulo().FindById(ID).FirstOrDefault <Model.Titulo>();

                if (titulo == null)
                {
                    return;
                }

                DateTime parsed;
                if (DateTime.TryParse(GridListaFormaPgtos.Rows[e.RowIndex].Cells["Column1"].Value.ToString(), out parsed))
                {
                    titulo.Vencimento = Validation.ConvertDateToSql(GridListaFormaPgtos.Rows[e.RowIndex].Cells["Column1"].Value);
                }
                else
                {
                    GridListaFormaPgtos.Rows[e.RowIndex].Cells["Column1"].Value = Validation.ConvertDateToForm(titulo.Vencimento);
                }

                titulo.Total    = Validation.ConvertToDouble(GridListaFormaPgtos.Rows[e.RowIndex].Cells["Column3"].Value);
                titulo.Recebido = Validation.ConvertToDouble(GridListaFormaPgtos.Rows[e.RowIndex].Cells["Column3"].Value);

                if (titulo.Save(titulo, false))
                {
                    //_controllerTitulo.GetDataTableTitulos(GridListaFormaPgtos, IdPedido);
                    Alert.Message("Pronto!", "Recebimento atualizado com sucesso.", Alert.AlertType.success);
                    AtualizarDados(false);
                }
                else
                {
                    Alert.Message("Opsss!", "Algo deu errado ao atualizar o recebimento.", Alert.AlertType.error);
                }
            };

            GridListaFormaPgtos.Scroll += (s, e) =>
            {
                if (mtxt.Visible)
                {
                    Rectangle rec = GridListaFormaPgtos.GetCellDisplayRectangle(GridListaFormaPgtos.CurrentCell.ColumnIndex, GridListaFormaPgtos.CurrentCell.RowIndex, true);
                    mtxt.Location = rec.Location;
                }

                if (mtxt2.Visible)
                {
                    Rectangle rec = GridListaFormaPgtos.GetCellDisplayRectangle(GridListaFormaPgtos.CurrentCell.ColumnIndex, GridListaFormaPgtos.CurrentCell.RowIndex, true);
                    mtxt2.Location = rec.Location;
                }
            };
        }
Beispiel #7
0
        private void Eventos()
        {
            BuscarProduto.Select();

            KeyDown                   += KeyDowns;
            ModoRapido.KeyDown        += KeyDowns;
            BuscarProduto.KeyDown     += KeyDowns;
            GridListaProdutos.KeyDown += KeyDowns;
            Quantidade.KeyDown        += KeyDowns;
            Masks.SetToUpper(this);

            Shown += (s, e) =>
            {
                // Autocomplete de produtos
                collection = _mItem.AutoComplete("Produtos");
                BuscarProduto.AutoCompleteCustomSource = collection;

                Medidas.DataSource = Support.GetMedidas();

                SetHeadersTable(GridListaProdutos);
                GetDataTableItens(GridListaProdutos, _mNota.id_pedido);
                LoadTotais();
                ClearForms();
                BuscarProduto.Select();

                if (_mNota.Status != "Pendente")
                {
                    progress5.Visible   = false;
                    pictureBox1.Visible = false;
                    label9.Visible      = false;
                }
            };

            ModoRapido.Click += (s, e) => AlterarModo();

            Next.Click += (s, e) => OpenForm.Show <TelaFrete>(this);

            Back.Click += (s, e) => Close();

            addProduto.Click += (s, e) => LoadItens();

            BuscarProduto.KeyDown += (s, e) =>
            {
                if (e.KeyCode == Keys.Enter)
                {
                    if (ModoRapAva == 1)
                    {
                        if (!string.IsNullOrEmpty(nomeProduto()[0]))
                        {
                            var item = _mItem.FindById(collection.Lookup(nomeProduto()[0])).FirstOrDefault <Model.Item>();
                            if (item != null)
                            {
                                Preco.Text           = Validation.FormatPrice(item.ValorVenda);
                                Medidas.SelectedItem = item.Medida;
                            }

                            Quantidade.Focus();
                            return;
                        }
                    }

                    if (string.IsNullOrEmpty(nomeProduto()[0]))
                    {
                        ModalItens();
                    }
                    else
                    {
                        LoadItens();
                    }
                }
            };

            GridListaProdutos.DoubleClick += (s, e) =>
            {
                if (GridListaProdutos.SelectedRows.Count > 0)
                {
                    EditProduct.idPdt  = Validation.ConvertToInt32(GridListaProdutos.SelectedRows[0].Cells["ID"].Value);
                    EditProduct.nrItem = Validation.ConvertToInt32(GridListaProdutos.SelectedRows[0].Cells["#"].Value);
                    EditProduct f = new EditProduct();
                    f.TopMost = true;
                    if (f.ShowDialog() == DialogResult.OK)
                    {
                        GetDataTableItens(GridListaProdutos, _mNota.id_pedido);
                        LoadTotais();
                    }
                }
            };

            Preco.TextChanged += (s, e) =>
            {
                TextBox txt = (TextBox)s;
                Masks.MaskPrice(ref txt);
            };

            Preco.KeyDown += (s, e) =>
            {
                if (e.KeyCode == Keys.Enter)
                {
                    LoadItens();
                }
            };

            Quantidade.KeyPress += (s, e) => Masks.MaskDouble(s, e);
            Quantidade.KeyDown  += (s, e) =>
            {
                if (e.KeyCode == Keys.Enter)
                {
                    if (String.IsNullOrEmpty(nomeProduto()[0]))
                    {
                        BuscarProduto.Focus();
                    }
                    else if (ModoRapAva == 1 && !String.IsNullOrEmpty(nomeProduto()[0]))
                    {
                        Preco.Focus();
                    }
                    else
                    {
                        LoadItens();
                    }
                }
            };

            DescontoPorcentagem.KeyDown += (s, e) =>
            {
                if (e.KeyCode == Keys.Enter)
                {
                    LoadItens();
                }
            };
            DescontoReais.KeyDown += (s, e) =>
            {
                if (e.KeyCode == Keys.Enter)
                {
                    LoadItens();
                }
            };

            AlterarImposto.Click += (s, e) =>
            {
                if (GridListaProdutos.SelectedRows.Count > 0)
                {
                    AlterarImposto f = new AlterarImposto();
                    f.TopMost = true;
                    if (f.ShowDialog() == DialogResult.OK)
                    {
                        if (idImposto > 0)
                        {
                            foreach (DataGridViewRow item in GridListaProdutos.Rows)
                            {
                                if ((bool)item.Cells["Selecione"].Value == true)
                                {
                                    new Controller.Imposto().SetImposto(Validation.ConvertToInt32(item.Cells["ID"].Value), idImposto, "NFe", NCM);
                                }
                            }
                        }

                        GetDataTableItens(GridListaProdutos, _mNota.id_pedido);
                    }

                    NCM       = "";
                    idImposto = 0;
                }

                BuscarProduto.Select();
            };

            btnMarcarCheckBox.Click += (s, e) =>
            {
                foreach (DataGridViewRow item in GridListaProdutos.Rows)
                {
                    if (btnMarcarCheckBox.Text == "Marcar Todos")
                    {
                        if ((bool)item.Cells["Selecione"].Value == false)
                        {
                            item.Cells["Selecione"].Value = true;
                            AlterarImposto.Visible        = true;
                        }
                    }
                    else
                    {
                        item.Cells["Selecione"].Value = false;
                        AlterarImposto.Visible        = false;
                    }
                }

                if (btnMarcarCheckBox.Text == "Marcar Todos")
                {
                    btnMarcarCheckBox.Text = "Desmarcar Todos";
                }
                else
                {
                    btnMarcarCheckBox.Text = "Marcar Todos";
                }
            };

            GridListaProdutos.CellClick += (s, e) =>
            {
                if (GridListaProdutos.Columns[e.ColumnIndex].Name == "Selecione")
                {
                    if ((bool)GridListaProdutos.SelectedRows[0].Cells["Selecione"].Value == false)
                    {
                        GridListaProdutos.SelectedRows[0].Cells["Selecione"].Value = true;
                        AlterarImposto.Visible = true;
                    }
                    else
                    {
                        GridListaProdutos.SelectedRows[0].Cells["Selecione"].Value = false;

                        bool hideBtns = false;
                        foreach (DataGridViewRow item in GridListaProdutos.Rows)
                        {
                            if ((bool)item.Cells["Selecione"].Value == true)
                            {
                                hideBtns = true;
                            }
                        }

                        AlterarImposto.Visible = hideBtns;
                    }
                }
            };

            GridListaProdutos.CellMouseEnter += (s, e) =>
            {
                if (e.ColumnIndex < 0 || e.RowIndex < 0)
                {
                    return;
                }

                var dataGridView = (s as DataGridView);
                if (GridListaProdutos.Columns[e.ColumnIndex].Name == "Selecione")
                {
                    dataGridView.Cursor = Cursors.Hand;
                }
            };

            GridListaProdutos.CellMouseLeave += (s, e) =>
            {
                if (e.ColumnIndex < 0 || e.RowIndex < 0)
                {
                    return;
                }

                var dataGridView = (s as DataGridView);
                if (GridListaProdutos.Columns[e.ColumnIndex].Name == "Selecione")
                {
                    dataGridView.Cursor = Cursors.Default;
                }
            };
        }
Beispiel #8
0
        private void Eventos()
        {
            KeyDown   += KeyDowns;
            KeyPreview = true;
            Masks.SetToUpper(this);

            Shown += (s, e) =>
            {
                txtQtdItens.Text = @"0";
                txtValor.Text    = @"R$ 00,00";

                SetHeadersTableItens(GridLista);
                SetHeadersTableSelecionados(GridListaSelecionados);
                LoadItens();
            };

            txtDinheiro.KeyPress += (s, e) => Masks.MaskDouble(s, e);

            txtDinheiro.TextChanged += (s, e) =>
            {
                var txt = (TextBox)s;
                Masks.MaskPrice(ref txt);

                var troco = Validation.ConvertToDouble(txtDinheiro.Text) -
                            Validation.ConvertToDouble(txtValor.Text.Replace("R$ ", ""));
                label6.Text = Validation.FormatPrice(troco, true);
            };

            btnContinuar.Click += (s, e) =>
            {
                Itens.Clear();

                if (GridLista.Rows.Count > 0)
                {
                    foreach (DataGridViewRow row in GridLista.Rows)
                    {
                        Itens.Add(new
                        {
                            Id         = row.Cells[0].Value,
                            CProd      = row.Cells[1].Value,
                            xProd      = row.Cells[2].Value,
                            Quantidade = row.Cells[3].Value,
                            Total      = Validation.ConvertToDouble(row.Cells[4].Value.ToString().Replace("R$ ", ""))
                        });
                    }
                }

                DialogResult = DialogResult.OK;
                Close();
            };

            #region Table Itens

            GridLista.CellClick += (s, e) =>
            {
                if (GridLista.Columns[e.ColumnIndex].Name == "Dividir")
                {
                    ModalDividirValor.Valor = Validation.ConvertToDouble(GridLista.SelectedRows[0].Cells["Valor"].Value
                                                                         .ToString().Replace("R$ ", ""));
                    var form = new ModalDividirValor {
                        TopMost = true
                    };
                    if (form.ShowDialog() == DialogResult.OK)
                    {
                        GridListaSelecionados.Rows.Add(
                            GridLista.SelectedRows[0].Cells["ID"].Value,
                            GridLista.SelectedRows[0].Cells["Referência"].Value,
                            GridLista.SelectedRows[0].Cells["Item"].Value,
                            GridLista.SelectedRows[0].Cells["Qtd."].Value,
                            Validation.FormatPrice(ModalDividirValor.ValorDivido, true),
                            Resources.error20x
                            );

                        RefreshTotal();

                        if (ModalDividirValor.ValorRestante <= 0)
                        {
                            GridLista.Rows.RemoveAt(e.RowIndex);
                        }
                        else
                        {
                            GridLista.Rows[e.RowIndex].Cells[4].Value =
                                Validation.FormatPrice(ModalDividirValor.ValorRestante, true);
                        }

                        Alert.Message("Pronto", "Item adicionado.", Alert.AlertType.success);
                    }
                }

                if (GridLista.Columns[e.ColumnIndex].Name == "Adicionar")
                {
                    GridListaSelecionados.Rows.Add(
                        GridLista.SelectedRows[0].Cells["ID"].Value,
                        GridLista.SelectedRows[0].Cells["Referência"].Value,
                        GridLista.SelectedRows[0].Cells["Item"].Value,
                        GridLista.SelectedRows[0].Cells["Qtd."].Value,
                        GridLista.SelectedRows[0].Cells["Valor"].Value,
                        Resources.error20x
                        );

                    RefreshTotal();

                    GridLista.Rows.RemoveAt(e.RowIndex);

                    Alert.Message("Pronto", "Item adicionado.", Alert.AlertType.success);
                }
            };

            GridLista.CellMouseEnter += (s, e) =>
            {
                if (e.ColumnIndex < 0 || e.RowIndex < 0)
                {
                    return;
                }

                var dataGridView = s as DataGridView;
                if (GridLista.Columns[e.ColumnIndex].Name == "Adicionar" ||
                    GridLista.Columns[e.ColumnIndex].Name == "Dividir")
                {
                    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 == "Adicionar" ||
                    GridLista.Columns[e.ColumnIndex].Name == "Dividir")
                {
                    dataGridView.Cursor = Cursors.Default;
                }
            };

            #endregion

            #region Itens Selecionados

            GridListaSelecionados.CellClick += (s, e) =>
            {
                if (GridListaSelecionados.Columns[e.ColumnIndex].Name == "Remover")
                {
                    var notFound = true;
                    foreach (DataGridViewRow row in GridLista.Rows)
                    {
                        if (row.Cells[0].Value.ToString() ==
                            GridListaSelecionados.Rows[e.RowIndex].Cells[0].Value.ToString())
                        {
                            var valor    = Validation.ConvertToDouble(row.Cells[4].Value.ToString().Replace("R$ ", ""));
                            var addValor = Validation.ConvertToDouble(GridListaSelecionados.Rows[e.RowIndex].Cells[4]
                                                                      .Value.ToString().Replace("R$ ", ""));
                            row.Cells[4].Value = Validation.FormatPrice(valor + addValor, true);
                            notFound           = false;
                            break;
                        }
                    }

                    if (notFound)
                    {
                        GridLista.Rows.Add(
                            GridListaSelecionados.SelectedRows[0].Cells["ID"].Value,
                            GridListaSelecionados.SelectedRows[0].Cells["Referência"].Value,
                            GridListaSelecionados.SelectedRows[0].Cells["Item"].Value,
                            GridListaSelecionados.SelectedRows[0].Cells["Qtd."].Value,
                            GridListaSelecionados.SelectedRows[0].Cells["Valor"].Value,
                            Resources.divide20x,
                            Resources.plus20x
                            );
                    }

                    GridListaSelecionados.Rows.RemoveAt(e.RowIndex);

                    RefreshTotal();
                }
            };

            GridListaSelecionados.CellMouseEnter += (s, e) =>
            {
                if (e.ColumnIndex < 0 || e.RowIndex < 0)
                {
                    return;
                }

                var dataGridView = s as DataGridView;
                if (GridListaSelecionados.Columns[e.ColumnIndex].Name == "Remover")
                {
                    dataGridView.Cursor = Cursors.Hand;
                }
            };

            GridListaSelecionados.CellMouseLeave += (s, e) =>
            {
                if (e.ColumnIndex < 0 || e.RowIndex < 0)
                {
                    return;
                }

                var dataGridView = s as DataGridView;
                if (GridListaSelecionados.Columns[e.ColumnIndex].Name == "Remover")
                {
                    dataGridView.Cursor = Cursors.Default;
                }
            };

            #endregion
        }