Ejemplo n.º 1
0
        private void Continuar()
        {
            if (nomeRS.Text != "Consumidor Final")
            {
                _mPedido.cfe_nome = Validation.CleanStringForFiscal(nomeRS.Text);
            }

            _mPedido.cfe_cpf = Validation.CleanStringForFiscal(cpfCnpj.Text.Replace(".", "").Replace(" ", ""));

            _mPedido.Save(_mPedido);

            if (emitir)
            {
                OpcoesCfeEmitir.idPedido = idPedido;
                var f = new OpcoesCfeEmitir {
                    TopMost = true
                };
                f.Show();

                Close();
            }
            else
            {
                OpcoesCfe.idPedido = idPedido;
                var f = new OpcoesCfe {
                    TopMost = true
                };
                f.Show();

                Close();
            }
        }
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 3
0
        public void Cfe(int tipo = 0)
        {
            OpcoesCfe.idNota = 0;
            OpcoesCfe.tipo   = tipo == 1 ? "NFCe" : "";

            var checkNota = new Nota().FindByIdPedidoUltReg(idPedido, "", tipo == 1 ? "NFCe" : "CFe").FirstOrDefault <Nota>();

            if (checkNota == null)
            {
                var _modelNota = new Nota
                {
                    Id        = 0,
                    Tipo      = tipo == 1 ? "NFCe" : "CFe",
                    Status    = "Pendente",
                    id_pedido = idPedido
                };

                if (!_modelNota.Save(_modelNota, false))
                {
                    Alert.Message("Ação não permitida",
                                  "Problema com tabela Notas. Entre em contato com o suporte técnico!", Alert.AlertType.warning);
                    return;
                }

                checkNota = _modelNota;
            }

            if (checkNota != null)
            {
                OpcoesCfe.idNota = checkNota.Id;
            }
            else
            {
                return;
            }

            switch (checkNota.Status)
            {
            case "Falha":
                Alert.Message("Ação não permitida", "Entre em contato com o suporte técnico", Alert.AlertType.warning);
                break;

            case "Autorizada":
            case "Autorizado":
            {
                OpcoesCfe.idPedido = idPedido;
                var f = new OpcoesCfe();
                f.Show();
                break;
            }

            case "Cancelada":
            case "Cancelado":
            {
                var result = AlertOptions.Message("Atenção!",
                                                  "Existem registro(s) de cupon(s) cancelado(s) a partir desta venda. Deseja gerar um novo cupom?",
                                                  AlertBig.AlertType.warning, AlertBig.AlertBtn.YesNo);
                if (result)
                {
                    var _modelNota = new Nota
                    {
                        Id        = 0,
                        Tipo      = tipo == 1 ? "NFCe" : "CFe",
                        Status    = "Pendente",
                        id_pedido = idPedido
                    };

                    _modelNota.Save(_modelNota, false);

                    checkNota = _modelNota;

                    OpcoesCfeEmitir.fecharTelas = false;

                    OpcoesCfeCpf.idPedido = idPedido;
                    OpcoesCfeCpf.emitir   = true;
                    var f = new OpcoesCfeCpf();
                    f.Show();
                }

                break;
            }

            case "Pendente":
            {
                OpcoesCfeEmitir.fecharTelas = false;

                OpcoesCfeCpf.idPedido = idPedido;
                OpcoesCfeCpf.emitir   = true;
                var f = new OpcoesCfeCpf();
                f.Show();
                break;
            }
            }
        }
Ejemplo n.º 4
0
        public void Cfe()
        {
            if (Home.pedidoPage == "Vendas" && aPagartxt.Text != @"R$ 0,00")
            {
                Alert.Message("Ação não permitida", "É necessário informar recebimentos para continuar",
                              Alert.AlertType.warning);
                return;
            }

            Concluir(false);

            OpcoesCfe.idNota = 0;

            var checkNota = new Nota().FindByIdPedidoUltReg(idPedido, "", "CFe").FirstOrDefault <Nota>();

            if (checkNota == null)
            {
                var _modelNota = new Nota
                {
                    Id        = 0,
                    Tipo      = "CFe",
                    Status    = "Pendente",
                    id_pedido = idPedido
                };
                if (!_modelNota.Save(_modelNota, false))
                {
                    Alert.Message("Ação não permitida",
                                  "Problema com tabela Notas. Entre em contato com o suporte técnico!", Alert.AlertType.warning);
                    return;
                }

                checkNota = _modelNota;
            }

            if (checkNota != null)
            {
                OpcoesCfe.idNota = checkNota.Id;
            }
            else
            {
                return;
            }

            switch (checkNota.Status)
            {
            case "Falha":
                Alert.Message("Ação não permitida", "Entre em contato com o suporte técnico", Alert.AlertType.warning);
                break;

            case "Autorizada":
            case "Autorizado":
            {
                OpcoesCfe.idPedido = idPedido;
                var f = new OpcoesCfe {
                    TopMost = true
                };
                f.Show();
                break;
            }

            case "Cancelada":
            case "Cancelado":
            {
                var result = AlertOptions.Message("Atenção!",
                                                  "Existem registro(s) de cupon(s) cancelado(s) a partir desta venda. Deseja gerar um novo cupom?",
                                                  AlertBig.AlertType.warning, AlertBig.AlertBtn.YesNo);
                if (result)
                {
                    var _modelNota = new Nota
                    {
                        Id        = 0,
                        Tipo      = "CFe",
                        Status    = "Pendente",
                        id_pedido = idPedido
                    };
                    _modelNota.Save(_modelNota, false);

                    checkNota = _modelNota;

                    OpcoesCfeEmitir.fecharTelas = true;

                    OpcoesCfeCpf.idPedido = idPedido;
                    OpcoesCfeCpf.emitir   = true;
                    var f = new OpcoesCfeCpf {
                        TopMost = true
                    };
                    f.Show();
                }

                break;
            }

            case "Pendente":
            {
                OpcoesCfeEmitir.fecharTelas = true;

                OpcoesCfeCpf.idPedido = idPedido;
                OpcoesCfeCpf.emitir   = true;
                var f = new OpcoesCfeCpf {
                    TopMost = true
                };
                f.Show();
                break;
            }
            }
        }