*****************************************************************************************
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using InfoPlat.Components;
using System.Web.Configuration;
using System.Data.SqlClient;
using System.Configuration;
public AddAbsence()
{
Page.Init += new System.EventHandler(Page_Init);
}
private void Page_Load(object sender, System.EventArgs e)
{
L_tname.Text = Request.Cookies["InfoPlat_UserNo"].Value;
String command = "select chname from course,opencourse where course.id=opencourse.courseid and opencourse.teachername = "+"'"+L_tname.Text+"'";
DataSet myDataset = pubsql.sql(command);
for(int i = 0 ;i<myDataset.Tables[0].Rows.Count;i++)
{
D_tCourse.Items.Add(myDataset.Tables[0].Rows[i].ItemArray.GetValue(0).ToString());
}
///////////////////////////////////////////////
command = "select classtime from opencourse where teachername = "+"'"+L_tname.Text+"'"+" and opencourse.courseid = (select id from course where course.chname = "+"'"+D_tCourse.SelectedItem.Text+"'"+")";
myDataset.Reset();
myDataset = pubsql.sql(command);
for (int i= 0 ;i<myDataset.Tables[0].Rows.Count;i++)
{
string [] split=myDataset.Tables[0].Rows[i].ItemArray.GetValue(0).ToString().Split(new Char [] {' '});
for(int j= 0; j<split.Length;j++)
{
D_tCoursetime.Items.Add(split[j]);
}
}
////////////////////////////////////////
command = "select term from opencourse,course where opencourse.teachername = "+"'"+L_tname.Text+"'"+" and course.id=opencourse.courseid and course.chname = "+"'"+D_tCourse.SelectedItem.Text+"'";
myDataset.Reset();
myDataset = pubsql.sql(command);
for (int i= 0 ;i<myDataset.Tables[0].Rows.Count;i++)
{
string [] split=myDataset.Tables[0].Rows[i].ItemArray.GetValue(0).ToString().Split(new Char [] {' '});
for(int j= 0; j<split.Length;j++)
{
D_tTerm.Items.Add(split[j]);
}
}
/////////////////////////////////////////
command = "select stuno as '学号',student.chname as '姓名',sex as '性别',student.grade as '年级' from student,stuselcourse,opencourse,course where stuselcourse.stuid=student.id and stuselcourse.opencourseid=opencourse.id and opencourse.teachername = "+"'"+L_tname.Text+"'"+" and course.chname="+"'"+D_tCourse.SelectedItem.Text+"'"+" and opencourse.term="+"'"+D_tTerm.SelectedItem.Text+"'"+" and course.id=opencourse.courseid order by student.stuno";
myDataset.Reset();
try
{
myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
SqlCommand sqlcommand = new SqlCommand(command,myConnection);
SqlDataAdapter sqlAdapter = new SqlDataAdapter(sqlcommand);
sqlAdapter.Fill(myDataset,"selstudent");
DataGrid1.DataSource=myDataset.Tables["selstudent"];
DataGrid1.DataBind();
}
catch
{
Console.Write("asdasd");
}
}
private void Page_Init(object sender, EventArgs e) {
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
}
#region Web Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
this.D_tWeek.SelectedIndexChanged += new System.EventHandler(this.D_tWeek_SelectedIndexChanged);
this.Load += new System.EventHandler(this.Page_Load);