Esempio n. 1
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;
                }
            };
        }
Esempio n. 2
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();
                }
            };
        }