private Vivina.Erp.DataClasses.Address LoadPostalCode(string postalCode) { Vivina.Erp.DataClasses.Address address = null; if (!String.IsNullOrEmpty(postalCode)) { var manager = new AddressManager(this); address = manager.GetAddress(postalCode.Replace("-", "")); if (address != null) { txtNeighborhood.Text = address.Neighborhood; txtCity.Text = address.City; txtAddress.Text = address.Name; cboStates.SelectedValue = address.StateId; ViewState["NeighborhoodId"] = address.NeighborhoodId; ViewState["CityId"] = address.CityId; ViewState["StateId"] = address.StateId; ViewState["addressExists"] = true; } } else { ViewState["addressExists"] = false; txtNeighborhood.Text = String.Empty; txtCity.Text = String.Empty; txtAddress.Text = String.Empty; txtNumber.Text = String.Empty; cboStates.ClearSelection(); } EnableValidators(true); return(address); }
private Boletos ConvertInvoiceParcelsInBoleto(Int32 companyId, Int32 accountId, DateTime beginDate, DateTime endDate) { var customerManager = new CustomerManager(this); var profileManager = new ProfileManager(this); var companyManager = new CompanyManager(this); var accountManager = new AccountManager(this); Boleto boleto; Sacado sacado; Endereco endereco; var address = new Address(); Company company = companyManager.GetCompany(companyId); Account account = accountManager.GetAccount(accountId, companyId); var boletos = new Boletos(); var cedente = new Cedente(company.LegalEntityProfile.CNPJ, company.LegalEntityProfile.CompanyName, account.Agency, Convert.ToString(account.AgencyDigit), account.AccountNumber, Convert.ToString(account.AccountNumberDigit)); foreach (Parcel parcel in GetOpenInvoiceParcelInPeriodByAccount(companyId, accountId, beginDate, endDate)) { endereco = new Endereco(); if (parcel.Invoice.Customer.LegalEntityProfileId.HasValue) { //Address address = parcel.Invoice.Customer.LegalEntityProfile.Address; endereco.Numero = parcel.Invoice.Customer.LegalEntityProfile.AddressNumber; endereco.Complemento = parcel.Invoice.Customer.LegalEntityProfile.AddressComp; //sacado sacado = new Sacado(parcel.Invoice.Customer.LegalEntityProfile.CNPJ, parcel.Invoice.Customer.LegalEntityProfile.CompanyName); } else { //Address address = parcel.Invoice.Customer.Profile.Address; endereco.Numero = parcel.Invoice.Customer.Profile.AddressNumber; endereco.Complemento = parcel.Invoice.Customer.Profile.AddressComp; //sacado sacado = new Sacado(parcel.Invoice.Customer.Profile.CPF, parcel.Invoice.Customer.Profile.Name); } //Address endereco.Bairro = address.Neighborhood; endereco.CEP = address.PostalCode; endereco.Cidade = address.City ?? String.Empty; endereco.Logradouro = address.Name; endereco.UF = address.State; //boleto boleto = new Boleto(parcel.DueDate, Convert.ToDouble(parcel.Amount), String.Empty, String.Empty, cedente); sacado.Endereco = endereco; boleto.Sacado = sacado; var instrucao = new Instrucao(Convert.ToInt32(account.Bank.BankNumber)); var banco = new Banco(Convert.ToInt32(account.Bank.BankNumber)); instrucao.Banco = banco; instrucao.QuantidadeDias = 0; instrucao.Descricao = String.Empty; instrucao.Codigo = 0; boleto.CodigoBarra.LinhaDigitavel = String.Empty; boleto.DataDocumento = DateTime.Now; boleto.DataVencimento = parcel.DueDate; boleto.ValorDesconto = 0; boleto.Instrucoes = new List<IInstrucao>(); boleto.Instrucoes.Add(instrucao); boletos.Add(boleto); } return boletos; }