コード例 #1
0
 public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
 {
     RptOverallComparative rpt = new RptOverallComparative();
     rpt.Site = this.Site;
     return rpt;
 }
コード例 #2
0
        private void OVERALL_COMPARATIVE()
        {
            try
            {
                string BrandName = Request.QueryString["brandname"];
                int Previous_Year = Convert.ToDateTime(Request.QueryString["ToDate"]).Year - 1;
                int Current_Year = Convert.ToDateTime(Request.QueryString["ToDate"]).Year;
                DateTime From = Convert.ToDateTime(Request.QueryString["FromDate"]);
                DateTime To = Convert.ToDateTime(Request.QueryString["ToDate"]);

                ReportDocument rpt;
                //string rptDocCachedKey = null;
                if (Request.QueryString["rptname"] == "OverAllComParativeYearly")
                {
                //    rptDocCachedKey = "OverAllComParativeYearly";
                //    if (rptDocCachedKey != null)
                //    {
                //        rpt = (RptOverallComparative)Cache[rptDocCachedKey];
                //    }
                //    else
                //    {
                        rpt = new RptOverallComparative();
                    //    Cache.Insert(rptDocCachedKey, rpt);
                    //}
                }
                else
                {
                    //rptDocCachedKey = "OverAllComParativeYearlyperBrand";
                    //if (rptDocCachedKey != null)
                    //{
                    //    rpt = (RptOverallComparativePerBrand)Cache[rptDocCachedKey];
                    //}
                    //else
                    //{
                        rpt = new RptOverallComparativePerBrand();
                    //    Cache.Insert(rptDocCachedKey, rpt);
                    //}
                }

                SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["IRMSConnectionString"].ConnectionString);
                conn.Open();
                SqlCommand cmd = new SqlCommand();

                if (Request.QueryString["brandname"] != "")
                {
                    cmd.Connection = conn;
                    cmd.CommandTimeout = 600;
                    cmd.CommandText = "GenRptOverAllComparativePerBrand '" + Session["USER_ID"] + "', " + Previous_Year + ", " + Current_Year + ", '" + From + "','" + To + "', '" + BrandName + "'";
                    cmd.ExecuteNonQuery();
                }
                else
                {
                    cmd.Connection = conn;
                    cmd.CommandTimeout = 3000;
                    cmd.CommandText = "GenRptOverAllComparative '" + Session["USER_ID"] + "', " + Previous_Year + ", " + Current_Year + ", '" + From + "','" + To + "'";
                    cmd.ExecuteNonQuery();
                }
                DataBaseLogIn(rpt);

                ParameterField prmUserName = new ParameterField();
                ParameterField prmDateFrom = new ParameterField();
                ParameterField prmDateTo = new ParameterField();
                ParameterFields prmList = new ParameterFields();

                prmUserName.ParameterFieldName = "username";
                prmDateFrom.ParameterFieldName = "datefrom";
                prmDateTo.ParameterFieldName = "dateto";

                ParameterDiscreteValue prmUserNameValue = new ParameterDiscreteValue();
                ParameterDiscreteValue prmDateFromValue = new ParameterDiscreteValue();
                ParameterDiscreteValue prmDateToValue = new ParameterDiscreteValue();

                prmUserNameValue.Value = Session["USER_ID"];
                prmDateFromValue.Value = From;
                prmDateToValue.Value = To;

                prmUserName.CurrentValues.Add(prmUserNameValue);
                prmDateFrom.CurrentValues.Add(prmDateFromValue);
                prmDateTo.CurrentValues.Add(prmDateToValue);

                prmList.Add(prmUserName);
                prmList.Add(prmDateFrom);
                prmList.Add(prmDateTo);

                crvDailyReport.ParameterFieldInfo = prmList;
                crvDailyReport.ReportSource = rpt;
            }
            catch (Exception except)
            {
                throw new Exception(except.Message);
            }
        }