simpleDemo

d

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using DAL;
using System.Data;
using System.Data.SqlClient;


namespace WebApp
{
    public partial class Details1 : System.Web.UI.Page
    {
       static int id = 0;//使用全局变量用来保存浏览器从首页传过来的id值

       static string authority = string.Empty;//用来读取用户登录的权限值

       static int UserId = 0;//存储当前登录用户的权限和关系表中的对应的用户表的外键值

       static int WorkId = 0;//保存当前选中的工作gridview的数据行的id值,也可以在模版中使用<%# Bind("id")%>的形式取到
              
     
       protected void Page_Load(object sender, EventArgs e)
        {

            if (!IsPostBack)//如果是第一次进入页面的话
            {
                id = int.Parse(Request.QueryString["id"]);//取到浏览器传送过来的id值


                UserId = int.Parse(Session["UserId"].ToString());//当用户第一次登录这个页面的时候,得到当前登录用户的用户表中的主键ID值

                
                //记住是在第一次加载页面的时候(时机)绑定数据库中的数据,否则数据不会发生变化的,加载的始终都是第一项的数据

                bindDpList();//在登录事件中绑定静态数据
                bindDpGridView();//在登录事件中绑定gridview数据
               
                bindTxt();
            }

          


            //下面没有写在第一次加载页面的里面是错误的写法

            #region  MyRegion
            //bindDpList();//在登录事件中绑定静态数据
            //bindDpGridView();//在登录事件中绑定gridview数据
            //bindTxt();
            //basicInformation();
            #endregion

 


            //为出生日期文本框前台标签注册onfocus事件
            txtBirthday.Attributes.Add("onfocus", "new WdatePicker({dateFmt:'yyyy-MM-dd',readOnly:true})");
            txtProposeTime.Attributes.Add("onfocus", "new WdatePicker({dateFmt:'yyyy-MM-dd',readOnly:true})");


            //思路:读取数据库中保存权限的那个表中的权限字段的值,然后根据值来进行判断

            string strs = "select FAuthority from dbo.TAuthority where FUserId=" + UserId;

           
            DataTable dt= SqlHelper.ExcuteTable(strs);//得到一个用户权限表


            int num= int.Parse(dt.Rows[0]["FAuthority"].ToString());
            if (num != 2)
            {
                //btnConfirmed.Enabled = false;//把确认按钮禁用掉

                btnConfirmed.Visible = false;//让确认按钮不可见

            }

            //else
           if(num==2)
            {
                btnSubmit.Visible = false;//把提交按钮不显示,
                btnCancel.Visible  = false;//把删除按钮不显示

                //this.GridView2.FindControl("a2").Visible = false;


                GridView1.Enabled = false;//禁用gridview的时候也会放置在gridview中的服务器端控件也会给禁用掉
                GridView2.Enabled = false;
                GridView3.Enabled = false;//禁用gridview的时候也会放置在gridview中的服务器端控件也会给禁用掉


                //HyperLink Hlink = this.GridView1.FindControl("HlnkEducation") as HyperLink;//在模版中找到服务器端超链接控件
                //Hlink.Enabled = false;//把服务器端超链接控件禁用
               
            }

           if (num == 3)
           {
              
               btnSubmit.Visible = false;//把提交按钮不显示,
               btnCancel.Visible = false;//把删除按钮不显示
               btnConfirmed.Visible = false;//把确认按钮不显示
              
               GridView1.Visible = false;//把gridview设置成不显示状态
               GridView2.Visible = false;
               GridView3.Visible = false;//把gridview设置成不显示状态
           }


           if (num == 4)
           {
               btnSubmit.Visible = false;//把提交按钮不显示,
               btnCancel.Visible = false;//把删除按钮不显示
               btnConfirmed.Visible = false;//把确认按钮不显示

               GridView1.Enabled = false;//禁用gridview的时候也会放置在gridview中的服务器端控件也会给禁用掉
               GridView2.Enabled = false;
               GridView3.Enabled = false;//禁用gridview的时候也会放置在gridview中的服务器端控件也会给禁用掉

           }

           if (num==5)//(体现管理和业务要分离开的思想)
           {
               btnConfirmed.Visible = false;//让确认按钮不可见
               btnCancel.Visible = false;//让取消按钮不可见
               btnSubmit.Visible = false;//让提交按钮不可见

               GridView1.Enabled = false;//禁用gridview的时候也会放置在gridview中的服务器端控件也会给禁用掉
               GridView2.Enabled = false;
               GridView3.Enabled = false;//禁用gridview的时候也会放置在gridview中的服务器端控件也会给禁用掉
           }


            //TextBox tb = (TextBox)this.GridView2.FindControl("TextBox1");//拿到gridview中的textbox控件玩
            //tb.Text = "hello";//为从gridview中拿到的textbox控件赋值


           basicInformation();//绑定基本信息
   
        }

 


        //绑定下拉数据的方法
        void bindDpList()
        {
            //绑定民族
            string sqlPeople = "select * from TpeopleDetail";
            dpListPeople.DataSource = SqlHelper.ExcuteTable(sqlPeople);
            dpListPeople.DataTextField = "FpersonName";//实际的数据值
            dpListPeople.DataValueField = "id";//真实的数据值
            dpListPeople.DataBind();

            //绑定性别
            string sqlSex = "select * from TSex";
            dplistSex.DataSource = SqlHelper.ExcuteTable(sqlSex);
            dplistSex.DataTextField = "FsexName";
            dplistSex.DataValueField = "id";
            dplistSex.DataBind();

            //绑定政治面貌
            string sqlPolice = "select * from TPolitical";
            dpListPolice.DataSource = SqlHelper.ExcuteTable(sqlPolice);
            dpListPolice.DataTextField = "FPolicName";
            dpListPolice.DataValueField = "id";
            dpListPolice.DataBind();

            //绑定婚姻列表
            string sqlMarried = "select * from TYesOrNot";
            dpListMarried.DataSource = SqlHelper.ExcuteTable(sqlMarried);
            dpListMarried.DataTextField = "FValue";
            dpListMarried.DataValueField = "id";
            dpListMarried.DataBind();


            //绑定部门列表
            string sqlDepartment = "select * from TDepartment";
            dpListDepartment.DataSource = SqlHelper.ExcuteTable(sqlDepartment);
            dpListDepartment.DataTextField = "FDepartment";
            dpListDepartment.DataValueField = "id";
            dpListDepartment.DataBind();
        }


        //绑定gridview数据
        void bindDpGridView()
        {
            //绑定教育信息的代码
            #region  绑定教育信息的代码

            int id = int.Parse(Request.QueryString["id"]);//得到传过来的id值
            string strTEducation = @"SELECT id
                      ,CONVERT(varchar(10),FEduBeginTime,120) FEduBeginTime1
                      ,CONVERT(varchar(10),FEduEndTime,120) FEduEndTime1
                      ,FEduSchool
                      ,FEduProfession
                      ,FEduBackground
                      ,FEduCertifier
                      ,FEduRelationShip
                      ,FEduContactPhone
                      ,FPersonId     

                      FROM TEducation where FIsDel=1 and FPersonId=" + id;

            DataTable dt = SqlHelper.ExcuteTable(strTEducation);//得到一个DataTable数据源


            //EducationId = int.Parse(dt.Rows[0]["id"].ToString());//取到教育的数据id值
           


            GridView1.DataSource = dt.DefaultView;
            GridView1.DataBind();
            #endregion


            //绑定培训经历的代码
            #region  绑定培训经历的代码

            string strTTrainingExperience = @"SELECT id
                  ,CONVERT(varchar(10),FPracBeginTime,120) FPracBeginTime1
                  ,CONVERT(varchar(10),FPracEndTime,120) FPracEndTime1
                  ,FTrainingInstitution
                  ,FTrainingContent
                  ,Fcertificate
                  ,FPersonId
    
                FROM TTrainingExperience where FIsDel=1 and FPersonId=" + id;
    
            DataTable dtTTrainingExperience = SqlHelper.ExcuteTable(strTTrainingExperience);


            //TrainId = int.Parse(dt.Rows[0]["id"].ToString());//取到培训的数据id值
           

            GridView2.DataSource = dtTTrainingExperience.DefaultView;
            GridView2.DataBind();
            #endregion


            //绑定工作经历信息的代码
            #region  绑定工作经历信息的代码

            string strTWorkExperience = @"SELECT id
                    
                      ,CONVERT(varchar(10),FWorkBeginTime,120) FWorkBeginTime1
                      ,CONVERT(varchar(10),FWorkEndTime,120) FWorkEndTime1 
                      ,FWorkCompanyName
                      ,FWorkPosition
                      ,FWorkLastSalary
                      ,FWorkLeaveReason
                      ,FWorkCertifier
                      ,FWorkContactPhone
                      ,FPersonId
    
                FROM TWorkExperience where FIsDel=1 and FPersonId=" + id;


            DataTable dtTWorkExperience = SqlHelper.ExcuteTable(strTWorkExperience);


            //WorkId = int.Parse(dt.Rows[0]["id"].ToString());//取到工作的id值


            GridView3.DataSource = dtTWorkExperience.DefaultView;
            GridView3.DataBind();
            #endregion

        }

        //绑定自我评价数据和基本信息
        void bindTxt()
        {
            string strs = "select * from dbo.TSelfEvaluation where FIsDel=1 and FPersonId=" + id;
           
            DataTable dt= SqlHelper.ExcuteTable(strs);

            if (dt.Rows.Count>0)
            {
                txtAdvantage.Text = dt.Rows[0]["FAdvantages"].ToString();
                txtHobby.Text = dt.Rows[0]["FHobbies"].ToString();
            }

            #region  MyRegion
            //if (dt.Rows[0]["FAdvantages"]!=null && dt.Rows[0]["FHobbies"]!=null)
            //{
            //      txtAdvantage.Text = dt.Rows[0]["FAdvantages"].ToString();
            //      txtHobby.Text = dt.Rows[0]["FHobbies"].ToString();
            //}
            #endregion
           
        }


        //绑定基本信息
        void basicInformation()
        {
            string strsBasic = @"SELECT id
                  ,FName
                  ,FSexId
                  ,FPeopleId
                  ,FHousehoId

                  ,convert(varchar(10),FBirthday,120) FBirthday

                  ,FMarried
                  ,FPolitical
                  ,FPastHistory
                  ,FMobilePhone
                  ,FPhoneNumber

                  ,FsfzMember
                  ,FEmail
                  ,FhjAddress
                  ,FxjAddress
                  ,FFirstPersonName
                  ,FRelationship
                  ,FContactPhone
                  ,FIsDel
                  ,FConfirmed

               
                  ,FDepartmentId

                  
                  ,FSQRen
                  ,CONVERT(varchar(10),FSQTime,120) FSQTime


                  FROM TBasicInfor where id=" + id;

             DataTable dt= SqlHelper.ExcuteTable(strsBasic);


             if (dt.Rows.Count>0)
             {
                 txtName.Text = dt.Rows[0]["FName"].ToString();
                 dplistSex.SelectedValue = dt.Rows[0]["FSexId"].ToString();
                 dpListPeople.SelectedValue = dt.Rows[0]["FPeopleId"].ToString();

                 dpListDepartment.SelectedValue = dt.Rows[0]["FDepartmentId"].ToString();//后添加的绑定部门信息地方


                //把数据库中的数值取出来然后为RadionButton控件的状态设置设置选中状态

               // string tbValue = string.Empty;
               // foreach (var c in Page.Form.Controls)
               // {
               //      if (c is RadioButton)
               //      {
               //          RadioButton btn = c as RadioButton;
               //          if (btn.GroupName == "CountryOrTown")
               //          {
               //              //tbValue=btn.Text;//这里拿到的是户籍类别radionButton的text属性

               //              string strTest = dt.Rows[0]["FHousehoId"].ToString();

               //              if (btn.Text == strTest)
               //              {
               //                  btn.Checked = true;
               //              }
               //          }

               //          //else
               //          //{
               //          //    break;//跳出当前的循环
               //          //}
               //      }
               //}


               string strTest = dt.Rows[0]["FHousehoId"].ToString();
               if (strTest == "农村")
               {
                   rbCountry.Checked = true;
               }

               if (strTest == "城镇")
               {
                   rbTown.Checked = true;
               }


               #region  原来的代码
               //if (strTest=="农村")
               //{
               //    cbCountry.Checked = true;
               //}

               //if (strTest=="城镇")
               //{
               //    cbTown.Checked = true;
               //}
               #endregion


               if (strTest == "农村")
               {
                   CheckBoxList1.Items.FindByText("农村").Selected = true;
               }

               if (strTest=="城镇")
               {
                   CheckBoxList1.Items.FindByText("城镇").Selected = true;
               }

 

               txtBirthday.Text = dt.Rows[0]["FBirthday"].ToString().Substring(0,10);


               dpListMarried.SelectedValue = dt.Rows[0]["FMarried"].ToString();
               dpListPolice.SelectedValue = dt.Rows[0]["FPolitical"].ToString();


               //string tbHistory = string.Empty;
               //foreach (var c in Page.Form.Controls)
               //{
               //    if (c is RadioButton)
               //    {
               //        RadioButton btn = c as RadioButton;
               //        if (btn.GroupName == "YesOrNo")
               //        {
               //            //tbValue=btn.Text;//这里拿到的是户籍类别radionButton的text属性

               //            string strVal = dt.Rows[0]["FPastHistory"].ToString();

               //            if (btn.Text == strVal)
               //            {
               //                btn.Checked = true;
               //            }
               //        }
               //    }
               //}


               string strVal = dt.Rows[0]["FPastHistory"].ToString();

               if (strVal == "有")
               {
                   ckYes.Checked = true;
               }

               if (strVal == "无")
               {
                   ckNo.Checked = true;
               }

 


             
               txtMobilePhone.Text = dt.Rows[0]["FMobilePhone"].ToString();
               txtHomePhone.Text = dt.Rows[0]["FPhoneNumber"].ToString();


               txtSfzNumber.Text = dt.Rows[0]["FsfzMember"].ToString();
               txtEmail.Text = dt.Rows[0]["FEmail"].ToString();
               txtHomePlace.Text = dt.Rows[0]["FhjAddress"].ToString();
               txtNowAddress.Text = dt.Rows[0]["FxjAddress"].ToString();
               txtFirstPeopleName.Text = dt.Rows[0]["FFirstPersonName"].ToString();
               txtRelation.Text = dt.Rows[0]["FRelationship"].ToString();
               txtContectPhone.Text = dt.Rows[0]["FContactPhone"].ToString();


               //后添加的申请人和申请时间的两个字段
               txtProposer.Text = dt.Rows[0]["FSQRen"].ToString();
               txtProposeTime.Text = dt.Rows[0]["FSQTime"].ToString();

 


               string strVal1 = dt.Rows[0]["FPastHistory"].ToString();

               if (strVal1 == "有")
               {
                   ckYes.Checked = true;
               }

               if (strVal1 == "无")
               {
                   ckNo.Checked = true;
               }

 


             }
        }


        //点击超链接按钮的时候,进行的页面跳转
        protected void returnIndex_Click(object sender, EventArgs e)
        {
            //思路:读取数据库中保存权限的那个表中的权限字段的值,然后把这个值在进行页面跳转的时候传到首页

            string strs = "select FAuthority from dbo.TAuthority where FUserId=" + UserId;
            DataTable dt = SqlHelper.ExcuteTable(strs);//得到一个数据表

            authority = dt.Rows[0]["FAuthority"].ToString();//得到数据表中的权限字段的值

            Response.Redirect("Index.aspx?authority="+authority);

        }


        //实现审核的功能
        protected void btnConfirmed_Click(object sender, EventArgs e)
        {
            string strUpdateSql = "update TBasicInfor set FConfirmed=1 where FIsDel=1 and id=" + int.Parse(Request.QueryString["id"]);
            SqlHelper.ExcuteNonQuery(strUpdateSql);

            btnConfirmed.Enabled = false;//审核成功以后就把审核按钮禁用掉
        }


        //实现删除的功能
        protected void btnCancel_Click(object sender, EventArgs e)
        {
            //准备一个要执行的sql语句
            string sqlCancel = "update TBasicInfor set FIsDel=0 where id=" + id;
            //DataTable dt=
                SqlHelper.ExcuteNonQuery(sqlCancel);//得到一个数据源

            //准备一个要从插入的权限表中读取当前用户的权限值
            string sqlAuthoity = "select t.FAuthority from dbo.TAuthority t where FUserId=" + UserId;
            DataTable dtAu= SqlHelper.ExcuteTable(sqlAuthoity);

            //删除完以后立刻跳转到首页
            Response.Redirect("Index.aspx?authority=" + int.Parse(dtAu.Rows[0]["FAuthority"].ToString()));
                          
        }


        //完成修改提交的功能
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            //if (IsPostBack)
            //{
                          
            // FName=txtName.Text
            //,FSexId=int.Parse(dplistSex.SelectedValue)

            #region  更新基本信息的Sql字符串
            string strUpdate = @"UPDATE TBasicInfor set
   
       
         FName=@FName
              ,FSexId=@FSexId
              ,FPeopleId=@FPeopleId
              ,FHousehoId=@FHousehoId


              ,FBirthday=@FBirthday
              ,FMarried=@FMarried
              ,FPolitical=@FPolitical
              ,FPastHistory=@FPastHistory
              ,FMobilePhone=@FMobilePhone
              ,FPhoneNumber=@FPhoneNumber
              ,FsfzMember=@FsfzMember
              ,FEmail=@FEmail
              ,FhjAddress=@FhjAddress
              ,FxjAddress=@FxjAddress
              ,FFirstPersonName=@FFirstPersonName
              ,FRelationship=@FRelationship
              ,FContactPhone=@FContactPhone


              ,FDepartmentId=@FDepartmentId


              ,FSQRen=@FSQRen
              ,FSQTime=@FSQTime


               where id=           
              " + id;

 

            //得到RadionButton控件中选中的值

           // string tbValue = string.Empty;
           // foreach (var c in Page.Form.Controls)
           // {
           //  if (c is RadioButton)
           //  {
           //      RadioButton btn = c as RadioButton;
           //     if (btn.Checked&&btn.GroupName=="CountryOrTown" )
           //      {
           //         tbValue=btn.Text;//这里拿到的是户籍类别radionButton的text属性
           //      }
           //  }
           //}


             //得到CheckBox控件中选中的值

            string tbValuePastHistory = string.Empty;//定义一个变量,这样可以让下面sql参数中也可以使用到

            foreach (var c in Page.Form.Controls)
            {
             if (c is CheckBox)
             {
                 CheckBox cb = c as CheckBox;

                 tbValuePastHistory = cb.Text;//这里拿到的是户籍类别radionButton的text属性
                
             }
           } 
 #endregion


            string sqlSelfSubmit = @"update dbo.TSelfEvaluation set
                                                    FAdvantages=@FAdvantages,
                                                    FHobbies=@FHobbies 
                                                    where
                                                    FIsDel=1 and "

                                                   //+ "id=" + id;
                                                  
                                                   +"FPersonId=" + id;
                                   
            //应该是自我评价中对应的基本信息的表的外键要更新,而自我评价表的主键

 


             //判断申请时间(如果申请时间为空的话,则在代码中默认为当前时间)(再次感受代码为数据赋之和数据库为数据赋值的感觉)
            if (string.IsNullOrEmpty(txtProposeTime.Text))
            {

                txtProposeTime.Text = DateTime.Now.ToString("yyyy-MM-dd");

            }

 


            SqlParameter[] parsBasic = new SqlParameter[] {
            #region  基本信息的参数化查询
  
                   new SqlParameter("@FName",txtName.Text),
                   new SqlParameter("@FSexId",dplistSex.SelectedValue),
                   new SqlParameter("@FPeopleId",dpListPeople.SelectedValue),

                   //new SqlParameter("@FHousehoId",    tbValue),


                   new SqlParameter("@FBirthday",DateTime.Parse(txtBirthday.Text)),//把字符串转换成datetime类型
                   new SqlParameter("@FMarried",dpListMarried.SelectedValue),
                   new SqlParameter("@FPolitical",dpListPolice.SelectedValue),

                   new SqlParameter("@FPastHistory",     tbValuePastHistory),
                  
                  
                  
                   new SqlParameter("@FMobilePhone",txtMobilePhone.Text),
                   new SqlParameter("@FPhoneNumber",txtHomePhone.Text),
                   new SqlParameter("@FsfzMember",txtSfzNumber.Text),
                   new SqlParameter("@FEmail",txtEmail.Text),
                   new SqlParameter("@FhjAddress",txtHomePlace.Text),
                   new SqlParameter("@FxjAddress",txtNowAddress.Text),
                   new SqlParameter("@FFirstPersonName",txtFirstPeopleName.Text),
                   new SqlParameter("@FRelationship",txtRelation.Text),
                   new SqlParameter("@FContactPhone",txtContectPhone.Text),


                   new SqlParameter("@FDepartmentId",dpListDepartment.SelectedValue),

 

                   new SqlParameter("@FSQRen",txtProposer.Text),    //后添加的申请人的信息

 

                   new SqlParameter("@FSQTime",DateTime.Parse(txtProposeTime.Text))     //后添加的申请时间的信息

            };
            #endregion

 

            SqlParameter[] parasSelf = new SqlParameter[]{
                    new SqlParameter("@FAdvantages",txtAdvantage.Text),
                    new SqlParameter("@FHobbies",txtHobby.Text)
                };


                SqlHelper.ExcuteNonQuery(strUpdate, parsBasic);//执行更新基本信息的SQL语句

                SqlHelper.ExcuteNonQuery(sqlSelfSubmit, parasSelf);//执行更新自我评价的内容


            //准备一个要从插入的权限表中读取当前用户的权限值
            string sqlAuthoity = "select t.FAuthority from dbo.TAuthority t where FUserId=" + UserId;
            DataTable dtAu = SqlHelper.ExcuteTable(sqlAuthoity);

            //删除完以后立刻跳转到首页
            Response.Redirect("Index.aspx?authority=" + int.Parse(dtAu.Rows[0]["FAuthority"].ToString()));

            //}
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Response.Write(txtName.Text);//显示名字文本框的内容
        }

 

        //在第一个gridview里面实现删除工作经历的操作


        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {

            #region  没用的测试代码
            //Response.Write("删除数据");

            //拿到当前选中这一行的行号怎么拿到
            //Response.Write(e.Keys.ToString()+"下一个数据<br/>");//经过测试,这个不是
            //Response.Write(e.RowIndex);//这个参数需要加1才是


            //Response.Write(e.Keys["id"].ToString());

            //Response.Write(e.Values[0].ToString());
            #endregion

            string sqlDelete = "update TEducation  set  FIsDel=0   where  FPersonId=" + id + " and id=" + e.Values[0].ToString();
            //注意:e.Values[0]指的是gridview的前台显示的列Columns中的第一个字段,所以需要注意的是把第一个字段需要设置为主键才可以取到选中的主键列

            SqlHelper.ExcuteNonQuery(sqlDelete);

            bindDpGridView();//删完以后再重新绑定一个gridview数据

        }

        protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
        {
            //Response.Redirect("~/教育情况/SecondEducation.aspx?id=" + id + "&action=create");
           
            //int i = e.NewSelectedIndex;
            //Response.Write(i);
        }


        //使用gridview实现新增的功能
        //protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        //{
        //    //测试拿到的命令名字是什么
        //    //string s = e.CommandName;
        //    //Response.Write(s);

        //    //测试成功,终于拿到了新增的那个命令按钮了
        //    string ComName = e.CommandName;
        //    if (ComName == "New")
        //    {
        //        //Response.Redirect("~/教育情况/SecondEducation.aspx?id=" + id + "&action=New" + "EducationId=" + EducationId);

        //        Response.Redirect("~/教育情况/SecondEducation.aspx?id=" + id + "&action=New");
        //    }
        //}


        //实现教育情况创建列的功能
        //protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
        //{

        //    //Response.Write("hello");

        //    //Response.Redirect("~/教育情况/SecondEducation.aspx?id=" + id + "&action=create");

        //}


      
        //实现培训经历编辑列的功能
        //protected void GridView2_RowEditing(object sender, GridViewEditEventArgs e)
        //{

        //    //Response.Redirect("~/培训经历/SecondTraining.aspx?id=" + id + "&action=edit" + "TrainId=" + TrainId);

        //    //Response.Write(strUserId+"你");
        //    //Response.Write(strUserName+"你");
        //    //Response.Write(strUserPassword+"你");

        //    //Response.Write(id2);

        //}

 

        protected void GridView2_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            string ComName = e.CommandName;
            if (ComName == "New")
            {
                Response.Redirect("~/培训经历/SecondTraining.aspx?id=" + id + "&action=New");

            }
        }


        protected void GridView2_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
        {

           //id2= e.NewSelectedIndex;

           // //GridViewRow row = GridView1.Rows[e.NewSelectedIndex];
           // //strUserId = row.Cells[1].Text;
           // //strUserName = row.Cells[2].Text;
           // //strUserPassword = row.Cells[3].Text;

           // Response.Write(strUserId);
           // Response.Write(strUserName);
           // Response.Write(strUserPassword);

        }

 

        //实现删除培训经历的代码
        protected void GridView2_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            #region  MyRegion
            //Response.Write("gridview2的值");

            //Response.Write(e.Values[0].ToString());
            //经过测试,只有把主键列显示在gridview里面,然后使用e.Values[0].ToString()才能取到当前选中的gridview中的数据的主键值
           
            #endregion

            string sqlDelete = "update TTrainingExperience  set  FIsDel=0   where  FPersonId=" + id + " and id=" + e.Values[0].ToString();
            SqlHelper.ExcuteNonQuery(sqlDelete);
            bindDpGridView();
        }


        protected void GridView3_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            string ComName = e.CommandName;
            if (ComName == "New")
            {
                Response.Redirect("~/工作经历/SecondWorkExperience.aspx?id=" + id + "&action=New");
            }
        }


        //实现删除工作经历的代码
        protected void GridView3_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
             //Response.Write("gridview3的值");

            WorkId = int.Parse(e.Values[0].ToString());

            string sqlDelete = "update TWorkExperience set  FIsDel=0   where  FPersonId=" + id + " and id=" + e.Values[0].ToString();
            SqlHelper.ExcuteNonQuery(sqlDelete);
            bindDpGridView();

        }


        protected void GridView3_RowEditing(object sender, GridViewEditEventArgs e)
        {
            #region  MyRegion
            //Response.Write(e.NewEditIndex);
            //Response.Redirect("~/工作经历/SecondWorkExperience.aspx?id=" + id + "&action=edit" + "WorkId=" + WorkId);

            //Response.Redirect("~/工作经历/SecondWorkExperience.aspx?id=" + id + "&action=edit" + "WorkId=" + WorkId);
           
            #endregion

            Response.Write(e.NewEditIndex);
        }

 

        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {

            //HyperLink Hlink = this.GridView1.FindControl("HlnkEducation") as HyperLink;//在模版中找到服务器端超链接控件
            Hlink.Enabled = false;//把服务器端超链接控件禁用
            //Hlink.Text = "hello";

 

 

            //GridViewRow rows = (GridViewRow)((Control)sender).Parent;
            //TextBox tb = rows.FindControl("TextBox1") as TextBox;
            //tb.Text = "myName";

        }


        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            //TextBox tb = e.Row.FindControl("TextBox1") as TextBox;

            //tb.Text = "myHello";

            //GridView1.ed

        }
            

     


    }
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值