📄 addevent.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>
/// addevent 的摘要说明。
/// </summary>
public class addevent : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label lblstu;
protected System.Web.UI.WebControls.RadioButtonList Rlsel;
protected System.Web.UI.WebControls.Button btnok;
protected System.Web.UI.WebControls.TextBox Edevent;
protected System.Web.UI.WebControls.Calendar Calendar1;
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.Request.QueryString.Count==0)
{
this.Response.Redirect("searchstu.aspx?geturl="+"addevent");
}
int stuid=Convert.ToInt32(this.Request.QueryString["stuid"]);
this.lblstu.Text=this.Request.QueryString["stuid"];
}
private void add_event()
{
try
{
FileStream xmlfilein;
xmlfilein=new FileStream(Server.MapPath(datafile_stusum),FileMode.Open,FileAccess.Read,FileShare.ReadWrite);
DataSet ds=new DataSet();
ds.ReadXml(xmlfilein,XmlReadMode.ReadSchema);
xmlfilein.Close();
int count=ds.Tables["summain"].Rows.Count;
int stuid=Convert.ToInt32(this.Request.QueryString["stuid"]);
for (int i=0;i<count;i++)
{
if (Convert.ToInt32(ds.Tables["summain"].Rows[i]["stuid"])==stuid)
{
DataRow newrow;
if (this.Rlsel.SelectedValue=="prace")
{
newrow=ds.Tables["prace"].NewRow();
}
else
{
newrow=ds.Tables["mistake"].NewRow();
}
newrow["date"]=this.Calendar1.SelectedDate;
newrow["event"]=this.Edevent.Text;
if (this.Rlsel.SelectedValue=="prace")
{
ds.Tables["prace"].Rows.Add(newrow);
newrow.SetParentRow(ds.Tables["summain"].Rows[i]);
}
else
{
ds.Tables["mistake"].Rows.Add(newrow);
newrow.SetParentRow(ds.Tables["summain"].Rows[i]);
}
break;
}
}
FileStream xmlfileout;
xmlfileout=new FileStream(Server.MapPath(datafile_stusum),FileMode.Open,FileAccess.Write,FileShare.ReadWrite);
ds.WriteXml(xmlfileout,XmlWriteMode.WriteSchema);
xmlfileout.Close();
}
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.btnok.Click += new System.EventHandler(this.btnok_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void btnok_Click(object sender, System.EventArgs e)
{
this.add_event();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -