protected void Print(Invoice newInvoice,  DataClasses1DataContext dbContext)
 {
     using (MemoryStream memS = new MemoryStream())
     {
         InvoiceHelper.CreateAccounts(dbContext, newInvoice);
         newInvoice.Print(dbContext, memS, "");
         dbContext.SubmitChanges();
         string fileName = "Rechnung_" +newInvoice.InvoiceNumber.Number+ "_"+ newInvoice.CreateDate.Day + "_" + newInvoice.CreateDate.Month + "_" + newInvoice.CreateDate.Year + ".pdf";
         string serverPath = ConfigurationManager.AppSettings["DataPath"] + "\\UserData";
         if (!Directory.Exists(serverPath)) Directory.CreateDirectory(serverPath);
         if (!Directory.Exists(serverPath + "\\" + Session["CurrentUserId"].ToString())) Directory.CreateDirectory(serverPath + "\\" + Session["CurrentUserId"].ToString());
         serverPath = serverPath + "\\" + Session["CurrentUserId"].ToString();
         File.WriteAllBytes(serverPath + "\\" + fileName, memS.ToArray());
         OpenPrintfile(fileName);
         dbContext.SubmitChanges();
     }
 }
Пример #2
0
 protected void Print(Invoice newInvoice, DataClasses1DataContext dbContext)
 {
     using (MemoryStream memS = new MemoryStream())
     {
         string serverPath = ConfigurationManager.AppSettings["DataPath"] + "\\UserData";
         InvoiceHelper.CreateAccounts(dbContext, newInvoice);
         newInvoice.Print(dbContext, memS, "");
         string fileName = "Rechnung_" + newInvoice.InvoiceNumber.Number + "_" + newInvoice.CreateDate.Day + "_" + newInvoice.CreateDate.Month + "_" + newInvoice.CreateDate.Year + ".pdf";
         if (!Directory.Exists(serverPath)) Directory.CreateDirectory(serverPath);
         if (!Directory.Exists(serverPath + "\\" + Session["CurrentUserId"].ToString())) Directory.CreateDirectory(serverPath + "\\" + Session["CurrentUserId"].ToString());
         serverPath = serverPath + "\\" + Session["CurrentUserId"].ToString();
         File.WriteAllBytes(serverPath + "\\" + fileName, memS.ToArray());
         string url = ConfigurationManager.AppSettings["BaseUrl"];
         string path = url + "UserData/" + Session["CurrentUserId"].ToString() + "/" + fileName;
         ScriptManager.RegisterStartupScript(this, this.GetType(), "Invoice", "<script>openFile('" + path + "');</script>", false);
         dbContext.SubmitChanges();
     }
 }