⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 serch.aspx.cs

📁 校友录的总体功能分为三个子功能模块:管理功能模块,用户注册功能模块,用户个性化服务
💻 CS
📖 第 1 页 / 共 2 页
字号:
    protected void ProvinceSel(object sender, EventArgs e)
    {
        SqlConnection conn2 = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
        conn2.Open();
        SqlCommand cmd2 = new SqlCommand();
        cmd2.Connection = conn2;
        cmd2.CommandText = "select  distinct id,city from city where father IN (select provinceID from province where province='" + this.Province.SelectedItem.Text + "')";//"+this.Province.Text.ToString()+"
        SqlDataReader sdr2 = cmd2.ExecuteReader();
        this.City.DataSource = sdr2;
        this.City.DataTextField = "city";
        this.City.DataValueField = "id";
        this.City.DataBind();
        conn2.Close();
        SetCountry();
        Serch("Province",this.Province.SelectedItem.Text );

    }
    protected void CtrySel(object sender, EventArgs e)
    {

        if (this.Country.SelectedIndex == 1)
        {


            //ArrayList ListImg = new ArrayList();

            //String temp = "不用填写";

            //ListImg.Add(temp);

            //this.Province.DataSource = ListImg;
            //this.Province.DataBind();
            //this.City.DataSource = ListImg;
            //this.City.DataBind();
            this.Province.Items.Clear();
            this.City.Items.Clear();
        }
        else
        {
            this.Binder();

        }
        Serch("Country", this.Country.SelectedItem.Text );
    }
    protected void CitySel(object sender, EventArgs e)
    {
        SetCountry();
        if (this.Province.SelectedItem.Text == "")
        {
            this.Binder();

        }
        Serch("City", this.City.SelectedItem.Text );
     
    }
    protected void EmaiClk(object sender, EventArgs e)
    {
      //  Session["MailTo"]=
 //  


       //  object TempEmal = Session["MailTo"];
   //     this.testtext.Text ="sdhf";


    }
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {

                    
        //LinkEmail
        switch (e.CommandName)
        {
            case "GetEmail":
                {


                    //   this.GridView1.EditRowStyle.BackColor = Color.FromName("#F7CE90");

                    int index = Convert.ToInt32(e.CommandArgument) - this.GridView1.PageIndex*10;
                    //获取行的位置
                    GridViewRow row = GridView1.Rows[index];
                    //获取选定行的列的位置,比如第三列,付给你自己的变量表达式,这里是全局变量varImpID
                    //  Session["MailTo"] = row.Cells[0].Text;

                    LinkButton lb = (LinkButton)row.FindControl("EMailLink");

                    //   this.testtext.Text = row.Cells[4].Text;
                    String StrTemp = lb.Text;
                    if (StrTemp.Substring(StrTemp.Length - 3, 3) == "---")
                    {
                        Session["MailTo"] = null;
                        //  this.testtext.Text = "";
                    }
                    else
                    {
                        Session["MailTo"] = lb.Text;
                        //   this.testtext.Text = lb.Text;
                        Response.Redirect("Email.aspx");
                    }
                    break;
                }
            case "SendMsg":
                {
                    int index = Convert.ToInt32(e.CommandArgument) - this.GridView1.PageIndex * 10;
                    //获取行的位置
                    GridViewRow row = GridView1.Rows[index];
                    //获取选定行的列的位置,比如第三列,付给你自己的变量表达式,这里是全局变量varImpID
                    //  Session["MailTo"] = row.Cells[0].Text;

                    Label  lb = (Label )row.FindControl("UserLab");

                    //   this.testtext.Text = row.Cells[4].Text;
                    String StrTemp = lb.Text;
                    Session["MsgTo"] = StrTemp;
                    Response.Redirect("SendMsg.aspx");

                    ///////MsgBtn  ImageButton2
                    //ImageButton ibtn = ((ImageButton)e.Row.FindControl("MsgBtn"));
                    //if (ibtn == null)
                    //{
                    //    return;
                    //}
                    //ibtn.Enabled = true;
                    ////switch   (Convert.ToInt32((e.Row.Cells[4].Text.Trim())))   
                    ////{   
                    ////        case   1:   
                    //ibtn.CommandArgument = e.Row.DataItemIndex.ToString();
      
        



                } break;
            case "friend":
                {
                    int index = Convert.ToInt32(e.CommandArgument) - this.GridView1.PageIndex * 10;
                    //获取行的位置
                    GridViewRow row = GridView1.Rows[index];
                    //获取选定行的列的位置,比如第三列,付给你自己的变量表达式,这里是全局变量varImpID
                    //  Session["MailTo"] = row.Cells[0].Text;

                    Label lb = (Label)row.FindControl("UserLab");

                    //   this.testtext.Text = row.Cells[4].Text;
                    String StrTemp = lb.Text;



                   addfrien(StrTemp);
                   
                    Response.Redirect("friend.aspx");

                  


                } break;





            default: break;

        }

     }
    public void addfrien(string fid)
    {

        SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);

        SqlCommand cmd = new SqlCommand();
        cmd.Connection = conn;

        cmd.CommandText = "select * from friend where friend='" + fid + "'and UserID='" + Session["UserID"].ToString().Trim() + "'"; ;
        cmd.Connection.Open();

        SqlDataReader sdr = cmd.ExecuteReader();

        if (sdr.HasRows != true)
        {
            cmd.Connection.Close();

            string sql;
            sql = "insert into friend (UserID,friend,type) values ('" + Session["UserID"].ToString().Trim() + "','" + fid + "','好友')";
      
      
            cmd.Connection = conn;

            cmd.CommandText = sql;

            cmd.Connection.Open();

            cmd.ExecuteNonQuery();

            cmd.Connection.Close();

        }

        cmd.Connection.Close();

        conn.Close();





    
       



    }
    protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
    {

        if (e.Row.RowType == DataControlRowType.DataRow)
        {

            // Retrieve the LinkButton control from the first column.
//
          //  LinkButton LinkButton1 = (LinkButton)e.Row.FindControl("EMailLink");

            //// Set the LinkButton's CommandArgument property with the row's index.
          //      LinkButton1.CommandArgument = e.Row.RowIndex.ToString();


            LinkButton lb = ((LinkButton)e.Row.FindControl("EMailLink"));
            if (lb == null)
            {
                return;
            }
            lb.Enabled = true;
            //switch   (Convert.ToInt32((e.Row.Cells[4].Text.Trim())))   
            //{   
            //        case   1:   
            lb.CommandArgument = e.Row.DataItemIndex.ToString();
            //break;   

            /////MsgBtn  ImageButton2
            ImageButton ibtn = ((ImageButton)e.Row.FindControl("MsgBtn"));
            if (ibtn == null)
            {
                return;
            }
            ibtn.Enabled = true;
            //switch   (Convert.ToInt32((e.Row.Cells[4].Text.Trim())))   
            //{   
            //        case   1:   
            ibtn.CommandArgument = e.Row.DataItemIndex.ToString();

            ImageButton addf = ((ImageButton)e.Row.FindControl("head1"));
            if (addf == null)
            {
                return;
            }
            addf.Enabled = true;
            //switch   (Convert.ToInt32((e.Row.Cells[4].Text.Trim())))   
            //{   
            //        case   1:   
            addf.CommandArgument = e.Row.DataItemIndex.ToString();
      
        
        
        
        
        }


    }
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {


        LinkButton lb = ((LinkButton)e.Row.FindControl("EMailLink"));   
                  if   (lb   ==   null)   
                  {   
                          return;   
                  }   
                  lb.Enabled   =   true;   
                  //switch   (Convert.ToInt32((e.Row.Cells[4].Text.Trim())))   
                  //{   
                    lb.CommandArgument   =   e.Row.DataItemIndex.ToString();   
                          //break;   
                            
                    //}   

                    /////MsgBtn  ImageButton2
                    ImageButton ibtn = ((ImageButton)e.Row.FindControl("MsgBtn"));
                    if (ibtn == null)
                    {
                        return;
                    }
                    ibtn.Enabled = true;
                    //switch   (Convert.ToInt32((e.Row.Cells[4].Text.Trim())))   
                    //{   
                    //        case   1:   
                    ibtn.CommandArgument = e.Row.DataItemIndex.ToString();


                    ImageButton addf = ((ImageButton)e.Row.FindControl("head1"));
                    if (addf == null)
                    {
                        return;
                    }
                    addf.Enabled = true;
                    //switch   (Convert.ToInt32((e.Row.Cells[4].Text.Trim())))   
                    //{   
                    //        case   1:   
                    addf.CommandArgument = e.Row.DataItemIndex.ToString();
      
        
        
    
    
    
    
    
    
    
    }
    protected void ddl_SelectedIndexChanged(object sender, System.EventArgs e) //一定要声明成protected或者public,不能是private的。 
    {
        //在这里就可以加入其他代码 

                    DropDownList ddl = (DropDownList)sender;

      
               Session["classname"] = ddl.SelectedItem.Text;
               ddl.SelectedIndex = 0;
               sender = null;

                SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
                conn.Open();
                SqlCommand cmd = new SqlCommand();
                cmd.Connection = conn;

                cmd.CommandText = "select   Num ,ClassName from UserToClass where ClassName='" + Session["classname"].ToString().Trim() + "' and UserID='" + Session["UserID"].ToString().Trim() + "'"; ;
                SqlDataReader sdr = cmd.ExecuteReader();

                if (sdr.HasRows == true)
                {
                    conn.Close();

                  
                    Response.Redirect("ClassView.aspx");


                }
                else
                {
                   // Response.Write("<script>window.alter('你没有注册该班级!')</script>");
              //     // Response.Write("javascript:window.open(\"nlskdjvlk\")");
              //      Response.Write("<script>window.open('你要打开窗体的路径')</script>")   
              //Response.Write("<script>window.alert('警告信息')</script>")   
              //      Session["classname"] = null;   
              //RegisterStartupScript("alerm","<script>alert('你没有注册该班级!');</script>");   
                    //((LinkButton)e.Row.Cells[6].Controls[0]).Attributes.Add("onclick", "javascript:return confirm('你确认要删除:\"" + e.Row.Cells[1].Text + "\"吗?')");
             //       Response.Write("javascript:return confirm('你确认要删除:吗?')");
               
             //    return;
                    conn.Close();

                 
                    Response.Redirect("RegClass.aspx");
                
                }

               

    }

    protected void head1_Click(object sender, ImageClickEventArgs e)
    {


    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -