using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;


public partial class personal_audituser : PageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            GridViewBin();      //调用绑定数据信息函数

        }
    }

    public void GridViewBin()
    {

        SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["constring"].ConnectionString);
        string indexTopMainStr = "SELECT [Number], [PersonnelName], [LoginName], [Pwd],  [WorkName], [Sex], [IdCardNum],[Birthday],[CallPhone],[Pid],[approvestate] FROM [v_tabp_work] where approvestate = 1";
        SqlDataAdapter rst = new SqlDataAdapter(indexTopMainStr, conn);
        DataSet rdt = new DataSet();
        rst.Fill(rdt);
        this.Repeater1.DataSourceID = null;
        Repeater1.DataSource = rdt;//数据绑定 
        Repeater1.DataBind();


    }


    protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
    {

        string strsql;
        SqlConnection sqlcon = new SqlConnection(ConfigurationManager.ConnectionStrings["constring"].ConnectionString);

        int str = Convert.ToInt32(e.CommandArgument.ToString());
        string strid = (e.Item.FindControl("HiddenField1") as HiddenField).Value;


        if (e.CommandName == "Delete")
        {


            strsql = "update tabP_Personnel set approvestate = 0 where  pid ='" + Convert.ToInt32(strid) + "'";
     
            sqlcon.Open();


            SqlCommand mycmd = new SqlCommand(strsql, sqlcon);

            mycmd.ExecuteNonQuery();
            mycmd.Dispose();



            Response.Write("<script>alert('执行成功！')</script>");

            string indexTopMainStr = "SELECT [Number], [PersonnelName], [LoginName], [Pwd],  [WorkName], [Sex], [IdCardNum],[Birthday],[CallPhone],[Pid],[approvestate] FROM [v_tabp_work] where approvestate = 1";
            SqlDataAdapter rst = new SqlDataAdapter(indexTopMainStr, sqlcon);
            DataSet rdt = new DataSet();
            rst.Fill(rdt);
            this.Repeater1.DataSourceID = null;
            Repeater1.DataSource = rdt;//数据绑定 
            Repeater1.DataBind();

            sqlcon.Close();


        }
        if (e.CommandName == "detaileduser")
        {
            string url;
            url = "detaileduser.aspx?name=" + strid + "&name1=0"; 
            Response.Redirect(url);

        }
        

    }








}


