Exemple #1
0
        private void 打开OToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenForm open = new OpenForm();

            open.OnConfirmOpen += new ConfirmOpenFileHander(open_OnConfirmOpen);
            open.Show();
        }
Exemple #2
0
        private void Eventos()
        {
            Load += (s, e) =>
            {
                var dadosFornecedor = dataNfe.GetNotas();

                if (dadosFornecedor.Count <= 0)
                {
                    return;
                }

                foreach (Controller.ImportarNfe item in dadosFornecedor)
                {
                    cnpj.Text        = item.GetFornecedor().CPFcnpj;
                    IE.Text          = item.GetFornecedor().IE;
                    razaosocial.Text = item.GetFornecedor().razaoSocial;

                    rua.Text    = item.GetFornecedor().Addr_Rua + " " + item.GetFornecedor().Addr_Nr;
                    bairro.Text = item.GetFornecedor().Addr_Bairro;
                    cep.Text    = item.GetFornecedor().Addr_CEP;
                    cidade.Text = item.GetFornecedor().Addr_Cidade;
                    estado.Text = item.GetFornecedor().Addr_UF;
                }
            };

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

            btnBack.Click += (s, e) => { Close(); };
        }
Exemple #3
0
        private void EditMovimentacao()
        {
            if (Restrito())
            {
                return;
            }

            if (GridLista.SelectedRows.Count == 0)
            {
                return;
            }

            if (Convert.ToInt32(GridLista.SelectedRows[0].Cells["ID"].Value) <= 0)
            {
                return;
            }

            if (GridLista.SelectedRows[0].Cells["Descrição"].Value.ToString().Contains("Venda"))
            {
                DetailsPedido.idPedido = Validation.ConvertToInt32(GridLista.SelectedRows[0].Cells["ID"].Value);
                OpenForm.Show <DetailsPedido>(this);
                return;
            }

            AddCaixaMov.idMov = Convert.ToInt32(GridLista.SelectedRows[0].Cells["ID"].Value);
            var f = new AddCaixaMov();

            if (f.ShowDialog() == DialogResult.OK)
            {
                LoadTotais();
            }
        }
Exemple #4
0
        private void Eventos()
        {
            btnAddItem.Click += (s, e) =>
            {
                var form = new AddItemMesa();
                form.ShowDialog();
            };

            Clientes.Click += (s, e) =>
            {
                if (UserPermission.SetControl(Clientes, pictureBox11, "com_clientes"))
                {
                    return;
                }

                Home.pessoaPage = "Clientes";
                OpenForm.Show <Clientes>(this);
            };

            btnEntregadores.Click += (s, e) =>
            {
                Home.pessoaPage = "Entregadores";
                OpenForm.Show <Clientes>(this);
            };

            Pedidos.Click += (s, e) =>
            {
                if (UserPermission.SetControl(Pedidos, pictureBox5, "com_novavenda"))
                {
                    return;
                }

                Home.pedidoPage = "Balcao";
                AddPedidos.Id   = 0;
                AddPedidos.PDV  = false;
                var novoPedido = new AddPedidos();
                novoPedido.ShowDialog();
            };

            btnDelivery.Click += (s, e) =>
            {
                Home.pedidoPage = "Delivery";
                AddPedidos.Id   = 0;
                AddPedidos.PDV  = false;
                var novoPedido = new AddPedidos();
                novoPedido.ShowDialog();
            };

            VendasRel.Click += (s, e) =>
            {
                Home.pedidoPage = "Food";
                OpenForm.Show <Pedidos>(this);
            };

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

            Mesas.Click += (s, e) => { OpenForm.Show <Comercial.Mesas>(this); };
        }
Exemple #5
0
        private void ViewComissao()
        {
            if (GridLista.SelectedRows.Count <= 0)
            {
                return;
            }

            DetalhesComissao.idUser = Convert.ToInt32(GridLista.SelectedRows[0].Cells["ID"].Value);
            OpenForm.Show <DetalhesComissao>(this);
        }
Exemple #6
0
        private void EditarPedido()
        {
            if (GridLista.SelectedRows.Count <= 0)
            {
                return;
            }

            DetailsPedido.idPedido = Convert.ToInt32(GridLista.SelectedRows[0].Cells["ID"].Value);
            Home.pedidoPage        = GridLista.SelectedRows[0].Cells["Venda"].Value.ToString();
            OpenForm.Show <DetailsPedido>(this);
        }
Exemple #7
0
        /// <summary>
        /// Func para editar ou criar novo combo
        /// </summary>
        /// <param name="create"></param>
        private void EditCombo(bool create = false)
        {
            if (create)
            {
                AddComboProdutos.IdCombo = 0;
                OpenForm.Show <AddComboProdutos>(this);
                return;
            }

            if (GridLista.SelectedRows.Count > 0)
            {
                AddComboProdutos.IdCombo = Validation.ConvertToInt32(GridLista.SelectedRows[0].Cells["ID"].Value);
                OpenForm.Show <AddComboProdutos>(this);
            }
        }
Exemple #8
0
        private void EditCategoria(bool create = false)
        {
            if (create)
            {
                idCatSelected = 0;
                OpenForm.Show <AddCategorias>(this);
                return;
            }

            if (GridListaCategorias.SelectedRows.Count > 0)
            {
                idCatSelected = Convert.ToInt32(GridListaCategorias.SelectedRows[0].Cells["ID"].Value);
                OpenForm.Show <AddCategorias>(this);
            }
        }
Exemple #9
0
        private void EditImposto(bool create = false)
        {
            if (create)
            {
                idImpSelected = 0;
                OpenForm.Show <AddImpostos>(this);
                return;
            }

            if (GridListaImpostos.SelectedRows.Count > 0)
            {
                idImpSelected = Convert.ToInt32(GridListaImpostos.SelectedRows[0].Cells["ID"].Value);
                OpenForm.Show <AddImpostos>(this);
            }
        }
Exemple #10
0
        private void EditProduct(bool create = false)
        {
            if (create)
            {
                AddServicos.idSelecionado = 0;
                OpenForm.Show <AddServicos>(this);
                return;
            }

            if (GridLista.SelectedRows.Count > 0)
            {
                AddServicos.idSelecionado = Validation.ConvertToInt32(GridLista.SelectedRows[0].Cells["ID"].Value);
                OpenForm.Show <AddServicos>(this);
            }
        }
Exemple #11
0
        private void EditCategoria(bool create = false)
        {
            if (create)
            {
                idSelected = 0;
                OpenForm.Show <AddNatureza>(this);
                return;
            }

            if (GridLista.SelectedRows.Count > 0)
            {
                idSelected = Validation.ConvertToInt32(GridLista.SelectedRows[0].Cells["ID"].Value);
                OpenForm.Show <AddNatureza>(this);
            }
        }
Exemple #12
0
        private void EditClientes(bool create = false)
        {
            if (create)
            {
                Clientes.Id = 0;
                OpenForm.Show <AddClientes>(this);
                return;
            }

            if (GridLista.SelectedRows.Count > 0)
            {
                Id = Validation.ConvertToInt32(GridLista.SelectedRows[0].Cells["ID"].Value);
                OpenForm.Show <AddClientes>(this);
            }
        }
Exemple #13
0
        private void EditarTaxa(bool create = false)
        {
            if (create)
            {
                AddTaxa.Id = 0;
                OpenForm.Show <AddTaxa>(this);
                return;
            }

            if (GridLista.SelectedRows.Count <= 0)
            {
                return;
            }

            AddTaxa.Id = Validation.ConvertToInt32(GridLista.SelectedRows[0].Cells["ID"].Value);
            OpenForm.Show <AddTaxa>(this);
        }
Exemple #14
0
        private void EditTitulo(bool create = false)
        {
            if (create)
            {
                EditarTitulo.IdTitulo = 0;
                OpenForm.Show <EditarTitulo>(this);
                return;
            }

            if (GridLista.SelectedRows.Count <= 0)
            {
                return;
            }

            EditarTitulo.IdTitulo = Validation.ConvertToInt32(GridLista.SelectedRows[0].Cells["ID"].Value);
            OpenForm.Show <EditarTitulo>(this);
        }
Exemple #15
0
        private void LoginConfirmButton_Click(object sender, EventArgs e)
        {
            string email = LoginEmailInput.Text;
            string password = LoginPasswordInput.Text;

            List<SqlParameter> sqlParams = new List<SqlParameter>();
            sqlParams.Add(new SqlParameter("Email", email));
            sqlParams.Add(new SqlParameter("Password", password));

            DataTable dt = DataController.Instance().ExecSP("Login", sqlParams);

            if (dt.Rows.Count == 1)
            {
                DataController.Instance().setId(Convert.ToInt32(dt.Rows[0]["Id"]));
                OpenForm openForm = new OpenForm();
                openForm.Show();
                this.Hide();
            }        
        }
Exemple #16
0
        private void EditProduct(bool create = false)
        {
            if (EditAllProducts.FormOpen)
            {
                return;
            }

            if (create)
            {
                AddAdicional.Id = 0;
                OpenForm.Show <AddAdicional>(this);
                return;
            }

            if (GridLista.SelectedRows.Count > 0)
            {
                AddAdicional.Id = Validation.ConvertToInt32(GridLista.SelectedRows[0].Cells["ID"].Value);
                OpenForm.Show <AddAdicional>(this);
            }
        }
Exemple #17
0
        private void Eventos()
        {
            workerBackground.DoWork += (s, e) => GridLista.Invoke((MethodInvoker)LoadProdutos);

            workerBackground.RunWorkerCompleted += (s, e) =>
            {
                label2.Visible      = false;
                pictureBox2.Visible = false;
                GridLista.Visible   = true;
            };

            Shown += (s, e) =>
            {
                Refresh();
                AutoCompleteItens();
                pictureBox2.Visible = true;

                var cat = new Categoria().FindAll().Where("tipo", "Produtos").WhereFalse("excluir").OrderByDesc("nome").Get();
                if (cat.Any())
                {
                    Categorias.DataSource    = cat;
                    Categorias.DisplayMember = "NOME";
                    Categorias.ValueMember   = "ID";
                }

                Medidas.DataSource = Support.GetMedidas();

                if (ImportarNfe.optionSelected == 1)
                {
                    BuscarProduto.Visible = false;
                    label10.Visible       = false;
                    pictureBox4.Visible   = false;
                    btnVincular.Visible   = false;
                    label9.Text           = @"Edite o produto selecionado abaixo";
                }


                pictureBox2.Visible = true;
                GridLista.Visible   = false;
                workerBackground.RunWorkerAsync();
            };

            btnVincular.Click += (s, e) => VincularProduto();

            GridLista.CellClick += (s, e) =>
            {
                BuscarProduto.Enabled = true;

                if (GridLista.Columns[e.ColumnIndex].Name == "Editar")
                {
                    VincularProduto(true);
                    GridLista.Enabled = false;
                }

                if (GridLista.Columns[e.ColumnIndex].Name == "Importar")
                {
                    GridLista.SelectedRows[0].Cells["Importar"].Value = (bool)GridLista.SelectedRows[0].Cells["Importar"].Value == false;
                }
            };

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

                var dataGridView = s as DataGridView;
                if (GridLista.Columns[e.ColumnIndex].Name == "Importar" ||
                    GridLista.Columns[e.ColumnIndex].Name == "Editar")
                {
                    dataGridView.Cursor = Cursors.Hand;
                }
            };

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

                var dataGridView = s as DataGridView;
                if (GridLista.Columns[e.ColumnIndex].Name == "Importar" ||
                    GridLista.Columns[e.ColumnIndex].Name == "Editar")
                {
                    dataGridView.Cursor = Cursors.Default;
                }
            };

            btnSalvarVinculacao.Click += (s, e) =>
            {
                SalvarProduto();

                if (ImportarNfe.optionSelected != 1)
                {
                    label10.Visible          = true;
                    pictureBox4.Visible      = true;
                    BuscarProduto.Visible    = true;
                    btnVincular.Visible      = true;
                    label9.Text              = @"Vincular a produtos existentes";
                    panelVinculacao.Location = new Point(34, 517);
                }

                panelVinculacao.Visible = false;
            };

            btnImportar.Click += (s, e) =>
            {
                produtos.Clear();

                var i = -1;
                foreach (DataGridViewRow item in GridLista.Rows)
                {
                    i++;
                    if ((bool)item.Cells["Importar"].Value)
                    {
                        var    id         = Validation.ConvertToInt32(item.Cells["IDVINCULO"].Value);
                        double estoque    = 0;
                        var    codeBarras = item.Cells["Cód. de Barras"].Value.ToString();
                        var    id_sync    = 0;

                        if (!string.IsNullOrEmpty(codeBarras))
                        {
                            var _mItem = new Item();
                            _mItem = _mItem.Query().Select("*").Where("codebarras", codeBarras).Where("excluir", 0)
                                     .FirstOrDefault <Item>();
                            if (_mItem != null)
                            {
                                id      = _mItem.Id;
                                estoque = _mItem.EstoqueAtual;
                                id_sync = _mItem.id_sync;
                            }
                        }

                        //estoque = Validation.ConvertToDouble(item.Cells[6].Value) + estoque;

                        switch (ImportarNfe.optionSelected)
                        {
                        case 1:
                            estoque = 0;
                            break;

                        case 3:
                            //estoque = Validation.ConvertToDouble(item.Cells[6].Value) + estoque;
                            break;
                        }

                        produtos.Add(new
                        {
                            Ordem         = i,
                            Id            = id,
                            Referencia    = item.Cells["Referência"].Value.ToString(),
                            CodeBarras    = item.Cells["Cód. de Barras"].Value.ToString(),
                            Nome          = item.Cells["Descrição"].Value.ToString(),
                            Medida        = item.Cells["Medida"].Value.ToString(),
                            Estoque       = estoque,
                            CategoriaId   = Validation.ConvertToInt32(item.Cells["CATEGORIAID"].Value),
                            ValorCompra   = Validation.ConvertToDouble(item.Cells["Vlr. Compra"].Value),
                            ValorVenda    = Validation.ConvertToDouble(item.Cells["Vlr. Venda"].Value),
                            Fornecedor    = item.Cells["Fornecedor"].Value.ToString(),
                            NCM           = item.Cells["NCM"].Value.ToString(),
                            idSync        = id_sync,
                            EstoqueCompra = Validation.ConvertToDouble(item.Cells[6].Value)
                        });
                    }
                }

                if (ImportarNfe.optionSelected == 3)
                {
                    OpenForm.Show <ImportarPagamentos>(this);
                }
                else
                {
                    OpenForm.Show <ImportarProdutosConcluido>(this);
                }
            };

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

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

                Validation.WarningInput(txt, warning);
            };

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

                btnMarcarCheckBox.Text = btnMarcarCheckBox.Text == @"Marcar Todos" ? @"Desmarcar Todos" : @"Marcar Todos";
            };

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

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

                    ModalItens();

                    return;
                }

                if (string.IsNullOrEmpty(BuscarProduto.Text))
                {
                    ModalItens();
                }
                else
                {
                    VincularProduto();
                }
            };

            Back.Click += (s, e) => Close();
        }
Exemple #18
0
        private void Eventos()
        {
            KeyDown   += KeyDowns;
            KeyPreview = true;

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

                Refresh();
                LoadData();

                await DataTableAsync();
            };

            if (_modelCaixa.Tipo != "Fechado")
            {
                GridLista.CellDoubleClick += (s, e) => EditMovimentacao();

                GridLista2.CellDoubleClick += (s, e) =>
                {
                    DetailsPedido.idPedido = Convert.ToInt32(GridLista2.SelectedRows[0].Cells["N° Venda"].Value);
                    OpenForm.Show <DetailsPedido>(this);
                };
            }

            btnEditar.Click += (s, e) => EditMovimentacao();

            btnLancamentos.Click += (s, e) =>
            {
                if (Restrito())
                {
                    return;
                }

                if (_modelCaixa.Tipo == "Fechado")
                {
                    Alert.Message("Oppss!", "Não é possível fazer lançamentos em um caixa fechado.",
                                  Alert.AlertType.warning);
                    return;
                }

                AddCaixaMov.idCaixa = idCaixa;
                AddCaixaMov.idMov   = 0;
                using (var f = new AddCaixaMov())
                {
                    if (f.ShowDialog() == DialogResult.OK)
                    {
                        LoadTotais();
                    }
                }
            };

            FecharCaixa.Click += async(s, e) =>
            {
                if (Restrito())
                {
                    return;
                }

                Financeiro.FecharCaixa.idCaixa = idCaixa;
                var f = new FecharCaixa();
                if (f.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                txtFechado.Text        = DateTime.Now.ToString("dd/mm/YYYY HH:mm", Program.cultura);
                panel7.BackColor       = Color.FromArgb(192, 0, 0);
                label7.Text            = @"Caixa Fechado";
                FecharCaixa.Enabled    = false;
                btnLancamentos.Enabled = false;

                if (Financeiro.FecharCaixa.fecharImprimir)
                {
                    await RenderizarAsync();
                }
            };

            GridLista2.CellFormatting += (s, e) =>
            {
                foreach (DataGridViewRow row in GridLista2.Rows)
                {
                    if (Validation.ConvertToDouble(row.Cells[3].Value) < Validation.ConvertToDouble(row.Cells[2].Value))
                    {
                        row.Cells[3].Style.Font = new Font("Segoe UI Semibold", 9.75F, FontStyle.Bold,
                                                           GraphicsUnit.Point, 0);
                        row.Cells[3].Style.ForeColor = Color.White;
                        row.Cells[3].Style.BackColor = Color.FromArgb(255, 89, 89);
                    }
                    else
                    {
                        row.Cells[3].Style.Font = new Font("Segoe UI Semibold", 9.75F, FontStyle.Bold,
                                                           GraphicsUnit.Point, 0);
                        row.Cells[3].Style.ForeColor = Color.White;
                        row.Cells[3].Style.BackColor = Color.FromArgb(139, 215, 146);
                    }
                }
            };

            GridLista.CellFormatting += (s, e) =>
            {
                foreach (DataGridViewRow row in GridLista.Rows)
                {
                    if (row.Cells[2].Value.ToString().Contains("ENTRADA") ||
                        row.Cells[2].Value.ToString().Contains("Venda"))
                    {
                        row.Cells[3].Style.Font = new Font("Segoe UI Semibold", 9.75F, FontStyle.Bold,
                                                           GraphicsUnit.Point, 0);
                        row.Cells[3].Style.ForeColor = Color.White;
                        row.Cells[3].Style.BackColor = Color.FromArgb(139, 215, 146);
                    }
                    else
                    {
                        row.Cells[3].Style.Font = new Font("Segoe UI Semibold", 9.75F, FontStyle.Bold,
                                                           GraphicsUnit.Point, 0);
                        row.Cells[3].Style.ForeColor = Color.White;
                        row.Cells[3].Style.BackColor = Color.FromArgb(255, 89, 89);
                    }
                }
            };

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

            btnHelp.Click += (s, e) => Support.OpenLinkBrowser(Program.URL_BASE + "/ajuda");

            btnFinalizarImprimir.Click += async(s, e) => await RenderizarAsync();
        }
Exemple #19
0
        private void Eventos()
        {
            Shown += async(s, e) =>
            {
                Refresh();

                loading.Visible = true;
                workerBackground.RunWorkerAsync();

                ToolHelp.Show(
                    $"Referente ao período ({DateTime.Now.AddDays(-Days):dd/MM/yyyy}) até Hoje ({DateTime.Now:dd/MM/yyyy})",
                    pictureBox4, ToolHelp.ToolTipIcon.Info, "Ajuda!");

                dataSemana.Text = $@"{DateTime.Now.AddDays(-Days):dd/MM/yyyy} até Hoje ({DateTime.Now:dd/MM/yyyy})";
                LoadGrafico();

                SetHeadersTable(GridLista);

                await Task.Delay(500);

                new Caixa().CheckCaixaDate();
            };

            timer1.Tick += (s, e) =>
            {
                panel1.Visible  = false;
                loading.Visible = true;

                workerBackground.RunWorkerAsync();
                timer1.Enabled = true;
                timer1.Stop();
            };

            btnTodosAreceber.Click += (s, e) =>
            {
                if (UserPermission.SetControlLabel(btnTodosAreceber, pictureBox3, "fin_recebimentos"))
                {
                    return;
                }

                Home.financeiroPage = "Receber";
                OpenForm.Show <Titulos>(this);
            };

            btnTodosApagar.Click += (s, e) =>
            {
                if (UserPermission.SetControlLabel(btnTodosApagar, pictureBox3, "fin_pagamentos"))
                {
                    return;
                }

                Home.financeiroPage = "Pagar";
                OpenForm.Show <Titulos>(this);
            };

            btnNovoRecebimento.Click += (s, e) =>
            {
                Home.financeiroPage   = "Receber";
                EditarTitulo.IdTitulo = 0;
                OpenForm.Show <EditarTitulo>(this);
            };

            btnNovoPagamento.Click += (s, e) =>
            {
                Home.financeiroPage   = "Pagar";
                EditarTitulo.IdTitulo = 0;
                OpenForm.Show <EditarTitulo>(this);
            };

            workerBackground.DoWork += (s, e) =>
            {
                GetDados();

                aReceber = GetValues("Receber");
                aPagar   = GetValues("Pagar");
                vendas   = GetVendas();

                dataProductsEstoque = new Item().FindAll()
                                      .WhereRaw("estoqueminimo >= estoqueatual")
                                      .Where("estoqueminimo", "!=", "0")
                                      .WhereFalse("excluir")
                                      .Get();
            };

            workerBackground.RunWorkerCompleted += async(s, e) =>
            {
                panel1.Visible  = true;
                loading.Visible = false;
                //timer1.Start();
                LoadData();
                LoadSeriesGrafico();

                await SetContentTableAsync(GridLista, dataProductsEstoque);
            };

            btnRefresh.Click += (s, e) =>
            {
                panel1.Visible  = false;
                loading.Visible = true;

                workerBackground.RunWorkerAsync();
            };
        }
Exemple #20
0
        private void Eventos()
        {
            novaNFE.Click += (s, e) =>
            {
                if (UserPermission.SetControl(novaNFE, pictureBox6, "fiscal_novanfe"))
                {
                    return;
                }

                Nota.disableCampos = false;
                Nota.Id            = 0;
                var nota = new Nota();
                nota.ShowDialog();
            };

            nfe.Click += (s, e) =>
            {
                if (UserPermission.SetControl(nfe, pictureBox7, "fiscal_nfe"))
                {
                    return;
                }

                Home.pedidoPage = "Notas";
                OpenForm.Show <Pedido>(this);
            };

            naturezaOP.Click += (s, e) =>
            {
                if (UserPermission.SetControl(naturezaOP, pictureBox5, "fiscal_natop"))
                {
                    return;
                }

                OpenForm.Show <Natureza>(this);
            };

            clientes.Click += (s, e) =>
            {
                if (UserPermission.SetControl(clientes, pictureBox11, "fiscal_clientes"))
                {
                    return;
                }

                Home.pessoaPage = "Clientes";
                OpenForm.Show <Clientes>(this);
            };

            fornecedores.Click += (s, e) =>
            {
                if (UserPermission.SetControl(fornecedores, pictureBox2, "fiscal_fornecedores"))
                {
                    return;
                }

                Home.pessoaPage = "Fornecedores";
                OpenForm.Show <Clientes>(this);
            };

            transportadoras.Click += (s, e) =>
            {
                if (UserPermission.SetControl(transportadoras, pictureBox3, "fiscal_transportadoras"))
                {
                    return;
                }

                Home.pessoaPage = "Transportadoras";
                OpenForm.Show <Clientes>(this);
            };

            impostos.Click += (s, e) =>
            {
                if (UserPermission.SetControl(impostos, pictureBox4, "fiscal_impostos"))
                {
                    return;
                }

                OpenForm.Show <Impostos>(this);
            };

            InutilizarNFE.Click += (s, e) =>
            {
                if (UserPermission.SetControl(InutilizarNFE, pictureBox9, "fiscal_inutilizar"))
                {
                    return;
                }

                OpenForm.Show <InutilizarNotas>(this);
            };

            AlterarNFE.Click += (s, e) =>
            {
                if (UserPermission.SetControl(AlterarNFE, pictureBox10, "fiscal_alterar"))
                {
                    return;
                }

                AlertOptions.Message("", "Para alterar o últ. n° da NF-e acesse nossa área do Cliente online.",
                                     AlertBig.AlertType.info, AlertBig.AlertBtn.OK);
            };

            EnviarXml.Click += (s, e) =>
            {
                if (UserPermission.SetControl(EnviarXml, pictureBox12, "fiscal_enviar"))
                {
                    return;
                }

                Alert.Message("Ação não permitida", "Função não disponível", Alert.AlertType.warning);
            };

            CFE.Click += (s, e) =>
            {
                if (UserPermission.SetControl(CFE, pictureBox8, "fiscal_cfe"))
                {
                    return;
                }

                Home.pedidoPage = "Cupons";
                OpenForm.Show <Pedido>(this);
            };
        }
Exemple #21
0
        private void Eventos()
        {
            Masks.SetToUpper(this);

            Load += (s, e) =>
            {
                if (Id > 0)
                {
                    LoadData();
                }

                if (_mNota.Status != "Pendente")
                {
                    Nota.disableCampos = true;
                    DisableCampos();

                    progress5.Visible = false;
                    step5.Visible     = false;
                    label16.Visible   = false;
                    Apagar.Visible    = false;
                }
            };

            addNatureza.Click += (s, e) =>
            {
                AddNatureza f = new AddNatureza();
                f.btnSalvarText     = "Salvar e Inserir";
                f.btnSalvarWidth    = 150;
                f.btnSalvarLocation = 590;
                f.FormBorderStyle   = FormBorderStyle.FixedSingle;
                f.StartPosition     = FormStartPosition.CenterParent;
                f.TopMost           = true;
                if (f.ShowDialog() == DialogResult.OK)
                {
                    DialogResult = DialogResult.OK;
                    IdNatureza   = AddNatureza.idSelected;
                    LoadNatureza();
                }
            };

            Next.Click += (s, e) =>
            {
                if (Validate())
                {
                    return;
                }

                telaDados = true;

                #region CONFERE DADOS

                var dataAddrFirst = _mClienteAddr.Query().Where("id_pessoa", IdCliente).FirstOrDefault <Model.PessoaEndereco>();

                if (_mPedido.id_useraddress > 0)
                {
                    dataAddrFirst = new Model.PessoaEndereco().Query().Where("id", _mPedido.id_useraddress).FirstOrDefault <Model.PessoaEndereco>();
                }

                if (DetailsClient.IdAddress > 0)
                {
                    dataAddrFirst = new Model.PessoaEndereco().Query().Where("id", DetailsClient.IdAddress).FirstOrDefault <Model.PessoaEndereco>();
                }

                if (dataAddrFirst != null)
                {
                    if (String.IsNullOrEmpty(dataAddrFirst.Rua))
                    {
                        Alert.Message("Atenção!", "O endereço do destinatário não pode ser vazio. Acesse o cadastro do cliente para corrigir!", Alert.AlertType.warning);
                        return;
                    }

                    if (String.IsNullOrEmpty(dataAddrFirst.Cep))
                    {
                        Alert.Message("Atenção!", "O cep do destinatário não pode ser vazio. Acesse o cadastro do cliente para corrigir!", Alert.AlertType.warning);
                        return;
                    }

                    if (String.IsNullOrEmpty(dataAddrFirst.Bairro))
                    {
                        Alert.Message("Atenção!", "O bairro do destinatário não pode ser vazio. Acesse o cadastro do cliente para corrigir!", Alert.AlertType.warning);
                        return;
                    }

                    if (String.IsNullOrEmpty(dataAddrFirst.Cidade))
                    {
                        Alert.Message("Atenção!", "A cidade do destinatário não pode ser vazio. Acesse o cadastro do cliente para corrigir!", Alert.AlertType.warning);
                        return;
                    }

                    if (String.IsNullOrEmpty(dataAddrFirst.IBGE))
                    {
                        Alert.Message("Atenção!", "O código do municipio (IBGE) do destinatário não pode ser vazio. Acesse o cadastro do cliente para corrigir!", Alert.AlertType.warning);
                        return;
                    }
                }

                #endregion

                GetData();

                if (!Nota.disableCampos)
                {
                    _mPedido.Save(_mPedido);
                }

                OpenForm.Show <TelaProdutos>(this);
            };

            SelecionarCliente.Click += (s, e) =>
            {
                PedidoModalClientes form = new PedidoModalClientes();
                form.TopMost = true;
                if (form.ShowDialog() == DialogResult.OK)
                {
                    GetData();
                    _mPedido.Save(_mPedido);
                    LoadCliente();
                }
            };

            btnAddAddr.Click += (s, e) =>
            {
                if (_mPedido.Cliente > 0)
                {
                    DetailsClient.IdClient = _mPedido.Cliente;
                    DetailsClient form = new DetailsClient();
                    form.TopMost = true;
                    if (form.ShowDialog() == DialogResult.OK)
                    {
                        GetData();
                        _mPedido.Save(_mPedido);
                        LoadCliente();

                        var dataAddr = _mClienteAddr.FindById(_mPedido.id_useraddress).FirstOrDefault <Model.PessoaEndereco>();
                        if (dataAddr != null)
                        {
                            AddrInfo.Text = $"Rua: {dataAddr.Rua}, {dataAddr.Cep} - {dataAddr.Bairro} - {dataAddr.Cidade}/{dataAddr.Estado} - {dataAddr.Pais}";
                            IdAddr        = dataAddr.Id;
                        }

                        btnAddAddr.Text = "Selecionar outro Endereço.";
                    }
                }
                else
                {
                    Alert.Message("Opps", "Selecione um destinatário..", Alert.AlertType.info);
                }
            };

            Documentos.Click += (s, e) =>
            {
                DocumentosReferenciados form = new DocumentosReferenciados();
                form.TopMost = true;
                form.Show();
            };

            emissao.KeyPress += (s, e) => Masks.MaskBirthday(s, e);
            saida.KeyPress   += (s, e) => Masks.MaskBirthday(s, e);
            hora.KeyPress    += (s, e) => Masks.MaskHour(s, e);

            Apagar.Click += (s, e) =>
            {
                var result = AlertOptions.Message("Atenção!", "Você está prestes a excluir! Deseja continuar?", AlertBig.AlertType.warning, AlertBig.AlertBtn.YesNo);
                if (result)
                {
                    if (_mPedido != null)
                    {
                        if (_mPedido.Tipo == "NFe")
                        {
                            _mPedido.Excluir = 1;
                            _mPedido.Save(_mPedido);
                        }
                    }

                    if (_mNota != null)
                    {
                        _mNota.Excluir   = 1;
                        _mNota.id_pedido = 0;
                        _mNota.Save(_mNota, false);
                    }

                    telaDados = true;
                    Alert.Message("Pronto!", "Removido com sucesso!", Alert.AlertType.info);
                    Application.OpenForms["Nota"].Close();
                    Close();
                }
            };
        }
Exemple #22
0
        private void EditPedido(bool create = false)
        {
            OpcoesCfe.tipoTela = 0;

            if (create)
            {
                switch (Home.pedidoPage)
                {
                case "Notas":
                {
                    Nota.disableCampos = false;
                    Nota.Id            = 0;
                    //OpcoesNfeRapida.idPedido = 0;
                    var nota = new Nota();
                    nota.ShowDialog();
                    //Filter();
                    return;
                }

                case "Ordens de Servico":
                    AddOs.Id = 0;
                    OpenForm.Show <AddOs>(this);
                    return;
                }

                AddPedidos.Id = 0;
                var novoPedido = new AddPedidos();
                novoPedido.ShowDialog();
                //Filter();
                return;
            }

            if (GridLista.SelectedRows.Count > 0)
            {
                var dataTipo = new Model.Pedido().FindById(Convert.ToInt32(GridLista.SelectedRows[0].Cells["ID"].Value))
                               .FirstOrDefault <Model.Pedido>();
                if (dataTipo != null && dataTipo.Tipo != Home.pedidoPage && Home.pedidoPage != "Notas" &&
                    Home.pedidoPage != "Cupons")
                {
                    Alert.Message("Opss", "Não é possível carregar este registro", Alert.AlertType.warning);
                    return;
                }

                switch (Home.pedidoPage)
                {
                case "Ordens de Servico":
                    AddOs.Id = Convert.ToInt32(GridLista.SelectedRows[0].Cells["ID"].Value);
                    OpenForm.Show <AddOs>(this);
                    return;

                case "Orçamentos":
                case "Consignações":
                case "Devoluções":
                {
                    AddPedidos.Id = Convert.ToInt32(GridLista.SelectedRows[0].Cells["ID"].Value);
                    var novoPedido = new AddPedidos();
                    novoPedido.ShowDialog();
                    return;
                }

                case "Cupons":
                {
                    OpcoesCfe.tipoTela = 1;
                    OpcoesCfe.idPedido = Convert.ToInt32(GridLista.SelectedRows[0].Cells["ID"].Value);
                    OpcoesCfe.idNota   = Convert.ToInt32(GridLista.SelectedRows[0].Cells["IDNOTA"].Value);
                    var f = new OpcoesCfe();
                    f.Show();
                    return;
                }

                case "Notas" when !GridLista.SelectedRows[0].Cells["Status"].Value.ToString().Contains("Pendente"):
                {
                    OpcoesNfeRapida.idNota   = Convert.ToInt32(GridLista.SelectedRows[0].Cells["IDNOTA"].Value);
                    OpcoesNfeRapida.idPedido = Convert.ToInt32(GridLista.SelectedRows[0].Cells["ID"].Value);
                    var f = new OpcoesNfeRapida();
                    f.Show();
                    break;
                }

                case "Notas":
                {
                    Nota.Id = Convert.ToInt32(GridLista.SelectedRows[0].Cells["IDNOTA"].Value);
                    var nota = new Nota();
                    nota.ShowDialog();
                    break;
                }

                default:
                {
                    if (Validation.ConvertToInt32(GridLista.SelectedRows[0].Cells["EXCLUIR"].Value) > 0)
                    {
                        Alert.Message("Erro", "Esse registro foi excluido e não é permitido acessá-lo", Alert.AlertType.warning);
                        return;
                    }

                    switch (Home.pedidoPage)
                    {
                    case "Compras" when GridLista.SelectedRows[0].Cells["Status"].Value.ToString() == "Pendente":
                    {
                        AddPedidos.Id = Convert.ToInt32(GridLista.SelectedRows[0].Cells["ID"].Value);
                        var novoPedido = new AddPedidos();
                        novoPedido.ShowDialog();
                        return;
                    }

                    case "Vendas" when GridLista.SelectedRows[0].Cells["Status"].Value.ToString() == "Pendente":
                    {
                        AddPedidos.Id = Convert.ToInt32(GridLista.SelectedRows[0].Cells["ID"].Value);
                        var novoPedido = new AddPedidos();
                        novoPedido.ShowDialog();
                        return;
                    }
                    }

                    DetailsPedido.idPedido = Convert.ToInt32(GridLista.SelectedRows[0].Cells["ID"].Value);
                    //DetailsPedido detailsPedido = new DetailsPedido();
                    //detailsPedido.ShowDialog();
                    OpenForm.Show <DetailsPedido>(this);
                    break;
                }
                }

                //Filter();
            }
            else
            {
                Alert.Message("Opps", "Selecione um item na tabela.", Alert.AlertType.info);
            }
        }
Exemple #23
0
        private void Eventos()
        {
            Clientes.Click += (s, e) =>
            {
                if (UserPermission.SetControl(Clientes, pictureBox1, "fin_clientes"))
                {
                    return;
                }

                Home.pessoaPage = "Clientes";
                OpenForm.Show <Clientes>(this);
            };

            Receitas.Click += (s, e) =>
            {
                if (UserPermission.SetControl(Receitas, pictureBox11, "fin_receitas"))
                {
                    return;
                }

                Home.CategoriaPage = "Receitas";
                OpenForm.Show <Categorias>(this);
            };

            Despesas.Click += (s, e) =>
            {
                if (UserPermission.SetControl(Despesas, pictureBox13, "fin_despesas"))
                {
                    return;
                }

                Home.CategoriaPage = "Despesas";
                OpenForm.Show <Categorias>(this);
            };

            fornecedores.Click += (s, e) =>
            {
                if (UserPermission.SetControl(fornecedores, pictureBox3, "fin_fornecedores"))
                {
                    return;
                }

                Home.pessoaPage = "Fornecedores";
                OpenForm.Show <Clientes>(this);
            };

            aReceber.Click += (s, e) =>
            {
                if (UserPermission.SetControl(aReceber, pictureBox9, "fin_recebimentos"))
                {
                    return;
                }

                Home.financeiroPage = "Receber";
                OpenForm.Show <Titulos>(this);
            };

            aPagar.Click += (s, e) =>
            {
                if (UserPermission.SetControl(aPagar, pictureBox10, "fin_pagamentos"))
                {
                    return;
                }

                Home.financeiroPage = "Pagar";
                OpenForm.Show <Titulos>(this);
            };

            novoRecebimento.Click += (s, e) =>
            {
                if (UserPermission.SetControl(novoRecebimento, pictureBox4, "fin_novorecebimento"))
                {
                    return;
                }

                EditarTitulo.IdTitulo = 0;
                Home.financeiroPage   = "Receber";
                OpenForm.Show <EditarTitulo>(this);
            };

            novoPagamento.Click += (s, e) =>
            {
                if (UserPermission.SetControl(novoPagamento, pictureBox5, "fin_novopag"))
                {
                    return;
                }

                EditarTitulo.IdTitulo = 0;
                Home.financeiroPage   = "Pagar";
                OpenForm.Show <EditarTitulo>(this);
            };

            AbrirCaixa.Click += (s, e) =>
            {
                if (UserPermission.SetControl(AbrirCaixa, pictureBox6, "fin_abrircaixa"))
                {
                    return;
                }

                if (Home.idCaixa == 0)
                {
                    var f = new AbrirCaixa();
                    f.ShowDialog();
                }
                else
                {
                    Alert.Message("Oopps!", "Já existe um caixa aberto.", Alert.AlertType.warning);
                }
            };

            Caixa.Click += (s, e) =>
            {
                if (UserPermission.SetControl(Caixa, pictureBox12, "fin_caixa"))
                {
                    return;
                }

                OpenForm.Show <Caixa>(this);
            };

            EntradaSaidaCaixa.Click += (s, e) =>
            {
                if (UserPermission.SetControl(EntradaSaidaCaixa, pictureBox7, "fin_entradasaidacaixa"))
                {
                    return;
                }

                if (Home.idCaixa == 0)
                {
                    Alert.Message("Oopps!", "Você não possui um caixa aberto.", Alert.AlertType.warning);
                    return;
                }

                AddCaixaMov.idCaixa = Home.idCaixa;
                AddCaixaMov.idMov   = 0;
                var f = new AddCaixaMov();
                f.ShowDialog();
            };

            FecharCaixa.Click += (s, e) =>
            {
                if (UserPermission.SetControl(FecharCaixa, pictureBox8, "fin_fecharcaixa"))
                {
                    return;
                }

                if (Home.idCaixa == 0)
                {
                    Alert.Message("Oopps!", "Você não possui um caixa aberto.", Alert.AlertType.warning);
                    return;
                }

                Financeiro.FecharCaixa.idCaixa = Home.idCaixa;
                var f = new FecharCaixa();
                if (f.ShowDialog() == DialogResult.OK)
                {
                    Alert.Message("Pronto!", "Caixa fechado com sucesso.", Alert.AlertType.success);
                }
            };

            btnTaxas.Click += (s, e) => { OpenForm.Show <Taxas>(this); };
        }
Exemple #24
0
        private void Eventos()
        {
            BuscarProduto.Select();

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

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

                Medidas.DataSource = Support.GetMedidas();

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

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

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

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

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

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

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

                            Quantidade.Focus();
                            return;
                        }
                    }

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

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

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

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

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

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

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

                        GetDataTableItens(GridListaProdutos, _mNota.id_pedido);
                    }

                    NCM       = "";
                    idImposto = 0;
                }

                BuscarProduto.Select();
            };

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

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

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

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

                        AlterarImposto.Visible = hideBtns;
                    }
                }
            };

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

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

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

                var dataGridView = (s as DataGridView);
                if (GridListaProdutos.Columns[e.ColumnIndex].Name == "Selecione")
                {
                    dataGridView.Cursor = Cursors.Default;
                }
            };
        }
Exemple #25
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();
        }
Exemple #26
0
        private void Eventos()
        {
            Produtos.Click += (s, e) =>
            {
                if (UserPermission.SetControl(Produtos, pictureBox9, "pdt_pdt"))
                {
                    return;
                }

                OpenForm.Show <Produtos.Produtos>(this);
            };

            Servicos.Click += (s, e) =>
            {
                //if (UserPermission.SetControl(Produtos, pictureBox9, "pdt_pdt"))
                //    return;

                OpenForm.Show <Servicos>(this);
            };

            Etiquetas.Click += (s, e) =>
            {
                if (UserPermission.SetControl(Etiquetas, pictureBox2, "pdt_etiquetas"))
                {
                    return;
                }

                OpenForm.Show <Etiquetas>(this);
            };

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

                Home.CategoriaPage = "Produtos";
                OpenForm.Show <Categorias>(this);
            };

            Impostos.Click += (s, e) =>
            {
                if (UserPermission.SetControl(Impostos, pictureBox3, "pdt_impostos"))
                {
                    return;
                }

                OpenForm.Show <Impostos>(this);
            };

            fornecedores.Click += (s, e) =>
            {
                if (UserPermission.SetControl(fornecedores, pictureBox5, "pdt_fornecedores"))
                {
                    return;
                }

                Home.pessoaPage = "Fornecedores";
                OpenForm.Show <Clientes>(this);
            };

            transportadoras.Click += (s, e) =>
            {
                if (UserPermission.SetControl(transportadoras, pictureBox6, "pdt_transportadoras"))
                {
                    return;
                }

                Home.pessoaPage = "Transportadoras";
                OpenForm.Show <Clientes>(this);
            };

            ReajusteProduto.Click += (s, e) =>
            {
                if (UserPermission.SetControl(ReajusteProduto, pictureBox7, "pdt_reajuste"))
                {
                    return;
                }

                OpenForm.Show <ReajusteDeProduto>(this);
            };

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

            Compras.Click += (s, e) =>
            {
                if (UserPermission.SetControl(Compras, pictureBox8, "pdt_novacompra"))
                {
                    return;
                }

                Home.pedidoPage = "Compras";
                OpenForm.Show <Pedido>(this);
            };

            btnRemessas.Click += (s, e) =>
            {
                Home.pedidoPage = "Remessas";
                OpenForm.Show <Pedido>(this);
            };

            btnRemessa.Click += (s, e) =>
            {
                Home.pedidoPage = "Remessas";
                AddPedidos.Id   = 0;
                var novoPedido = new AddPedidos();
                novoPedido.ShowDialog();
            };

            HistoricoEntradaSaida.Click += (s, e) =>
            {
                if (UserPermission.SetControl(HistoricoEntradaSaida, pictureBox11, "pdt_entradassaidas"))
                {
                    return;
                }

                OpenForm.Show <EstoqueEntradaSaida>(this);
            };

            Estoque.Click += (s, e) =>
            {
                if (UserPermission.SetControl(Estoque, pictureBox12, "pdt_inventario"))
                {
                    return;
                }

                OpenForm.Show <Inventario>(this);
            };

            CompraNova.Click += (s, e) =>
            {
                if (UserPermission.SetControl(Compras, pictureBox13, "pdt_compras"))
                {
                    return;
                }

                Home.pedidoPage = "Compras";
                AddPedidos.Id   = 0;
                var novoPedido = new AddPedidos();
                novoPedido.ShowDialog();
            };

            importarNfe.Click += (s, e) =>
            {
                if (UserPermission.SetControl(importarNfe, pictureBox14, "pdt_importarnfe"))
                {
                    return;
                }

                var f = new ImportarNfe();
                f.ShowDialog();
            };

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

            btnVariation.Click += (s, e) => OpenForm.Show <Variacoes>(this);
        }
Exemple #27
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;
            }
        }
Exemple #28
0
 private void ActionMesa(object sender, EventArgs e)
 {
     var label = (Label) sender;
     Mesa.nrMesa = label.Name;
     OpenForm.Show<Mesa>(this);
 }
Exemple #29
0
        private void Eventos()
        {
            OS.Click += (s, e) =>
            {
                //if (UserPermission.SetControl(Clientes, pictureBox11, "com_clientes"))
                //    return;

                AddOs.Id = 0;
                OpenForm.Show <AddOs>(this);
            };

            OSRel.Click += (s, e) =>
            {
                //if (UserPermission.SetControl(Pedidos, pictureBox5, "com_novavenda"))
                //    return;

                Home.pedidoPage = "Ordens de Servico";
                OpenForm.Show <Pedido>(this);
            };

            btnPdv.Click += (s, e) =>
            {
                Home.pedidoPage = "Vendas";
                AddPedidos.Id   = 0;
                AddPedidos.PDV  = true;
                var novoPedido = new AddPedidos();
                novoPedido.ShowDialog();
            };

            Clientes.Click += (s, e) =>
            {
                if (UserPermission.SetControl(Clientes, pictureBox11, "com_clientes"))
                {
                    return;
                }

                Home.pessoaPage = "Clientes";
                OpenForm.Show <Clientes>(this);
            };

            Pedidos.Click += (s, e) =>
            {
                if (UserPermission.SetControl(Pedidos, pictureBox5, "com_novavenda"))
                {
                    return;
                }

                Home.pedidoPage = "Vendas";
                AddPedidos.Id   = 0;
                AddPedidos.PDV  = false;
                var novoPedido = new AddPedidos();
                novoPedido.ShowDialog();
            };

            Orcamentos.Click += (s, e) =>
            {
                if (UserPermission.SetControl(Orcamentos, pictureBox3, "com_novoorcamento"))
                {
                    return;
                }

                Home.pedidoPage = "Orçamentos";
                AddPedidos.Id   = 0;
                var novoPedido = new AddPedidos();
                novoPedido.ShowDialog();
            };

            Consignacoes.Click += (s, e) =>
            {
                if (UserPermission.SetControl(Consignacoes, pictureBox4, "com_novaconsig"))
                {
                    return;
                }

                Home.pedidoPage = "Consignações";
                AddPedidos.Id   = 0;
                var novoPedido = new AddPedidos();
                novoPedido.ShowDialog();
            };

            Devolucoes.Click += (s, e) =>
            {
                if (UserPermission.SetControl(Devolucoes, pictureBox6, "com_novadevo"))
                {
                    return;
                }

                Home.pedidoPage = "Devoluções";
                AddPedidos.Id   = 0;
                var novoPedido = new AddPedidos();
                novoPedido.ShowDialog();
            };

            VendasRel.Click += (s, e) =>
            {
                if (UserPermission.SetControl(VendasRel, pictureBox12, "com_vendas"))
                {
                    return;
                }

                Home.pedidoPage = "Vendas";
                OpenForm.Show <Pedido>(this);
            };

            ProdutosVendidos.Click += (s, e) =>
            {
                if (UserPermission.SetControl(ProdutosVendidos, pictureBox13, "com_pdtvendidos"))
                {
                    return;
                }

                Home.pedidoPage = "Vendas";
                OpenForm.Show <ProdutosVendidos>(this);
                //Reports.ProdutosVendidos ProdVendidos = new Reports.ProdutosVendidos();
                //ProdVendidos.ShowDialog();
            };

            ConsignacoesRel.Click += (s, e) =>
            {
                if (UserPermission.SetControl(ConsignacoesRel, pictureBox9, "com_consig"))
                {
                    return;
                }

                Home.pedidoPage = "Consignações";
                OpenForm.Show <Pedido>(this);
            };

            ProdutosConsignados.Click += (s, e) =>
            {
                //if (UserPermission.SetControl(ProdutosConsignados, pictureBox10, "com_pdtconsignados"))
                //    return;

                //Home.pedidoPage = "Consignações";
                //Reports.ProdutosVendidos ProdVendidos = new Reports.ProdutosVendidos();
                //ProdVendidos.ShowDialog();
            };

            DevolucoesRel.Click += (s, e) =>
            {
                if (UserPermission.SetControl(DevolucoesRel, pictureBox15, "com_devolucoes"))
                {
                    return;
                }

                Home.pedidoPage = "Devoluções";
                OpenForm.Show <Pedido>(this);
            };

            OrcamentosRel.Click += (s, e) =>
            {
                if (UserPermission.SetControl(OrcamentosRel, pictureBox7, "com_orcamentos"))
                {
                    return;
                }

                Home.pedidoPage = "Orçamentos";
                OpenForm.Show <Pedido>(this);
            };

            ProdutosOrcados.Click += (s, e) =>
            {
                //if (UserPermission.SetControl(ProdutosOrcados, pictureBox8, "com_pdtorcados"))
                //    return;

                //Home.pedidoPage = "Orçamentos";
                //Reports.ProdutosVendidos ProdVendidos = new Reports.ProdutosVendidos();
                //ProdVendidos.ShowDialog();
            };

            Comissoes.Click += (s, e) =>
            {
                if (UserPermission.SetControl(Comissoes, pictureBox14, "com_comissoes"))
                {
                    return;
                }

                var usuarios = new Usuarios().FindByUserId(Settings.Default.user_id).FirstOrDefault <Usuarios>();
                if (usuarios.Sub_user == 0)
                {
                    OpenForm.Show <Comissão>(this);
                }
                else
                {
                    DetalhesComissao.idUser = Settings.Default.user_id;
                    OpenForm.Show <DetalhesComissao>(this);
                }
            };
        }
Exemple #30
0
        /// <summary>
        /// Eventos do form
        /// </summary>
        public void Eventos()
        {
            KeyDown           += KeyDowns;
            Dinheiro.KeyDown  += KeyDowns;
            Cheque.KeyDown    += KeyDowns;
            Debito.KeyDown    += KeyDowns;
            Credito.KeyDown   += KeyDowns;
            Crediario.KeyDown += KeyDowns;
            Boleto.KeyDown    += KeyDowns;
            Desconto.KeyDown  += KeyDowns;
            Acrescimo.KeyDown += KeyDowns;

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

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

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

                AtualizarDados();

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

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

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

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

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

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

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

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

                AtualizarDados();
            };

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

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

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

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

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

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

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

                    mtxt.Visible = true;
                }

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

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

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

                    mtxt2.Visible = true;
                }
            };

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

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

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

                if (ID == 0)
                {
                    return;
                }

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

                if (titulo == null)
                {
                    return;
                }

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

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

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

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

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