예제 #1
0
    protected void btnExportToExcel_Click(object sender, EventArgs e)
    {
        string        str           = "";
        string        str1          = "";
        CaseDetailsBO caseDetailsBO = new CaseDetailsBO();

        for (int i = 0; i < this.grdPatientList.Rows.Count; i++)
        {
            if (((CheckBox)this.grdPatientList.Rows[i].FindControl("chkDelete")).Checked)
            {
                if (!((Bill_Sys_BillingCompanyObject)this.Session["BILLING_COMPANY_OBJECT"]).BT_REFERRING_FACILITY)
                {
                    LinkButton linkButton = (LinkButton)this.grdPatientList.Rows[i].Cells[2].FindControl("lnkSelectCase");
                    str  = linkButton.Text.ToString();
                    str1 = (!(str1 == "") ? string.Concat(str1, ",", str) : str);
                }
                else
                {
                    LinkButton linkButton1 = (LinkButton)this.grdPatientList.Rows[i].Cells[3].FindControl("lnkSelectRCase");
                    str  = linkButton1.Text.ToString();
                    str1 = (!(str1 == "") ? string.Concat(str1, ",", str) : str);
                }
            }
        }
        if (str1 != "")
        {
            DataSet dataSet = new DataSet();
            dataSet = caseDetailsBO.GetBillInfo(str1, this.txtCompanyID.Text);
            if (dataSet.Tables[0].Rows.Count == 0)
            {
                ScriptManager.RegisterStartupScript(this, base.GetType(), "ss", "alert('No Bills are available to Export to Excel sheet!');", true);
            }
            else
            {
                string str2 = ConfigurationManager.AppSettings["EXCEL_SHEET"].ToString();
                string str3 = string.Concat(this.lfnFileName(), ".xls");
                File.Copy(ConfigurationSettings.AppSettings["ExportToExcelPath"].ToString(), string.Concat(str2, str3).Trim());
                (new XGridViewControl()).GenerateXL(dataSet.Tables[0], string.Concat(str2, str3));
                ScriptManager.RegisterClientScriptBlock(this, base.GetType(), "mm", string.Concat(" window.location.href =' ", ConfigurationManager.AppSettings["FETCHEXCEL_SHEET"].ToString(), str3, "'"), true);
            }
        }
    }