protected void LinkBtnExportExcel_Click(object sender, EventArgs e) { try { System.Threading.Thread.Sleep(2000); Response.Clear(); Response.Buffer = true; Response.ClearContent(); Response.ClearHeaders(); Response.Charset = ""; string FileName = "EmployeeLoanList.xls"; StringWriter strwritter = new StringWriter(); HtmlTextWriter htmltextwrtter = new HtmlTextWriter(strwritter); Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.ContentType = "application/vnd.ms-excel"; Response.AddHeader("Content-Disposition", "attachment;filename=" + FileName); GV_EmpCre.GridLines = GridLines.Both; GV_EmpCre.HeaderStyle.Font.Bold = true; GV_EmpCre.RenderControl(htmltextwrtter); Response.Write(strwritter.ToString()); Response.End(); } catch (Exception ex) { throw; //ScriptManager.RegisterStartupScript(this, this.GetType(), "isActive", "Alert();", true); //lblalert.Text = ex.Message; } }
private void get_Empcre() { dt_ = new DataTable(); query = " select * from SubHeadCategories where SubHeadCategoriesName = '" + EmpLoan + "'"; dt_ = DBConnection.GetQueryData(query); if (dt_.Rows.Count > 0) { accno = dt_.Rows[0]["SubHeadCategoriesGeneratedID"].ToString(); } query = " select * from v_emploan where AccNo = '" + accno + "'"; dt_ = DBConnection.GetQueryData(query); if (dt_.Rows.Count > 0) { GV_EmpCre.DataSource = dt_; GV_EmpCre.DataBind(); } }
private void get_Empcre(string fdat) { dt_ = new DataTable(); query = " select * from SubHeadCategories where SubHeadCategoriesName = '" + EmpLoan + "' and SubHeadGeneratedID = '0023'"; dt_ = DBConnection.GetQueryData(query); if (dt_.Rows.Count > 0) { accno = dt_.Rows[0]["SubHeadCategoriesGeneratedID"].ToString(); } query = " select * from v_emploan where AccNo = '" + accno + "' and LoanDat >= '" + fdat + "' and SubHeadGeneratedID = '0023'"; dt_ = DBConnection.GetQueryData(query); if (dt_.Rows.Count > 0) { lbl_Emp.Text = dt_.Rows[0]["SubHeadCategoriesName"].ToString(); GV_EmpCre.DataSource = dt_; GV_EmpCre.DataBind(); } float GTotal = 0; for (int k = 0; k < GV_EmpCre.Rows.Count; k++) { Label total = (Label)GV_EmpCre.Rows[k].FindControl("lbl_lonamt"); GTotal += Convert.ToSingle(total.Text); } lbl_ttl.Text = GTotal.ToString(); }