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 InsertDocumentTemplate(DocumentTemplate documentTemplate)
 {
     DbContext.DocumentTemplates.InsertOnSubmit(documentTemplate);
     DbContext.SubmitChanges();
 }
 public DocumentBuilder(DocumentTemplate template)
 {
     this.template = template;
 }
    private void ExportDocumentTemplate(Budget budget, string fileName, DocumentTemplate documentTemplate)
    {

        //
        // Clean buffers of response to not send headers of APSX pages
        // 
        Response.Clear();
        Response.ContentType = "text/doc";
        //
        // Sets the header that tells to browser to download not show in the screen
        // 
        Response.AddHeader("content-disposition", "attachment;filename=" + fileName + ".doc");
        //
        // Indicate that file format will be the same model
        // 
        Response.ContentEncoding = System.Text.Encoding.Default;

        //
        // Apply the changes from model, changing []'s for the content
        // 
        Response.Write(saleManager.ApplyBudgetTemplate(budget, documentTemplate.DocumentTemplateId));

        //
        // Cut the page process to not merge the model content to the page HTML
        // 
        Response.End();
    }