Ejemplo n.º 1
0
    private void BindGrid(int btnval)
    {
        //DateTime date = System.DateTime.Now;
        //string sess = date.ToString("tt");
        sess = string.Empty;
        string name1 = string.Empty;

        periobj = 0;

        DataTable dt = new DataTable();
        DataSet   ds = new DataSet();

        plant_Code = Session["User_ID"].ToString();

        if (rd_Am.Checked == true)
        {
            sess = "AM";
            dt   = GetProcurementData(txt_FromDate.Text, sess, route_id, plant_Code, Company_code);
            //GridView1.DataSource = dt;
            //GridView1.DataBind();
        }
        else if (rd_Pm.Checked == true)
        {
            sess = "PM";
            dt   = GetProcurementData(txt_FromDate.Text, sess, route_id, plant_Code, Company_code);
        }
        else if (rd_Period.Checked == true)
        {
            periobj = 1;
            sess    = "Period";
            dt      = GetProcurementDataPeriod(txt_FromDate.Text, txt_ToDtate.Text, route_id, plant_Code, Company_code);
        }
        else
        {
            sess = "Bill";
            dt   = GetProcurementData(txt_ToDtate.Text, sess, route_id, plant_Code, Company_code);
        }
        ds.Tables.Add(dt);
        if (dt.Rows.Count > 0)
        {
            ViewFilename = string.Empty;
            if (periobj == 0)
            {
                name1        = Server.MapPath(".") + "/kk/" + plant_Code.Trim() + '_' + txt_FromDate.Text.Trim() + '_' + sess.Trim();
                ViewFilename = plant_Code.Trim() + '_' + txt_FromDate.Text.Trim() + '_' + sess.Trim();
            }
            else
            {
                name1        = Server.MapPath(".") + "/kk/" + plant_Code.Trim() + '_' + txt_FromDate.Text.Trim() + '_' + txt_ToDtate.Text.Trim() + '_' + sess.Trim();
                ViewFilename = plant_Code.Trim() + '_' + txt_FromDate.Text.Trim() + '_' + txt_ToDtate.Text.Trim() + '_' + sess.Trim();
            }

            name2 = Server.MapPath(".") + "/kk/" + "Nasa-logo1.gif";
            SETBO();
            PdfReport pd = new PdfReport(ds, name1, Cpdf);
            if (butview > 1)
            {
                pd.Execute1();
                string fileName          = ViewFilename + ".pdf";
                string surverUrl         = Request.Url.AbsoluteUri.Split('/')[0] + "//" + Request.Url.Authority + Request.ApplicationPath.TrimEnd('/') + "/";
                string fileStoreLocation = "kk/";
                string downloadFilePath  = surverUrl + fileStoreLocation + fileName;
                iframShowFiles.Attributes.Add("src", downloadFilePath);
            }
            else
            {
                pd.Execute();
            }

            name1 = string.Empty;
        }
        else
        {
            iframShowFiles.Visible = false;
            uscMsgBox1.AddMessage("Report Not Found", MessageBoxUsc_Message.enmMessageType.Info);
        }
    }