Beispiel #1
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;
            }
            }
        }
Beispiel #2
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;
            }
            }
        }