=======================
using System;
using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;public partial class cpadmin_deactivepin : System.Web.UI.Page{using System;
SqlConnection con = new SqlConnection(method.constr);
SqlCommand com;
SqlDataReader dr;
SqlDataAdapter da;
DataTable t = new DataTable();
DataTable t1;
protected void Page_Load(object sender, EventArgs e){
if (!IsPostBack){
bind();
}
}
protected void Button1_Click(object sender, EventArgs e){
bind();
}
public void bind(){
t = getdata();
if (t.Rows.Count > 0){
btnsendaward.Visible =
true;Label1.Text =
"";Label3.Text =
"Total Deactive Pin " + ":" + t.Rows.Count.ToString();GridView1.PageSize =
Convert.ToInt32(TextBox1.Text);GridView1.DataSource = t;
GridView1.DataBind();
}
else{
btnsendaward.Visible = false;Label1.Text =
"No DeActive Pin!";Label3.Text =
"";GridView1.DataSource =
null;GridView1.DataBind();
}
}
protected void btnsendaward_Click(object sender, EventArgs e){
string tt = "";
string strinsert = "";
string grid = "";
bool chk = false; con.Open();
foreach (GridViewRow gr in GridView1.Rows){
CheckBox deletechkbox = (CheckBox)gr.FindControl("chkregno");
if (deletechkbox.Checked){
chk =
true;grid = ((
Label)gr.FindControl("lblcheckid")).Text.ToString();tt = ((
Label)gr.FindControl("lbltype")).Text.ToString();
if (tt == "Registration"){
strinsert =
"update pinmst set isactivate=1 where pinsrno='" + grid + "'";}
else { strinsert = "update rechargepin set isactivate=1 where pinsrno='" + grid + "'"; }
com =
new SqlCommand(strinsert, con);com.ExecuteNonQuery();
}
} con.Close();
bind();
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e){
GridView1.PageIndex = e.NewPageIndex;
bind();
}
protected void Button1_Click1(object sender, EventArgs e){
bind();
}
protected void excelreport_Click1(object sender, EventArgs e){
DataTable dsExport = new DataTable();System.IO.
StringWriter tw = new System.IO.StringWriter();System.Web.UI.
HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
DataGrid dgGrid = new DataGrid();dgGrid.DataSource = getdata();
// Report Headerhw.WriteLine("<b><u><font size='5'> PIN List </font></u></b>");
// Get the HTML for the control.dgGrid.HeaderStyle.Font.Bold = true;dgGrid.DataBind();
dgGrid.RenderControl(hw);
// Write the HTML back to the browser.Response.ContentType = "application/vnd.ms-excel";Response.Write(tw.ToString());
Response.End();
}
public DataTable getdata(){
com =
new SqlCommand("sp_nonactivepin", con);com.CommandType =
CommandType.StoredProcedure;com.Parameters.AddWithValue(
"@type", DropDownList1.SelectedValue.ToString());da =
new SqlDataAdapter(com);
DataTable t1 = new DataTable();da.Fill(t1);
return t1;}
}
No comments:
Post a Comment