Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class PrintService : IPrintService
- {
- readonly ReportDocument _reportDocument = new ReportDocument();
- private readonly string _reportPath = ConfigurationManager.AppSettings["ReportPath"];
- private readonly string _reportUser = ConfigurationManager.AppSettings["ReportUser"];
- private readonly string _reportPassword = ConfigurationManager.AppSettings["ReportPassword"];
- private readonly string _reportServer = ConfigurationManager.AppSettings["ReportServer"];
- private readonly string _reportDatabase = ConfigurationManager.AppSettings["ReportDatabase"];
- private readonly string _spbuNumber = ConfigurationManager.AppSettings["SPBUNumber"];
- private readonly string _spbuAddress = ConfigurationManager.AppSettings["SPBUAddress"];
- private readonly string _spbuPhone = ConfigurationManager.AppSettings["SPBUPhone"];
- public void Print(string number, string reportName)
- {
- var path = _reportPath + reportName;
- _reportDocument.Load(path);
- _reportDocument.SetDatabaseLogon(_reportUser, _reportPassword, _reportServer, _reportDatabase);
- _reportDocument.SetParameterValue("@Number", number);
- _reportDocument.SetParameterValue("@Location", _spbuNumber );
- _reportDocument.SetParameterValue("@Address", _spbuAddress);
- _reportDocument.SetParameterValue("@Phone", _spbuPhone);
- var print = new PrintDocument();
- _reportDocument.PrintOptions.PrinterName = print.PrinterSettings.PrinterName;
- _reportDocument.PrintOptions.PaperSize = (PaperSize) print.PrinterSettings.DefaultPageSettings.PaperSize.RawKind;
- _reportDocument.PrintToPrinter(1, false, 1, 1);
- }
- }
- ReportDocument doc = new ReportDocument();
- String CS = (String)ConfigurationManager.ConnectionStrings[csName].ConnectionString;
- doc.Load(prerap);
- String DS = CS.Substring(12 + CS.IndexOf("data source"), CS.IndexOf("SQLEXPRESS") - CS.IndexOf("data source") - 2);
- if (doc.DataSourceConnections[0].ServerName != DS)
- {
- for(int i=0;i<doc.DataSourceConnections.Count;i++)
- {
- doc.DataSourceConnections[i].SetConnection(DS, dbName, true);
- }
- doc.SaveAs(prerap);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement