Example #1
0
        protected void btnShowReport_Click(object sender, EventArgs e)
        {
            if (!sec.UserRight("2585", "006"))
            {
                Response.Redirect("~/Test.aspx");
            }
            SqlDataReader  rder;
            ReportDocument RD = new ReportDocument();
            DataTable      dt = new DataTable();
            DateTime       FromDate;
            DateTime       ToDate;

            if (dtFrom.Text == "" || dtTo.Text == "")
            {
                lblMSG.Text = "Please select dates";
                return;
            }
            string FDate = myFunc.SaveDate(dtFrom.Text).ToString();
            string TDate = myFunc.SaveDate(dtTo.Text).ToString();

            FromDate = Convert.ToDateTime(FDate);
            ToDate   = Convert.ToDateTime(TDate);
            DXBMS.Data.DataSet1 objDsReports = new Data.DataSet1();
            if (rbStatus.SelectedItem.Text == "GST")
            {
                SqlParameter[] param =
                {
                    new SqlParameter("@DealerCode", SqlDbType.Char, 5),           //0
                    new SqlParameter("@FromDate",   SqlDbType.DateTime),          //0
                    new SqlParameter("@ToDate",     SqlDbType.DateTime),          //0
                };
                param[0].Value = Session["DealerCode"].ToString();
                param[1].Value = FromDate.ToString("yyyy-MM-dd");
                param[2].Value = ToDate.ToString("yyyy-MM-dd");
                string sql = "exec SP__Get_rptGSTDetailReport '" + Session["DealerCode"].ToString() + "','" + FromDate.ToString("yyyy-MM-dd") + "','" + ToDate.ToString("yyyy-MM-dd") + "'";
                dt = myFunc.GetData(sql);
                RD.PrintOptions.PaperSize = PaperSize.PaperA4;
                RD.Load(Server.MapPath("../GSTDetailReport.rpt"));
            }
            else if (rbStatus.SelectedItem.Text == "Combine")
            {
                SqlParameter[] param =
                {
                    new SqlParameter("@DealerCode", SqlDbType.Char, 5),           //0
                    new SqlParameter("@FromDate",   SqlDbType.DateTime),          //0
                    new SqlParameter("@ToDate",     SqlDbType.DateTime),          //0
                };
                param[0].Value = Session["DealerCode"].ToString();
                param[1].Value = FromDate.ToString("yyyy-MM-dd");
                param[2].Value = ToDate.ToString("yyyy-MM-dd");
                string sql = "exec SP__Get_rptComDetailReport '" + Session["DealerCode"].ToString() + "','" + FromDate.ToString("yyyy-MM-dd") + "','" + ToDate.ToString("yyyy-MM-dd") + "'";
                dt = myFunc.GetData(sql);
                RD.PrintOptions.PaperSize = PaperSize.PaperA4;
                RD.Load(Server.MapPath("../ConbineTaxDetail.rpt"));
            }
            else
            {
                SqlParameter[] param =
                {
                    new SqlParameter("@DealerCode", SqlDbType.Char, 5),           //0
                    new SqlParameter("@FromDate",   SqlDbType.DateTime),          //0
                    new SqlParameter("@ToDate",     SqlDbType.DateTime),          //0
                };
                param[0].Value = Session["DealerCode"].ToString();
                param[1].Value = FromDate.ToString("yyyy-MM-dd");
                param[2].Value = ToDate.ToString("yyyy-MM-dd");

                string sql = "exec SP__Get_rptPSTDetailReport '" + Session["DealerCode"].ToString() + "','" + FromDate.ToString("yyyy-MM-dd") + "','" + ToDate.ToString("yyyy-MM-dd") + "'";
                dt = myFunc.GetData(sql);
                RD.PrintOptions.PaperSize = PaperSize.PaperA4;

                RD.Load(Server.MapPath("../PSTDetailReport.rpt"));
            }
            RD.DataDefinition.FormulaFields["DealerDesc"].Text    = "'" + Session["DealerDesc"].ToString() + "'";
            RD.DataDefinition.FormulaFields["DealerAddress"].Text = "'" + Session["DealerAddress"].ToString() + "'";
            RD.DataDefinition.FormulaFields["DealerPhone"].Text   = "'" + Session["DealerPhone"].ToString() + "'";
            RD.DataDefinition.FormulaFields["DealerEmail"].Text   = "'" + Session["DealerEmail"].ToString() + "'";
            RD.DataDefinition.FormulaFields["DealerFax"].Text     = "'" + Session["DealerFax"].ToString() + "'";
            RD.DataDefinition.FormulaFields["NTN"].Text           = "'N.T.N # " + Session["DealerNTN"].ToString() + "'";
            RD.DataDefinition.FormulaFields["SalesTaxNo"].Text    = "'Sales Tax No.  " + Session["DealerSaleTaxNo"].ToString() + " '";
            RD.DataDefinition.FormulaFields["CompanyName"].Text   = "'" + Session["DealerDesc"].ToString() + "'";
            RD.DataDefinition.FormulaFields["UserID"].Text        = "'" + Session["UserID"].ToString() + "'";
            RD.DataDefinition.FormulaFields["FromCode"].Text      = "'" + FDate + "'";
            RD.DataDefinition.FormulaFields["ToCode"].Text        = "'" + TDate + "'";
            RD.DataDefinition.FormulaFields["Terminal"].Text      = "'" + Environment.MachineName + "'";
            if (rbStatus.SelectedItem.Text == "PST")
            {
                RD.DataDefinition.FormulaFields["ReportTitle"].Text = "\"" + "PST Collection" + "\"";
            }
            else if (rbStatus.SelectedItem.Text == "Combine")
            {
                RD.DataDefinition.FormulaFields["ReportTitle"].Text = "\"" + "Combine Tax Collection" + "\"";
            }

            else
            {
                RD.DataDefinition.FormulaFields["ReportTitle"].Text = "\"" + "GST Collection" + "\"";
            }
            RD.DataDefinition.FormulaFields["CompanyName"].Text = "'" + Session["DealerDesc"].ToString() + "'";
            RD.DataDefinition.FormulaFields["Pic"].Text         = "'" + Server.MapPath("~") + Session["Logo"] + "'";
            RD.SetDataSource(dt);
            //      Session["RD"]=RD;
            //// convert and show
            string FilePath = Server.MapPath("~") + "\\Download\\";
            string FileName = "Report.pdf";
            string File     = FilePath + FileName;


            Session["RD"] = RD;

            string URL;

            URL = "../../../../Download/OpenPdf.aspx?ReportID=" + FileName;
            string fullURL = "window.open('" + URL + "', '_blank', 'height=800,width=1000,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,titlebar=no');";

            ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", fullURL, true);



            //string FilePath = Server.MapPath("~") + "\\Download\\";
            //string FileName = "Report.pdf";
            //string File = FilePath + FileName;

            //PdfDocument outputDocument = new PdfDocument();
            //Stream stream = RD.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
            //stream.Seek(0, SeekOrigin.Begin);
            //DirectoryInfo info = new DirectoryInfo(FilePath);
            //if (!info.Exists)
            //{
            //    info.Create();
            //}

            //string path = Path.Combine(FilePath, FileName);
            //using (FileStream outputFileStream = new FileStream(path, FileMode.Create))
            //{
            //    stream.CopyTo(outputFileStream);
            //}
            //stream.Dispose(); stream.Close();
            //string URL = "../../../../Download/PrintReport.aspx";

            //string fullURL = "window.open('" + URL + "', '_blank', 'height=800,width=1000,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,titlebar=no');";

            //ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", fullURL, true);
        }
        protected void btnShowReport_Click(object sender, EventArgs e)
        {
            if (!sec.UserRight("2564", "006"))
            {
                Response.Redirect("~/Test.aspx");
            }
            if (dtFrom.Text == "" || dtTo.Text == "")
            {
                lblMSG.Text = "Please select dates";
                return;
            }
            SqlDataReader  rder;
            ReportDocument RD = new ReportDocument();
            DateTime       FromDate;
            DateTime       ToDate;

            string FDate = myFunc.SaveDate(dtFrom.Text).ToString();
            string TDate = myFunc.SaveDate(dtTo.Text).ToString();

            FromDate = Convert.ToDateTime(FDate);
            ToDate   = Convert.ToDateTime(TDate);

            //ReportDocument RD = new ReportDocument();
            //DataSet dsRpt = new DataSet();
            DXBMS.Data.DataSet1 objDsReports = new Data.DataSet1();



            SqlParameter[] param =
            {
                new SqlParameter("@DealerCode", SqlDbType.Char, 5),               //0
                new SqlParameter("@FromDate",   SqlDbType.DateTime),              //0
                new SqlParameter("@ToDate",     SqlDbType.DateTime),              //0
                new SqlParameter("@Status",     SqlDbType.VarChar, 10),           //0
                new SqlParameter("@EmpCode",    SqlDbType.Char, 06)               //0
            };
            param[0].Value = Session["DealerCode"].ToString();
            param[1].Value = FromDate.ToString("yyyy-MM-dd");
            param[2].Value = ToDate.ToString("yyyy-MM-dd");
            param[3].Value = rbStatus.SelectedItem.Value.ToString();
            param[4].Value = ddlAdvisorCode.SelectedValue;


            DataTable dt  = new DataTable();
            string    sql = "exec sp_JobCardDetailReport '" + Session["DealerCode"].ToString() + "','" + FromDate.ToString("yyyy-MM-dd") + "','" + ToDate.ToString("yyyy-MM-dd") + "','" + rbStatus.SelectedItem.Value.ToString() + "','" + ddlAdvisorCode.SelectedValue + "'";

            dt = myFunc.GetData(sql);
            RD.Load(Server.MapPath("../rptJobCardDateWise.rpt"));
            RD.OpenSubreport(Server.MapPath("../JobCardSummary.rpt"));

            RD.DataDefinition.FormulaFields["DealerDesc"].Text    = "'" + Session["DealerDesc"].ToString() + "'";
            RD.DataDefinition.FormulaFields["DealerAddress"].Text = "'" + Session["DealerAddress"].ToString() + "'";
            RD.DataDefinition.FormulaFields["DealerPhone"].Text   = "'" + Session["DealerPhone"].ToString() + "'";
            RD.DataDefinition.FormulaFields["DealerEmail"].Text   = "'" + Session["DealerEmail"].ToString() + "'";
            RD.DataDefinition.FormulaFields["DealerFax"].Text     = "'" + Session["DealerFax"].ToString() + "'";
            RD.DataDefinition.FormulaFields["NTN"].Text           = "'N.T.N # " + Session["DealerNTN"].ToString() + "'";
            RD.DataDefinition.FormulaFields["SalesTaxNo"].Text    = "'Sales Tax No.  " + Session["DealerSaleTaxNo"].ToString() + " '";
            RD.DataDefinition.FormulaFields["CompanyName"].Text   = "'" + Session["DealerDesc"].ToString() + "'";
            RD.DataDefinition.FormulaFields["UserID"].Text        = "'" + Session["UserID"].ToString() + "'";
            RD.DataDefinition.FormulaFields["FromCode"].Text      = "'" + FDate + "'";
            RD.DataDefinition.FormulaFields["ToCode"].Text        = "'" + TDate + "'";
            RD.DataDefinition.FormulaFields["Terminal"].Text      = "'" + Environment.MachineName + "'";
            RD.DataDefinition.FormulaFields["ReportTitle"].Text   = "\"" + "Jobcard Detail Report" + "\"";
            RD.DataDefinition.FormulaFields["CompanyName"].Text   = "'" + Session["DealerDesc"].ToString() + "'";
            //RD.DataDefinition.FormulaFields["DealershipName"].Text = "'Authorised " + Session["ParentDesc"].ToString() + " Dealership'";
            //RD.Database.Tables[0].SetDataSource(objDsReports);
            //RD.DataDefinition.FormulaFields["Pic"].Text = "'C:\\Users\\u_ahm\\OneDrive\\Documents\\Visual Studio 2010\\Projects\\WebApplication1\\WebApplication1\\" + Session["Logo"] + "'";
            RD.DataDefinition.FormulaFields["Pic"].Text = "'" + Server.MapPath("~") + Session["Logo"] + "'";
            RD.SetDataSource(dt);
            string FilePath = Server.MapPath("~") + "\\Download\\";
            string FileName = "Report.pdf";
            string File     = FilePath + FileName;

            PdfDocument outputDocument = new PdfDocument();
            Stream      stream         = RD.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

            stream.Seek(0, SeekOrigin.Begin);
            DirectoryInfo info = new DirectoryInfo(FilePath);

            if (!info.Exists)
            {
                info.Create();
            }

            string path = Path.Combine(FilePath, FileName);

            using (FileStream outputFileStream = new FileStream(path, FileMode.Create))
            {
                stream.CopyTo(outputFileStream);
            }
            stream.Dispose(); stream.Close();
            string URL = "../../../../Download/PrintReport.aspx";

            string fullURL = "window.open('" + URL + "', '_blank', 'height=800,width=1000,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,titlebar=no');";

            ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", fullURL, true);


            //string FilePath = Server.MapPath("~") + "\\Download\\";
            //string FileName = "JobCardDetail" + this.Session["DealerCode"].ToString() + DateTime.Now.ToString("ddMMyyyy") + ".pdf";
            //string File = FilePath + FileName;

            //Session["RD"] = RD;



            //string URL = "../../../../Download/rptViewerService.aspx?ReportID="+ FileName;
            //string fullURL = "window.open('" + URL + "', '_blank', 'height=800,width=1500,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,titlebar=no');";
            //ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", fullURL, true);
        }
        protected void BtnHistory_Click(object sender, EventArgs e)
        {
            if (!sec.UserRight("2565", "006"))
            {
                Response.Redirect("~/Test.aspx");
            }
            if (ddlRegNo.SelectedIndex == 0 || ddlEngineNo.SelectedIndex == 0 || ddlChassisNo.SelectedIndex == 0)
            {
                lblMSG.Text = "Please select Engine Number, Chassis Number and Registration Number";
                return;
            }


            ReportDocument RD    = new ReportDocument();
            DataSet        dsRpt = new DataSet();

            DXBMS.Data.DataSet1 objDsReports = new Data.DataSet1();


            SqlParameter[] param =
            {
                new SqlParameter("@DealerCode", SqlDbType.Char,    5),
                new SqlParameter("@EngNo",      SqlDbType.VarChar,30),             //1
                new SqlParameter("@ChasNo",     SqlDbType.VarChar,30),             //2
                new SqlParameter("@RegNo",      SqlDbType.VarChar,15),             //3
            };
            param[0].Value = Session["DealerCode"].ToString();
            param[1].Value = ddlEngineNo.Text;
            param[2].Value = ddlChassisNo.Text;
            param[3].Value = ddlRegNo.Text;



            //if (myFunc.ExecuteSPDMIS("sp2W_Spare_InvoiceDetail", param, ref rder))
            //if(myFunc.ExecuteSP("sp2W_Spare_InvoiceDetail",param,ref rder))
            //{
            //    objDsReports.sp2W_Spare_InvoiceDetail.Load(rder);


            //}

            DataTable dt  = new DataTable();
            string    sql = "exec sp_JobcardHistory '" + Session["DealerCode"].ToString() + "','" + ddlEngineNo.Text + "','" + ddlChassisNo.Text + "','" + ddlRegNo.Text + "'";

            dt = myFunc.GetData(sql);
            RD.PrintOptions.PaperSize = PaperSize.PaperA4;


            //RD.Load(Server.MapPath("../../SpareReports/rptInvoices.rpt"));
            RD.Load(Server.MapPath("../rptJobHistory.rpt"));
            RD.DataDefinition.FormulaFields["DealerPhone"].Text = "'" + Session["DealerPhone"].ToString() + "'";
            RD.DataDefinition.FormulaFields["DealerEmail"].Text = "'" + Session["DealerEmail"].ToString() + "'";

            RD.DataDefinition.FormulaFields["DealerName"].Text = "'" + Session["DealerDesc"].ToString() + "'";

            RD.DataDefinition.FormulaFields["DealerAddress"].Text = "'" + Session["DealerAddress"].ToString() + "'";
            RD.DataDefinition.FormulaFields["NTN"].Text           = "'" + Session["DealerNTN"].ToString() + "'";
            RD.DataDefinition.FormulaFields["SalesTaxNo"].Text    = "'" + Session["DealerSaleTaxNo"].ToString() + " '";
            RD.DataDefinition.FormulaFields["UserID"].Text        = "'" + Session["UserID"].ToString() + "'";
            //RD.DataDefinition.FormulaFields["FromCode"].Text = "'" + FDate + "'";
            //RD.DataDefinition.FormulaFields["ToCode"].Text = "'" + TDate + "'";
            RD.DataDefinition.FormulaFields["Terminal"].Text    = "'" + Environment.MachineName + "'";
            RD.DataDefinition.FormulaFields["ReportTitle"].Text = "\"" + "Jobcard History" + "\"";
            RD.DataDefinition.FormulaFields["CompanyName"].Text = "'" + Session["DealerDesc"].ToString() + "'";
            //RD.DataDefinition.FormulaFields["DealershipName"].Text = "'Authorised " + Session["ParentDesc"].ToString() + " Dealership'";
            //RD.DataDefinition.FormulaFields["Pic"].Text = "'C:\\Users\\u_ahm\\OneDrive\\Documents\\Visual Studio 2010\\Projects\\WebApplication1\\WebApplication1\\" + Session["Logo"] + "'";
            RD.DataDefinition.FormulaFields["Pic"].Text = "'" + Server.MapPath("~") + Session["Logo"] + "'";
            //RD.Database.Tables[0].SetDataSource(objDsReports);
            RD.Database.Tables[0].SetDataSource(dt);
            string FilePath = Server.MapPath("~") + "\\Download\\";
            string FileName = "Report.pdf";
            string File     = FilePath + FileName;

            PdfDocument outputDocument = new PdfDocument();
            Stream      stream         = RD.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

            stream.Seek(0, SeekOrigin.Begin);
            DirectoryInfo info = new DirectoryInfo(FilePath);

            if (!info.Exists)
            {
                info.Create();
            }

            string path = Path.Combine(FilePath, FileName);

            using (FileStream outputFileStream = new FileStream(path, FileMode.Create))
            {
                stream.CopyTo(outputFileStream);
            }
            stream.Dispose(); stream.Close();
            string URL = "../../../../Download/PrintReport.aspx";

            string fullURL = "window.open('" + URL + "', '_blank', 'height=800,width=1000,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,titlebar=no');";

            ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", fullURL, true);

            //// convert and show
            //string FilePath = Server.MapPath("~") + "\\Download\\";
            //string FileName = "JobcardHistory" + this.Session["DealerCode"].ToString() + DateTime.Now.ToString("ddMMyyyy") + ".pdf";
            //string File = FilePath + FileName;



            //Session["RD"] = RD;

            //string URL;
            //URL = "../../../../Download/rptViewerService.aspx?FileName=" + FileName;
            //string fullURL = "window.open('" + URL + "', '_blank', 'height=800,width=1200,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,titlebar=no');";
            //ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", fullURL, true);



            //string URL = "../../Service/ServiceReports/rptViewerService.aspx?ReportID=History&EngineNo=" + ddlEngineNo.SelectedItem.Text;
            //string fullURL = "window.open('" + URL + "', '_blank', 'height=800,width=1000,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,titlebar=no');";
            //ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", fullURL, true);
        }
        protected void btnShowReport_Click(object sender, EventArgs e)
        {
            if (dtFrom.Text == "" || dtTo.Text == "")
            {
                lblMSG.Text = "Please select dates";
                return;
            }
            SqlDataReader  rder;
            ReportDocument RD = new ReportDocument();
            DateTime       FromDate;
            DateTime       ToDate;

            string FDate = dtFrom.Date.ToString("yyyy/MM/dd");
            string TDate = dtTo.Date.ToString("yyyy/MM/dd");

            FromDate = Convert.ToDateTime(FDate);
            ToDate   = Convert.ToDateTime(TDate);

            //ReportDocument RD = new ReportDocument();
            //DataSet dsRpt = new DataSet();
            DXBMS.Data.DataSet1 objDsReports = new Data.DataSet1();



            SqlParameter[] param =
            {
                new SqlParameter("@DealerCode", SqlDbType.Char, 5),               //0
                new SqlParameter("@FromDate",   SqlDbType.DateTime),              //0
                new SqlParameter("@ToDate",     SqlDbType.DateTime),              //0
                new SqlParameter("@Status",     SqlDbType.VarChar, 10)            //0
            };
            param[0].Value = Session["DealerCode"].ToString();
            param[1].Value = FromDate.ToString("yyyy-MM-dd");
            param[2].Value = ToDate.ToString("yyyy-MM-dd");
            param[2].Value = rbStatus.SelectedItem.Value.ToString();



            //if (myFunc.ExecuteSPDMIS("sp2W_Spare_InvoiceDetail", param, ref rder))
            //if(myFunc.ExecuteSP("sp2W_Spare_InvoiceDetail",param,ref rder))
            //{
            //    objDsReports.sp2W_Spare_InvoiceDetail.Load(rder);


            //}

            DataTable dt  = new DataTable();
            string    sql = "exec sp_JobCardDetailReport '" + Session["DealerCode"].ToString() + "','" + FromDate.ToString("yyyy-MM-dd") + "','" + ToDate.ToString("yyyy-MM-dd") + "','" + rbStatus.SelectedItem.Value.ToString() + "'";

            dt = myFunc.GetData(sql);
            RD.PrintOptions.PaperSize = PaperSize.PaperA4;


            //RD.Load(Server.MapPath("../../SpareReports/rptJobCardDateWise.rpt"));
            RD.Load(Server.MapPath("../rptJobCardDateWise.rpt"));
            //RD.DataDefinition.FormulaFields["DealerPhone"].Text = "'" + myFunc.GetStringValuesAgainstCodes("DealerCode", Session["DealerCode"].ToString(), "Phone1", "Dealer") + "'";
            //RD.DataDefinition.FormulaFields["DealerEmail"].Text = "'" + myFunc.GetStringValuesAgainstCodes("DealerCode", Session["DealerCode"].ToString(), "Email", "Dealer") + "'";

            //RD.DataDefinition.FormulaFields["DealerName"].Text = "'" + myFunc.GetStringValuesAgainstCodes("DealerCode", Session["DealerCode"].ToString(), "DealerDesc", "Dealer") + "'";
            //RD.DataDefinition.FormulaFields["DealerAddress"].Text = "'" + myFunc.GetStringValuesAgainstCodes("DealerCode", Session["DealerCode"].ToString(), "Address1", "Dealer") + "" +
            //                                                               myFunc.GetStringValuesAgainstCodes("DealerCode", Session["DealerCode"].ToString(), "Address2", "Dealer") + "" +
            //                                                               myFunc.GetStringValuesAgainstCodes("DealerCode", Session["DealerCode"].ToString(), "Address3", "Dealer") + " (" +
            //                                                               myFunc.GetStringValuesAgainstCodes("DealerCode", Session["DealerCode"].ToString(), "Phone1", "Dealer") + ") '";
            RD.DataDefinition.FormulaFields["UserID"].Text      = "'" + Session["UserID"].ToString() + "'";
            RD.DataDefinition.FormulaFields["FromCode"].Text    = "'" + FDate + "'";
            RD.DataDefinition.FormulaFields["ToCode"].Text      = "'" + TDate + "'";
            RD.DataDefinition.FormulaFields["Terminal"].Text    = "'" + Environment.MachineName + "'";
            RD.DataDefinition.FormulaFields["ReportTitle"].Text = "\"" + "Jobcard Detail Report" + "\"";
            RD.DataDefinition.FormulaFields["CompanyName"].Text = "'" + Session["DealerDesc"].ToString() + "'";
            //RD.DataDefinition.FormulaFields["DealershipName"].Text = "'Authorised " + Session["ParentDesc"].ToString() + " Dealership'";
            //RD.Database.Tables[0].SetDataSource(objDsReports);
            RD.DataDefinition.FormulaFields["Pic"].Text = "'C:\\Users\\u_ahm\\OneDrive\\Documents\\Visual Studio 2010\\Projects\\WebApplication1\\WebApplication1\\" + Session["Logo"] + "'";
            RD.Database.Tables[0].SetDataSource(dt);

            // convert and show
            string FilePath = Server.MapPath("~") + "\\Download\\";
            string FileName = "JobCardDetail" + this.Session["DealerCode"].ToString() + DateTime.Now.ToString("ddMMyyyy") + ".pdf";
            string File     = FilePath + FileName;

            RD.ExportToDisk(ExportFormatType.PortableDocFormat, File);

            string URL;

            URL = "../../../../Download/OpenPdf.aspx?FileName=" + FileName;
            string fullURL = "window.open('" + URL + "', '_blank', 'height=800,width=1000,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,titlebar=no');";

            ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", fullURL, true);
        }
Example #5
0
        protected void btnShowReport_Click(object sender, EventArgs e)
        {
            if (!sec.UserRight("2586", "006"))
            {
                Response.Redirect("~/Test.aspx");
            }
            if (dtFrom.Text == "" || dtTo.Text == "")
            {
                MessageBox.Show("Please select dates", "Message");
                return;
            }
            Data.DSReports data = new Data.DSReports();
            SqlDataReader  rder = null;
            DataTable      dt   = new DataTable();
            ReportDocument RD   = new ReportDocument();
            DateTime       FromDate;
            DateTime       ToDate;

            string FDate = myFunc.SaveDate(dtFrom.Text).ToString();
            string TDate = myFunc.SaveDate(dtTo.Text).ToString();

            FromDate = Convert.ToDateTime(FDate);
            ToDate   = Convert.ToDateTime(TDate);

            //ReportDocument RD = new ReportDocument();
            //DataSet dsRpt = new DataSet();
            DXBMS.Data.DataSet1 objDsReports = new Data.DataSet1();

            SqlParameter[] param =
            {
                new SqlParameter("@DealerCode",      SqlDbType.Char),    //
                new SqlParameter("@FromDate",        SqlDbType.VarChar), //1
                new SqlParameter("@ToDate",          SqlDbType.VarChar), //2
                new SqlParameter("@VehicleCategory", SqlDbType.VarChar),
                new SqlParameter("@ChassisNo",       SqlDbType.VarChar), //2
                new SqlParameter("@EngineNo",        SqlDbType.VarChar),
                new SqlParameter("@RegNo",           SqlDbType.VarChar),
                new SqlParameter("@RptType",         SqlDbType.VarChar),
            };


            param[0].Value = Session["DealerCode"].ToString();
            param[1].Value = FromDate;
            param[2].Value = ToDate;
            param[3].Value = rbStatus.SelectedItem.Value.ToString();
            param[4].Value = "";
            param[5].Value = "";
            param[6].Value = "";
            param[7].Value = "Warranty";


            if (sysfunc.ExecuteSP("SP_PPR_Detail_Report", param, ref rder))
            {
                //data.SP_selectjobcategorydetail.Load(rder);
                data.EnforceConstraints = false;
                data.SP_PPR_Detail_Report.Load(rder);
            }
            RD.Load(Server.MapPath("~/Modules/Service/ServiceReports/rptWarrantyDetailHCV.rpt"));

            // RD.DataDefinition.FormulaFields["DealerName"].Text = "'" + Session["DealerDesc"].ToString() + "'";
            RD.DataDefinition.FormulaFields["DealerAddress"].Text = "'" + Session["DealerAddress"].ToString() + "'";
            RD.DataDefinition.FormulaFields["DealerPhone"].Text   = "'" + Session["DealerPhone"].ToString() + "'";
            //  RD.DataDefinition.FormulaFields["DealerEmail"].Text = "'" + Session["DealerEmail"].ToString() + "'";
            RD.DataDefinition.FormulaFields["ReportTitle"].Text = "'Warranty Claim  Report'";
            RD.DataDefinition.FormulaFields["Terminal"].Text    = "'" + Request.ServerVariables["REMOTE_ADDR"].ToString() + "'";
            RD.DataDefinition.FormulaFields["UserId"].Text      = "'" + Session["UserName"].ToString() + "'";
            //RD.DataDefinition.FormulaFields["NTN"].Text = "'N.T.N # " + Session["DealerNTN"].ToString() + "'";
            //RD.DataDefinition.FormulaFields["SalesTaxNo"].Text = "'Sales Tax No.  " + Session["DealerSaleTaxNo"].ToString() + " '";
            //rpt.DataDefinition.FormulaFields["UserCell"].Text = "'" + GetStringValuesAgainstCodes("CusCode", , "CellNo", "Customer") + "'";
            RD.DataDefinition.FormulaFields["CompanyName"].Text = "'" + Session["DealerDesc"].ToString() + "'";
            //RD.DataDefinition.FormulaFields["DealershipName"].Text = "'Authorised " + Session["ParentDesc"].ToString() + " Dealership'";
            //RD.DataDefinition.FormulaFields["Pic"].Text = "'C:\\Users\\u_ahm\\OneDrive\\Documents\\Visual Studio 2010\\Projects\\WebApplication1\\WebApplication1\\" + Session["Logo"] + "'";
            RD.DataDefinition.FormulaFields["Pic"].Text = "'" + Server.MapPath("~") + Session["Logo"] + "'";
            //RD.DataDefinition.FormulaFields["Pic1"].Text = "'" + Server.MapPath("~") + dt.Rows[0]["item"].ToString() + "'";

            RD.Database.Tables[0].SetDataSource(data);
            string FilePath = Server.MapPath("~") + "\\Download\\";
            string FileName = "Report.pdf";
            string File     = FilePath + FileName;

            PdfDocument outputDocument = new PdfDocument();
            Stream      stream         = RD.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

            stream.Seek(0, SeekOrigin.Begin);
            DirectoryInfo info = new DirectoryInfo(FilePath);

            if (!info.Exists)
            {
                info.Create();
            }

            string path = Path.Combine(FilePath, FileName);

            using (FileStream outputFileStream = new FileStream(path, FileMode.Create))
            {
                stream.CopyTo(outputFileStream);
            }
            stream.Dispose(); stream.Close();
            string URL = "../../../../Download/PrintReport.aspx";

            string fullURL = "window.open('" + URL + "', '_blank', 'height=800,width=1000,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,titlebar=no');";

            ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", fullURL, true);


            //convert and show
            //string FilePath = Server.MapPath("~") + "\\Download\\";
            //string FileName = "BillingReport" + this.Session["DealerCode"].ToString() + DateTime.Now.ToString("ddMMyyyy") + ".pdf";
            //string File = FilePath + FileName;

            //Session["RD"] = RD;


            //string URL;
            //URL = "../../../../Download/rptViewerService.aspx?FileName=" + FileName;
            //string fullURL = "window.open('" + URL + "', '_blank', 'height=800,width=1000,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,titlebar=no');";
            //ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", fullURL, true);
        }