Example #1
0
        private void KeyDowns(object sender, KeyEventArgs e)
        {
            if (!CheckCaixa())
            {
                return;
            }

            switch (e.KeyCode)
            {
            case Keys.Enter:
                BSalvar();
                e.SuppressKeyPress = true;
                break;

            case Keys.F1:
                TelaEsc = true;
                JanelasRecebimento("Dinheiro");
                e.SuppressKeyPress = true;
                break;

            case Keys.F2:
                TelaEsc = true;
                JanelasRecebimento("Cheque");
                e.SuppressKeyPress = true;
                break;

            case Keys.F3:
                TelaEsc = true;
                JanelasRecebimento("Cartão de Débito");
                e.SuppressKeyPress = true;
                break;

            case Keys.F4:
                TelaEsc = true;
                JanelasRecebimento("Cartão de Crédito");
                e.SuppressKeyPress = true;
                break;

            case Keys.F5:
                TelaEsc = true;
                JanelasRecebimento("Crediário");
                e.SuppressKeyPress = true;
                break;

            case Keys.F6:
                TelaEsc = true;
                JanelasRecebimento("Boleto");
                e.SuppressKeyPress = true;
                break;

            case Keys.F7:

                break;

            case Keys.F8:

                break;

            case Keys.F9:
                Cfe();
                break;

            case Keys.F10:

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

                Nfe();
                e.SuppressKeyPress = true;
                break;

            case Keys.F11:
                new Controller.Pedido().Imprimir(idPedido);
                //new PedidoImpressao().Print(IdPedido);
                break;

            case Keys.F12:
                Concluir();
                e.SuppressKeyPress = true;
                break;

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

                            AtualizarDados();

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

                            Close();
                        }
                        else
                        {
                            return;
                        }
                    }

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

                break;
            }
        }
Example #2
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;
                }
            };
        }