📄 searchstu.aspx.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Xml;
namespace stuman
{
/// <summary>
/// searchstu 的摘要说明。
/// </summary>
public class searchstu : System.Web.UI.Page
{
protected System.Web.UI.WebControls.RadioButtonList Rlsel;
protected System.Web.UI.WebControls.Button btnok1;
protected System.Web.UI.WebControls.Button btnok2;
protected System.Web.UI.WebControls.Button btnok3;
protected System.Web.UI.HtmlControls.HtmlGenericControl selstuid;
protected System.Web.UI.HtmlControls.HtmlGenericControl sel;
protected System.Web.UI.HtmlControls.HtmlGenericControl selmethod;
protected System.Web.UI.HtmlControls.HtmlGenericControl selname;
protected System.Web.UI.WebControls.TextBox Edstuid;
protected System.Web.UI.WebControls.TextBox Edname;
protected System.Web.UI.WebControls.ListBox ListBox1;
private string datafile_stumain="stumain.xml";
private string datafile_stusrc="stusrc.xml";
private string datafile_stusum="stusum.xml";
private void Page_Load(object sender, System.EventArgs e)
{
if (!this.IsPostBack)
{
if (this.Request.QueryString.Count>=1)
{
Session["url"]=this.Request.QueryString["geturl"]+".aspx";
}
else
{
Session["url"]="searchstu.aspx";
}
this.selmethod.Visible=true;
this.selstuid.Visible=false;
this.selname.Visible=false;
this.sel.Visible=false;
}
}
private void geturl_stuid()
{
try
{
string url=(string)Session["url"];
string geturl=url+"?stuid="+this.Edstuid.Text;
this.Response.Redirect(geturl);
}
catch (Exception ex)
{
this.Response.Write(ex.ToString());
}
}
private void geturl_name()
{
try
{
FileStream xmlfile;
xmlfile=new FileStream(Server.MapPath(datafile_stumain),FileMode.Open,FileAccess.Read,FileShare.ReadWrite);
DataSet ds=new DataSet();
ds.ReadXml(xmlfile,XmlReadMode.ReadSchema);
xmlfile.Close();
int count=ds.Tables["stu"].Rows.Count;
string name=this.Edname.Text;
for (int i=0;i<count;i++)
{
if (Convert.ToString(ds.Tables["stu"].Rows[i]["name"])==name)
{
DataRelation rel=ds.Tables["stu"].ParentRelations[0];
string sdate=Convert.ToString(Convert.ToDateTime(ds.Tables["stu"].Rows[i].GetParentRow(rel)["schooldate"]).Year);
string sclass=Convert.ToString(ds.Tables["stu"].Rows[i].GetParentRow(rel)["class"]);
ListItem newitem=new ListItem(name+" "+sdate+"级"+sclass+"班",Convert.ToString(ds.Tables["stu"].Rows[i]["stuid"]));
this.ListBox1.Items.Add(newitem);
}
}
}
catch (Exception ex)
{
this.Response.Write(ex.ToString());
}
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Rlsel.SelectedIndexChanged += new System.EventHandler(this.Rlsel_SelectedIndexChanged);
this.btnok1.Click += new System.EventHandler(this.btnok1_Click);
this.btnok2.Click += new System.EventHandler(this.btnok2_Click);
this.btnok3.Click += new System.EventHandler(this.btnok3_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void Rlsel_SelectedIndexChanged(object sender, System.EventArgs e)
{
if (this.Rlsel.SelectedValue=="stuid")
{
this.selmethod.Visible=false;
this.selstuid.Visible=true;
this.selname.Visible=false;
this.sel.Visible=false;
}
else
{
this.selmethod.Visible=false;
this.selstuid.Visible=false;
this.selname.Visible=true;
this.sel.Visible=false;
}
}
private void btnok1_Click(object sender, System.EventArgs e)
{
this.geturl_stuid();
}
private void btnok2_Click(object sender, System.EventArgs e)
{
this.geturl_name();
this.selmethod.Visible=false;
this.selstuid.Visible=false;
this.selname.Visible=false;
this.sel.Visible=true;
}
private void btnok3_Click(object sender, System.EventArgs e)
{
string url=(string)Session["url"]+"?stuid="+this.ListBox1.SelectedValue;
this.Response.Redirect(url);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -