private void SendEmail(Takers Taker, Companys Company, Models.Models.NFeSStructure.NFeSProcessingResult.tbnfd NFeSAuthorized, Models.Models.NFeSStructure.NFeSPreview.util NFeSUrl) { Functions.Mail.SendEmail("*****@*****.**", Taker.Email, "NFSe N° " + NFeSAuthorized.nfdok.numeronfd + " emitida!", "A nota fiscal <b>N° " + NFeSAuthorized.nfdok.numeronfd + "</b> " + "foi emitida pela empresa <b>" + Company.Name.ToUpper() + "</b> portadora do CNPJ <b>" + Company.CNPJ + "</b>,<br/>" + "em favor de sua empresa/pessoa <b>" + Taker.Name.ToUpper() + "</b> portadora do CNPJ/CPF <b>" + Taker.CPF_CNPJ + "</b><br/>" + "no dia " + Functions.DateTimeBr().ToString("dd/MM/yyyy HH:mm") + " com o <b>Valor Total de R$ " + Functions.FormatNumber(decimal.Parse(NFeSAuthorized.nfdok.NewDataSet.NOTA_FISCAL.ValorTotalNota.Replace(".", ","))) + "</b>.<br/><br/>" + "<b>A nota fiscal pode ser consultada em:</b> " + NFeSUrl.urlNfd, "NFSe Fácil - Emp: " + Company.Name.ToUpper()); }
public Takers Put(Takers takers) { try { Validate(takers); if (takers.TakerId <= 0) { throw new InternalProgramException("Informe o código do tomador!"); } SQL.AppendLine(" Update Takers Set "); SQL.AppendLine(" CompanyId = " + takers.CompanyId + ","); SQL.AppendLine(" IM = '" + Functions.RemoveCharSpecial(Functions.NoQuote(Functions.IIf(takers.IM))) + "',"); SQL.AppendLine(" CPF_CNPJ = '" + Functions.RemoveCharSpecial(Functions.NoQuote(takers.CPF_CNPJ)) + "',"); SQL.AppendLine(" RG_IE = '" + Functions.RemoveCharSpecial(Functions.NoQuote(Functions.IIf(takers.RG_IE))) + "',"); SQL.AppendLine(" Name = '" + Functions.NoQuote(takers.Name) + "',"); SQL.AppendLine(" NameFantasy = '" + Functions.NoQuote(takers.NameFantasy) + "',"); SQL.AppendLine(" TypePerson = '" + Functions.NoQuote(takers.TypePerson) + "',"); SQL.AppendLine(" CEP = '" + Functions.RemoveCharSpecial(Functions.NoQuote(takers.CEP)) + "',"); SQL.AppendLine(" Street = '" + Functions.NoQuote(takers.Street) + "',"); SQL.AppendLine(" Number = '" + Functions.NoQuote(Functions.IIf(takers.Number)) + "',"); SQL.AppendLine(" Neighborhood = '" + Functions.NoQuote(takers.Neighborhood) + "',"); SQL.AppendLine(" City = '" + Functions.NoQuote(takers.City) + "', "); SQL.AppendLine(" State = '" + Functions.NoQuote(takers.State) + "',"); SQL.AppendLine(" Telephone = '" + Functions.RemoveCharSpecial(Functions.NoQuote(takers.Telephone)) + "',"); SQL.AppendLine(" Email = '" + Functions.NoQuote(takers.Email) + "',"); SQL.AppendLine(" DateUpdate = GetDate() "); SQL.AppendLine(" Where TakerId = " + takers.TakerId); if (Functions.Conn.Update(SQL.ToString())) { return(takers); } throw new InternalProgramException("Houve um problema ao atualizar o tomador."); } catch (Exception ex) { throw ex; } }
private Takers Fill(DataRow row) { Takers taker = new Takers(); taker.TakerId = long.Parse(row["TakerId"].ToString()); taker.CompanyId = long.Parse(row["CompanyId"].ToString()); taker.IM = row["IM"].ToString(); taker.CPF_CNPJ = row["CPF_CNPJ"].ToString(); taker.RG_IE = row["RG_IE"].ToString(); taker.Name = row["Name"].ToString(); taker.NameFantasy = row["NameFantasy"].ToString(); taker.TypePerson = row["TypePerson"].ToString(); taker.CEP = row["CEP"].ToString(); taker.Street = row["Street"].ToString(); taker.Neighborhood = row["Neighborhood"].ToString(); taker.City = row["City"].ToString(); taker.State = row["State"].ToString(); taker.Email = row["Email"].ToString(); taker.Active = bool.Parse(row["Active"].ToString()); taker.DateInsert = row.Field <DateTime>("DateInsert").ToString("dd-MM-yyyy"); taker.DateUpdate = row.Field <DateTime>("DateUpdate").ToString("dd-MM-yyyy"); return(taker); }
private void Save(Takers takers, Companys companys, CFPS cFPS, ShippingCompany shippingCompany, Models.Models.NFeSStructure.NFeSProcessingResult.tbnfd NFeS, Models.Models.NFeSStructure.NFeSPreview.util NFeSUrl, string XML = "", string PDF = "") { try { var NFDet = NFeS.nfdok.NewDataSet.NOTA_FISCAL; SQL = new StringBuilder(); SQL.AppendLine("Insert Into NFeS "); SQL.AppendLine(" ( TakerId , "); SQL.AppendLine(" CompanyId , "); SQL.AppendLine(" CFPSId , "); SQL.AppendLine(" ShippingCompanyId , "); SQL.AppendLine(" Cae , "); SQL.AppendLine(" DataEmissao , "); SQL.AppendLine(" NaturezaOperacao , "); SQL.AppendLine(" NumeroNota , "); SQL.AppendLine(" NumeroRps , "); SQL.AppendLine(" SituacaoNf , "); SQL.AppendLine(" ChaveValidacao , "); SQL.AppendLine(" ClienteNomeRazaoSocial , "); SQL.AppendLine(" ClienteNomeFantasia , "); SQL.AppendLine(" ClienteCNPJCPF , "); SQL.AppendLine(" ClienteEndereco , "); SQL.AppendLine(" ClienteBairro , "); SQL.AppendLine(" ClienteNumeroLogradouro , "); SQL.AppendLine(" ClienteCidade , "); SQL.AppendLine(" ClienteUF , "); SQL.AppendLine(" ClientePais , "); SQL.AppendLine(" ClienteFone , "); SQL.AppendLine(" ClienteFax , "); SQL.AppendLine(" ClienteInscricaoMunicipal , "); SQL.AppendLine(" ClienteCEP , "); SQL.AppendLine(" ClienteEmail , "); SQL.AppendLine(" ClienteInscricaoEstadual , "); SQL.AppendLine(" BaseCalculo , "); SQL.AppendLine(" ISSQNCliente , "); SQL.AppendLine(" ISSQNSemRetencao , "); SQL.AppendLine(" ISSQNTotal , "); SQL.AppendLine(" Irrf , "); SQL.AppendLine(" Cofins , "); SQL.AppendLine(" Inss , "); SQL.AppendLine(" Csll , "); SQL.AppendLine(" Pis , "); SQL.AppendLine(" ValorTotalNota , "); SQL.AppendLine(" FreteCNPJ , "); SQL.AppendLine(" FreteRazaoSocial , "); SQL.AppendLine(" FreteEndereco , "); SQL.AppendLine(" FreteEmitente , "); SQL.AppendLine(" FreteDestinatario , "); SQL.AppendLine(" FreteQuantidade , "); SQL.AppendLine(" FreteEspecie , "); SQL.AppendLine(" FretePesoLiquido , "); SQL.AppendLine(" FretePesoBruto , "); SQL.AppendLine(" Serie , "); SQL.AppendLine(" SerieSimplificada , "); SQL.AppendLine(" CodigoSerie , "); SQL.AppendLine(" Observacao , "); SQL.AppendLine(" ServicoCidade , "); SQL.AppendLine(" ServicoEstado , "); SQL.AppendLine(" TimbreContribuinteLogo , "); SQL.AppendLine(" TimbreContribuinteLinha1 , "); SQL.AppendLine(" TimbreContribuinteLinha2 , "); SQL.AppendLine(" TimbreContribuinteLinha3 , "); SQL.AppendLine(" TimbreContribuinteLinha4 , "); SQL.AppendLine(" TimbrePrefeituraLogo , "); SQL.AppendLine(" TimbrePrefeituraLinha1 , "); SQL.AppendLine(" TimbrePrefeituraLinha2 , "); SQL.AppendLine(" TimbrePrefeituraLinha3 , "); SQL.AppendLine(" URLAutenticidade , "); SQL.AppendLine(" URL , "); SQL.AppendLine(" NotaFiscalPDF , "); SQL.AppendLine(" NotaFiscalXML , "); SQL.AppendLine(" Active , "); SQL.AppendLine(" DateInsert , "); SQL.AppendLine(" DateUpdate "); SQL.AppendLine(" ) "); SQL.AppendLine("Values ( " + takers.TakerId.ToString() + " , "); SQL.AppendLine(" " + companys.CompanyId.ToString() + " , "); SQL.AppendLine(" " + cFPS.CFPSId.ToString() + " , "); SQL.AppendLine(" " + (shippingCompany.ShippingCompanyId == 0 ? "Null" : shippingCompany.ShippingCompanyId.ToString()) + " , "); SQL.AppendLine(" '" + Functions.NoQuote(NFDet.Cae) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFDet.DataEmissao) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFDet.NaturezaOperacao) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFDet.NumeroNota) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFDet.NumeroRps) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFDet.SituacaoNf) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFDet.ChaveValidacao) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFDet.ClienteNomeRazaoSocial) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFDet.ClienteNomeFantasia) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFDet.ClienteCNPJCPF) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFDet.ClienteEndereco) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFDet.ClienteBairro) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFDet.ClienteNumeroLogradouro) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFDet.ClienteCidade) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFDet.ClienteUF) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFDet.ClientePais) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFDet.ClienteFone) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFDet.ClienteFax) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFDet.ClienteInscricaoMunicipal) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFDet.ClienteCEP) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFDet.ClienteEmail) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFDet.ClienteInscricaoEstadual) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFDet.BaseCalculo) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFDet.ISSQNCliente) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFDet.ISSQNSemRetencao) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFDet.ISSQNTotal) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFDet.Irrf) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFDet.Cofins) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFDet.Inss) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFDet.Csll) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFDet.Pis) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFDet.ValorTotalNota) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFDet.FreteCNPJ) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFDet.FreteRazaoSocial) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFDet.FreteEndereco) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFDet.FreteEmitente) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFDet.FreteDestinatario) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFDet.FreteQuantidade) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFDet.FreteEspecie) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFDet.FretePesoLiquido) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFDet.FretePesoBruto) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFDet.Serie) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFDet.SerieSimplificada) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFDet.CodigoSerie) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFDet.Observacao) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFDet.servicoCidade) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFDet.servicoEstado) + "' , "); SQL.AppendLine(" '' , "); SQL.AppendLine(" '' , "); SQL.AppendLine(" '' , "); SQL.AppendLine(" '' , "); SQL.AppendLine(" '' , "); SQL.AppendLine(" '' , "); SQL.AppendLine(" '' , "); SQL.AppendLine(" '' , "); SQL.AppendLine(" '' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFeSUrl.urlAutenticidade) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(NFeSUrl.urlNfd) + "' , "); SQL.AppendLine(" '" + (string.IsNullOrEmpty(PDF) ? string.Empty : Functions.NoQuote(PDF)) + "' , "); SQL.AppendLine(" '" + (string.IsNullOrEmpty(XML)? string.Empty:Functions.NoQuote(XML)) + "' , "); SQL.AppendLine(" 1 , "); SQL.AppendLine(" '" + Functions.DateTimeBr().ToString("yyyy-MM-dd HH:mm:ss") + "' , "); SQL.AppendLine(" '" + Functions.DateTimeBr().ToString("yyyy-MM-dd HH:mm:ss") + "' "); SQL.AppendLine(" )"); long Id = Functions.Conn.Insert(SQL.ToString()); if (Id > 0) { SQL = new StringBuilder(); foreach (var Fat in NFDet.FATURA) { SQL.AppendLine("Insert Into NFeSInvoices "); SQL.AppendLine(" ( NFeSId , "); SQL.AppendLine(" Numero , "); SQL.AppendLine(" Vencimento , "); SQL.AppendLine(" Valor , "); SQL.AppendLine(" Active , "); SQL.AppendLine(" DateInsert , "); SQL.AppendLine(" DateUpdate "); SQL.AppendLine(" ) "); SQL.AppendLine("Values ( " + Id + " , "); SQL.AppendLine(" '" + Functions.NoQuote(Fat.Numero) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(Fat.Vencimento) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(Fat.Valor) + "' , "); SQL.AppendLine(" 1 , "); SQL.AppendLine(" '" + Functions.DateTimeBr().ToString("yyyy-MM-dd HH:mm:ss") + "' , "); SQL.AppendLine(" '" + Functions.DateTimeBr().ToString("yyyy-MM-dd HH:mm:ss") + "' "); SQL.AppendLine(" )"); SQL.AppendLine(" "); } foreach (var Item in NFDet.ITENS) { SQL.AppendLine("Insert Into NFeSItens "); SQL.AppendLine(" ( NFeSId , "); SQL.AppendLine(" Quantidade , "); SQL.AppendLine(" CodigoAtividade , "); SQL.AppendLine(" Servico , "); SQL.AppendLine(" ValorUnitario , "); SQL.AppendLine(" ValorTotal , "); SQL.AppendLine(" ImpostoRetido , "); SQL.AppendLine(" Aliquota , "); SQL.AppendLine(" Active , "); SQL.AppendLine(" DateInsert , "); SQL.AppendLine(" DateUpdate "); SQL.AppendLine(" ) "); SQL.AppendLine("Values ( " + Id + " , "); SQL.AppendLine(" '" + Functions.NoQuote(Item.Quantidade) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(Item.CodigoAtividade) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(Item.Servico) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(Item.ValorUnitario) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(Item.ValorTotal) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(Item.ImpostoRetido) + "' , "); SQL.AppendLine(" '" + Functions.NoQuote(Item.Aliquota) + "' , "); SQL.AppendLine(" 1 , "); SQL.AppendLine(" '" + Functions.DateTimeBr().ToString("yyyy-MM-dd HH:mm:ss") + "' , "); SQL.AppendLine(" '" + Functions.DateTimeBr().ToString("yyyy-MM-dd HH:mm:ss") + "' "); SQL.AppendLine(" )"); SQL.AppendLine(" "); } if ((NFDet.FATURA.Length > 0 | NFDet.ITENS.Length > 0) & SQL.ToString().Length > 0) { Functions.Conn.Insert(SQL.ToString()); } } }catch (Exception ex) { throw ex; } }
public Takers Post(Takers takers) { try { Validate(takers); if (Functions.ExistsRegister(takers.CPF_CNPJ, TypeInput.Texto, "CPF_CNPJ", "Takers", takers.CompanyId)) { throw new InternalProgramException("Tomador já existe!"); } SQL.AppendLine(" Insert Into Takers "); SQL.AppendLine(" (CompanyId, "); SQL.AppendLine(" IM, "); SQL.AppendLine(" CPF_CNPJ, "); SQL.AppendLine(" RG_IE, "); SQL.AppendLine(" Name, "); SQL.AppendLine(" NameFantasy, "); SQL.AppendLine(" TypePerson, "); SQL.AppendLine(" CEP, "); SQL.AppendLine(" Street, "); SQL.AppendLine(" Number, "); SQL.AppendLine(" Neighborhood, "); SQL.AppendLine(" City, "); SQL.AppendLine(" State, "); SQL.AppendLine(" Telephone, "); SQL.AppendLine(" Email, "); SQL.AppendLine(" Active, "); SQL.AppendLine(" DateInsert, "); SQL.AppendLine(" DateUpdate) "); SQL.AppendLine(" Values "); SQL.AppendLine(" ( " + takers.CompanyId + ","); SQL.AppendLine(" '" + Functions.RemoveCharSpecial(Functions.NoQuote(Functions.IIf(takers.IM))) + "',"); SQL.AppendLine(" '" + Functions.RemoveCharSpecial(Functions.NoQuote(takers.CPF_CNPJ)) + "',"); SQL.AppendLine(" '" + Functions.RemoveCharSpecial(Functions.NoQuote(Functions.IIf(takers.RG_IE))) + "',"); SQL.AppendLine(" '" + Functions.NoQuote(takers.Name) + "',"); SQL.AppendLine(" '" + Functions.NoQuote(takers.NameFantasy) + "',"); SQL.AppendLine(" '" + Functions.NoQuote(takers.TypePerson) + "',"); SQL.AppendLine(" '" + Functions.RemoveCharSpecial(Functions.NoQuote(takers.CEP)) + "',"); SQL.AppendLine(" '" + Functions.NoQuote(takers.Street) + "',"); SQL.AppendLine(" '" + Functions.NoQuote(Functions.IIf(takers.Number)) + "',"); SQL.AppendLine(" '" + Functions.NoQuote(takers.Neighborhood) + "',"); SQL.AppendLine(" '" + Functions.NoQuote(takers.City) + "',"); SQL.AppendLine(" '" + Functions.NoQuote(takers.State) + "',"); SQL.AppendLine(" '" + Functions.RemoveCharSpecial(Functions.NoQuote(takers.Telephone)) + "',"); SQL.AppendLine(" '" + Functions.NoQuote(takers.Email) + "',"); SQL.AppendLine(" 1 ,"); SQL.AppendLine(" GetDate(), "); SQL.AppendLine(" GetDate() "); SQL.AppendLine(" ) "); takers.TakerId = Functions.Conn.Insert(SQL.ToString()); if (takers.TakerId > 0) { takers.Active = true; takers.DateInsert = DateTime.Now.ToString("yyyy-MM-dd"); takers.DateUpdate = DateTime.Now.ToString("yyyy-MM-dd"); return(takers); } throw new InternalProgramException("Não foi possivel cadastar o tomador!"); } catch (Exception ex) { throw ex; } }
private void Validate(Takers takers) { if (takers.CompanyId <= 0) { throw new InternalProgramException("Informe a empresa!"); } if (string.IsNullOrEmpty(takers.CPF_CNPJ)) { throw new InternalProgramException("Informe o CPF/CNPJ!"); } if (string.IsNullOrEmpty(takers.RG_IE)) { throw new InternalProgramException("Informe a inscrição estadual!"); } if (string.IsNullOrEmpty(takers.Name)) { throw new InternalProgramException("Informe o nome do tomador!"); } if (string.IsNullOrEmpty(takers.NameFantasy)) { takers.NameFantasy = takers.Name; } if (string.IsNullOrEmpty(takers.TypePerson)) { throw new InternalProgramException("Informe o tipo de pessoa do tomador!"); } if (takers.TypePerson.Length > 1) { throw new InternalProgramException("Informe o tipo de pessoa F-Fisica /J-Juridica"); } if (string.IsNullOrEmpty(takers.CEP)) { throw new InternalProgramException("Informe o CEP!"); } if (string.IsNullOrEmpty(takers.Street)) { throw new InternalProgramException("Informe a Rua!"); } if (string.IsNullOrEmpty(takers.Neighborhood)) { throw new InternalProgramException("Informe o bairro!"); } if (string.IsNullOrEmpty(takers.City)) { throw new InternalProgramException("Informe a cidade!"); } if (string.IsNullOrEmpty(takers.State)) { throw new InternalProgramException("Informe a UF!"); } if (takers.State.Length > 2) { throw new InternalProgramException("Informe uma UF válida Ex: ES!"); } if (string.IsNullOrEmpty(takers.Telephone)) { throw new InternalProgramException("Informe o Telefone!"); } if (string.IsNullOrEmpty(takers.Email)) { throw new InternalProgramException("Informe o Email!"); } }