📄 updatemsg.aspx.cs
字号:
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 UpdateMsg : System.Web.UI.Page, ICallbackEventHandler ///小心
{
public string strcity;
public string strpro;
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;
}
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();
}
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();
}
}
private void SetCountry()
{
ArrayList CountryList = new ArrayList();
CountryList.Add("境内");
CountryList.Add("境外");
this.Country.DataSource = CountryList;
this.Country.DataBind();
}
public void datalist()
{
string cmd;
cmd = "SELECT StudentInfo.Name,UserInfo.Address,UserInfo.NickName,UserInfo.PostNum, UserInfo.Sex, UserInfo.Tele, UserInfo.MobilePh, UserInfo.QQ, UserInfo.Email, UserInfo.PicName FROM StudentInfo INNER JOIN UserInfo ON StudentInfo.StudentID = UserInfo.StudentID where UserID='" + Session["UserID"].ToString() + "'";
;//设置SQL命令
//}
this.SqlDataSource1.SelectCommand = cmd;
this.SqlDataSource1.DataBind(); //将SqlDataSource重新绑定
this.DataList1.DataBind();
}
protected void Page_Load(object sender, EventArgs e)
{
if (Session["UserID"] == null)
Response.Redirect("index.aspx");
//////if ( other != "")
//////{
// cmd = " SELECT [UserID], [Email], [Tele], [MobilePh], [PicName], [QQ], [StudentID] FROM [UserInfo] where " + field + "='" + condition + "' or" + other + "='" + condition + "'"; ;//设置SQL命令
//}
//else
//{
//SELECT StudentInfo.Name, UserInfo.Sex, UserInfo.Tele, UserInfo.MobilePh, UserInfo.QQ, UserInfo.Email FROM StudentInfo INNER JOIN UserInfo ON StudentInfo.StudentID = UserInfo.StudentID
////接收参数
//string sortid = this.Request.QueryString["sortid"];
//string sType = this.Request.QueryString["sType"];
//strcity = Request.Form["hideCity"];
//strpro = Request.Form["Hiddenpro"];
//// this.City.Value = strcity;
////判断参数是否为空(注意:空有两种形式,一种为null,一种为空)
//if (sortid + "a" != "a")
//{
// //如果有传递上述参数,则表示联动操作开始
// this.xmlBind(sortid, sType);
//}
//// this.Country.Text = "qrwrwer";
// this.City. = "sdjfl";
if (!this.IsPostBack)
{
Databind();
datalist();
//// this.xmlBind("110000", "2");
//this.DownBind1();
//this.DownBind2();
// this.DownBind3();
this.Binder();
this.SetCountry();
this.SetTime();
// day(this.Mounth.SelectedValue, Convert.ToInt16(this.Year.SelectedValue));
ImgList();
}
//if (!IsPostBack)
//{
this.Mounth.Attributes.Add("onchange", "CallMounthSel(this,Year)");
this.Year.Attributes.Add("onchange", "CallYearSel(Mounth,this)");
this.Figure.Attributes.Add("onchange", "ImageSel(Figure)");
}
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)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -