Advertisement
Guest User

Untitled

a guest
Feb 9th, 2017
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.22 KB | None | 0 0
  1. CREATE PROCEDURE rptCheckListReport
  2.  
  3. @iCompanyId BIGINT,
  4. @szITSfromPersol VARCHAR(100),
  5. @szGroupBy varchar(10),
  6. @szGroupBy1 varchar(10),
  7. @szQuery1 VARCHAR(500),
  8. @szQuery2 VARCHAR(500),
  9. @szQuery3 VARCHAR(500),
  10. @szQuery4 VARCHAR(500),
  11. @szPicHeight VARCHAR(50),
  12. @szPicWeight VARCHAR(50)
  13.  
  14. AS
  15.  
  16. BEGIN
  17. SELECT
  18. distinct i.szDescription AS InspectionName, UPPER((Select Top 1 c.szName From Criteria c Where c.pkID = m.iCriteriaId)) AS CriteriaName,
  19. m.nInpectionScore as InspectionMasterScore,cq.szQuestion AS CriteriaQuestion, cq.nMax AS CriteriaQuestionMax,
  20. (Select Top(1) szCompanyName From ADMIN.dbo.psAdCompany) AS CompanyName
  21. FROM
  22.  
  23.  
  24. psIMLInspectionMaster m
  25. JOIN Inspection i ON m.iInspectionId = i.pkID
  26. JOIN CriteriaQuestion cq ON m.iCriteriaQuestionId = cq.pkID
  27. JOIN CriteriaQuestionGrading cqg ON m.iCriteriaQuestionGradingId = cqg.pkID
  28. WHERE dInspectionDate between '' + ltrim(rtrim(@szQuery3)) + '' and '' + ltrim(rtrim(@szQuery4)) + '' + ltrim(rtrim(@szQuery1)) + '' + ltrim(rtrim(@szQuery2))
  29. END
  30.  
  31. [HttpGet]
  32. public ActionResult CreateCheckListReport(long lngCompanyId, string szITSfromPersol, string strGroupBy,
  33. string strGroupBy1, string strQuery1, string strQuery2, string strQuery3,
  34. string strQuery4, string strPicHeight, string strPicWeight)
  35. {
  36. string Username = Convert.ToString(ConfigurationManager.AppSettings["username"]);
  37. string Password = Convert.ToString(ConfigurationManager.AppSettings["password"]);
  38. string Servername = Convert.ToString(ConfigurationManager.AppSettings["DSN2"]);
  39. string Databasename = Convert.ToString(ConfigurationManager.AppSettings["databasename"]);
  40. string type = Convert.ToString(ConfigurationManager.AppSettings["ReportType"]);
  41.  
  42. if (strGroupBy.IsEmpty()) strGroupBy = "";
  43. if (strGroupBy1.IsEmpty()) strGroupBy1 = "";
  44. if (strQuery1.IsEmpty()) strQuery1 = "";
  45. if (strQuery2.IsEmpty()) strQuery2 = "";
  46. if (strQuery3.IsEmpty()) strQuery3 = "";
  47. if (strQuery4.IsEmpty()) strQuery4 = "";
  48.  
  49. ReportDocument reportdocument = new ReportDocument();
  50. TableLogOnInfo crtablelogoninfo = new TableLogOnInfo();
  51. ConnectionInfo crConnectionInfo = new ConnectionInfo();
  52. Tables crTables;
  53. reportdocument.Load(Server.MapPath("~/Reports/rptCheckList.rpt"));
  54. crConnectionInfo.ServerName = Servername;
  55. crConnectionInfo.DatabaseName = Databasename;
  56. crConnectionInfo.UserID = Username;
  57. crConnectionInfo.Password = Password;
  58. crTables = reportdocument.Database.Tables;
  59. foreach (CrystalDecisions.CrystalReports.Engine.Table crTable in crTables)
  60. {
  61. crtablelogoninfo = crTable.LogOnInfo;
  62. crtablelogoninfo.ConnectionInfo = crConnectionInfo;
  63. crTable.ApplyLogOnInfo(crtablelogoninfo);
  64. }
  65.  
  66. reportdocument.SetParameterValue("@iCompanyId", lngCompanyId);
  67. reportdocument.SetParameterValue("@szITSfromPersol", "Persol Systems Limited.");
  68. reportdocument.SetParameterValue("@szGroupBy", strGroupBy);
  69. reportdocument.SetParameterValue("@szGroupBy1", strGroupBy1);
  70. reportdocument.SetParameterValue("@szQuery1", strQuery1); // and #tblRetOutletSumm.iDistrictID=8
  71. reportdocument.SetParameterValue("@szQuery2", strQuery2);
  72. reportdocument.SetParameterValue("@szQuery3", strQuery3);
  73. reportdocument.SetParameterValue("@szQuery4", strQuery4);
  74. reportdocument.SetParameterValue("@szPicHeight", strPicHeight);
  75. reportdocument.SetParameterValue("@szPicWeight", strPicWeight);
  76.  
  77. ReportExportType ReportExportType = Helper.Helper.GetReportExportType(type);
  78.  
  79. reportdocument.ExportToDisk(ReportExportType.FormatType, Server.MapPath("~/Reports/rptFiles/" + ReportExportType.ExportName));
  80.  
  81. MoveImageFiles();
  82.  
  83. return File(Server.MapPath("~/Reports/rptFiles/" + ReportExportType.ExportName), ReportExportType.ExportMimeType);
  84. }
  85.  
  86. ****http://localhost:59139/home/CreateCheckListReport?lngCompanyId=1&szITSfromPersol=Persol&strGroupBy=Region&strGroupBy1=Inspection&strQuery1=&strQuery2=&strQuery3=2016-10-27&strQuery4=2016-10-27&strPicHeight=1&strPicWeight=1****
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement