📄 find_cl3.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.Configuration;
using System.Data.SqlClient;
namespace ClassOnline
{
/// <summary>
/// Find_cl3 的摘要说明。
/// </summary>
public class Find_cl3 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label lblNoCl;
protected System.Web.UI.WebControls.DataGrid dgdCl;
protected System.Web.UI.WebControls.TextBox txtClname;
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
protected System.Web.UI.WebControls.TextBox txtGrad;
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator2;
protected System.Web.UI.WebControls.RangeValidator RangeValidator1;
protected System.Web.UI.WebControls.Button btnNext;
string strSQL,strUrl;
int i;
SqlConnection objconn;
SqlDataAdapter da;
DataSet ds;
SqlCommand objcmd;
SqlDataReader dr;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if(Session.Count==0) Page.Response.Redirect("default.aspx");
else
if(Session["UserID"].ToString()=="") Page.Response.Redirect("default.aspx");
objconn=new SqlConnection(ConfigurationSettings.AppSettings["connstr"]);
objconn.Open();
strSQL="select CID,CName,Cgrad,Cnum,CManager1,CManager2,CType from ClassInfo where CSID="+Page.Request["SID"].ToString();
da=new SqlDataAdapter(strSQL,objconn);
ds=new DataSet();
da.Fill(ds,"cl");
ds.Tables["cl"].Columns.Add("t_name");
ds.Tables["cl"].Columns.Add("m1");
ds.Tables["cl"].Columns.Add("m2");
/*Page.Response.Write("行数");
Page.Response.Write(ds.Tables["cl"].Rows.Count);
Page.Response.Write("<br>");*/
for(i=0;i<ds.Tables["cl"].Rows.Count;i++)
if(ds.Tables["cl"].Rows[i]["CType"].ToString()!="")
{
strSQL="select CTypeName from ClassType where CTypeID="+ds.Tables["cl"].Rows[i]["CType"].ToString();
objcmd=new SqlCommand(strSQL,objconn);
dr=objcmd.ExecuteReader();
while(dr.Read())
ds.Tables["cl"].Rows[i]["t_name"]=dr[0].ToString();
dr.Close();
objcmd.Dispose();
/*Page.Response.Write("添加类型");
Page.Response.Write(i);
Page.Response.Write("<br>");*/
}
for(i=0;i<ds.Tables["cl"].Rows.Count;i++)
{
if(ds.Tables["cl"].Rows[i]["CManager1"].ToString()!="")
{
strSQL="select UserName from UserInfo where UserID="+ds.Tables["cl"].Rows[i]["CManager1"].ToString();
objcmd=new SqlCommand(strSQL,objconn);
dr=objcmd.ExecuteReader();
while(dr.Read())
ds.Tables["cl"].Rows[i]["m1"]=dr[0].ToString();
dr.Close();
objcmd.Dispose();
/*Page.Response.Write("添加正");
Page.Response.Write(i);
Page.Response.Write("<br>");*/
}
}
for(i=0;i<ds.Tables["cl"].Rows.Count;i++)
{
if(ds.Tables["cl"].Rows[i]["CManager2"].ToString()!="")
{
strSQL="select UserName from UserInfo where UserID="+ds.Tables["cl"].Rows[i]["CManager2"].ToString();
objcmd=new SqlCommand(strSQL,objconn);
dr=objcmd.ExecuteReader();
while(dr.Read())
ds.Tables["cl"].Rows[i]["m2"]=dr[0].ToString();
dr.Close();
objcmd.Dispose();
/*Page.Response.Write("添加副");
Page.Response.Write(i);
Page.Response.Write("<br>");*/
}
}
dgdCl.DataSource=ds.Tables["Cl"].DefaultView;
dgdCl.DataBind();
da.Dispose();
objconn.Close();
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.btnNext.Click += new System.EventHandler(this.btnNext_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void btnNext_Click(object sender, System.EventArgs e)
{
string PID="";string CityID="";string CTypeID="";
objconn=new SqlConnection(ConfigurationSettings.AppSettings["connstr"]);
objconn.Open();
strSQL="select SProID,SCID,SType from School where SID="+Page.Request["SID"].ToString();
objcmd=new SqlCommand (strSQL,objconn);
dr=objcmd.ExecuteReader();
while(dr.Read())
{
PID=dr[0].ToString();CityID=dr[1].ToString();CTypeID=dr[2].ToString();
}
dr.Close();
objcmd.Dispose();
strSQL="Insert into classinfo(CName,CPID,CityID,CSID,CDelFlag,CManager1,CType,Cnum,Cgrad) Values('";
strSQL+=txtClname.Text+"',"+PID+","+CityID+","+Page.Request["SID"].ToString()+",0,"+Session["UserID"].ToString()+","+CTypeID+",1,"+txtGrad.Text.ToString()+")";
objcmd=new SqlCommand(strSQL,objconn);
objcmd.ExecuteNonQuery();
objcmd.Dispose();
strSQL="select CID from ClassInfo where CManager1="+Session["UserID"].ToString()+" ORDER BY CID DESC";
objcmd=new SqlCommand(strSQL,objconn);
dr=objcmd.ExecuteReader();
dr.Read();
strUrl="find_end.aspx?CID="+dr[0].ToString();
objconn.Close();
Page.Response.Redirect(strUrl);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -