Esempio n. 1
0
        private NFCeService NewWebService()
        {
            var ws = new NFCeService {
                Url = BmsSoftware.ConfigNFCe.Default.UrlNfCeService
            };

            //WebProxy wp = GetProxy();
            //if (wp != null)
            //    ws.Proxy = wp;
            return(ws);
        }
Esempio n. 2
0
        private void cancelarCupomEletrônicoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CreaterCursor Cr = new CreaterCursor();

            this.Cursor = Cr.CreateCursor(Cr.btmap, 0, 0);

            NFCeService     ws        = NewWebService();
            retStatus       ret       = null;
            EMPRESAEntity   EMPRESATy = new EMPRESAEntity();
            EMPRESAProvider EMPRESAP  = new EMPRESAProvider();

            try
            {
                CUPOMELETRONICOEntity CUPOMELETRONICOTy = new CUPOMELETRONICOEntity();
                CUPOMELETRONICOTy = CUPOMELETRONICOP.Read(_CUPOMELETRONICOID);

                if (CUPOMELETRONICOTy != null)
                {
                    DialogResult dr = MessageBox.Show("Deseja realmente cancelar o Cupom Eletrônico?",
                                                      ConfigSistema1.Default.NameSytem, MessageBoxButtons.YesNo);
                    {
                        string justificativa = InputBox("Justificativa de Cancelamento da NFCe", ConfigSistema1.Default.NomeEmpresa, "");

                        if (justificativa.Trim() == string.Empty)
                        {
                            MessageBox.Show("Campo de Justificativa não poderá ser vazio!");
                        }
                        else if (justificativa.Trim().Length < 15)
                        {
                            MessageBox.Show("Campo de Justificativa deverá conter igual ou superior a 15 caracteres!");
                        }
                        else
                        {
                            EMPRESATy = EMPRESAP.Read(1);
                            ret       = ws.Cancela(Util.RetiraLetras(EMPRESATy.CNPJCPF), CUPOMELETRONICOTy.CHAVEACESSO, justificativa);

                            if (ret != null)
                            {
                                int resultCancel = ret.detalheCancelamento.ToString().IndexOf("135");  //135 : CANCELAMENTO -
                                if (resultCancel != -1)
                                {
                                    CUPOMELETRONICOTy.IDSTATUSNFCE = 2; // cancelamento

                                    char[]   split               = new char[] { '/', ',' };
                                    string[] detalheAut          = ret.detalheCancelamento.Split(split);
                                    string   DetalheCancelamento = string.Empty;
                                    foreach (var s in detalheAut)
                                    {
                                        DetalheCancelamento = @"  ==> " + s.Trim() + Environment.NewLine;
                                        if (DetalheCancelamento.ToString().IndexOf("nProt") != -1)
                                        {
                                            CUPOMELETRONICOTy.PROTOCOLOCANCEL = Util.RetiraLetras(DetalheCancelamento).Trim();
                                        }
                                    }

                                    CUPOMELETRONICOP.Save(CUPOMELETRONICOTy);
                                    MessageBox.Show(ret.detalheCancelamento);
                                }
                            }
                        }
                    }

                    this.Cursor = Cursors.Default;
                }
                else
                {
                    this.Cursor = Cursors.Default;
                    MessageBox.Show("Cupom não selecionado!");
                }
            }
            catch (Exception exception)
            {
                this.Cursor = Cursors.Default;
                MessageBox.Show(exception.Message);
                Log.Debug(exception.Message);
            }
        }