Example #1
0
    private void LoadActivatedBill()
    {
        try
        {
            String  BillStatus = "InActive"; //drpBillStatusype.SelectedItem.Text;
            String  BillType   = drpActivatedBillType.SelectedItem.Text;
            String  FlatNumber = txtActBillsFlats.Text;
            Bill    billCycle  = new Bill();
            DataSet dsActivatedBill;// = billCycle.GetActivatedBill(BillStatus, BillType, FlatNumber);

            if (BillStatus == "Active")
            {
                dsActivatedBill = billCycle.GetActivatedBill(BillStatus, BillType, FlatNumber);
            }
            else
            {
                dsActivatedBill = billCycle.GetDeActivatedBill(BillStatus, BillType, FlatNumber);
            }

            if (dsActivatedBill != null)
            {
                if (dsActivatedBill.Tables.Count > 0)
                {
                    FlatsBillsGrid.DataSource = dsActivatedBill;
                    FlatsBillsGrid.DataBind();
                    // lblTotalBillscount.Text = dsActivatedBill.Tables[0].Rows.Count.ToString();
                    lblActvBillsCount.Text            = dsActivatedBill.Tables[0].Rows.Count.ToString();
                    FlatsBillsGrid.Columns[6].Visible = false;
                    FlatsBillsGrid.Columns[0].Visible = false;
                    DataTable model = dsActivatedBill.Tables[0];

                    //Added by Aarshi on 14 - Sept - 2017 for bug fix

                    /* if (dsActivatedBill.Tables[1].Rows[0][0].ToString() != string.Empty)
                     *   lblActivateCount.Text = dsActivatedBill.Tables[1].Rows[0][0].ToString();
                     * if (dsActivatedBill.Tables[2].Rows[0][0].ToString() != string.Empty)
                     *   lblDeactivateCount.Text = dsActivatedBill.Tables[2].Rows[0][0].ToString();
                     * if (dsActivatedBill.Tables[3].Rows[0][0].ToString() != string.Empty)
                     *   lblNotActivateCount.Text = dsActivatedBill.Tables[3].Rows[0][0].ToString();*/
                    //Ends here
                }
                else
                {
                }
            }
        }
        catch (Exception ex)
        {
        }
    }
Example #2
0
    protected void ExportToExcelActive(object sender, EventArgs e)
    {
        Response.Clear();
        Response.Buffer = true;
        Response.AddHeader("content-disposition", "attachment;filename=GridViewExport.xls");
        Response.Charset     = "";
        Response.ContentType = "application/vnd.ms-excel";
        using (StringWriter sw = new StringWriter())
        {
            HtmlTextWriter hw = new HtmlTextWriter(sw);

            //To Export all pages
            FlatsBillsGrid.AllowPaging = false;
            this.LoadActivatedBill();

            FlatsBillsGrid.HeaderRow.BackColor = System.Drawing.Color.White;
            foreach (TableCell cell in FlatsBillsGrid.HeaderRow.Cells)
            {
                cell.BackColor = FlatsBillsGrid.HeaderStyle.BackColor;
            }
            foreach (GridViewRow row in FlatsBillsGrid.Rows)
            {
                row.BackColor = System.Drawing.Color.White;
                foreach (TableCell cell in row.Cells)
                {
                    if (row.RowIndex % 2 == 0)
                    {
                        cell.BackColor = FlatsBillsGrid.AlternatingRowStyle.BackColor;
                    }
                    else
                    {
                        cell.BackColor = FlatsBillsGrid.RowStyle.BackColor;
                    }
                    cell.CssClass = "textmode";
                }
            }

            FlatsBillsGrid.RenderControl(hw);

            //style to format numbers to string
            string style = @"<style> .textmode { } </style>";
            Response.Write(style);
            Response.Output.Write(sw.ToString());
            Response.Flush();
            Response.End();
        }
    }