protected override void LookForNewUrl(HttpContext context, string requestedUrl) { base.LookForNewUrl(context, requestedUrl); if (IsUserLogged) { string query = context.Request.Url.Query.Replace("?", ""); using (CompanyManager manager = new CompanyManager(null)) { Company company = manager.GetCompanyByContext(Context); if (company != null) { string newUrl; // // Try the company website // string webSite = ("" + company.LegalEntityProfile.Website).ToLower().Replace("http://", "").Replace("www.", ""); if (!String.IsNullOrEmpty(webSite) && !requestedUrl.Contains(webSite.ToLower())) { newUrl = "~/infocontrol/_companies/" + webSite + "/" + requestedUrl.ToLower().Replace("infocontrol/", ""); // rewrite the path.. if (newUrl != requestedUrl && System.IO.File.Exists(Context.Server.MapPath(newUrl))) { RewritePath(newUrl, String.Empty, query); return; } } } } } }
protected void btnDelete_Click(object sender, EventArgs e) { CompanyManager cManager = new CompanyManager(this); char delimiter = new char(); delimiter = ','; //make a list of customers String[] lista = Request["chkCompany"].Split(delimiter); //delete company for (int index = 0; index < lista.Length; index++) { try { cManager.DeleteCompany(Convert.ToInt32(lista[index])); } catch (Exception ex) { ClientScript.RegisterStartupScript(this.GetType(), "errorAlert1", "alert('" + ex.Message + "');", true); ShowError("Companhia contendo registros relacionados!"); } } grdCompanies.DataBind(); }
/// <summary> /// this method returns true if the user exists in task /// </summary> /// <param name="task"></param> /// <param name="userId"></param> /// <returns></returns> public Boolean ExistUserInTask(Task task, Int32 userId) { var companyManager = new CompanyManager(this); IQueryable <User> users = GetUsersByTask(task.TaskId); return(users.Any(user => user.UserId == userId)); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (!String.IsNullOrEmpty(Request["StatementId"])) { Page.ViewState["StatementId"] = Request["StatementId"]; var companyManager = new CompanyManager(this); var statement = companyManager.GetStatement(Convert.ToInt32(Page.ViewState["StatementId"])); var l = statement.Company.LegalEntityProfile; litCustomerName.Text = l.CompanyName; litCustomerAddress.Text = l.Address.Name + " - " + l.AddressNumber + " " + l.AddressComp; litCustomerEmail.Text = l.Email; litCustomerPhone.Text = l.Phone; litPeriodBegin.Text = statement.PeriodBegin.ToShortDateString(); litPeriodEnd.Text = statement.PeriodEnd.ToShortDateString(); litBoletusNumber.Text = statement.BoletusNumber; grdStatementItems.DataSource = statement.StatementItems; grdStatementItems.DataBind(); } } }
private void ShowCompanyContract() { RefreshCredentials(); CompanyConfiguration companyConfiguration = new CompanyManager(this).GetCompanyConfiguration(Company.CompanyConfiguration.CompanyConfigurationId); txtContractAdicionalValue1Name.Text = companyConfiguration.ContractAdditionalValue1Name; txtContractAdicionalValue2Name.Text = companyConfiguration.ContractAdditionalValue2Name; txtContractAdicionalValue3Name.Text = companyConfiguration.ContractAdditionalValue3Name; txtContractAdicionalValue4Name.Text = companyConfiguration.ContractAdditionalValue4Name; txtContractAdicionalValue5Name.Text = companyConfiguration.ContractAdditionalValue5Name; }
protected void btnSave_Click(object sender, EventArgs e) { companyManager = new CompanyManager(this); companyConfigurationUpdated = new CompanyConfiguration(); companyConfigurationUpdated.CopyPropertiesFrom(Company.CompanyConfiguration); companyConfigurationUpdated.PrinterFooter = txtPrinterFooter.Text; companyManager.UpdateCompanyConfiguration(Company.CompanyConfiguration, companyConfigurationUpdated); }
private void ShowUnitPricesNames() { RefreshCredentials(); CompanyConfiguration companyConfiguration = new CompanyManager(this).GetCompanyConfiguration(Company.CompanyConfiguration.CompanyConfigurationId); txtUnitPrice1Name.Text = companyConfiguration.UnitPrice1Name; txtUnitPrice2Name.Text = companyConfiguration.UnitPrice2Name; txtUnitPrice3Name.Text = companyConfiguration.UnitPrice3Name; txtUnitPrice4Name.Text = companyConfiguration.UnitPrice4Name; txtUnitPrice5Name.Text = companyConfiguration.UnitPrice5Name; }
private void ShowReport() { RefreshCredentials(); CompanyConfiguration companyConfiguration = new CompanyManager(this).GetCompanyConfiguration(Company.CompanyConfiguration.CompanyConfigurationId); txtFooter.Value = companyConfiguration.ReportFooter; txtHeader.Value = companyConfiguration.ReportHeader; txtReportBottom.Text = companyConfiguration.ReportMargimBottom; txtReportLeft.Text = companyConfiguration.ReportMarginLeft; txtReportRight.Text = companyConfiguration.ReportMarginRight; txtReportUp.Text = companyConfiguration.ReportMarginTop; }
public override InfoControl.Web.Auditing.Event LogErrorInDatabase(Exception ex) { var eventEntity = base.LogErrorInDatabase(ex); HttpContext context = HttpContext.Current; if (context != null && context.Session != null) using (var customerManager = new CustomerManager(null)) using (var companyManager = new CompanyManager(null)) using (var membershipManager = new MembershipManager(null)) { Company hostCompany = companyManager.GetHostCompany(); Company company = companyManager.GetCompanyByContext(context); Customer customer = customerManager.GetCustomerByLegalEntityProfile(hostCompany.CompanyId, company.LegalEntityProfileId); if (customer != null) { var customerCall = new CustomerCall(); customerCall.EventId = eventEntity.EventId; customerCall.Subject = (ex.Message.Length > 100 ? ex.Message.Substring(0, 90) + " ..." : ex.Message); customerCall.CallNumber = Util.GenerateUniqueID(); customerCall.CompanyId = hostCompany.CompanyId; customerCall.CustomerId = customer.CustomerId; customerCall.OpenedDate = customerCall.ModifiedDate = DateTime.Now.Date; customerCall.Description = String.Empty; customerCall.CustomerCallTypeId = CustomerCallType.ERROR; customerCall.CustomerCallStatusId = CustomerCallStatus.New; customerCall.Rating = 5; customerCall.CallNumberAssociated = context.Request.RawUrl; customerCall.Sector = Convert.ToString(context.Session["_lastPageTitle"]); if (context.User != null) if (context.User.Identity != null) if (context.User.Identity.IsAuthenticated) { User user = membershipManager.GetUserByEmail(context.User.Identity.Name); if (user != null) customerCall.UserId = user.UserId; } customerManager.InsertCustomerCall(customerCall, null, null, null); } } return eventEntity; }
public override bool ValidateUser(string username, string password, bool checkIsOnline) { var isValidUser = base.ValidateUser(username, password, checkIsOnline); if (!isValidUser) return isValidUser; using (var companyManager = new CompanyManager(null)) { var user = companyManager.GetUserByUserName(username); return user.CompanyUsers.Any() || user.Customers.Any(); } }
protected void btnSave_Click(object sender, EventArgs e) { companyManager = new CompanyManager(this); companyConfigurationUpdated = new CompanyConfiguration(); companyConfigurationUpdated.CopyPropertiesFrom(Company.CompanyConfiguration); companyConfigurationUpdated.ContractAdditionalValue1Name = txtContractAdicionalValue1Name.Text; companyConfigurationUpdated.ContractAdditionalValue2Name = txtContractAdicionalValue2Name.Text; companyConfigurationUpdated.ContractAdditionalValue3Name = txtContractAdicionalValue3Name.Text; companyConfigurationUpdated.ContractAdditionalValue4Name = txtContractAdicionalValue4Name.Text; companyConfigurationUpdated.ContractAdditionalValue5Name = txtContractAdicionalValue5Name.Text; companyManager.UpdateCompanyConfiguration(Company.CompanyConfiguration, companyConfigurationUpdated); }
protected void btnSave_Click(object sender, EventArgs e) { companyManager = new CompanyManager(this); companyConfigurationUpdated = new CompanyConfiguration(); companyConfigurationUpdated.CopyPropertiesFrom(Company.CompanyConfiguration); companyConfigurationUpdated.UnitPrice1Name = txtUnitPrice1Name.Text; companyConfigurationUpdated.UnitPrice2Name = txtUnitPrice2Name.Text; companyConfigurationUpdated.UnitPrice3Name = txtUnitPrice3Name.Text; companyConfigurationUpdated.UnitPrice4Name = txtUnitPrice4Name.Text; companyConfigurationUpdated.UnitPrice5Name = txtUnitPrice5Name.Text; companyManager.UpdateCompanyConfiguration(Company.CompanyConfiguration, companyConfigurationUpdated); }
protected void btnSave_Click(object sender, EventArgs e) { companyConfigurationUpdated = new CompanyConfiguration(); companyManager = new CompanyManager(this); companyConfigurationUpdated.CopyPropertiesFrom(Company.CompanyConfiguration); companyConfigurationUpdated.ReportFooter = txtFooter.Value; companyConfigurationUpdated.ReportHeader = txtHeader.Value; companyConfigurationUpdated.ReportMarginTop = txtReportUp.Text; companyConfigurationUpdated.ReportMarginRight = txtReportRight.Text; companyConfigurationUpdated.ReportMarginLeft = txtReportLeft.Text; companyConfigurationUpdated.ReportMargimBottom = txtReportBottom.Text; companyManager.UpdateCompanyConfiguration(Company.CompanyConfiguration, companyConfigurationUpdated); }
protected void btnSave_Click(object sender, EventArgs e) { companyManager = new CompanyManager(this); companyConfigurationUpdated = new CompanyConfiguration(); companyConfigurationUpdated.CopyPropertiesFrom(Company.CompanyConfiguration); string file = txtImageUpload.PostedFile.FileName; string fileExtension = Path.GetExtension(file); companyConfigurationUpdated.WelcomeText = txtWelcomeText.Value; if (fileExtension.ToUpper() != ".GIF" && fileExtension.ToUpper() != ".JPG" && fileExtension.ToUpper() != ".PNG") companyConfigurationUpdated.Logo = Company.CompanyConfiguration.Logo; else companyConfigurationUpdated.Logo = resizeImage(txtImageUpload, 183, 51); companyManager.UpdateCompanyConfiguration(Company.CompanyConfiguration, companyConfigurationUpdated); }
private void ShowCompany() { var companyManager = new CompanyManager(this); var company = companyManager.GetCompany(Convert.ToInt32(Page.ViewState["CompanyId"])); txtCompanyName.Text = company.LegalEntityProfile.CompanyName; txtCompanyPlan.Text = company.Plan.Name; if (company.User != null) txtLastActivityDate.Text = company.User.LastActivityDate.ToString(); txtUserQuantity.Text = companyManager.GetCompanyUsersCount(company.CompanyId).ToString(); txtStartDate.Text = company.StartDate.ToShortDateString(); var responsableForCompany = companyManager.GetResponsableForCompany(company.CompanyId); if (responsableForCompany != null) txtEmail.Text = responsableForCompany.Email; }
protected void btnAddContractTemplate_Click(object sender, ImageClickEventArgs e) { if (String.IsNullOrEmpty(Company.LegalEntityProfile.Website)) { ShowError("A empresa não tem um site configurado! Ex: www.vivina.com.br"); return; } var modelFileName = fupDocumentTemplate.PostedFile.FileName; if (!modelFileName.EndsWith(".htm") && !modelFileName.EndsWith(".html") && !modelFileName.EndsWith(".rtf")) { ShowError("Extensão do documento inválida! Selecione documentos de extensão .htm, .html ou .rtf"); return; } companyManager = new CompanyManager(this); var documentTemplate = new DocumentTemplate { CompanyId = Company.CompanyId, FileName = fupDocumentTemplate.FileName, FileUrl = Company.GetDocumentTemplateDirectory() + fupDocumentTemplate.PostedFile.FileName, DocumentTemplateTypeId = Convert.ToInt32(cboDocumentTemplateTypes.SelectedValue) }; companyManager.InsertDocumentTemplate(documentTemplate); grdDocumentsTemplate.DataBind(); // // Save in Hard Disk // fupDocumentTemplate.SaveAs(Server.MapPath(documentTemplate.FileUrl)); }
public void GerarArquivoRemessa(Int32 companyId, Int32 accountId, DateTime beginDate, DateTime endDate, Stream stream) { var accountManager = new AccountManager(this); var companyManager = new CompanyManager(this); Company company = companyManager.GetCompany(companyId); FinancierOperation operation = accountManager.GetFinancierOperationBoleto(companyId); Boletos boletos = ConvertInvoiceParcelsInBoleto(companyId, accountId, beginDate, endDate); var exportFile = new ArquivoRemessa(TipoArquivo.CNAB400); var cedente = new Cedente(company.LegalEntityProfile.CNPJ, company.LegalEntityProfile.CompanyName, operation.Account.Agency, Convert.ToString(operation.Account.AgencyDigit), operation.Account.AccountNumber, Convert.ToString(operation.Account.AccountNumberDigit)); exportFile.GerarArquivoRemessa(String.Empty, new Banco(Convert.ToInt32(operation.Account.Bank.BankNumber)), cedente, boletos, stream, 1); }
/// <summary> /// this method returns a customer by customer LegalEntityProfileId /// </summary> /// <param name="profileId"></param> /// <returns></returns> public Customer GetHostCustomerByLegalEntityProfileId(Int32 legalEntityProfileId) { var companyManager = new CompanyManager(this); Company hostCompany = companyManager.GetHostCompany(); return GetCustomerByLegalEntityProfile(hostCompany.CompanyId, legalEntityProfileId); }
/// <summary> /// This method insert an customer and an user atached /// this method return true when customer and user inserted /// </summary> public MembershipCreateStatus Insert(Customer customer, User user) { MembershipCreateStatus status; var companyManager = new CompanyManager(this); var membershipManager = new MembershipManager(this); membershipManager.Insert(user, out status, true); // // creates an new user // if (status == MembershipCreateStatus.Success) { customer.UserId = user.UserId; customer.CreatedDate = customer.ModifiedDate = DateTime.Now; Insert(customer); return MembershipCreateStatus.Success; } return status; }
private void GenerateTaskFromCustomerFollowUp(CustomerFollowup customerFollowup, Int32 userId, DateTime appointmentDate, string appoimentSubject) { // ver se já existe tarefa associada ao followUp var taskManager = new TaskManager(this); var task = new Task(); Task originalTask; originalTask = taskManager.GetTask(customerFollowup.CustomerFollowupId, "CustomerFollowUp.aspx"); if (originalTask != null) task.CopyPropertiesFrom(originalTask); task.SubjectId = customerFollowup.CustomerFollowupId; task.PageName = "CustomerFollowUp.aspx"; task.Priority = 3; task.Name = appoimentSubject; task.StartDate = appointmentDate; DataClasses.User user = new CompanyManager(null).GetUser(customerFollowup.CompanyId, userId); var listUser = new List<DataClasses.User>(); listUser.Add(user); if (originalTask != null) taskManager.SaveTask(originalTask, task, listUser); else taskManager.SaveTask(task, null, listUser); }
public String ApplyBudgetTemplate(Budget budget, Int32 budgetDocumentTemplateId) { var addressManager = new AddressManager(this); DocumentTemplate documentTemplate = new CompanyManager(this).GetDocumentTemplate(budgetDocumentTemplateId); string template = documentTemplate == null ? GetTempBudgetTemplate() : documentTemplate.Content; bool isRtf = documentTemplate.FileName.EndsWith("rtf", StringComparison.OrdinalIgnoreCase); var stringBuilder = new StringBuilder(template); var tempStringBuilder = new StringBuilder(); if (budget.BudgetItems == null) budget = GetBudget(budget.BudgetId, budget.CompanyId); stringBuilder.Replace("[NumeroDoOrcamento]", budget.BudgetCode); stringBuilder.Replace("[DataEmissao]", budget.ModifiedDate.ToShortDateString() + (isRtf ? "<br />".ToRtf() : "<br />")); //header with informations of current date string header = budget.Company.LegalEntityProfile.Address.State + " , " + DateTime.Now.ToLongDateString().Split(',').ElementAt(1); stringBuilder.Replace("[Cabecalho]", header); #region CompanyInformations stringBuilder.Replace("[NomeDaEmpresa]", budget.Company.LegalEntityProfile.CompanyName); stringBuilder.Replace("[TelefoneDaEmpresa]", budget.Company.LegalEntityProfile.Phone); stringBuilder.Replace("[Endereco-Empresa]", budget.Company.LegalEntityProfile.Address.Name.ToCapitalize()); stringBuilder.Replace("[Endereco-Complemento-Empresa]", String.Empty); if (!String.IsNullOrEmpty(budget.Company.LegalEntityProfile.AddressComp)) stringBuilder.Replace("[Endereco-Complemento-Empresa]", budget.Company.LegalEntityProfile.AddressComp.ToCapitalize()); stringBuilder.Replace("[Endereco-Numero-Empresa]", budget.Company.LegalEntityProfile.AddressNumber); stringBuilder.Replace("[Endereco-Cep-Empresa]", budget.Company.LegalEntityProfile.PostalCode); stringBuilder.Replace("[Endereco-Cidade-Empresa]", budget.Company.LegalEntityProfile.Address.City.ToCapitalize()); stringBuilder.Replace("[Endereco-Estado-Empresa]", addressManager.GetAcronymState(budget.Company.LegalEntityProfile.Address.State)); stringBuilder.Replace("[Endereco-Bairro-Empresa]", budget.Company.LegalEntityProfile.Address.Neighborhood.ToCapitalize()); #endregion //Customer if (budget.CustomerId.HasValue || !String.IsNullOrEmpty(budget.CustomerName)) { #region Customer Data stringBuilder.Replace("[NomeDoCliente]", String.IsNullOrEmpty(budget.CustomerName) ? budget.Customer.Name : budget.CustomerName); stringBuilder.Replace("[EmailDoClente]", budget.Customer != null ? budget.Customer.Email : budget.CustomerMail); stringBuilder.Replace("[TelefoneDoCliente]", String.IsNullOrEmpty(budget.CustomerPhone) ? budget.Customer.Phone : budget.CustomerPhone); #endregion if (budget.Customer != null) { #region Customer Address if (budget.Customer.Address != null) { stringBuilder.Replace("[EnderecoDoCliente]", String.Empty); if (!String.IsNullOrEmpty(budget.Customer.Address.Name)) stringBuilder.Replace("[EnderecoDoCliente]", budget.Customer.Address.Name.ToCapitalize()); stringBuilder.Replace("[Endereco-Complemento]", String.Empty); if (!String.IsNullOrEmpty(budget.Customer.AddressComp)) stringBuilder.Replace("[Endereco-Complemento]", budget.Customer.AddressComp.ToCapitalize()); stringBuilder.Replace("[Endereco-Bairro]", String.Empty); if (!String.IsNullOrEmpty(budget.Customer.Address.Neighborhood)) stringBuilder.Replace("[Endereco-Bairro]", budget.Customer.Address.Neighborhood.ToCapitalize()); stringBuilder.Replace("[Endereco-Cidade]", String.Empty); if (!String.IsNullOrEmpty(budget.Customer.Address.City)) stringBuilder.Replace("[Endereco-Cidade]", budget.Customer.Address.City.ToCapitalize()); stringBuilder.Replace("[Endereco-Numero]", String.Empty); if (!String.IsNullOrEmpty(budget.Customer.AddressNumber)) stringBuilder.Replace("[Endereco-Numero]", budget.Customer.AddressNumber); stringBuilder.Replace("[Endereco-Cep]", String.Empty); if (!String.IsNullOrEmpty(budget.Customer.Address.PostalCode)) stringBuilder.Replace("[Endereco-Cep]", budget.Customer.Address.PostalCode); stringBuilder.Replace("[Endereco-Estado]", addressManager.GetAcronymState(budget.Company.LegalEntityProfile.Address.State)); } #endregion string phone2 = "", phone3 = ""; if (budget.Customer.LegalEntityProfile != null) { phone2 = budget.Customer.LegalEntityProfile.Phone2; phone3 = budget.Customer.LegalEntityProfile.Phone3; } stringBuilder.Replace("[Telefone2]", phone2); stringBuilder.Replace("[Telefone3]", phone3); stringBuilder.Replace("[CNPJ]", budget.Customer.LegalEntityProfile != null ? "CNPJ: " + budget.Customer.LegalEntityProfile.CNPJ : String.Empty); stringBuilder.Replace("[CPF]", budget.Customer.Profile != null ? "CPF: " + budget.Customer.Profile.CPF : String.Empty); stringBuilder.Replace("[IE]", budget.Customer.LegalEntityProfile != null ? "IE: " + budget.Customer.LegalEntityProfile.IE : String.Empty); stringBuilder.Replace("[RG]", budget.Customer.Profile != null ? "RG: " + budget.Customer.Profile.RG : String.Empty); } else { stringBuilder.Replace("[EnderecoDoCliente]", String.Empty); stringBuilder.Replace("[Endereco-Complemento]", String.Empty); stringBuilder.Replace("[Endereco-Numero]", String.Empty); stringBuilder.Replace("[Endereco-Cep]", String.Empty); stringBuilder.Replace("[Endereco-Cidade]", String.Empty); stringBuilder.Replace("[Endereco-Estado]", String.Empty); stringBuilder.Replace("[Telefone2]", String.Empty); stringBuilder.Replace("[Telefone3]", String.Empty); } } #region BudgetItems tempStringBuilder = new StringBuilder(); //Header //Body Int32 itemCount = 0; Decimal totalValue = Decimal.Zero; foreach (BudgetItem item in GetBudgetItemByBudget(budget.BudgetId, budget.CompanyId)) { itemCount++; string itemName = item.SpecialProductName; tempStringBuilder.AppendFormat(@" <fieldset> <table> <tr> <td style='white-space:nowrap; width:1%;' width='1%'>Código:</td> <td class='code' colspan='2'>{0}</td> </tr> <tr> <td style='white-space:nowrap'>Qtd:</td> <td class='qtd' colspan='2'>{1}</td> </tr> <tr> <td style='white-space:nowrap'>Desc:</td> <td class='description' colspan='2'>{2}</td> </tr> <tr> <td style='white-space:nowrap'>Vlr Unit:</td> <td>{3}</td> <td style='text-align:right'>Valor: {4}</td> </tr> </table> </fieldset>", item.ProductCode + " | " + itemName, item.Quantity, item.ProductDescription, item.UnitPrice.Value.ToString("c"), (item.Quantity * item.UnitPrice.Value).ToString("c")); totalValue += (item.Quantity * item.UnitPrice.Value); } // Subtotal tempStringBuilder.AppendFormat(@"<table width='100%'><tr> <td style='white-space:nowrap'><b>Subtotal (R$): </b></td> <td style='white-space:nowrap; text-align:right'>{0}<td> </tr>", totalValue); // AdditionalCost if (budget.AdditionalCost.HasValue) { tempStringBuilder.AppendFormat(@"<tr> <td style='white-space:nowrap'><b>Adicional (R$): </b></td> <td style='white-space:nowrap; text-align:right'>{0}<td> </tr>", budget.AdditionalCost.Value.ToString("c")); totalValue += budget.AdditionalCost.Value; } // Discount if (budget.Discount.HasValue) { tempStringBuilder.AppendFormat(@"<tr> <td style='white-space:nowrap'><b>Desconto (R$): </b></td> <td style='white-space:nowrap; text-align:right'>{0}<td> </tr>", budget.Discount.Value.ToString("c")); totalValue -= budget.Discount.Value; } //Footer tempStringBuilder.AppendFormat(@"<tr> <td style='white-space:nowrap'><b>Valor Total da Proposta (R$): </b></td> <td style='white-space:nowrap; text-align:right'> <b>{0}<b></td> </tr> <tr> <td style='white-space:nowrap; text-align:center' colspan='2'><b>({1})<b></td> </tr> </table>", totalValue.ToString("c"), totalValue.AtFull().ToUpper()); stringBuilder.Replace("[Items]", isRtf ? tempStringBuilder.ToString().ToRtf() : tempStringBuilder.ToString()); stringBuilder.Replace("[TotalDaProposta]", totalValue.ToString()); stringBuilder.Replace("[ValorTotalPorExtenso]", totalValue.AtFull().ToUpper()); #endregion #region Others stringBuilder.Replace("[Contato]", budget.ContactName); stringBuilder.Replace("[DataEntrega]", budget.DeliveryDate); stringBuilder.Replace("[Garantia]", budget.Warranty); stringBuilder.Replace("[Validade]", budget.ExpirationDate.ToString()); stringBuilder.Replace("[FormaPagamento]", budget.PaymentMethod); stringBuilder.Replace("[Observacao]", budget.Observation); stringBuilder.Replace("[Vendedor]", budget.Employee.Profile.AbreviatedName); stringBuilder.Replace("[EmailVendedor]", budget.Employee.Profile.Email); stringBuilder.Replace("[FormaEntrega]", budget.DeliveryDescription); stringBuilder.Replace("[Pintura/Tratamento]", budget.Treatment); #endregion return stringBuilder.ToString(); }
/// <summary> /// This method replaces the keywords to informations of specified invoice /// </summary> /// <param name="invoice"></param> /// <param name="parcelId"></param> /// <param name="documentTemplateId"></param> /// <returns>The string with keywords replaced to invoice informations</returns> public String ApplyInvoiceTemplate(Invoice invoice, Int32 parcelId, Int32 documentTemplateId) { var documentTemplate = new CompanyManager(this).GetDocumentTemplate(documentTemplateId); var content = new StringBuilder(documentTemplate.Content); // // Invoice // content.Replace("[Descrição]", invoice.Description); content.Replace("[DataDeCadastro]", invoice.EntryDate.ToString()); content.Replace("[NomeDoCliente]", invoice.Customer.Name); content.Replace("[CentroDeCusto]", invoice.CostCenter.Name); content.Replace("[PlanoDeContas]", invoice.AccountingPlan.Name); // // Parcel // var parcel = new ParcelsManager(this).GetParcel(parcelId, invoice.CompanyId); content.Replace("[Vencimento]", parcel.DueDate.ToString()); content.Replace("[ValorDaParcela]", parcel.Amount.ToString()); content.Replace("[FormaDePagamento]", parcel.PaymentMethod.Name); content.Replace("[DescriçaoDaParcela]", parcel.Description); if (parcel.EffectedDate.HasValue) content.Replace("[DataDoPagamento]", parcel.EffectedDate.ToString()); else content.Replace("[DataDoPagamento]", String.Empty); if (parcel.EffectedAmount.HasValue) content.Replace("[ValorPago]", parcel.EffectedAmount.ToString()); else content.Replace("[ValorPago]", String.Empty); if (!String.IsNullOrEmpty(parcel.IdentificationNumber)) content.Replace("[Identificação]", parcel.IdentificationNumber); else content.Replace("[Identificação]", String.Empty); if (parcel.AccountId.HasValue) content.Replace("[Conta]", parcel.Account.Bank.ShortName + " - " + parcel.Account.AccountNumber); else content.Replace("[Conta]", String.Empty); return content.ToString(); }
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; }
public ClientResponse FindUser(string q, int limit) { return new ClientResponse(() => { using (var companyManager = new CompanyManager(null)) return companyManager.SearchUser(Company.CompanyId, q, limit).ToArray(); }); }