protected void ImgBtnExport_Click(object sender, ImageClickEventArgs e) { if (ViewState["Summary"] != null) { DataTable DtGrd = (DataTable)ViewState["Summary"]; string PURINVNO = string.Empty; if (DtGrd.Rows.Count > 0) { GridView GridExp = new GridView(); GridExp.DataSource = DtGrd; GridExp.DataBind(); Obj_Comm.Export("ListOfReceipts.xls", GridExp); } else { Obj_Comm.ShowPopUpMsg("No Data Found To Export..!", this.Page); GridExpenseList.DataSource = null; GridExpenseList.DataBind(); } } else { Obj_Comm.ShowPopUpMsg("No Data Found To Export..!", this.Page); SetInitialRow(); } }
public void SetInitialRow() { try { DataTable dt = new DataTable(); DataRow dr = null; dt.Columns.Add(new DataColumn("ExpRegNo", typeof(string))); dt.Columns.Add(new DataColumn("ExpenceRegDate", typeof(string))); dt.Columns.Add(new DataColumn("Expense", typeof(string))); dt.Columns.Add(new DataColumn("Amount", typeof(decimal))); dt.Columns.Add(new DataColumn("Remark", typeof(string))); dt.Columns.Add(new DataColumn("#", typeof(int))); dr = dt.NewRow(); dr["#"] = 0; dr["ExpRegNo"] = ""; dr["ExpenceRegDate"] = ""; dr["Expense"] = ""; dr["Amount"] = 0; dr["Remark"] = ""; dt.Rows.Add(dr); ViewState["Summary"] = dt; GridExpenseList.DataSource = dt; GridExpenseList.DataBind(); dt = null; dr = null; } catch (Exception ex) { throw new Exception(ex.Message); } }
protected void BtnShow_Click(object sender, EventArgs e) { try { ReportGrid(); GridExpenseList.Focus(); } catch (Exception ex) { Obj_Comm.ShowPopUpMsg(ex.Message, this.Page); } }
private void ReportGrid() { try { StrCondition = string.Empty; if (ChkFrmDate.Checked == true) { StrCondition = StrCondition + " and ER.ExpenceRegDate between '" + Convert.ToDateTime(txtFromDate.Text).ToString("MM-dd-yyyy") + "' AND '" + Convert.ToDateTime(txtToDate.Text).ToString("MM-dd-yyyy") + "' "; } if (Convert.ToInt32(ddlExpense.SelectedValue) > 0) { StrCondition = StrCondition + " and ED.ExpenseHdId='" + (ddlExpense.SelectedValue) + "' "; } DS = Obj_Receipt.GetExpenseList(StrCondition, out StrError); if (DS.Tables.Count > 0 && DS.Tables[0].Rows.Count > 0) { ViewState["Summary"] = DS.Tables[0]; GridExpenseList.DataSource = DS.Tables[0]; GridExpenseList.DataBind(); if (!FlagPrint) { ImgBtnPrint.Visible = false; ImgBtnExport.Visible = true; ImgPDF.Visible = true; } lblCount.Text = DS.Tables[0].Rows.Count + " Records Found"; lblCount.Visible = true; dsExport = DS.Copy(); } else { GridExpenseList.DataSource = null; GridExpenseList.DataBind(); lblCount.Text = "No Records Found!!"; lblCount.Visible = true; SetInitialRow(); ImgBtnPrint.Visible = false; ImgBtnExport.Visible = false; ImgPDF.Visible = false; } } catch (Exception ex) { Obj_Comm.ShowPopUpMsg(ex.Message, this.Page); } }