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

📄 regedit2.aspx.cs

📁 校友录的总体功能分为三个子功能模块:管理功能模块,用户注册功能模块,用户个性化服务
💻 CS
📖 第 1 页 / 共 2 页
字号:
using System;
using System.Data;
using System.Data.SqlClient;
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.IO;
using System.ComponentModel;
using System.Web.SessionState;
using System.Globalization;


public partial class regedit : System.Web.UI.Page, ICallbackEventHandler ///小心
{
    public string strcity;
    private void Binder()
    {

        //绑定省
        ////string cmd2 = "select * from province";
        //SqlCommand cmd=new SqlCommand("select * from province")
        ////SqlDataAdapter sda2 = new SqlDataAdapter(cmd2, con);
        //SqlDataReader ds2 =cmd.ExecuteReader() ;
        ////sda2.Fill(ds2, "t2");
        //this.Province.DataSource = ds2;
        //this.Province.DataTextField = "t2.province";
        //this.Province.DataValueField = "t2.id";
        ////this.Province.DataBind();
        //绑定市
        //string cmd3 = "select * from 市表 where 行省编号=" + (this.CBProvince.SelectedValue);
        //SqlDataAdapter sda3 = new SqlDataAdapter(cmd3, con);
        //DataSet ds3 = new DataSet();
        //sda3.Fill(ds3, "t3");
        //this.CBCity.DataSource = ds3;
        //this.CBCity.DisplayMember = "t3.市名称";
        //this.CBCity.ValueMember = "t3.市编号";
        //SqlConnection conn = DB.createSqlConnection();
        SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
        conn.Open();
        SqlCommand cmd = new SqlCommand();
        cmd.Connection = conn;
        cmd.CommandText = "select distinct id,province from province ";
        SqlDataReader sdr = cmd.ExecuteReader();
        this.Province.DataSource = sdr;
        this.Province.DataTextField = "province";
        this.Province.DataValueField = "id";
        this.Province.DataBind();
        conn.Close();
        Session["TempPro"] = this.Province.SelectedItem.Text;
        //绑定市
        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();

        //SqlDataAdapter sda3 = new SqlDataAdapter(cmd3, con);
        //DataSet ds3 = new DataSet();
        //sda3.Fill(ds3, "t3");
        //this.CBCity.DataSource = ds3;
        //this.CBCity.DisplayMember = "t3.市名称";
        //this.CBCity.ValueMember = "t3.市编号";

        conn2.Close();
        //    Session["TempPro"] = this.Province.SelectedItem.Text;

    }
    public void SetTime()
    {
        int i;
        ArrayList mounth = new ArrayList();
        for (i = 1; i <= 12; i++)
            mounth.Add(i);
        this.Mounth.DataSource = mounth;
        this.Mounth.DataBind();
        //以上初始化月 
        int j;
        ArrayList year = new ArrayList();
        for (j = 1900; j <= 2020; j++)
            year.Add(j);
        this.Year.DataSource = year;
        this.Year.DataBind();
        //以上初始化年 
        //    this.Mounth.AutoPostBack = true;
        //     this.Year.AutoPostBack = true;
        ArrayList ETRyear = new ArrayList();
        for (j = 1964; j <= 2020; j++)
            ETRyear.Add(j);
        this.ETRTime.DataSource = ETRyear;
        this.ETRTime.DataBind();


    }

    public void day(string mth, int year)
    {
        switch (mth)
        {
            case "1":
            case "3":
            case "5":
            case "7":
            case "8":
            case "10":
            case "12":
                daynum("31");
                break;
            case "2":
                if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
                    daynum("29");
                else
                    daynum("28");
                break;
            default:
                daynum("30");
                break;
        }

    }
 private void ImgList()
    {
        if (!IsPostBack)
        {
            int j;
            ArrayList ListImg = new ArrayList();
            for (j = 1; j <= 100; j++)
            {
                String temp;//image9.gif
                temp = "image" + j + ".gif";
                ListImg.Add(temp);
            }
            this.Figure.DataSource = ListImg;
            this.Figure.DataBind();
        }

    }
    public void daynum(string num)
    {
        int i;
        ArrayList day = new ArrayList();
        for (i = 1; i <= Convert.ToInt16(num); i++)
            day.Add(i);
        this.Day.DataSource = day;
        this.Day.DataBind();
    }


   
    private void SetCountry()
    {
        ArrayList CountryList = new ArrayList();

        CountryList.Add("境内");
        CountryList.Add("境外");

        this.Country.DataSource = CountryList;
        this.Country.DataBind();
    }
    private DataTable Get_Dt(string sql)
    {
        //数据库连接串,本数据库为Sql数据库,当前在本目录的根目录下
        SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
        conn.Open();

        SqlDataAdapter myAdp = new SqlDataAdapter(sql, conn);
        DataTable myDt = new DataTable();

        //填充数据
        myAdp.Fill(myDt);
        //返回数据集 
        conn.Close();
        return (myDt);



    }
    protected override void Render(HtmlTextWriter writer)
    {

        ClientScript.RegisterForEventValidation(City.UniqueID, "北京市");
        base.Render(writer);
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        
        ////接收参数
        string sortid = this.Request.QueryString["sortid"];
        string sType = this.Request.QueryString["sType"];
        strcity = Request.Form["hideCity"];
      //  this.City.Value = strcity;

        //判断参数是否为空(注意:空有两种形式,一种为null,一种为空)
        if (sortid + "a" != "a")
        {
            //如果有传递上述参数,则表示联动操作开始				


            this.xmlBind(sortid, sType);




        }

        if (!this.IsPostBack)
        {

            //  this.xmlBind("110000", "2");
            this.DownBind1();
            this.DownBind2();

            //   this.DownBind3();


            this.SetTime();
            //this.Mounth.SelectedValue
            day(this.Mounth.SelectedValue, Convert.ToInt16(this.Year.SelectedValue));
            ImgList();

        }


        //if (!IsPostBack)
        //{

        //   // this.Binder();
        //    this.SetCountry();
        this.Mounth.Attributes.Add("onchange", "CallMounthSel(this,Year)");
        this.Year.Attributes.Add("onchange", "CallYearSel(Mounth,this)");
        this.Figure.Attributes.Add("onchange", "ImageSel(Figure)");

        //}


        //else
        //{
        //    this.DownBind2();

        //    this.DownBind3();


        //}
       
        //在页面初次加载的时候,绑定第一/二/三个下拉框
        //默认第一个下拉框选中第一个选项
        //第二个下拉框选中第一个下拉框值所对应的选项
        //第三个下拉框选中第二个下拉框值所对应的选项
      


        ////Province.AutoPostBack = false;

        ////if (Province.AutoPostBack == true)

        ////    this.Province.SelectedItem.Text = Session["TempPro"].ToString();
        ////Province.AutoPostBack = true;

        //绑定市
        //string cmd3 = "select * from 市表 where 行省编号=" + (this.CBProvince.SelectedValue);
        //SqlDataAdapter sda3 = new SqlDataAdapter(cmd3, con);
        //DataSet ds3 = new DataSet();
        //sda3.Fill(ds3, "t3");
        //this.CBCity.DataSource = ds3;
        //this.CBCity.DisplayMember = "t3.市名称";
        //this.CBCity.ValueMember = "t3.市编号";
     
        

    }


    private string serverReturn;

    public string GetCallbackResult()
    {
        //为便于查看加载效果,添加延时
        //   System.Threading.Thread.Sleep(2000);


        string[] parts = serverReturn.Split('|');
        //根据传递的方法名进行调用,并传递相应的参数,目前只支持一个参数
        return (string)GetType().GetMethod(parts[0]).Invoke(this, new object[] { parts[1] });
        //  return ServerMethod2(serverReturn);
    }

    public void RaiseCallbackEvent(string eventArgument)
    {
        serverReturn = eventArgument;
        //可直接返加 return eventArgument;


    }


  //  根据从客户端传来的值,对内容进行更新,并将更新后返回
    public string MounthSel(string arg)
    {
        string[] parts = arg.Split('*');
        day(parts[0], Convert.ToInt16(parts[1]));
        return RenderControl(Day);
    }
    public string YearSel(string arg)
    {
        // DropDownList1.SelectedValue = arg;
        //.DataBind();//Convert.ToInt16(num)

        string[] parts = arg.Split('*');
        day(parts[0], Convert.ToInt16(parts[1]));
        return RenderControl(Day);
    }
    public string SelPic(string arg)
    {

        //string temp = this.Figure.SelectedItem.Text;
        //   头像列表 <img id="SelPic" alt="" src="HeadPic/image28.gif" style="width: 46px; height: 43px" />
        this.PicLink.Text = " 头像列表 <img id=\"SelPic\" alt=\"\" src=\"HeadPic/" + arg + "\" style=\"width: 46px; height: 43px;;border-top-style: none; border-right-style: none; border-left-style: none; border-bottom-style: none;\" />";


        return RenderControl(PicLink);
    }



    private string RenderControl(Control control)
    {
        StringWriter writer1 = new StringWriter(CultureInfo.InvariantCulture);
        HtmlTextWriter writer2 = new HtmlTextWriter(writer1);

        control.RenderControl(writer2);
        writer2.Flush();
        writer2.Close();

        return writer1.ToString();
    }
  
    protected void Alumni_CheckedChanged(object sender, EventArgs e)
    {
        if (Alumni.Checked == true)
        {
            ChkID.Text ="学号";
            ETRYear.Text ="入学年份";
        }

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

        if (Teacher.Checked == true)
        {
            ChkID.Text ="校职工号";
            ETRYear.Text ="聘用年份";
        }
    }

    protected void ChkNuser()
    {
        this.RegularExpressionValidator3.Validate();
        if (this.RegularExpressionValidator3.IsValid != true)
        {
            this.ExitUserText.Text = "该用户名不可用!";
            return;
        }
        SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
        if (this.UserID.Text.Length == 0 || this.UserID.Text == "" | this.UserID.Text == null)
        {
            this.ExitUserText.Text = "该用户名不可用!!";
            return;
        }
        string cmd = "select * from UserInfo where UserID='" + this.UserID.Text.ToString() + "'"; //设置SQL命令
        conn.Open();
        SqlCommand myCommand = new SqlCommand(cmd, conn);
        SqlDataReader jie = myCommand.ExecuteReader();
         
      //  this.RegularExpressionValidator3.IsValid = true;
        if (jie.Read())
            {
                this.ExitUserText.Text = "该用户名已注册!";
              //this.RegularExpressionValidator3.
            }
            else
            {
                this.ExitUserText.Text = "该用户名可用";
           //     this.ExitUserText.Text = "该用户名可用!";

                //Response.Write("javascript:return confirm('你确认要删除此记录吗?')");
            }
     

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

        this.ChkNuser();


        //if (Page.IsValid)
        //{
        //    SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
        //    //  conn.Open();
        //    SqlCommand cmd = new SqlCommand("AddUser", conn);
        //    cmd.CommandType = CommandType.StoredProcedure;
        //    cmd.Parameters.Add(new SqlParameter("@UserID", SqlDbType.Char, 20));
        


⌨️ 快捷键说明

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