Example #1
0
        private void Eventos()
        {
            KeyDown   += KeyDowns;
            KeyPreview = true;
            Masks.SetToUpper(this);

            Load += (s, e) =>
            {
                search.Select();
                DataTableStart();
            };

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

            Adicionar.Click += (s, e) => EditImposto(true);
            Editar.Click    += (s, e) => EditImposto();
            GridListaImpostos.DoubleClick += (s, e) => EditImposto();

            search.TextChanged += (s, e) =>
            {
                timer.Stop();
                timer.Start();
                Loading.Visible           = true;
                GridListaImpostos.Visible = false;
            };
            //search.KeyDown += KeyDowns;
            //GridListaImpostos.KeyDown += KeyDowns;

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

            using (var b = workerBackground)
            {
                b.DoWork += async(s, e) => { dataTable = await _controller.GetDataTable(); };

                b.RunWorkerCompleted += async(s, e) =>
                {
                    await _controller.SetTable(GridListaImpostos, dataTable);

                    Loading.Visible           = false;
                    GridListaImpostos.Visible = true;
                };
            }

            timer.AutoReset = false;
            timer.Elapsed  += (s, e) => search.Invoke((MethodInvoker) delegate
            {
                DataTable();
                Loading.Visible           = false;
                GridListaImpostos.Visible = true;
            });

            search.Enter += async(s, e) =>
            {
                await Task.Delay(100);

                DataTable();
            };
        }
Example #2
0
        private void Eventos()
        {
            Masks.SetToUpper(this);

            Shown += (s, e) =>
            {
                Impostos();
                LoadDados();
            };

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

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

            btnExcluir.Click += (s, e) =>
            {
                itemPedido.Id      = idPdt;
                itemPedido.Excluir = 1;
                if (itemPedido.Save(itemPedido))
                {
                    DialogResult = DialogResult.OK;
                    Close();
                }
            };

            valorUnitario.TextChanged += new EventHandler(Masks.MaskPriceEvent);
            valorDesconto.TextChanged += new EventHandler(Masks.MaskPriceEvent);
            valorFrete.TextChanged    += new EventHandler(Masks.MaskPriceEvent);
            valorSeguro.TextChanged   += new EventHandler(Masks.MaskPriceEvent);
            vlrDespesa.TextChanged    += new EventHandler(Masks.MaskPriceEvent);
            valorTotal.TextChanged    += new EventHandler(Masks.MaskPriceEvent);

            icmsaliq.TextChanged += new EventHandler(Masks.MaskPriceEvent);
            icmsBase.TextChanged += new EventHandler(Masks.MaskPriceEvent);
            icmsvlr.TextChanged  += new EventHandler(Masks.MaskPriceEvent);

            icmsstaliq.TextChanged           += new EventHandler(Masks.MaskPriceEvent);
            icmsstbasecomreducao.TextChanged += new EventHandler(Masks.MaskPriceEvent);
            icmsstbase.TextChanged           += new EventHandler(Masks.MaskPriceEvent);
            icmsstvlr.TextChanged            += new EventHandler(Masks.MaskPriceEvent);
            pisaliq.TextChanged += new EventHandler(Masks.MaskPriceEvent);
            pisvlr.TextChanged  += new EventHandler(Masks.MaskPriceEvent);

            cofinsaliq.TextChanged += new EventHandler(Masks.MaskPriceEvent);
            cofinsvlr.TextChanged  += new EventHandler(Masks.MaskPriceEvent);
            ipialiq.TextChanged    += new EventHandler(Masks.MaskPriceEvent);
            ipivlr.TextChanged     += new EventHandler(Masks.MaskPriceEvent);

            federal.TextChanged   += new EventHandler(Masks.MaskPriceEvent);
            estadual.TextChanged  += new EventHandler(Masks.MaskPriceEvent);
            municipal.TextChanged += new EventHandler(Masks.MaskPriceEvent);
        }
Example #3
0
        private void Eventos()
        {
            KeyDown   += KeyDowns;
            KeyPreview = true;
            Masks.SetToUpper(this);

            ToolHelp.Show("Título para identificar a Mesa.", pictureBox1, ToolHelp.ToolTipIcon.Info, "Ajuda!");
            ToolHelp.Show("A quantidade de pessoas que cabem na mesa.", pictureBox5, ToolHelp.ToolTipIcon.Info,
                          "Ajuda!");

            Shown += (s, e) =>
            {
                mesa.Focus();

                if (IdMesa > 0)
                {
                    _mMesas = _mMesas.FindById(IdMesa).WhereFalse("excluir").FirstOrDefault <Model.Mesas>();
                    if (_mMesas == null)
                    {
                        return;
                    }

                    label11.Text   = @"Editar mesa";
                    mesa.Text      = _mMesas.Mesa;
                    nrPessoas.Text = _mMesas.NrPessoas.ToString();
                }
                else
                {
                    IdMesa = 0;
                }
            };

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

            btnDelete.Click += (s, e) =>
            {
                if (IdMesa <= 0)
                {
                    return;
                }

                if (_mMesas.Remove(IdMesa))
                {
                    Alert.Message("Pronto", "Mesa removida com sucesso.", Alert.AlertType.success);

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

                Alert.Message("Opps", "Erro ao remover mesa.", Alert.AlertType.error);
            };

            FormClosing += (s, e) => { DialogResult = DialogResult.OK; };
        }
Example #4
0
        private void Eventos()
        {
            KeyDown   += KeyDowns;
            KeyPreview = true;
            Masks.SetToUpper(this);

            Load += (s, e) => Carregar();

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

            btnSalvar.Click += (s, e) =>
            {
                _modelImposto.Id   = idImpSelected;
                _modelImposto.Nome = nome.Text;
                _modelImposto.Cfop = cfop.Text;

                GetImpostos(0);

                if (_modelImposto.Save(_modelImposto))
                {
                    DialogResult = DialogResult.OK;
                    Close();
                }
            };

            btnRemover.Click += (s, e) =>
            {
                var data = _modelImposto.Remove(idImpSelected);
                if (data)
                {
                    Close();
                }
            };

            Icms.SelectedValueChanged += (s, e) => SetIcms();

            addCfop.Click += (s, e) =>
            {
                var form = new Cfops {
                    TopMost = true
                };
                if (form.ShowDialog() == DialogResult.OK)
                {
                    //    _mPedido.Id = Id;
                    //    _mPedido.Colaborador = PedidoModalClientes.Id;
                    //    _mPedido.Save(_mPedido);
                    //    LoadData();
                }
            };

            cfop.KeyPress += (s, e) => Masks.MaskOnlyNumbers(s, e, 4);

            btnHelp.Click += (s, e) => Support.OpenLinkBrowser(Configs.LinkAjuda);
        }
Example #5
0
        private void Eventos()
        {
            KeyDown   += KeyDowns;
            KeyPreview = true;
            Masks.SetToUpper(this);

            Shown += (s, e) =>
            {
                switch (Home.pedidoPage)
                {
                case "Delivery":
                    if (page == "Entregadores")
                    {
                        label11.Text      = @"Selecione o Entregador!";
                        label2.Text       = @"Buscar entregador (F1):";
                        NovoCliente.Text  = @"Entregador Novo ? (F9)";
                        label1.Text       = @"Entregadores encontrados:";
                        pictureBox1.Image = Resources.deliveryman;
                    }
                    else
                    {
                        label11.Text     = @"Selecione o Cliente!";
                        label2.Text      = @"Buscar cliente (F1):";
                        NovoCliente.Text = @"Cliente Novo ? (F9)";
                        label1.Text      = @"Clientes encontrados:";
                    }

                    break;

                case "Compras":
                    label11.Text     = @"Selecione o Fornecedor!";
                    label2.Text      = @"Buscar fornecedor (F1):";
                    NovoCliente.Text = @"Fornecedor Novo ? (F9)";
                    label1.Text      = @"Fornecedores encontrados:";
                    break;

                default:
                    label11.Text     = @"Selecione o Cliente!";
                    label2.Text      = @"Buscar cliente (F1):";
                    NovoCliente.Text = @"Cliente Novo ? (F9)";
                    label1.Text      = @"Clientes encontrados:";
                    break;
                }
            };

            search.TextChanged += (s, e) => DataTable();
            search.Enter       += (s, e) => DataTable();

            NovoCliente.Click   += (s, e) => FormNovoCliente();
            btnSelecionar.Click += (s, e) => SelectItemGrid();
            GridListaClientes.CellDoubleClick += (s, e) => SelectItemGrid();

            search.KeyPress += (s, e) => Masks.MaskOnlyNumberAndCharAndMore(s, e);
        }
Example #6
0
        private void Eventos()
        {
            Masks.SetToUpper(this);

            Shown += (s, e) =>
            {
                if (Home.financeiroPage == "Pagar")
                {
                    label6.Text = @"Pagamentos";
                    label2.Text = @"Pagamentoss a serem editados:";
                    label3.Text = @"As alterações abaixo, será aplicado a todos os pagamentos listado acima.";

                    label23.Text         = @"Pagar para";
                    label8.Text          = @"Despesa";
                    visualGroupBox2.Text = @"Pagamento";
                    label9.Text          = @"Data Pagamento";
                    label10.Text         = @"Valor Pagamento";
                }

                Refresh();

                formaPgto.ValueMember   = "Id";
                formaPgto.DisplayMember = "Nome";
                formaPgto.DataSource    = new FormaPagamento().GetAll();

                LoadFornecedores();
                LoadCategorias();

                SetHeadersTable(GridLista);
                SetContentTable(GridLista);
            };

            btnSalvar.Click += (s, e) =>
            {
                var result = AlertOptions.Message("Atenção!", "Confirmar alterações?", AlertBig.AlertType.warning,
                                                  AlertBig.AlertBtn.YesNo);
                if (result)
                {
                    Save();
                }
            };

            dataRecebido.KeyPress += Masks.MaskBirthday;
            recebido.TextChanged  += (s, e) =>
            {
                var txt = (TextBox)s;
                Masks.MaskPrice(ref txt);
            };

            label6.Click  += (s, e) => Close();
            btnExit.Click += (s, e) => Close();
        }
Example #7
0
        private void Eventos()
        {
            KeyDown   += KeyDowns;
            KeyPreview = true;
            Masks.SetToUpper(this);

            search.TextChanged += (s, e) => DataTable();
            search.Enter       += (s, e) => DataTable();

            Novo.Click          += (s, e) => FormNovoCliente();
            btnSelecionar.Click += (s, e) => SelectItemGrid();

            search.KeyPress += (s, e) => Masks.MaskOnlyNumberAndCharAndMore(s, e);
        }
Example #8
0
        private void Eventos()
        {
            KeyDown   += KeyDowns;
            KeyPreview = true;
            Masks.SetToUpper(this);

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

                if (Id > 0)
                {
                    LoadData();
                }
                else
                {
                    _mItemAdicional.Id = 0;
                    if (_mItemAdicional.Save(_mItemAdicional))
                    {
                        Id = _mItemAdicional.GetLastId();
                        LoadData();
                    }
                    else
                    {
                        Alert.Message("Opss", "Erro ao criar.", Alert.AlertType.error);
                        Close();
                    }
                }
            };

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

            btnRemover.Click += (s, e) =>
            {
                if (_mItemAdicional.Remove(Id))
                {
                    Alert.Message("Pronto", "Adicional removido com sucesso.", Alert.AlertType.success);
                    Close();
                }
            };

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

            btnHelp.Click += (s, e) => Support.OpenLinkBrowser(Configs.LinkAjuda);
            btnExit.Click += (s, e) => Close();
        }
Example #9
0
        private void Eventos()
        {
            KeyDown   += KeyDowns;
            KeyPreview = true;
            Masks.SetToUpper(this);

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

            btnSelecionar.Click       += (s, e) => SelectItemGrid();
            GridLista.CellDoubleClick += (s, e) => SelectItemGrid();
        }
Example #10
0
        private void Eventos()
        {
            KeyDown   += KeyDowns;
            KeyPreview = true;
            Masks.SetToUpper(this);

            Load += (s, e) =>
            {
                nome.Select();

                ToolHelp.Show(
                    "Digite o nome que deseja para a categoria.\nVocê pode cadastrar a Marca do produto como uma categoria por exemplo.",
                    pictureBox6, ToolHelp.ToolTipIcon.Info, "Ajuda!");
            };

            btnSalvar.Click += (s, e) =>
            {
                _modelCategoria.Id   = idCatSelected;
                _modelCategoria.Nome = nome.Text;
                _modelCategoria.Tipo = Home.CategoriaPage;

                if (!_modelCategoria.Save(_modelCategoria))
                {
                    return;
                }

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

            btnRemover.Click += (s, e) =>
            {
                var data = _modelCategoria.Remove(idCatSelected);
                if (data)
                {
                    Close();
                }
            };

            nome.KeyPress += (s, e) => Masks.MaskOnlyNumberAndChar(s, e, 50);

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

            btnHelp.Click += (s, e) => Support.OpenLinkBrowser(Configs.LinkAjuda);
        }
Example #11
0
        private void Eventos()
        {
            KeyDown   += KeyDowns;
            KeyPreview = true;
            Masks.SetToUpper(this);

            Load += async(s, e) =>
                    await _controllerItem.SetTable(GridListaProdutos, null, buscarProduto.Text, 1, false, true);

            buscarProduto.Text = txtSearch;

            buscarProduto.TextChanged += async(s, e) =>
                                         await _controllerItem.SetTable(GridListaProdutos, null, buscarProduto.Text, 1, false, true);

            GridListaProdutos.CellDoubleClick += (s, e) => SelectItemGrid();
            Selecionar.Click += (s, e) => SelectItemGrid();
        }
Example #12
0
        private void Eventos()
        {
            KeyDown   += KeyDowns;
            KeyPreview = true;
            Masks.SetToUpper(this);

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

                BuscarProduto.Select();
                AutoCompleteItens();
                AutoCompleteUsers();

                dataInicial.Text = DateTime.Today.AddMonths(-1).ToString();
                dataFinal.Text   = DateTime.Now.ToString();

                var origens = new ArrayList
                {
                    new { Id = "0", Nome = "Todos" },
                    new { Id = "1", Nome = "Cadastro de Produtos" },
                    new { Id = "2", Nome = "Vendas" },
                    new { Id = "3", Nome = "Orçamentos" },
                    new { Id = "4", Nome = "Consignações" },
                    new { Id = "5", Nome = "Devoluções" }
                };

                Locais.DataSource    = origens;
                Locais.DisplayMember = "Nome";
                Locais.ValueMember   = "Id";

                await DataTableAsync();
            };

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

            btnSearch.Click += async(s, e) => { await DataTableAsync(); };

            imprimir.Click += async(s, e) => await RenderizarAsync();

            btnHelp.Click += (s, e) => Support.OpenLinkBrowser(Program.URL_BASE + "/ajuda");
        }
Example #13
0
        private void Eventos()
        {
            KeyDown   += KeyDowns;
            KeyPreview = true;
            Masks.SetToUpper(this);

            Load += (s, e) =>
            {
                nome.Select();

                ToolHelp.Show("Título identificador da categoria.", pictureBox6, ToolHelp.ToolTipIcon.Info, "Ajuda!");
            };

            btnSalvar.Click += (s, e) =>
            {
                _model.Id   = idSelected;
                _model.Nome = nome.Text;

                if (_model.Save(_model))
                {
                    DialogResult = DialogResult.OK;
                    Close();
                }
            };
            btnRemover.Click += (s, e) =>
            {
                var data = _model.Remove(idSelected);
                if (data)
                {
                    Close();
                }
            };

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

            btnHelp.Click += (s, e) => Support.OpenLinkBrowser(Configs.LinkAjuda);
        }
Example #14
0
        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();
        }
Example #15
0
        private void Eventos()
        {
            KeyDown   += KeyDowns;
            KeyPreview = true;
            Masks.SetToUpper(this);

            Load += (s, e) =>
            {
                Tipo.DataSource = new List <String> {
                    "Cadastro Manual", "Cadastro automático por CNPJ"
                };
            };

            cpfCnpj.KeyPress += (s, e) =>
            {
                Masks.MaskCNPJ(s, e);
            };

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

            btnCancelar.Click += (s, e) => Close();
        }
Example #16
0
        private void Eventos()
        {
            KeyDown   += KeyDowns;
            KeyPreview = true;
            Masks.SetToUpper(this);

            Load += (s, e) =>
            {
                BuscarProduto.Select();
                BuscarProduto.Focus();

                AutoCompleteItens();
                Start();
                DataTableStart();
                LoadItens();
            };

            addProduto.Click += (s, e) =>
            {
                for (var i = 0; i < Validation.ConvertToInt32(Quantidade.Text); i++)
                {
                    AddItem();
                }

                // Limpa os campos
                ClearForms();
                DataTable();
                LoadItens();
            };

            imprimir.Click += (s, e) => Render();

            modelos.SelectedValueChanged += (s, e) => { label9.Text = modelos.SelectedValue.ToString(); };

            btnClean.Click += (s, e) =>
            {
                new Model.Etiqueta().Clean();
                DataTable();
                LoadItens();
            };

            BuscarProduto.TextChanged += (s, e) =>
            {
                labelEstoque.Visible = false;
                if (collection.Lookup(BuscarProduto.Text) <= 0)
                {
                    return;
                }

                labelEstoque.Visible = true;
                var itemId = collection.Lookup(BuscarProduto.Text);
                var item   = _mItem.FindById(itemId).Where("excluir", 0).Where("tipo", "Produtos").First <Item>();
                labelEstoque.Text = $"Estoque atual: {item.EstoqueAtual}";
            };

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

            using (var b = workerBackground)
            {
                b.DoWork += async(s, e) => { dataTable = await _controller.GetDataTable(); };

                b.RunWorkerCompleted += async(s, e) =>
                {
                    LoadItens();
                    await _controller.SetTable(GridLista, dataTable);

                    Loading.Visible   = false;
                    GridLista.Visible = true;
                };
            }

            timer.AutoReset = false;

            btnVideoAjuda.Click += (s, e) => Support.Video("https://www.youtube.com/watch?v=_ybEHAVTXUA");
        }
Example #17
0
        private void Eventos()
        {
            KeyDown   += KeyDowns;
            KeyPreview = true;
            Masks.SetToUpper(this);

            Shown += (s, e) =>
            {
                ToolHelp.Show("Descreva seu serviço... Lembre-se de utilizar as características do serviço.",
                              pictureBox5, ToolHelp.ToolTipIcon.Info, "Ajuda!");

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

                Refresh();
            };

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

                    nome.Focus();
                }

                Close();
            };

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

                var data = _modelItem.Remove(idSelecionado);
                if (data)
                {
                    Close();
                }
            };

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

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

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

            btnHelp.Click += (s, e) => Support.OpenLinkBrowser(Configs.LinkAjuda);
        }
Example #18
0
        private void Eventos()
        {
            KeyDown           += KeyDowns;
            txtGrupos.KeyDown += KeyDowns;
            KeyPreview         = true;
            Masks.SetToUpper(this);

            Load += (s, e) =>
            {
                ToolHelp.Show(
                    "Com essa opção marcada é possível que o sistema dê uma travada para gerar\ncada código de barras diferente um do outro.",
                    pictureBox4, ToolHelp.ToolTipIcon.Info, "Ajuda!");
            };

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

                _mItem = _mItem.FindById(idProduto).FirstOrDefault <Item>();
                AutoCompleteGrupos();
                SetHeadersTable(dataGridVariacao);
                LoadDataGrid();

                txtGrupos.Focus();
            };

            btnAddGrupo.Click += (s, e) => { AddCombination(); };

            btnClearCombinacao.Click += (s, e) =>
            {
                ClearEstoque();
                txtBuscarVariacao.Text     = "";
                btnClearCombinacao.Visible = false;
                btnGerar.Visible           = true;
            };

            btnGerar.Click += (sender, e) =>
            {
                if (string.IsNullOrEmpty(txtBuscarVariacao.Text))
                {
                    Alert.Message("Opps", "Escolhe pelo menos um grupo de variação.", Alert.AlertType.error);
                    return;
                }

                if (dataGridVariacao.Rows.Count > 0)
                {
                    var generateAlert = AlertOptions.Message("Atenção",
                                                             "Ao gerar novas combinações, você irá perder a atual!\n Continuar?", AlertBig.AlertType.info,
                                                             AlertBig.AlertBtn.YesNo);
                    if (!generateAlert)
                    {
                        return;
                    }

                    dataGridVariacao.Rows.Clear();
                }

                var attr1Name = new List <string>();
                var attr2Name = new List <string>();
                var attr3Name = new List <string>();

                var attr1Id = new List <string>();
                var attr2Id = new List <string>();
                var attr3Id = new List <string>();

                var grupos  = txtBuscarVariacao.Text.Split('+');
                var i_attrs = 0;
                foreach (var word in grupos)
                {
                    i_attrs++;

                    var grupo = new ItemGrupo().FindAll().WhereFalse("excluir").Where("title", word)
                                .FirstOrDefault <ItemGrupo>();
                    if (grupo == null)
                    {
                        continue;
                    }

                    var attr = new ItemAtributos().FindAll().WhereFalse("excluir").Where("grupo", grupo.Id)
                               .Get <ItemAtributos>();
                    foreach (var data in attr)
                    {
                        switch (i_attrs)
                        {
                        case 1:
                            attr1Name.Add($"{data.Atributo}");
                            attr1Id.Add($"{data.Id}");
                            break;

                        case 2:
                            attr2Name.Add($" - {data.Atributo}");
                            attr2Id.Add($", {data.Id}");
                            break;

                        case 3:
                            attr3Name.Add($" - {data.Atributo}");
                            attr3Id.Add($", {data.Id}");
                            break;
                        }
                    }
                }

                var lstMaster = new List <List <string> >();
                if (attr1Id.Count > 0)
                {
                    lstMaster.Add(attr1Id);
                }

                if (attr2Id.Count > 0)
                {
                    lstMaster.Add(attr2Id);
                }

                if (attr3Id.Count > 0)
                {
                    lstMaster.Add(attr3Id);
                }

                var lstMasterNames = new List <List <string> >();
                if (attr1Name.Count > 0)
                {
                    lstMasterNames.Add(attr1Name);
                }

                if (attr2Name.Count > 0)
                {
                    lstMasterNames.Add(attr2Name);
                }

                if (attr3Name.Count > 0)
                {
                    lstMasterNames.Add(attr3Name);
                }

                var ids   = GetPermutation(lstMaster.Count, lstMaster);
                var names = GetPermutation(lstMasterNames.Count, lstMasterNames);

                if (ids.Count != names.Count)
                {
                    return;
                }

                for (var u = 0; u < ids.Count; u++)
                {
                    var codeBarras = "";
                    if (checkCodeBarras.Checked)
                    {
                        codeBarras = CodeBarrasRandom();
                    }

                    dataGridVariacao.Rows.Add(
                        false,
                        ids[u],
                        names[u],
                        0,
                        "",
                        codeBarras
                        );
                }

                dataGridVariacao.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            };

            btnSalvar.Click += (s, e) =>
            {
                if (dataGridVariacao.Rows.Count <= 0)
                {
                    return;
                }

                var item = new Item().FindById(idProduto).WhereFalse("excluir").FirstOrDefault <Item>();
                if (item != null)
                {
                    item.Atributos = txtBuscarVariacao.Text;
                    item.Save(item);
                }

                foreach (DataGridViewRow row in dataGridVariacao.Rows)
                {
                    // Apaga o registro se estoque for 0 e se existir no banco
                    if (Validation.ConvertToDouble(row.Cells["Estoque"].Value) == 0)
                    {
                        if (row.Cells["IDAttr"].Value != null &&
                            !string.IsNullOrEmpty(row.Cells["IDAttr"].Value.ToString()))
                        {
                            new ItemEstoque().Remove(Validation.ConvertToInt32(row.Cells["IDAttr"].Value));
                            continue;
                        }
                    }

                    // Se a coluna for diferente de 0 ou diferente de vazio, inclui a linha no banco!
                    if (!(Validation.ConvertToDouble(row.Cells["Estoque"].Value) > 0))
                    {
                        continue;
                    }

                    string codeBarras;
                    if (checkCodeBarras.Checked && string.IsNullOrEmpty(row.Cells["Código de Barras"].Value.ToString()))
                    {
                        codeBarras = CodeBarrasRandom();
                    }
                    else
                    {
                        codeBarras = row.Cells["Código de Barras"].Value.ToString();
                    }

                    // Se a coluna IDAttr não estiver vazio, atualiza o registro
                    if (row.Cells["IDAttr"].Value != null &&
                        !string.IsNullOrEmpty(row.Cells["IDAttr"].Value.ToString()))
                    {
                        var updateEstoque = new ItemEstoque()
                                            .FindById(Validation.ConvertToInt32(row.Cells["IDAttr"].Value))
                                            .FirstOrDefault <ItemEstoque>();
                        updateEstoque.Item       = idProduto;
                        updateEstoque.Referencia = row.Cells["Referencia"].Value.ToString();
                        updateEstoque.Codebarras = codeBarras;
                        updateEstoque.Atributo   = row.Cells["ID"].Value.ToString();
                        updateEstoque.Estoque    = Validation.ConvertToDouble(row.Cells["Estoque"].Value);
                        updateEstoque.Usuario    = Settings.Default.user_id;
                        updateEstoque.Title      = row.Cells["Combinação"].Value.ToString();
                        updateEstoque.Save(updateEstoque);

                        continue;
                    }

                    var estoque = new ItemEstoque
                    {
                        Item       = idProduto,
                        Referencia = row.Cells["Referencia"].Value.ToString(),
                        Codebarras = codeBarras,
                        Atributo   = row.Cells["ID"].Value.ToString(),
                        Estoque    = Validation.ConvertToDouble(row.Cells["Estoque"].Value),
                        Usuario    = Settings.Default.user_id,
                        Title      = row.Cells["Combinação"].Value.ToString()
                    };
                    estoque.Save(estoque);

                    row.Cells["IDAttr"].Value = estoque.GetLastId();
                }

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

            btnClose.Click += (s, e) => Close();
        }
Example #19
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;
                }
            };
        }
Example #20
0
        private void Eventos()
        {
            KeyDown   += KeyDowns;
            KeyPreview = true;
            Masks.SetToUpper(this);

            Load += (s, e) =>
            {
                Categorias.DataSource    = new Categoria().GetAll("Produtos");
                Categorias.DisplayMember = "Nome";
                Categorias.ValueMember   = "Id";
            };

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

                SetHeadersTable(GridLista);
                SetHeadersTableProdutos(GridProdutos);

                if (IniFile.Read("MesasPreCadastrada", "Comercial") == "True")
                {
                    nrMesa.Visible = false;
                    Mesas.Visible  = true;

                    var listMesas = new ArrayList {
                        new { Id = "0", Nome = "SELECIONE" }
                    };
                    var getMesas = new Model.Mesas().FindAll().WhereFalse("excluir").Get <Model.Mesas>();
                    if (getMesas.Any())
                    {
                        foreach (var mesas in getMesas)
                        {
                            listMesas.Add(new { Id = $"{mesas.Id}", Nome = $"{mesas.Mesa}" });
                        }
                    }

                    Mesas.DataSource    = listMesas;
                    Mesas.DisplayMember = "Nome";
                    Mesas.ValueMember   = "Id";
                }
            };

            BuscarProduto.KeyDown += (s, e) =>
            {
                if (e.KeyCode != Keys.Enter)
                {
                    return;
                }

                var item = _mItem.FindById(collection.Lookup(BuscarProduto.Text)).FirstOrDefault <Item>();
                if (item == null)
                {
                    return;
                }

                if (!string.IsNullOrEmpty(item.Combos))
                {
                    var comboExits = false;
                    var idsCombo   = item.Combos.Split(',');
                    foreach (var id in idsCombo)
                    {
                        var checkCombo = new Model.ItemCombo().FindById(Validation.ConvertToInt32(id)).WhereFalse("excluir").FirstOrDefault <ItemCombo>();
                        if (checkCombo != null)
                        {
                            comboExits = true;
                        }
                    }

                    if (comboExits)
                    {
                        AddCombo.IdProduto = item.Id;
                        AddCombo.IdPedido  = 0;
                        var form = new AddCombo {
                            TopMost = true
                        };
                        if (form.ShowDialog() == DialogResult.OK)
                        {
                            foreach (PedidoItem data in AddCombo.listProdutosIncluir)
                            {
                                GridLista.Rows.Add(
                                    false,
                                    data.Item,
                                    data.xProd,
                                    Validation.FormatPrice(Validation.ConvertToDouble(data.ValorVenda)),
                                    "",
                                    data.Adicional,
                                    Validation.ConvertToDouble(data.ValorVenda),
                                    Resources.menu20x
                                    );
                            }

                            txtValorTotal.Text = $@"Valor Total: {Validation.FormatPrice(SumTotalGrid(), true)}";
                            BuscarProduto.Text = "";
                            BuscarProduto.Select();
                            return;
                        }
                    }
                }

                GridLista.Rows.Add(
                    false,
                    item.Id,
                    item.Nome,
                    Validation.FormatPrice(Validation.ConvertToDouble(item.ValorVenda)),
                    "",
                    "",
                    Validation.ConvertToDouble(item.ValorVenda),
                    Resources.menu20x
                    );

                txtValorTotal.Text = $@"Valor Total: {Validation.FormatPrice(SumTotalGrid(), true)}";
                BuscarProduto.Text = "";
                BuscarProduto.Select();
            };

            btnFiltrar.Click += (s, e) => LoadProdutos();
            btnEnviar.Click  += (s, e) => ActionEnviar();

            GridProdutos.CellClick += (s, e) =>
            {
                if (GridProdutos.Columns[e.ColumnIndex].Name == "Adicionar")
                {
                    var idItem = Validation.ConvertToInt32(GridProdutos.SelectedRows[0].Cells["ID"].Value);
                    var item   = _mItem.FindById(idItem).FirstOrDefault <Item>();
                    if (item == null)
                    {
                        return;
                    }

                    if (!string.IsNullOrEmpty(item.Combos))
                    {
                        var comboExits = false;
                        var idsCombo   = item.Combos.Split(',');
                        foreach (var id in idsCombo)
                        {
                            var checkCombo = new Model.ItemCombo().FindById(Validation.ConvertToInt32(id)).WhereFalse("excluir").FirstOrDefault <ItemCombo>();
                            if (checkCombo != null)
                            {
                                comboExits = true;
                            }
                        }

                        if (comboExits)
                        {
                            AddCombo.IdProduto = item.Id;
                            AddCombo.IdPedido  = 0;
                            var form = new AddCombo {
                                TopMost = true
                            };
                            if (form.ShowDialog() == DialogResult.OK)
                            {
                                foreach (PedidoItem data in AddCombo.listProdutosIncluir)
                                {
                                    GridLista.Rows.Add(
                                        false,
                                        data.Item,
                                        data.xProd,
                                        Validation.FormatPrice(Validation.ConvertToDouble(data.ValorVenda)),
                                        "",
                                        data.Adicional,
                                        Validation.ConvertToDouble(data.ValorVenda),
                                        Resources.menu20x
                                        );
                                }

                                BuscarProduto.Text = "";
                                BuscarProduto.Select();
                                Alert.Message("Pronto", "Item adicionado.", Alert.AlertType.success);
                                return;
                            }
                        }
                    }

                    GridLista.Rows.Add(
                        false,
                        GridProdutos.SelectedRows[0].Cells["ID"].Value,
                        GridProdutos.SelectedRows[0].Cells["Item"].Value,
                        GridProdutos.SelectedRows[0].Cells["Valor"].Value,
                        "",
                        "",
                        GridProdutos.SelectedRows[0].Cells["Valor"].Value,
                        Resources.menu20x
                        );

                    txtValorTotal.Text = $@"Valor Total: {Validation.FormatPrice(SumTotalGrid(), true)}";
                    Alert.Message("Pronto", "Item adicionado.", Alert.AlertType.success);
                }
            };

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

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

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

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

            btnRemover.Click += (s, e) =>
            {
                var toBeDeleted = new List <DataGridViewRow>();
                toBeDeleted.Clear();

                var result = AlertOptions.Message("Atenção!",
                                                  "Você está prestes a deletar os PRODUTOS selecionados, continuar?", AlertBig.AlertType.warning,
                                                  AlertBig.AlertBtn.YesNo);
                if (result)
                {
                    foreach (DataGridViewRow item in GridLista.Rows)
                    {
                        Console.WriteLine(item.Cells["Selecione"].Value);
                        if ((bool)item.Cells["Selecione"].Value)
                        {
                            toBeDeleted.Add(item);
                        }
                    }

                    toBeDeleted.ForEach(d => GridLista.Rows.Remove(d));
                }

                txtValorTotal.Text = $@"Valor Total: {Validation.FormatPrice(SumTotalGrid(), true)}";
                btnRemover.Visible = false;
            };

            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;
                    }
                    else
                    {
                        GridLista.SelectedRows[0].Cells["Selecione"].Value = false;

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

                        btnRemover.Visible = hideBtns;
                    }
                }

                if (GridLista.Columns[e.ColumnIndex].Name == "Adicional")
                {
                    AdicionaisDispon.ValorAddon    = 0;
                    AdicionaisDispon.AddonSelected = GridLista.SelectedRows[0].Cells["AddonSelected"].Value != null
                        ? GridLista.SelectedRows[0].Cells["AddonSelected"].Value.ToString()
                        : "";
                    AdicionaisDispon.IdPedidoItem = 0;
                    AdicionaisDispon.IdItem       = Validation.ConvertToInt32(GridLista.SelectedRows[0].Cells["ID"].Value);
                    var form = new AdicionaisDispon();
                    if (form.ShowDialog() == DialogResult.OK)
                    {
                        var getValor = Validation.ConvertToDouble(GridLista.SelectedRows[0].Cells["Unitario"].Value
                                                                  .ToString().Replace("R$ ", ""));
                        GridLista.SelectedRows[0].Cells["Valor"].Value         = Validation.FormatPrice(getValor + AdicionaisDispon.ValorAddon);
                        GridLista.SelectedRows[0].Cells["AddonSelected"].Value = AdicionaisDispon.AddonSelected;
                    }
                }
            };

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

                var dataGridView = s as DataGridView;
                if (GridLista.Columns[e.ColumnIndex].Name == "Selecione" ||
                    GridLista.Columns[e.ColumnIndex].Name == "Adicional")
                {
                    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" ||
                    GridLista.Columns[e.ColumnIndex].Name == "Adicional")
                {
                    dataGridView.Cursor = Cursors.Default;
                }
            };
        }
Example #21
0
        /// <summary>
        ///     Eventos do form
        /// </summary>
        public void Eventos()
        {
            KeyPreview = true;
            KeyDown   += KeyDowns;
            Masks.SetToUpper(this);

            Load += (s, e) =>
            {
                if (OpcoesCfe.tipo == "NFCe")
                {
                    pictureBox1.Image    = Resources.nfce;
                    pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
                    label10.Text         = @"Confirme as informações do cliente que serão enviadas ao NFCe";
                }

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

                if (_mPedido != null && _mPedido.Cliente > 0)
                {
                    _mCliente = _mCliente.FindById(_mPedido.Cliente).FirstOrDefault <Pessoa>();
                }

                pessoaJF.DataSource = new List <string> {
                    "Física", "Jurídica"
                };

                nomeRS.Text   = _mCliente.Nome ?? "";
                cpfCnpj.Text  = _mCliente.CPF ?? "";
                pessoaJF.Text = _mCliente.Pessoatipo ?? "Física";

                if (!string.IsNullOrEmpty(_mPedido?.cfe_nome) && _mPedido.cfe_nome != "Consumidor Final")
                {
                    nomeRS.Text = _mPedido.cfe_nome;
                }

                if (!string.IsNullOrEmpty(_mPedido?.cfe_cpf))
                {
                    cpfCnpj.Text = _mPedido.cfe_cpf;

                    pessoaJF.SelectedItem = _mPedido.cfe_cpf.Length == 11 ? "Física" : "Jurídica";
                }
            };

            cpfCnpj.KeyPress += (s, e) =>
            {
                switch (pessoaJF.Text)
                {
                case "Física":
                    Masks.MaskCPF(s, e);
                    break;

                case "Jurídica":
                    Masks.MaskCNPJ(s, e);
                    break;
                }
            };

            btnSalvar.Click += (s, e) => { Continuar(); };

            btnCancelar.Click += (s, e) => { Close(); };
        }
Example #22
0
        private void Eventos()
        {
            KeyDown   += KeyDowns;
            KeyPreview = true;
            Masks.SetToUpper(this);

            Load += (s, e) => { Start(); };

            Tipo1.Click += (s, e) =>
            {
                Categorias.Enabled = true;
                Fornecedor.Enabled = true;
                imprimir.Visible   = false;
                label4.Text        = @"Despesa:";
                LoadCategorias("Despesas");
            };
            Tipo2.Click += (s, e) =>
            {
                Categorias.Enabled = true;
                Fornecedor.Enabled = false;
                imprimir.Visible   = true;
                label4.Text        = @"Despesa:";
                LoadCategorias("Despesas");
            };

            Tipo3.Click += (s, e) =>
            {
                Categorias.Enabled = false;
                Fornecedor.Enabled = false;
                imprimir.Visible   = false;
                label4.Text        = @"Receita:";
                LoadCategorias("Receitas");
            };

            btnAddCategoria.Click += (s, e) =>
            {
                string categoriasdeContas;
                if (Tipo1.Checked || Tipo2.Checked)
                {
                    categoriasdeContas = "Despesas";
                }
                else
                {
                    categoriasdeContas = "Receitas";
                }

                Home.CategoriaPage = categoriasdeContas;
                var f = new AddCategorias
                {
                    FormBorderStyle = FormBorderStyle.FixedSingle,
                    StartPosition   = FormStartPosition.CenterScreen
                };
                if (f.ShowDialog() == DialogResult.OK)
                {
                    LoadCategorias(categoriasdeContas);
                }
            };

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

            btnSalvar.Click += (s, e) =>
            {
                _modelCaixaMov.id_caixa     = idCaixa;
                _modelCaixaMov.id_formapgto = Dinheiro.Checked ? 1 : Cheque.Checked ? 2 : 1;

                _modelCaixaMov.id_categoria = Validation.ConvertToInt32(Categorias.SelectedValue);
                _modelCaixaMov.id_pessoa    = Validation.ConvertToInt32(Fornecedor.SelectedValue);

                _modelCaixaMov.Tipo = Tipo1.Checked ? 1 : Tipo2.Checked ? 2 : Tipo3.Checked ? 3 : 1;

                var tipo = "";
                if (Tipo1.Checked)
                {
                    tipo = "Saída - Lançamento de Despesa";
                }
                else if (Tipo2.Checked)
                {
                    tipo = "Saída - Sangria";
                }
                else if (Tipo3.Checked)
                {
                    tipo = "Entrada - Acréscimo";
                }

                var formaPgto = "";
                if (Dinheiro.Checked)
                {
                    formaPgto = "Dinheiro";
                }
                else if (Cheque.Checked)
                {
                    formaPgto = "Cheque";
                }

                _modelCaixaMov.Descricao = $"{formaPgto} - {tipo}";
                _modelCaixaMov.Valor     = Validation.ConvertToDouble(Valor.Text);
                _modelCaixaMov.Obs       = Obs.Text;
                if (_modelCaixaMov.Save(_modelCaixaMov))
                {
                    if (Tipo1.Checked)
                    {
                        if (_modelCaixaMov.Id != 0)
                        {
                            _modelTitulo = _modelTitulo.Query().Where("id_caixa_mov", _modelCaixaMov.Id)
                                           .Where("excluir", 0).FirstOrDefault <Titulo>();
                        }

                        _modelTitulo.Tipo               = "Pagar";
                        _modelTitulo.Emissao            = Validation.DateNowToSql();
                        _modelTitulo.Id_Categoria       = _modelCaixaMov.id_categoria;
                        _modelTitulo.Id_Pessoa          = _modelCaixaMov.id_pessoa;
                        _modelTitulo.Total              = _modelCaixaMov.Valor;
                        _modelTitulo.Id_FormaPgto       = _modelCaixaMov.id_formapgto;
                        _modelTitulo.Vencimento         = Validation.DateNowToSql();
                        _modelTitulo.Baixa_data         = Validation.DateNowToSql();
                        _modelTitulo.Baixa_id_formapgto = _modelCaixaMov.id_formapgto;
                        _modelTitulo.Baixa_total        = _modelCaixaMov.Valor;
                        _modelTitulo.Id_Caixa           = idCaixa;
                        _modelTitulo.Id_Caixa_Mov       = _modelCaixaMov.GetLastId();
                        _modelTitulo.Obs = $"Pagamento gerado a partir de um lançamento do caixa. {Obs.Text}";
                        _modelTitulo.Save(_modelTitulo, false);
                    }

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

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

            btnApagar.Click += (s, e) =>
            {
                if (_modelCaixaMov.Remove(idMov))
                {
                    var titulo = _modelTitulo.Query().Where("ID_CAIXA_MOV", idMov).FirstOrDefault();
                    if (titulo != null)
                    {
                        _modelTitulo.RemoveIdCaixaMov(idMov);
                    }

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

            imprimir.Click += (s, e) =>
            {
                _modelCaixa = _modelCaixa.FindById(idCaixa).FirstOrDefault <Model.Caixa>();

                var user     = _modelUsuarios.FindByUserId(_modelCaixa.Usuario).FirstOrDefault();
                var userName = "";
                if (user != null)
                {
                    userName = user.NOME;
                }

                var html   = Template.Parse(File.ReadAllText($@"{Program.PATH_BASE}\html\CupomAssinaturaCaixaMov.html"));
                var render = html.Render(Hash.FromAnonymousObject(new
                {
                    INCLUDE_PATH = Program.PATH_BASE,
                    URL_BASE     = Program.PATH_BASE,
                    Emissao      = DateTime.Now.ToString("dd/MM/yyyy HH:mm"),
                    nrTerminal   = _modelCaixa.Terminal,
                    nrCaixa      = _modelCaixa.Id.ToString(),
                    Responsavel  = userName,
                    Valor        = Valor.Text
                }));

                Browser.htmlRender = render;
                var f = new Browser();
                f.ShowDialog();
            };
        }
Example #23
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));
                }
            };
        }
Example #24
0
        private void Eventos()
        {
            controle   = "";
            KeyDown   += KeyDowns;
            KeyPreview = true;
            Masks.SetToUpper(this);

            Load += (s, e) =>
            {
                int diff;

                if (Home.pedidoPage != "Ordens de Servico")
                {
                    aLabel.Visible = false;
                    aText.Visible  = false;
                    bLabel.Visible = false;
                    bText.Visible  = false;
                    cLabel.Visible = false;
                    cText.Visible  = false;
                    dLabel.Visible = false;
                    dText.Visible  = false;
                    eLabel.Visible = false;
                    eText.Visible  = false;
                    fLabel.Visible = false;
                    fText.Visible  = false;

                    diff = 112;
                    visualSeparator1.Location = new Point(visualSeparator1.Location.X, visualSeparator1.Location.Y - diff);
                    label8.Location           = new Point(label8.Location.X, label8.Location.Y - diff);
                    label9.Location           = new Point(label9.Location.X, label9.Location.Y - diff);
                    dataInicial.Location      = new Point(dataInicial.Location.X, dataInicial.Location.Y - diff);
                    label10.Location          = new Point(label10.Location.X, label10.Location.Y - diff);
                    dataFinal.Location        = new Point(dataFinal.Location.X, dataFinal.Location.Y - diff);
                    noFilterData.Location     = new Point(noFilterData.Location.X, noFilterData.Location.Y - diff);
                    btnSearch.Location        = new Point(btnSearch.Location.X, btnSearch.Location.Y - diff);
                    panel2.Location           = new Point(panel2.Location.X, panel2.Location.Y - diff);
                    panel2.Size = new Size(panel2.Size.Width, panel2.Size.Height + diff);

                    return;
                }

                aLabel.Visible = !string.IsNullOrEmpty(IniFile.Read("Campo_1_Pesquisa", "OS")) && Convert.ToBoolean(IniFile.Read("Campo_1_Pesquisa", "OS"));
                aText.Visible  = aLabel.Visible;
                aLabel.Text    = !string.IsNullOrEmpty(IniFile.Read("Campo_1_Descr", "OS"))
                    ? IniFile.Read("Campo_1_Descr", "OS")
                    : "";

                bLabel.Visible = !string.IsNullOrEmpty(IniFile.Read("Campo_2_Pesquisa", "OS")) && Convert.ToBoolean(IniFile.Read("Campo_2_Pesquisa", "OS"));
                bText.Visible  = bLabel.Visible;
                bLabel.Text    = !string.IsNullOrEmpty(IniFile.Read("Campo_2_Descr", "OS"))
                    ? IniFile.Read("Campo_2_Descr", "OS")
                    : "";

                cLabel.Visible = !string.IsNullOrEmpty(IniFile.Read("Campo_3_Pesquisa", "OS")) && Convert.ToBoolean(IniFile.Read("Campo_3_Pesquisa", "OS"));
                cText.Visible  = cLabel.Visible;
                cLabel.Text    = !string.IsNullOrEmpty(IniFile.Read("Campo_3_Descr", "OS"))
                    ? IniFile.Read("Campo_3_Descr", "OS")
                    : "";

                dLabel.Visible = !string.IsNullOrEmpty(IniFile.Read("Campo_4_Pesquisa", "OS")) && Convert.ToBoolean(IniFile.Read("Campo_4_Pesquisa", "OS"));
                dText.Visible  = dLabel.Visible;
                dLabel.Text    = !string.IsNullOrEmpty(IniFile.Read("Campo_4_Descr", "OS"))
                    ? IniFile.Read("Campo_4_Descr", "OS")
                    : "";

                eLabel.Visible = !string.IsNullOrEmpty(IniFile.Read("Campo_5_Pesquisa", "OS")) && Convert.ToBoolean(IniFile.Read("Campo_5_Pesquisa", "OS"));
                eText.Visible  = eLabel.Visible;
                eLabel.Text    = !string.IsNullOrEmpty(IniFile.Read("Campo_5_Descr", "OS"))
                    ? IniFile.Read("Campo_5_Descr", "OS")
                    : "";

                fLabel.Visible = !string.IsNullOrEmpty(IniFile.Read("Campo_6_Pesquisa", "OS")) && Convert.ToBoolean(IniFile.Read("Campo_6_Pesquisa", "OS"));
                fText.Visible  = fLabel.Visible;
                fLabel.Text    = !string.IsNullOrEmpty(IniFile.Read("Campo_6_Descr", "OS"))
                    ? IniFile.Read("Campo_6_Descr", "OS")
                    : "";

                if (!dLabel.Visible && !eLabel.Visible && !eLabel.Visible)
                {
                    diff = 59;
                    visualSeparator1.Location = new Point(visualSeparator1.Location.X, visualSeparator1.Location.Y - diff);
                    label8.Location           = new Point(label8.Location.X, label8.Location.Y - diff);
                    label9.Location           = new Point(label9.Location.X, label9.Location.Y - diff);
                    dataInicial.Location      = new Point(dataInicial.Location.X, dataInicial.Location.Y - diff);
                    label10.Location          = new Point(label10.Location.X, label10.Location.Y - diff);
                    dataFinal.Location        = new Point(dataFinal.Location.X, dataFinal.Location.Y - diff);
                    noFilterData.Location     = new Point(noFilterData.Location.X, noFilterData.Location.Y - diff);
                    btnSearch.Location        = new Point(btnSearch.Location.X, btnSearch.Location.Y - diff);
                    panel2.Location           = new Point(panel2.Location.X, panel2.Location.Y - diff);
                    panel2.Size = new Size(panel2.Size.Width, panel2.Size.Height + diff);
                }
            };

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

                DataTableStart();
                BuscarPessoa.Select();
                AutoCompletePessoas();
                AutoCompleteUsers();

                if (Home.pedidoPage == "Ordens de Servico")
                {
                    AutoCompleteOS();
                }

                produtoId.AutoCompleteCustomSource = _mItem.AutoComplete();

                dataInicial.Text = DateTime.Now.ToString();
                dataFinal.Text   = DateTime.Now.ToString();

                var status = new ArrayList {
                    new { ID = 99, NOME = "Todos" }
                };
                switch (Home.pedidoPage)
                {
                case "Notas":
                case "Cupons":
                {
                    if (Home.pedidoPage == "Notas")
                    {
                        status.Add(new { ID = 1, NOME = "Pendentes" });
                    }

                    status.Add(new { ID = 2, NOME = "Autorizadas" });
                    status.Add(new { ID = 3, NOME = "Canceladas" });
                    break;
                }

                case "Ordens de Servico":
                case "Orçamentos":
                case "Devoluções":
                case "Consignações":
                    status.Add(new { ID = 0, NOME = "Pendente" });
                    status.Add(new { ID = 1, NOME = "Finalizado" });
                    break;

                default:
                    status.Add(new { ID = 2, NOME = "Recebimento Pendente" });
                    status.Add(new { ID = 1, NOME = @"Finalizado\Recebido" });
                    break;
                }

                Status.DataSource    = status;
                Status.DisplayMember = "NOME";
                Status.ValueMember   = "ID";
                Status.SelectedValue = 99;
            };

            BuscarPessoa.KeyDown += (s, e) =>
            {
                controle = "BuscarPessoa";
                KeyDowns(s, e);
            };

            btnTotais.Click += (s, e) =>
            {
                OpenForm.Show <PedidoTotais>(this);
            };

            btnSearch.Click += (s, e) => Filter();

            btnAdicionar.Click += (s, e) => { EditPedido(true); };

            btnEditar.Click       += (s, e) => EditPedido();
            GridLista.DoubleClick += (s, e) => EditPedido();

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

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

            GridLista.CellFormatting += (s, e) =>
            {
                if (Home.pedidoPage != "Remessas")
                {
                    foreach (DataGridViewRow row in GridLista.Rows)
                    {
                        if (row.Cells[7].Value.ToString().Contains("Finalizado") || row.Cells[7].Value.ToString().Contains("Autorizada"))
                        {
                            row.Cells[7].Style.Font = new Font("Segoe UI Semibold", 9.75F, FontStyle.Bold,
                                                               GraphicsUnit.Point, 0);
                            row.Cells[7].Style.ForeColor = Color.White;
                            row.Cells[7].Style.BackColor = Color.FromArgb(139, 215, 146);
                        }
                        else if (row.Cells[7].Value.ToString().Contains("Cancelada"))
                        {
                            row.Cells[7].Style.Font = new Font("Segoe UI Semibold", 9.75F, FontStyle.Bold,
                                                               GraphicsUnit.Point, 0);
                            row.Cells[7].Style.ForeColor = Color.White;
                            row.Cells[7].Style.BackColor = Color.FromArgb(0, 150, 230);
                        }
                        else
                        {
                            row.Cells[7].Style.Font = new Font("Segoe UI Semibold", 9.75F, FontStyle.Bold,
                                                               GraphicsUnit.Point, 0);
                            row.Cells[7].Style.ForeColor = Color.White;
                            row.Cells[7].Style.BackColor = Color.FromArgb(255, 89, 89);
                        }
                    }
                }
            };

            using (var b = workerBackground)
            {
                b.DoWork += async(s, e) =>
                {
                    dataTable = await _cPedido.GetDataTablePedidos(Home.pedidoPage, dataInicial.Text,
                                                                   dataFinal.Text, noFilterData.Checked);
                };

                b.RunWorkerCompleted += async(s, e) =>
                {
                    await _cPedido.SetTablePedidos(GridLista, Home.pedidoPage, dataInicial.Text, dataFinal.Text,
                                                   noFilterData.Checked, dataTable, BuscarPessoa.Text);

                    Loading.Visible   = false;
                    GridLista.Visible = true;
                };
            }

            timer.AutoReset = false;
            timer.Elapsed  += (s, e) => BuscarPessoa.Invoke((MethodInvoker) delegate
            {
                Filter();
                Loading.Visible   = false;
                GridLista.Visible = true;
            });

            BuscarPessoa.Enter += async(s, e) =>
            {
                await Task.Delay(100);

                Filter();
            };

            imprimir.Click += async(s, e) => await RenderizarAsync();

            switch (Home.pedidoPage)
            {
            case "Vendas":
                btnVideoAjuda.Click += (s, e) => Support.Video("https://www.youtube.com/watch?v=Z2pkMEAAk4Q");
                break;

            case "Notas":
            case "Cupons":
            case "Orçamentos":
            case "Devoluções":
            case "Consignações":
                btnVideoAjuda.Visible = false;
                break;
            }
        }
Example #25
0
        private void Eventos()
        {
            KeyDown   += KeyDowns;
            KeyPreview = true;
            Masks.SetToUpper(this);

            Load += (s, e) => search.Focus();

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

                SetHeadersTable(GridLista);
                await SetContentTableAsync(GridLista);
            };

            btnAdicionar.Click += (s, e) => EditProduct(true);
            btnEditar.Click    += (s, e) => EditProduct();

            btnRemover.Click += (s, e) =>
            {
                ListAdicionais.Clear();
                foreach (DataGridViewRow item in GridLista.Rows)
                {
                    if ((bool)item.Cells["Selecione"].Value)
                    {
                        ListAdicionais.Add(Validation.ConvertToInt32(item.Cells["ID"].Value));
                    }
                }

                var result = AlertOptions.Message("Atenção!",
                                                  "Você está prestes a deletar os ADICIONAIS selecionados, continuar?", AlertBig.AlertType.warning,
                                                  AlertBig.AlertBtn.YesNo);
                if (result)
                {
                    foreach (var item in ListAdicionais)
                    {
                        new ItemAdicional().Remove(item);
                    }

                    SetContentTableAsync(GridLista);
                }

                btnRemover.Visible   = false;
                btnEditar.Visible    = true;
                btnAdicionar.Visible = true;
            };

            search.TextChanged += (s, e) => SetContentTableAsync(GridLista);

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

            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;
                }
            };
        }
Example #26
0
        private void Eventos()
        {
            KeyDown   += KeyDowns;
            KeyPreview = true;
            Masks.SetToUpper(this);
            search.Focus();

            Load += (s, e) =>
            {
                switch (Home.financeiroPage)
                {
                case "Receber":
                    label1.Text       = @"Recebimentos";
                    label6.Text       = @"Recebimentos";
                    label2.Text       = @"Confira aqui todas os títulos a Receber/Recebidos da sua empresa.";
                    status.DataSource = new List <string> {
                        "Todos", "Pendentes", "Recebidos"
                    };
                    break;

                case "Pagar":
                    label1.Text       = @"Pagamentos";
                    label6.Text       = @"Pagamentos";
                    label2.Text       = @"Confira aqui todas os títulos a Pagar/Pagos da sua empresa.";
                    status.DataSource = new List <string> {
                        "Todos", "Pendentes", "Pagos"
                    };
                    break;
                }

                data.DataSource = new List <string> {
                    "Vencimento", "Emissão"
                };

                dataInicial.Text = Validation.DateNowToSql();
                dataFinal.Text   = Validation.DateNowToSql();
            };

            Shown += (s, e) =>
            {
                SetHeadersTable(GridLista);
                SetContentTable(GridLista);
            };

            search.TextChanged += (s, e) => SetContentTable(GridLista);
            search.Enter       += (s, e) => SetContentTable(GridLista);
            filtrar.Click      += (s, e) => SetContentTable(GridLista);

            btnAdicionar.Click    += (s, e) => EditTitulo(true);
            btnEditar.Click       += (s, e) => EditTitulo();
            GridLista.DoubleClick += (s, e) => EditTitulo();
            btnExit.Click         += (s, e) => Close();

            btnEditAll.Click += (s, e) =>
            {
                listTitulos.Clear();

                foreach (DataGridViewRow item in GridLista.Rows)
                {
                    if ((bool)item.Cells["Selecione"].Value)
                    {
                        listTitulos.Add(Validation.ConvertToInt32(item.Cells["ID"].Value));
                    }
                }

                EditAllTitulos.listTitulos = listTitulos;
                OpenForm.Show <EditAllTitulos>(this);

                btnMarcarCheckBox.Text = @"Marcar Todos";
                btnRemover.Visible     = false;
                btnEditAll.Visible     = false;
                btnEditar.Enabled      = true;
                btnAdicionar.Enabled   = true;
            };

            btnMarcarCheckBox.Click += (s, e) =>
            {
                foreach (DataGridViewRow item in GridLista.Rows)
                {
                    if ((bool)item.Cells["Selecione"].Value)
                    {
                        item.Cells["Selecione"].Value = false;
                        btnMarcarCheckBox.Text        = @"Marcar Todos";
                        btnRemover.Visible            = false;
                        btnEditAll.Visible            = false;
                        btnEditar.Enabled             = true;
                        btnAdicionar.Enabled          = true;
                    }
                    else
                    {
                        item.Cells["Selecione"].Value = true;
                        btnMarcarCheckBox.Text        = @"Desmarcar Todos";
                        btnRemover.Visible            = true;
                        btnEditAll.Visible            = true;
                        btnEditar.Enabled             = false;
                        btnAdicionar.Enabled          = false;
                    }
                }
            };

            btnRemover.Click += (s, e) =>
            {
                listTitulos.Clear();
                foreach (DataGridViewRow item in GridLista.Rows)
                {
                    if ((bool)item.Cells["Selecione"].Value)
                    {
                        listTitulos.Add(Validation.ConvertToInt32(item.Cells["ID"].Value));
                    }
                }

                var result = AlertOptions.Message("Atenção!",
                                                  $"Você está prestes a deletar os {label1.Text.ToLower()} selecionados, continuar?",
                                                  AlertBig.AlertType.warning, AlertBig.AlertBtn.YesNo);
                if (result)
                {
                    foreach (var item in listTitulos)
                    {
                        new Model.Titulo().Remove(item, "ID", false);
                    }

                    SetContentTable(GridLista);
                }

                btnMarcarCheckBox.Text = @"Marcar Todos";
                btnRemover.Visible     = false;
                btnEditAll.Visible     = false;
                btnEditar.Enabled      = true;
                btnAdicionar.Enabled   = true;
            };

            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;
                        btnEditAll.Visible   = true;
                        btnEditar.Enabled    = false;
                        btnAdicionar.Enabled = 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;
                        btnEditAll.Visible   = hideBtns;
                        btnEditar.Enabled    = hideBtnsTop;
                        btnAdicionar.Enabled = 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;
                }
            };

            btnHelp.Click  += (s, e) => Support.OpenLinkBrowser(Configs.LinkAjuda);
            imprimir.Click += async(s, e) => await RenderizarAsync();
        }
Example #27
0
        private void Eventos()
        {
            KeyDown   += KeyDowns;
            KeyPreview = true;
            Masks.SetToUpper(this);

            Shown += (s, e) =>
            {
                SetHeadersTable(GridLista);

                if (Id == 0)
                {
                    txtVariacao.Visible    = false;
                    btnAddVariacao.Visible = false;
                    GridLista.Visible      = false;
                }

                if (Id <= 0)
                {
                    return;
                }

                var grupo = new ItemGrupo().FindAll().WhereFalse("excluir").Where("id", Id).FirstOrDefault <ItemGrupo>();
                if (grupo == null)
                {
                    return;
                }

                txtGrupo.Text = grupo.Title;

                txtVariacao.Visible    = true;
                btnAddVariacao.Visible = true;
                GridLista.Visible      = true;

                // Carrega os atributos
                LoadData(GridLista);
            };

            btnSalvarGrupo.Click += (s, e) =>
            {
                if (string.IsNullOrEmpty(txtGrupo.Text))
                {
                    Alert.Message("Opps", "O título do grupo não pode ficar vazio.", Alert.AlertType.error);
                    return;
                }

                var grupoCheck = new ItemGrupo().FindAll().WhereFalse("excluir").Where("title", txtGrupo.Text)
                                 .FirstOrDefault <ItemGrupo>();
                if (grupoCheck != null)
                {
                    Alert.Message("Opps", "Já existe um grupo com esse título.", Alert.AlertType.error);
                    return;
                }

                var grupo = new ItemGrupo
                {
                    Id    = Id,
                    Title = txtGrupo.Text
                };
                if (!grupo.Save(grupo))
                {
                    return;
                }

                Id = grupo.GetLastId();
                txtVariacao.Visible    = true;
                btnAddVariacao.Visible = true;
                GridLista.Visible      = true;
            };

            btnAddVariacao.Click += (s, e) =>
            {
                if (string.IsNullOrEmpty(txtVariacao.Text))
                {
                    Alert.Message("Opps", "O título da variação não pode ficar vazio.", Alert.AlertType.error);
                    return;
                }

                if (Id == 0)
                {
                    Alert.Message("Opps", "Você deve adicionar um grupo antes.", Alert.AlertType.error);
                    return;
                }

                var attrCheck = new ItemAtributos().FindAll().WhereFalse("excluir").Where("atributo", txtVariacao.Text)
                                .Where("grupo", Id).FirstOrDefault <ItemAtributos>();
                if (attrCheck != null)
                {
                    Alert.Message("Opps", "Já existe um atributo com esse título.", Alert.AlertType.error);
                    return;
                }

                var add = new ItemAtributos
                {
                    Grupo    = Id,
                    Atributo = txtVariacao.Text
                };
                if (!add.Save(add))
                {
                    return;
                }

                txtVariacao.Clear();

                // Carrega os atributos
                LoadData(GridLista);
            };

            btnDelete.Click += (s, e) =>
            {
                ListAtributos.Clear();
                foreach (DataGridViewRow item in GridLista.Rows)
                {
                    if ((bool)item.Cells["Selecione"].Value)
                    {
                        ListAtributos.Add(Validation.ConvertToInt32(item.Cells["ID"].Value));
                    }
                }

                var result = AlertOptions.Message("Atenção!",
                                                  "Você está prestes a deletar os ATRIBUTOS selecionados, continuar?", AlertBig.AlertType.warning,
                                                  AlertBig.AlertBtn.YesNo);
                if (result)
                {
                    foreach (var attr in ListAtributos)
                    {
                        new ItemAtributos().Remove(attr);
                    }

                    LoadData(GridLista);
                }

                btnDelete.Visible = false;
            };

            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;
                        btnDelete.Visible = true;
                    }
                    else
                    {
                        GridLista.SelectedRows[0].Cells["Selecione"].Value = false;

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

                        btnDelete.Visible = hideBtns;
                    }
                }
            };

            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;
                }
            };

            btnVoltar.Click += (s, e) =>
            {
                DialogResult = DialogResult.OK;
                Close();
            };
        }
Example #28
0
        private void Eventos()
        {
            KeyDown   += KeyDowns;
            KeyPreview = true;
            Masks.SetToUpper(this);

            Load += (s, e) =>
            {
                search.Select();
                SetHeadersTable(GridLista);
                DataTableStart();
            };

            btnAdicionar.Click    += (s, e) => EditProduct(true);
            btnEditar.Click       += (s, e) => EditProduct();
            GridLista.DoubleClick += (s, e) => EditProduct();

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

            search.TextChanged += (s, e) =>
            {
                timer.Stop();
                timer.Start();
                Loading.Visible   = true;
                GridLista.Visible = false;
            };

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

            using (var b = workerBackground)
            {
                b.DoWork += async(s, e) => { dataTable = await _controller.GetDataTableServicos(); };

                b.RunWorkerCompleted += async(s, e) =>
                {
                    await SetContentTableAsync(GridLista, dataTable);

                    Loading.Visible   = false;
                    GridLista.Visible = true;
                };
            }

            btnMarcarCheckBox.Click += (s, e) =>
            {
                foreach (DataGridViewRow item in GridLista.Rows)
                {
                    if ((bool)item.Cells["Selecione"].Value)
                    {
                        item.Cells["Selecione"].Value = false;
                        btnMarcarCheckBox.Text        = @"Marcar Todos";
                        btnRemover.Visible            = false;
                        btnEditar.Enabled             = true;
                        btnAdicionar.Enabled          = true;
                    }
                    else
                    {
                        item.Cells["Selecione"].Value = true;
                        btnMarcarCheckBox.Text        = @"Desmarcar Todos";
                        btnRemover.Visible            = true;
                        btnEditar.Enabled             = false;
                        btnAdicionar.Enabled          = false;
                    }
                }
            };

            btnRemover.Click += (s, e) =>
            {
                ListProdutos.Clear();
                foreach (DataGridViewRow item in GridLista.Rows)
                {
                    if ((bool)item.Cells["Selecione"].Value)
                    {
                        ListProdutos.Add(Validation.ConvertToInt32(item.Cells["ID"].Value));
                    }
                }

                var result = AlertOptions.Message("Atenção!",
                                                  "Você está prestes a deletar os SERVIÇOS selecionados, continuar?", AlertBig.AlertType.warning,
                                                  AlertBig.AlertBtn.YesNo);
                if (result)
                {
                    foreach (var item in ListProdutos)
                    {
                        new Model.Item().Remove(item, false);
                    }

                    DataTable();
                }

                btnMarcarCheckBox.Text = @"Marcar Todos";
                btnRemover.Visible     = false;
                btnEditar.Enabled      = true;
                btnAdicionar.Enabled   = true;
            };

            timer.AutoReset = false;
            timer.Elapsed  += (s, e) => search.Invoke((MethodInvoker) delegate
            {
                DataTable();
                Loading.Visible   = false;
                GridLista.Visible = true;
            });

            search.Enter += async(s, e) =>
            {
                await Task.Delay(100);

                DataTable();
            };

            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.Enabled    = false;
                        btnAdicionar.Enabled = 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.Enabled    = hideBtnsTop;
                        btnAdicionar.Enabled = 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;
                }
            };

            imprimir.Click += async(s, e) => await RenderizarAsync();
        }
Example #29
0
        private void Eventos()
        {
            KeyDown   += KeyDowns;
            KeyPreview = true;
            Masks.SetToUpper(this);

            Load += (s, e) =>
            {
                Caixas.SelectedValue = "1";
                Caixas.Enabled       = false;

                var caixas = new Model.Caixa().Query()
                             .LeftJoin("USUARIOS", "USUARIOS.ID_USER", "CAIXA.USUARIO")
                             .SelectRaw("USUARIOS.NOME, CAIXA.*")
                             .Where("CAIXA.tipo", "Aberto")
                             .WhereFalse("CAIXA.excluir")
                             .OrderByDesc("CAIXA.criado")
                             .Get();

                if (caixas.Any())
                {
                    Caixas.DataSource    = caixas;
                    Caixas.DisplayMember = "NOME";
                    Caixas.ValueMember   = "ID";
                }
                else
                {
                    OutroCaixa.Enabled = false;
                    Caixas.Enabled     = false;
                    label3.Visible     = true;
                }
            };

            OutroCaixa.Click += (s, e) =>
            {
                btnCriar.Text = @"Vincular Caixa";
                EnableDisableCampos(false, true);
            };
            MeuCaixa.Click += (s, e) =>
            {
                btnCriar.Text = @"Abrir Caixa";
                EnableDisableCampos(true, false);
            };

            btnCriar.Click += (s, e) =>
            {
                if (!MeuCaixa.Checked)
                {
                    if (OutroCaixa.Checked)
                    {
                        Home.idCaixa = Validation.ConvertToInt32(Caixas.SelectedValue);

                        Alert.Message("Pronto!", "Seu usuário foi vinculado ao caixa aberto.", Alert.AlertType.success);
                        DialogResult = DialogResult.OK;
                        Close();
                        return;
                    }
                }

                _modelCaixa.Tipo          = "Aberto";
                _modelCaixa.Usuario       = Settings.Default.user_id;
                _modelCaixa.Saldo_Inicial = Validation.ConvertToDouble(ValorInicial.Text);
                _modelCaixa.Terminal      = Terminal.Text;
                _modelCaixa.Observacao    = Obs.Text;

                if (_modelCaixa.Save(_modelCaixa))
                {
                    Home.idCaixa = _modelCaixa.GetLastId();
                    DialogResult = DialogResult.OK;
                    Close();
                }
            };

            ValorInicial.TextChanged += (s, e) =>
            {
                var txt = (TextBox)s;
                Masks.MaskPrice(ref txt);
            };
        }
Example #30
0
        /// <summary>
        /// Manipula todos os eventos do form
        /// </summary>
        private void Eventos()
        {
            KeyDown   += KeyDowns;
            KeyPreview = true;
            Masks.SetToUpper(this);

            Shown += (s, e) =>
            {
                ToolHelp.Show(
                    "Você pode selecionar um produto ou então selecionar uma categoria inteira de produtos.",
                    pictureBox4, ToolHelp.ToolTipIcon.Info, "Ajuda!");

                Tipo.SelectedIndex = 0;
                SetHeadersItens(dataGridItens);

                if (IdCombo > 0)
                {
                    LoadData();
                }
                else
                {
                    _mItemCombo = new ItemCombo {
                        Id = 0
                    };
                    _mItemCombo.Save(_mItemCombo);
                }
            };

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

            btnContinue.Click += (s, e) =>
            {
                switch (Tipo.SelectedItem.ToString())
                {
                case "Produtos":
                    label2.Text = @"Produtos";
                    AutoCompleteItens();
                    break;

                case "Categorias":
                    label2.Text = @"Categorias";
                    AutoCompleteCategorias();
                    break;
                }

                txtAutoComplete.Enabled = true;
                btnIncluir.Visible      = true;
            };

            btnIncluir.Click += (s, e) => AddItensTable();
            btnSalvar.Click  += (s, e) => SaveItensTable();

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

            btnRemoverSelecionados.Click += (s, e) =>
            {
                var toBeDeleted = new List <DataGridViewRow>();
                toBeDeleted.Clear();

                var result = AlertOptions.Message("Atenção!",
                                                  "Você está prestes a remover os ITENS selecionados, continuar?", AlertBig.AlertType.warning,
                                                  AlertBig.AlertBtn.YesNo);
                if (result)
                {
                    foreach (DataGridViewRow item in dataGridItens.Rows)
                    {
                        Console.WriteLine(item.Cells["Selecione"].Value);
                        if ((bool)item.Cells["Selecione"].Value)
                        {
                            toBeDeleted.Add(item);
                        }
                    }

                    toBeDeleted.ForEach(d => dataGridItens.Rows.Remove(d));
                }

                btnRemoverSelecionados.Visible = false;
            };

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

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

                        btnRemoverSelecionados.Visible = hideBtns;
                    }
                }
            };

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

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

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

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