实验三:学生工作管理系统asp和asp.cs代码

1 篇文章 0 订阅
1 篇文章 0 订阅

 

<%@Page Language="C#"AutoEventWireup="true"CodeFile="Login.aspx.cs"Inherits="Login" %>
 
<%@ Registerassembly="Microsoft.ReportViewer.WebForms,Version=11.0.0.0, Culture=neutral,PublicKeyToken=89845dcd8080cc91"namespace="Microsoft.Reporting.WebForms"tagprefix="rsweb" %>
<%@ Registerassembly="System.Web.DataVisualization,Version=4.0.0.0, Culture=neutral,PublicKeyToken=31bf3856ad364e35"namespace="System.Web.UI.DataVisualization.Charting"tagprefix="asp" %>
 
<!DOCTYPEhtml>
 
<htmlxmlns="http://www.w3.org/1999/xhtml"style="background-position:right bottom;background-image:url('http://localhost:53299/image/bluesky.jpg');background-repeat:no-repeat;background-attachment:fixed;">
<headrunat="server" >
    <title>教学管理系统入口</title>
    <styletype="text/css" >
        #dengruyemian {
            height: 250px;
            margin-top: 0px;
            width: 310px;
            margin-left: 257px;
            margin-right: 374px;
            margin-bottom: 0px;
        }
    </style>
</head>
 <bodystyle="margin-left:270px;margin-top:0px; margin-bottom:310px; height: 220px;" >
     <form id="DengRuYeMian" runat="server"   >
    <divstyle="margin-left:50px;margin-top:50px;height:136px">
                       <spanstyle="font-size:80pt;font-family:隶书;color:#FFFFFF;">
                       教学管理系统</span>
                      
                     
        </div>
         <pstyle="margin-left:270px;height:31px;margin-top: 200px">
             <asp:DropDownListID="xiaLAxuanding"runat="server" Height="31px" BackColor="#3333FF"style="margin-left:83px"Font-Names="新体"ForeColor="White" >
             <asp:ListItemValue="学生">学生</asp:ListItem>
             <asp:ListItemValue="老师">老师</asp:ListItem>
             <asp:ListItemValue="管理员">管理员</asp:ListItem>
                       </asp:DropDownList>  
             <asp:LinkButtonID="LinkButton1" runat="server" Font-Names="幼圆"ForeColor="#CCFFFF"OnClick="LinkButton1_Click">联系管理员</asp:LinkButton> 
         <asp:LabelID="YouXiang" runat="server" ForeColor="White"></asp:Label>
 
         </p>
                
     <pstyle="margin-left:270px;height:31px;margin-top: 0px">
            
       <spanstyle="font-size:17pt;font-family:圆体;color:#FFFFFF;font-weight: bold;"> 用户名</span>
        <asp:TextBoxID="Textmz" runat="server" Width="120px"  ></asp:TextBox>
         <asp:RequiredFieldValidatorID="RequiredFieldValidator1"runat="server" ErrorMessage="!!不可为空"Font-Bold="True" Font-Names="仿宋"ForeColor="Red" ControlToValidate="Textmz" ValidationGroup="zu1"></asp:RequiredFieldValidator>
           
    </p>
        <pstyle="margin-left:270px;height:31px;margin-top: 0px">
           
        <spanstyle="font-size:17pt;font-family:圆体;color:#FFFFFF;font-weight: bold;"> 密  码</span>
            <asp:TextBoxID="Textmm" runat="server" TextMode="Password"Width="120px" ></asp:TextBox>
             <asp:RequiredFieldValidatorID="RequiredFieldValidator2"runat="server" ErrorMessage="!!不可为空"Font-Bold="True" Font-Names="仿宋"ForeColor="Red" ControlToValidate="Textmm" ValidationGroup="zu1"></asp:RequiredFieldValidator>
            </p>
         <pstyle="margin-left:270px;height:31px;margin-top: 0px">
            <asp:ButtonID="Button1" runat="server" Text="登入"Width="46px" OnClick="ButtonDengRu_click" ValidationGroup="zu1" />
             <asp:LabelID="CWTS" runat="server"  ForeColor="#CC0000"></asp:Label>
            </p>
    </form>
    </body>
</html>

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
public partialclass Login : System.Web.UI.Page
{
    
 protected void Page_Load(object sender, EventArgs e)
{
   Textmz.Focus();//打开页面,把【输入光标】定位到用户名这个【文本框】中
    
}
 protected void LinkButton1_Click(object sender, EventArgs e)
 {
     string answer = "邮箱:xujiayu317@outlook.com";
    YouXiang.Text = answer;
 }
 
 protected void ButtonDengRu_click(object sender, EventArgs e)
 {
     //接受界面输入
     string DRM = Textmz.Text.Trim();//登入名
     string YHMM = Textmm.Text.Trim();//用户密码
     string YHJS = xiaLAxuanding.Text.Trim();//用户角色
     string SELECSTR = "";
     switch (YHJS)
     {
         case "学生":
            SELECSTR = "Select密码,姓名 from学生信息 where学号='" + DRM +"'";
             break;
         case "老师":
            SELECSTR = "Select密码,姓名 from老师信息 where教师编号='" + DRM +"'";
             break;
         case "管理员":
            SELECSTR = "Select密码,登入名 from管理员 where登入名='" + DRM +"'";
             break;
     } 
     SqlConnection LIANJIE=newSqlConnection(ConfigurationManager.ConnectionStrings["SJKLJ"].ConnectionString);
     SqlCommand MINGLING =new SqlCommand(SELECSTR,LIANJIE);
     try
     {
        LIANJIE.Open();
         SqlDataReader CHAXUNJIEGUO = MINGLING.ExecuteReader();//运行一条语句,此处是查询语句并给查询结果
         if (CHAXUNJIEGUO.Read())//从结果中读取一条记录
         {
             if (CHAXUNJIEGUO.GetString(0) == YHMM)
            {
                CWTS.Text = "正在连接服务器,请稍候";
            Session["userNumb"] = DRM;
            Session["userRole"] =YHJS;
            Session["userName"]=CHAXUNJIEGUO.GetString(1);
            LIANJIE.Close();
             switch (YHJS)
            {
                case"学生":
                    Response.Redirect("studentMAIN.aspx");
                    break;
                case "老师":
                    Response.Redirect("teacherMAIN.aspx");
                    break;
                case "管理员":
                    Response.Redirect("MAIN.aspx");
                    break;
            }
             }
             else
            {
                CWTS.Text = "用户名或密码错误!!";
            }
         }
         else
         {
            CWTS.Text = "用户名不存在!!";
         }
     }
     catch (Exception ee) {Response.Write("<script>alert('"+ ee.Message.ToString() +"')</script>"); }//这里在次看的时候发现我写成了修改alter
     finally { LIANJIE.Close(); }
 }
 
}

<%@ PageLanguage="C#" AutoEventWireup="true" CodeFile="studentMAIN.aspx.cs" Inherits="studentMAIN" %>
 
<%@ RegisterAssembly="Microsoft.ReportViewer.WebForms,Version=11.0.0.0, Culture=neutral,PublicKeyToken=89845dcd8080cc91"Namespace="Microsoft.Reporting.WebForms"TagPrefix="rsweb" %>
 
<!DOCTYPEhtml>
 
<htmlxmlns="http://www.w3.org/1999/xhtml"style="background-image:url('image/bluesky.jpg');background-repeat:no-repeat">
<headrunat="server">
    <title>学生信息页面</title> 
    <styletype="text/css">
        #form1 {
            height: 144px;
            margin-left: 0px;
            margin-right:770px;
            margin-top:40px;
            width: 1078px;
        }
        
        .auto-style2 {
            height: 95px;
        }
        .auto-style4 {
            height: 95px;
            width: 1051px;
        }
        .auto-style5 {
            height: 44px;
            width: 1051px;
        }
        .auto-style6 {
            height: 22px;
        }
        </style>  
</head> 
<body> 
    <formid="form1" runat="server" >  
    <spanstyle=" margin:70px 20px 0px 100px;font-family: 幼圆;font-size:60px;color: #FFFFFF;  ">亲爱的</span>
        <asp:LabelID="Label2" runat="server" ForeColor="#FFCC00"Font-Size="XX-Large"></asp:Label>
        <asp:ButtonID="Button4" runat="server" Text="退出系统"OnClick="Button4_Click"/>
        <p><spanstyle="margin:100px 0px 0px 600px;font-family: 幼圆;font-size:60px;color: #FFFFFF;  ">你好!</span></p>
        
        <table>
            <tr><tdclass="auto-style6"><div>           
                         <asp:LabelID="Label4" runat="server" ForeColor="Red"></asp:Label>
 
                    </div>
               </td>
            </tr>
            <tr>
              <tdclass="auto-style4">
                <asp:PanelID="Panel1" runat="server" style="margin-left:116px;margin-top: 0px"Width="822px" Height="183px" >
                    
                 <asp:MenuID="caidan" runat="server" ForeColor="White"Height="1px" OnMenuItemClick="caidan_Click" StaticSelectedStyle-ForeColor="#CCFFFF" style="text-align:center">
                    <Items>
                         <asp:MenuItemSelected="True" Text="个人信息"Value="学生信息视图"></asp:MenuItem>
                         <asp:MenuItemText="班级信息"Value="班级信息视图"></asp:MenuItem>
                        <asp:MenuItemText="学生成绩"Value="学生成绩视图"></asp:MenuItem>
                         <asp:MenuItem Text="课程表"Value="学生课表视图"></asp:MenuItem>
                         <asp:MenuItemText="选课"Value="开课信息视图"></asp:MenuItem>
                    </Items>
                    <StaticMenuItemStyleFont-Bold="False" Font-Names="黑体"Font-Overline="False"Font-Size="Larger"Font-Underline="False"ForeColor="White" Height="30px" ItemSpacing="10px"/>
                  </asp:Menu> 
                   
                     <asp:GridViewID="ST" runat="server" ForeColor="White"GridLines="Horizontal"Height="100px" ShowHeaderWhenEmpty="True" style="margin-left:119px; text-align:center;"Width="686px">
                         <Columns>
                            <asp:TemplateFieldHeaderText="选修/不选">
                                 <ItemTemplate>
                                     <asp:RadioButtonID="RadioButton1" runat="server" GroupName="e"ToolTip="选"ValidationGroup="确定选修"/>
                                     <asp:RadioButtonID="RadioButton2" runat="server" Checked="True"GroupName="e" ToolTip="不选"ValidationGroup="确定选修"/>
                                 </ItemTemplate>
                             </asp:TemplateField>
                         </Columns>
                         <RowStyleHeight="30px" Width="200px" />
                    </asp:GridView>
              </asp:Panel></td>
             <tdclass="auto-style2"> 
                <asp:PanelID="Panel2" runat="server" Height="91px" Width="288px" style="margin-left:32px;margin-right: 0px"Visible="False">  
                 <p><span style="color:#00FFFF">旧密码     </span><asp:TextBoxID="TextBox1" runat="server" TextMode="Password"ValidationGroup="修改密码"></asp:TextBox><asp:RequiredFieldValidatorID="RequiredFieldValidator3"runat="server" ErrorMessage="必填"ValidationGroup="修改密码"ControlToValidate="TextBox1"ForeColor="#FF3300"></asp:RequiredFieldValidator></p>
                 <p><span style="color:#00FFFF">新密码     </span><asp:TextBoxID="TextBox2" runat="server" TextMode="Password"ValidationGroup="修改密码"></asp:TextBox><asp:RequiredFieldValidatorID="RequiredFieldValidator2"runat="server" ErrorMessage="必填"ValidationGroup="修改密码"ControlToValidate="TextBox2"ForeColor="#FF3300"></asp:RequiredFieldValidator></p>
                 <p><span style="color:#00FFFF">新密码确认</span><asp:TextBoxID="TextBox3" runat="server" TextMode="Password"ValidationGroup="修改密码"></asp:TextBox><asp:RequiredFieldValidatorID="RequiredFieldValidator1"runat="server" ErrorMessage="必填"ValidationGroup="修改密码"ControlToValidate="TextBox3"ForeColor="#FF3300"></asp:RequiredFieldValidator></p>
                </asp:Panel>
                 <p>  <asp:ButtonID="Button1" runat="server" Height="29px"OnClick="Button1_Click"style="margin-left:32px;margin-top: 17px"Text="修改密码"ValidationGroup="修改密码"Width="88px" Visible="False" /></p>
             </td>
       </tr>
       <tr>
           <tdclass="auto-style5">
              <asp:PanelID="Panel3" runat="server" style="margin-left:257px"Visible="False" Width="428px">
              <asp:ButtonID="Button2" runat="server"  Text="确定选修"ValidationGroup="确定选修"Width="95px" OnClick="Button2_Click" />
                  <asp:LabelID="Label3" runat="server" ForeColor="Red"Text=""></asp:Label>
              <asp:ButtonID="Button3" runat="server"  Text="已选课程"Width="91px" Height="27px" OnClick="Button3_Click"/>
              </asp:Panel>
           </td>
       </tr> 
 </table> 
       
</form>  
</body> 
</html>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
public partialclass studentMAIN : System.Web.UI.Page
{
    bool nengxuankema = false;
    protected void Page_Load(object sender, EventArgs e)
    {
         if ((string)Session["userRole"] !="学生")
           Response.Redirect("Login.aspx");
   Label2.Text= Session["userName"]+" 这里是"+Session["userRole" ]+"管理系统" ;
    SqlConnection cnn =new SqlConnection(ConfigurationManager.ConnectionStrings["SJKLJ"].ConnectionString);
    SqlCommand cmd = cnn.CreateCommand();
   cnn.Open();
   cmd.CommandText = "select 提示信息,起始时间,结束时间 from 开课时间表 where项目='2'";
    SqlDataReader readd = cmd.ExecuteReader();
   readd.Read();
    if (readd.GetString(0) == "是")
    {
       nengxuankema = true;
       Label4.Text = "选课时间从" +readd.GetDateTime(1) +"到" + readd.GetDateTime(2);
    }
    else {  nengxuankema = false; Label4.Text = "当前不是选课时间"; }
       cnn.Close();
    }  
    protected void caidan_Click(object sender, MenuEventArgs e)
    { 
       string tempstr=" ";
       if (caidan.SelectedValue =="学生信息视图") Button1.Visible =true;
       else
       {
          Button1.Visible = false;
          Panel2.Visible = false;
          Button1.Text = "修改密码";
       }
       if (caidan.SelectedValue !="开课信息视图")
       {
          Panel3.Visible = false;
          ST.Columns[0].Visible = false;
           if (caidan.SelectedValue =="班级信息视图")
              tempstr = " where班级编号=(Select班级编号 from学生信息 where学号='" + Session["userNumb"].ToString() +"')";
           else
              tempstr = " where学号=" + Session["userNumb"].ToString();
       }
       else
       {
           if (nengxuankema==true)
           {
              tempstr = " A where NOT EXISTS(select *from课程表 B where A.课程编号=B.课程编号)";
               ST.Columns[0].Visible = true;
              Panel3.Visible = true;
              Button2.Visible = true;
              Button3.Text = "已选课程";
              Label3.Text = "";
           }
           else {  return; }
         
       }
       string SELECTR= "SELECT * from " +caidan.SelectedValue+tempstr;
       SqlConnection conn =new SqlConnection(ConfigurationManager.ConnectionStrings["SJKLJ"].ConnectionString);
      conn.Open();
       SqlDataAdapter SJJSPQ =new SqlDataAdapter();//数据集适配器
      SJJSPQ.SelectCommand= new SqlCommand(SELECTR,conn);
       DataSet SJJ = new DataSet();//数据集
      SJJSPQ.Fill(SJJ);//通过适配器对象的Fill方法将数据填充到数据集中
      conn.Close();
      ST.DataSource = SJJ;
      ST.DataBind();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (Button1.Text == "修改密码")
        {
           Panel2.Visible = true;
           Button1.Text = "确认修改";
           TextBox1.Focus();
        }
        else if (Button1.Text == "确认修改")
        {
            bool judge = false;
            string jiumm = TextBox1.Text.Trim();
            string xinmm = TextBox2.Text.Trim();
            string again = TextBox3.Text.Trim();
            string tishi = "";
            if (xinmm != again) tishi ="新密码不一致";
            else if (xinmm.Length >16||xinmm.Length<4) tishi = "新密码长度超过16或小于4个字符";
            else
            {
               string SELE = "select* from 学生信息  where学号='"+Session["userNumb"]+"'";
               SqlConnection con =new SqlConnection(ConfigurationManager.ConnectionStrings["SJKLJ"].ConnectionString); 
               SqlDataAdapter SP =new SqlDataAdapter();
               con.Open();
               SP.SelectCommand = newSqlCommand(SELE, con);
               DataSet GETs =new DataSet();
               SP.Fill(GETs);
               DataRow ROW =GETs.Tables[0].Rows[0];
               if (ROW["密码"].ToString() == jiumm)
               {
                        judge = true;
                        DataRow mrow = GETs.Tables[0].Rows[0];
                        SqlCommandBuilder scb =new SqlCommandBuilder(SP);/*缺了这个会报错:当传递具有已修改行的DataRow集合时,更新要求有效的UpdateCommand*/
                        mrow["密码"] = xinmm;
                        SP.Update(GETs);
                        tishi = "密码修改成功";
               }
               else { tishi = "密码错误,请重新输入"; }
               con.Close();
            }
            Response.Write("<script language=javascript>alert('" + tishi.ToString() +"')</script>");
            if (judge)
            {
              
               Panel2.Visible = false;
               Button1.Text = "修改密码";
               Response.Redirect("Login.aspx");
            }
           
        }
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
       Label3.Text = "";
        string strrr = "";
        if (Button3.Text == "已选课程")
        {
           ST.Columns[0].Visible = false;
           Button2.Visible = false;
           Button3.Text = "返回选课";
           strrr = "SELECT 开课信息视图.* from 开课信息视图,选课表 where开课信息视图.课程编号=选课表.课程编号 and 选课表.学号='"+Session["userNumb"].ToString()+"'";
            
        }
        else
        {
           ST.Columns[0].Visible = true;
           Button2.Visible = true;
           Button3.Text = "已选课程";
           strrr = "SELECT * from开课信息视图 A where NOTEXISTS(select * from课程表 B where A.课程编号=B.课程编号)";
        }
        SqlConnection cnn =new SqlConnection(ConfigurationManager.ConnectionStrings["SJKLJ"].ConnectionString);
       cnn.Open();
        SqlDataAdapter SJSPQ =new SqlDataAdapter();
       SJSPQ.SelectCommand = new SqlCommand(strrr, cnn);
        DataSet SJJ = new DataSet();
       SJSPQ.Fill(SJJ);
       cnn.Close();
       ST.DataSource = SJJ;
       ST.DataBind();
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        string studentid = Session["userNumb"].ToString();
        int courseid;
        SqlConnection cnn=newSqlConnection(ConfigurationManager.ConnectionStrings["SJKLJ"].ConnectionString);
        SqlCommand cmd=cnn.CreateCommand();
       cnn.Open();
        for (int i = 0; i < ST.Rows.Count; i++)
        {
            int.TryParse(ST.Rows[i].Cells[1].Text,out courseid);
            if (((RadioButton)ST.Rows[i].FindControl("RadioButton1")).Checked ==false)
            {
               cmd.CommandText = "delete from 选课表 where学号='" + studentid +"' and 课程编号=" + courseid;
               cmd.ExecuteNonQuery();
            }
            else
            {
               cmd.CommandText = "select COUNT(课程编号) from选课表 where学号='" + studentid +"' and 课程编号=" + courseid;
               if ((Int32)cmd.ExecuteScalar()==0)
               {
                   cmd.CommandText = "insert into  选课表(学号,课程编号) values('" + studentid + "' ," + courseid+")";
                   cmd.ExecuteNonQuery();
               }
            }
        }
       cnn.Close();
       Label3.Text = "操作成功!!详情请查看☞";
    }
 
    protected void Button4_Click(object sender, EventArgs e)
    {
       Response.Redirect("Login.aspx");
    }
}


<%@ PageLanguage="C#" AutoEventWireup="true" CodeFile="teacherMAIN.aspx.cs" Inherits="teacherMAIN" %>
 
<!DOCTYPEhtml>
 
<htmlxmlns="http://www.w3.org/1999/xhtml"style="background-image:url('image/bluesky.jpg');background-repeat:no-repeat">
<headrunat="server">
    <title>教师信息页面</title> 
    <styletype="text/css">
        #form1 {
            height: 135px;
            margin-left: 50px;
            margin-right:0px;
            margin-top:40px; 
        }
        .auto-style1 {
            width: 939px;
        }
        .auto-style2 {
            width: 939px;
            height: 63px;
        }
    </style>  
</head> 
<body> 
    <formid="form1" runat="server" >   
    <spanstyle=" margin:70px 20px 0px 100px;font-family: 幼圆;font-size:60px;color: #FFFFFF;  ">亲爱的</span>
        <asp:LabelID="Label2" runat="server" ForeColor="#FFCC00"Font-Size="XX-Large"></asp:Label>
        <asp:ButtonID="Button8" runat="server" Text="退出系统"Width="64px" BorderStyle="None" OnClick="Button8_Click" />
        <p><spanstyle="margin:100px 0px 0px 600px;font-family: 幼圆;font-size:60px;color: #FFFFFF;  ">你好!</span></p>
        <table> 
            <tr><td><asp:PanelID="Panel4" runat="server" Height="27px"style="margin-left:117px"Width="813px">
                      
                    <asp:LabelID="Label6" runat="server" ForeColor="#FF3300"></asp:Label></asp:Panel>
             </td>
            </tr>
            <tr>
              <tdclass="auto-style1">
         
             <asp:PanelID="Panel1" runat="server" style="margin-left:116px;margin-top: 0px"Width="934px" Height="213px" >
                <asp:MenuID="caidan" runat="server" ForeColor="White"Height="1px" OnMenuItemClick="caidan_Click" StaticSelectedStyle-ForeColor="#CCFFFF" style="text-align:center">
                    <Items>
                         <asp:MenuItemSelected="True" Text="个人信息"Value="老师信息视图"></asp:MenuItem>
                         <asp:MenuItemText="班级信息"Value="班级信息视图"></asp:MenuItem>
                         <asp:MenuItemText="学生成绩"Value="学生成绩视图"></asp:MenuItem>
                         <asp:MenuItemText="任课信息"Value="老师课表视图"></asp:MenuItem>
                         <asp:MenuItemText="开课信息"Value="老师开课信息视图"></asp:MenuItem>  
                    </Items>
                    <StaticMenuItemStyleFont-Bold="False" Font-Names="黑体"Font-Overline="False"Font-Size="Larger"Font-Underline="False"ForeColor="White" Height="30px" ItemSpacing="10px"/>
                    <StaticSelectedStyleBorderColor="#6600FF"Font-Italic="False"Font-Size="Large" ForeColor="#CCFFFF" />
                </asp:Menu>
                <asp:PanelID="Panel5" runat="server" style="margin-left:132px"Visible="False">
                    <asp:DropDownListID="DropDownList2"runat="server" DataSourceID="SqlDataSource2" DataTextField="课程名称"DataValueField="课程编号"OnSelectedIndexChanged="DropDownList2_SelectedIndexChanged"Width="134px">
                    </asp:DropDownList>
                    <asp:SqlDataSourceID="SqlDataSource2"runat="server"   ConnectionString="<%$ ConnectionStrings:SJKLJ%>" SelectCommand="SELECT [课程编号],[课程名称]FROM [课程信息]WHERE ([教师编号]= @教师编号)">
                         <SelectParameters>
                             <asp:SessionParameterDefaultValue="" Name="教师编号"SessionField="userNumb"Type="String" />
                         </SelectParameters>
                    </asp:SqlDataSource>
                    <asp:ButtonID="Button6" runat="server" Text="查询"OnClick="Button6_Click"/>
                    <asp:ButtonID="Button4" runat="server" OnClick="Button4_Click"style="margin-left:6px"Text="录入成绩"ValidationGroup="成绩录入"Width="90px" />
                    <asp:ButtonID="Button5" runat="server" Text="查询平均成绩"ValidationGroup="查询平均成绩"OnClick="Button5_Click"/>
                    <asp:LabelID="Label4" runat="server" Text=""ForeColor="White"></asp:Label>
                </asp:Panel>
                <asp:GridViewID="ST" runat="server" ForeColor="White"GridLines="Horizontal"Height="100px" ShowHeaderWhenEmpty="True" style="margin-left:119px;margin-top: 0px; text-align:center;"Width="692px">
                
                    <Columns>
                         <asp:TemplateFieldHeaderText="待录成绩">
                             <ItemTemplate>
                                 <asp:TextBoxID="TextBox7" runat="server" ValidationGroup="成绩录入"></asp:TextBox>
                             </ItemTemplate>
                         </asp:TemplateField>
                          <asp:TemplateFieldHeaderText="已选人数" >
                             <ItemTemplate>
                                 <asp:LabelID="Label1" runat="server" Text=""></asp:Label>
                             </ItemTemplate>
                         </asp:TemplateField> 
                    </Columns>
                
                    <RowStyleHeight="30px" Width="200px" />
                </asp:GridView>
                 
             </asp:Panel> 
                   </td>
             <tdclass="auto-style2"> 
                <asp:PanelID="Panel2" runat="server" Height="91px" Width="288px" style="margin-left:32px;margin-right: 0px"Visible="False">  
                 <p><span style="color:#00FFFF">旧密码     </span><asp:TextBoxID="TextBox1" runat="server" TextMode="Password"ValidationGroup="修改密码"></asp:TextBox><asp:RequiredFieldValidatorID="RequiredFieldValidator3"runat="server" ErrorMessage="必填"ValidationGroup="修改密码"ControlToValidate="TextBox1"ForeColor="#FF3300"></asp:RequiredFieldValidator></p>
                 <p><span style="color:#00FFFF">新密码     </span><asp:TextBoxID="TextBox2" runat="server" TextMode="Password"ValidationGroup="修改密码"></asp:TextBox><asp:RequiredFieldValidatorID="RequiredFieldValidator2"runat="server" ErrorMessage="必填"ValidationGroup="修改密码"ControlToValidate="TextBox2"ForeColor="#FF3300"></asp:RequiredFieldValidator></p>
                 <p><span style="color:#00FFFF">新密码确认</span><asp:TextBoxID="TextBox3" runat="server" TextMode="Password"ValidationGroup="修改密码"></asp:TextBox><asp:RequiredFieldValidatorID="RequiredFieldValidator1"runat="server" ErrorMessage="必填"ValidationGroup="修改密码"ControlToValidate="TextBox3"ForeColor="#FF3300"></asp:RequiredFieldValidator></p>
                </asp:Panel>
                 <p>  <asp:ButtonID="Button1" runat="server" Height="29px"OnClick="Button1_Click"style="margin-left:32px;margin-top: 17px"Text="修改密码"ValidationGroup="修改密码"Width="88px" Visible="False" /></p>
             </td>
       </tr>
       <tr>
           
           <tdclass="auto-style2">
              <asp:PanelID="Panel3" runat="server" Height="195px"style="margin-left:179px"Width="797px" Visible="False">
                  <spanstyle="margin:70px 20px 0px 20px;font-family: 幼圆;color:#FFFFFF;  ">院系</span>
                  <spanstyle="margin:70px 20px 0px 80px;font-family: 幼圆;color:#FFFFFF;  ">课程名称(*必填)</span>
                  <spanstyle="margin:70px 20px 0px 0px;font-family: 幼圆;color:#FFFFFF;  ">学分(<6)</span>
                  <spanstyle="margin:70px 20px 0px 0px;font-family: 幼圆;color:#FFFFFF;  ">人数(>0)</span>
                  <asp:LabelID="Label3" runat="server" ForeColor="#FF99FF"></asp:Label><br/> 
                  <asp:DropDownListID="DropDownList1"runat="server" Height="18px" Width="144px"ValidationGroup="开课录入"DataSourceID="SqlDataSource1"DataTextField="系名"DataValueField="院系编号">
                  </asp:DropDownList>
                  <asp:SqlDataSourceID="SqlDataSource1"runat="server"   ConnectionString="<%$ ConnectionStrings:SJKLJ%>" SelectCommand="SELECT * FROM [院系表]"></asp:SqlDataSource>
                  <asp:TextBoxID="TextBox5" runat="server" Width="135px"ValidationGroup="开课录入"></asp:TextBox>
                  <asp:TextBoxID="TextBox6" runat="server" style="margin-left:41px"Width="30px" ValidationGroup="开课录入"></asp:TextBox>
                  <asp:TextBoxID="TextBox4" runat="server" style="margin-left:83px"Width="29px" ValidationGroup="开课录入"></asp:TextBox>
                     
                  <asp:ButtonID="Button3" runat="server" OnClick="Button3_Click"Text="预定开课"ValidationGroup="开课录入"Width="72px" />
                   <asp:ButtonID="Button7" runat="server" OnClick="Button7_Click"Text="查询已选课人数"Width="120px" />
                  <div>
                       <spanstyle="font-family:幼圆;color:#FFFFFF;  ">    课程编号<br/> </span>
                   <asp:TextBoxID="TextBox8" runat="server" style="margin-bottom:0px"ValidationGroup="修改开课信息"Width="81px"></asp:TextBox>
                  <asp:ButtonID="Button9" runat="server" Text="修改开课信息"Width="122px" OnClick="Button9_Click" ValidationGroup="修改开课信息"/>
                 
                  <asp:LabelID="Label5" runat="server" Text=""></asp:Label>
                  </div>
                </asp:Panel>
           </td>
       </tr>
 </table> 
         </form>
</body> 
</html>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
public partialclass teacherMAIN : System.Web.UI.Page
{
    bool nengkaikema = false;
    protected void Page_Load(object sender, EventArgs e)
    {
        if ((string)Session["userRole"] !="老师")
           Response.Redirect("Login.aspx");
       Label2.Text = Session["userName"] +"  这里是" + Session["userRole"] +"管理系统";
        SqlConnection cnn =new SqlConnection(ConfigurationManager.ConnectionStrings["SJKLJ"].ConnectionString);
        SqlCommand cmd = cnn.CreateCommand();
       cnn.Open();
       cmd.CommandText = "select提示信息,起始时间,结束时间 from 开课时间表 where项目='1'";
        SqlDataReader readd = cmd.ExecuteReader();
       readd.Read();
        if (readd.GetString(0) =="是")
        {
            nengkaikema = true;
           Label6.Text = "开课时间从" +readd.GetDateTime(1) +"到" + readd.GetDateTime(2);
        }
        else { nengkaikema = false;Label6.Text = "当前不是开课时间"; }
       cnn.Close();
    }
    protected void caidan_Click(object sender, MenuEventArgs e)
    {
        string tempstr = "SELECT * from " + caidan.SelectedValue;
       Panel3.Visible = false;
       ST.Columns[0].Visible = false;
       Panel5.Visible = false;
       ST.Columns[1].Visible = false;
        if (caidan.SelectedValue =="老师信息视图")
        {
           Button1.Visible = true;
           tempstr = tempstr + " where 教师编号='" + Session["userNumb"].ToString()+"'";
        }
        else
        {
           Button1.Visible = false;
           Panel2.Visible = false;
            Button1.Text = "修改密码";
            if (caidan.SelectedValue =="老师课表视图")
            {tempstr = tempstr + " where 教师编号='" + Session["userNumb"].ToString()+"'"; }
            else if (caidan.SelectedValue == "班级信息视图")
               tempstr = tempstr + " A where EXISTS(Select *from 班级信息 B where A.班级编号=B.班级编号 and B.教师编号='" + Session["userNumb"].ToString() +"')";
            else if (caidan.SelectedValue == "老师开课信息视图")
            {
                
               if (nengkaikema ==true)
                {
                   tempstr = tempstr + " A where NOTEXISTS(select * from 课程表 B where A.课程编号=B.课程编号) and A.教师编号='" + Session["userNumb"].ToString() +"'";
                   Panel3.Visible = true;
                   Button7.Text = "查询已选课人数";
                }
               else { return; }
 
            }
            else if (caidan.SelectedValue == "学生成绩视图")
            {
               Panel5.Visible = true;
            }
        }
        SqlConnection conn =new SqlConnection(ConfigurationManager.ConnectionStrings["SJKLJ"].ConnectionString);
       conn.Open();
        SqlDataAdapter SJJSPQ =new SqlDataAdapter();//数据集适配器
       SJJSPQ.SelectCommand = newSqlCommand(tempstr, conn);
        DataSet SJJ = new DataSet();//数据集
       SJJSPQ.Fill(SJJ);//通过适配器对象的Fill方法将数据填充到数据集中
       conn.Close();
       ST.DataSource = SJJ;
       ST.DataBind();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (Button1.Text == "修改密码")
        {
           Panel2.Visible = true;
           Button1.Text = "确认修改";
           TextBox1.Focus();
        }
        else if (Button1.Text == "确认修改")
        {
            bool judge = false;
            string jiumm = TextBox1.Text.Trim();
            string xinmm = TextBox2.Text.Trim();
            string again = TextBox3.Text.Trim();
            string tishi = "";
            if (xinmm != again) tishi ="新密码不一致";
            else if (xinmm.Length > 16 ||xinmm.Length < 4) tishi = "新密码长度超过16或小于4个字符";
            else
            {
               string SELE = "select* from 老师信息  where教师编号=" + Session["userNumb"];
               SqlConnection con =new SqlConnection(ConfigurationManager.ConnectionStrings["SJKLJ"].ConnectionString);
               SqlDataAdapter SP =new SqlDataAdapter();
               con.Open();
               SP.SelectCommand = newSqlCommand(SELE, con);
               DataSet GETs =new DataSet();
               SP.Fill(GETs);
               DataRow ROW =GETs.Tables[0].Rows[0];
               if (ROW["密码"].ToString() == jiumm)
               {
                   judge = true;
                   DataRow mrow =GETs.Tables[0].Rows[0];
                   mrow["密码"] =xinmm;
                   SqlCommandBuilder scb =new SqlCommandBuilder(SP);/*缺了这个会报错:当传递具有已修改行的DataRow集合时,更新要求有效的UpdateCommand*/
                   SP.Update(GETs);
                   tishi = "密码修改成功";
               }
               else { tishi = "密码错误"; }
               con.Close();
            }
           Response.Write("<scriptlanguage=javascript>alert('" + tishi.ToString()+"')</script>");
            if (judge)
            {
 
               Panel2.Visible = false;
               Button1.Text = "修改密码";
               Response.Redirect("Login.aspx");
            }
 
        }
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        string coursename = TextBox5.Text.Trim();
        int score=0;
        int num = 0;
        int.TryParse(TextBox6.Text.ToString(),out score);
        int.TryParse(TextBox4.Text.ToString(),out num);
        /*这个和int.Parse的区别是【int.Parse参数null会报错否则返回参数整型】而【int.TryParse会给默认值0,并返回是否有错bool  true/false】
         Convert.ToInt32 与 int.Parse较为类似,实际上 Convert.ToInt32内部调用了 int.Parse:
         Convert.ToInt32 参数为 null时,返回 0;   int.Parse参数为 null 时,抛出异常。
          Convert.ToInt32参数为 ""时,抛出异常;   int.Parse参数为 "" 时,抛出异常。
         Convert.ToInt32 可以转换的类型较多;  int.Parse只能转换数字类型的字符串quote by baidu*/
        if (coursename!=""&&score< 6 && score >= 0 && num >0)
        {
            string INSER = "insert into 课程信息(课程名称,教师编号,院系编号,学分,人数)   values('";
           INSER = INSER + coursename + "','" + Session["userNumb"] + "'," +DropDownList1.SelectedValue.ToString() + "," + score + "," + num +")";
            SqlConnection cnn =new SqlConnection(ConfigurationManager.ConnectionStrings["SJKLJ"].ConnectionString);
            SqlCommand cmmd =new SqlCommand(INSER, cnn);
           cnn.Open();
            int judg = cmmd.ExecuteNonQuery();
           cnn.Close();
           caidan_Click(null, null);
            if (judg == 1) Label3.Text ="ε=ε=(ノ≧∇≦)ノ课程成功录入";
          
        }
        else
        {
           Label3.Text = "输入有误,请重新输入";
        }
    }
    protected void Button4_Click(object sender, EventArgs e)
    {
        if (Button4.Text == "录入成绩")
        {
           ST.Columns[0].Visible = true;
           Button4.Text = "录入";
        }
        else
        {
           
            int score=0;
            string stuID="";
            string courseID="";
            int countnumber = 0;
            SqlConnection conn =new SqlConnection(ConfigurationManager.ConnectionStrings["SJKLJ"].ConnectionString);
            SqlCommand cmd = conn.CreateCommand();
           conn.Open();
            for (int i = 0; i < ST.Rows.Count; i++)
            {
               courseID = ST.Rows[i].Cells[6].Text.ToString();
               score = int.Parse(((TextBox)ST.Rows[i].FindControl("TextBox7")).Text.ToString());/*取出学生成绩*/
               stuID = ST.Rows[i].Cells[4].Text.ToString();
               cmd.CommandText = "update  成绩表 set成绩=" + score +" where 成绩编号='" + stuID +"' and 课程编号=" + courseID;
               countnumber += cmd.ExecuteNonQuery();
            }
           conn.Close();
           caidan_Click(null, null);
           Label4.Text = "成功插入" +countnumber +"个学生的成绩";
           ST.Columns[0].Visible = false;
           Button4.Text = "录入成绩";
        }
      
    }
    protected void DropDownList2_SelectedIndexChanged(object sender,EventArgs e)
    {
        
    }
    protected void Button6_Click(object sender, EventArgs e)
    {
        string tempstr = "SELECT * from " + caidan.SelectedValue + "  where  课程编号=" + DropDownList2.SelectedValue.ToString();
        SqlConnection conn =new SqlConnection(ConfigurationManager.ConnectionStrings["SJKLJ"].ConnectionString);
       conn.Open();
        SqlDataAdapter SJJSPQ =new SqlDataAdapter();//数据集适配器
       SJJSPQ.SelectCommand = newSqlCommand(tempstr, conn);
        DataSet SJJ = new DataSet();//数据集
       SJJSPQ.Fill(SJJ);//通过适配器对象的Fill方法将数据填充到数据集中
       conn.Close();
       ST.DataSource = SJJ;
       ST.DataBind();
    }
    protected void Button5_Click(object sender, EventArgs e)
    {
        int ssum = 0;
        int i=0;
        for (; i < ST.Rows.Count; i++)
        {
           ssum += int.Parse(ST.Rows[i].Cells[7].Text.ToString());//取出学生成绩
        }
        if(i!=0)
       ssum/=i;
       Label4.Text = DropDownList2.SelectedItem.ToString() + "平均成绩是:" + ssum;
    }
    protected void Button8_Click(object sender, EventArgs e)
    {
       Response.Redirect("Login.aspx");
    }
    protected void Button7_Click(object sender, EventArgs e)
    {
        if (Button7.Text == "查询已选课人数")
        {
           Button7.Text ="取消已选课人数列";
            int courseid;
            SqlConnection cnn =new SqlConnection(ConfigurationManager.ConnectionStrings["SJKLJ"].ConnectionString);
            SqlCommand cmmd = cnn.CreateCommand();
            cnn.Open();
            for (int i = 0; i < ST.Rows.Count; i++)
            {
               int.TryParse(ST.Rows[i].Cells[3].Text,out courseid);
               cmmd.CommandText = "select COUNT(学号) from选课表 where课程编号=" + courseid;
               ST.Rows[i].Cells[1].Text = cmmd.ExecuteScalar().ToString();/*获取第一条第一个值返回其字符串形式*/
            }
           cnn.Close();
           Label3.Text = "查询已报人数成功";
           ST.Columns[1].Visible = true;
        }
        else
        {
           ST.Columns[1].Visible = false;
           Button7.Text = "查询已选课人数";
        }
    }
    protected void Button9_Click(object sender, EventArgs e)
    {
 
        string coursename = TextBox5.Text.Trim();
        int score = 0;
        int num = 0;
        int courseid = 0;
        int.TryParse(TextBox6.Text.ToString(),out score);
        int.TryParse(TextBox4.Text.ToString(),out num);
        int.TryParse(TextBox8.Text.ToString(),out courseid);
        /*这个和int.Parse的区别是【int.Parse参数null会报错否则返回参数整型】而【int.TryParse会给默认值0,并返回是否有错bool  true/false】
         Convert.ToInt32 与 int.Parse较为类似,实际上 Convert.ToInt32内部调用了 int.Parse:
         Convert.ToInt32 参数为 null时,返回 0;   int.Parse参数为 null 时,抛出异常。
         Convert.ToInt32 参数为 ""时,抛出异常;  int.Parse参数为 "" 时,抛出异常。
          Convert.ToInt32 可以转换的类型较多;  int.Parse只能转换数字类型的字符串quote by baidu*/
        if (coursename != ""&& score < 6 && score >= 0 && num>0&&courseid>0)
        {
            string UPUPUP = "update 课程信息   set课程名称='";
           UPUPUP = UPUPUP + coursename + "',院系编号=" + DropDownList1.SelectedValue.ToString() +",学分=" + score +", 人数=" + num +" where 课程编号="+courseid;
            SqlConnection cnn =new SqlConnection(ConfigurationManager.ConnectionStrings["SJKLJ"].ConnectionString);
            SqlCommand cmmd =new SqlCommand(UPUPUP, cnn);
           cnn.Open();
            int judg = cmmd.ExecuteNonQuery();
           cnn.Close();
            if (judg == 1)
            {
               Label3.Text = "更新成功";
                caidan_Click(null,null);
            }
            else Label3.Text = "更新失败或不存在";
          
        }
        else
        {
           Label5.Text = "输入有误,请重新输入";
        }
    }
}


<%@ PageLanguage="C#" AutoEventWireup="true" CodeFile="MAIN.aspx.cs" Inherits="MAIN" %>
 
<%@ RegisterAssembly="Microsoft.ReportViewer.WebForms,Version=11.0.0.0, Culture=neutral,PublicKeyToken=89845dcd8080cc91"Namespace="Microsoft.Reporting.WebForms"TagPrefix="rsweb" %>
 
<!DOCTYPEhtml>
 
<htmlxmlns="http://www.w3.org/1999/xhtml"style=" background-image:url('http://localhost:53299/image/bluesky.jpg');background-repeat:no-repeat;background-attachment:fixed;">
<headrunat="server">
    <title>管理员页面</title>
    <styletype="text/css">
         .auto-style6 {
            width: 1042px;
        }
        .auto-style7 {
            width: 1437px;
        }
        .auto-style13 {
            width: 164px;
        }
        .auto-style14 {
            width: 295px;
        }
        .auto-style15 {
            width: 229px;
        }
        .auto-style16 {
            width: 327px;
            text-align: center;
        }
        .auto-style17 {
            text-align: center;
        }
        .auto-style18 {
            width: 397px;
        }
        </style>
</head>
<body>
    <formid="form1" runat="server">
    <divstyle="height:57px;width: 1021px; margin-left:609px;">
        <spanstyle="font-size:60px;color: #FFFFFF; left:300px;"> 管理员平台</span>
        <asp:ButtonID="Button1" runat="server" Text="退出系统"OnClick="Button1_Click"/>
    </div>
         <tableclass="auto-style7">
       
             <tr><tdclass="auto-style15"><asp:TreeViewID="TreeView1" runat="server" ForeColor="White" OnSelectedNodeChanged="TreeView1_SelectedNodeChanged1"Height="255px" Width="140px"  >
            <Nodes>
               <asp:TreeNodeText="角色信息"Value="9">
                   <asp:TreeNodeText="学生信息"Value="0"></asp:TreeNode>
                    <asp:TreeNodeText="老师信息"Value="1"></asp:TreeNode>
                   <asp:TreeNodeText="管理员信息"Value="2"></asp:TreeNode>
               </asp:TreeNode>
               <asp:TreeNodeText="开课选课"Value="9">
                   <asp:TreeNodeText="开课时间设定"Value="3"></asp:TreeNode>
                   <asp:TreeNodeText="选课时间设定"Value="3"></asp:TreeNode>
                   <asp:TreeNodeText="课程录入取舍"Value="4"></asp:TreeNode>
                   <asp:TreeNodeText="选课情况查询"Value="10"></asp:TreeNode>
               </asp:TreeNode>
               <asp:TreeNodeText="院系调整"Value="5"></asp:TreeNode>
               <asp:TreeNodeText="班级信息"Value="6"></asp:TreeNode>
               <asp:TreeNodeText="课程维护"Value="7"></asp:TreeNode>
                <asp:TreeNodeText="成绩查询"Value="8"></asp:TreeNode>
            </Nodes>
            </asp:TreeView> 
             </td>
        <tdclass="auto-style6">
            <asp:MultiViewID="MultiView1" runat="server">
               <asp:ViewID="View1" runat="server"> 
                   <table >
                        <tr>
                            <tdclass="auto-style13">
                                <asp:PanelID="Panel6" runat="server" Height="48px">
                              <asp:DropDownListID="DropDownList11"runat="server" DataSourceID="SqlDataSource4" DataTextField="系名"DataValueField="院系编号"Height="20px">
                                </asp:DropDownList>
                                <asp:SqlDataSourceID="SqlDataSource4"runat="server" ConnectionString="<%$ConnectionStrings:SJKLJ%>" SelectCommand="SELECT * FROM [院系表]"></asp:SqlDataSource>
                                <asp:ButtonID="Button6" runat="server" Text="查询"style="margin-top:7px"Width="61px" OnClick="Button6_Click" /> </asp:Panel>
                            </td>
                            <tdclass="auto-style14"> 
                                 <asp:LabelID="Label4" runat="server" Font-Size="X-Large"ForeColor="#66FFFF"Text=""></asp:Label>
                                 <asp:PanelID="Panel4" runat="server" Width="316px"Height="53px" style="margin-top:0px;margin-left: 1px;">
                                <asp:LabelID="Label3" runat="server" Text="Label"ForeColor="White"></asp:Label> 
                        <asp:TextBoxID="YongHuMing" runat="server" Width="90px"></asp:TextBox>
                                <asp:LabelID="Label5" runat="server" ForeColor="White"Text=""></asp:Label>
                        <spanstyle="color:#FFFFFF">
                                    <br/>
                                    密码:</span><asp:TextBoxID="MiMa" runat="server"></asp:TextBox>
                   </asp:Panel><asp:PanelID="Panel3" runat="server" Height="104px"style="margin-top:0px;margin-right: 0px;"Width="316px">
                        <spanstyle="color:#FFFFFF">姓名:</span><asp:TextBoxID="MingZi" runat="server" Width="107px"></asp:TextBox>
                        <spanstyle="color:#FFFFFF">
                                    <br/>
                                    身份证号:</span><asp:TextBoxID="TextBox4" runat="server" Width="189px"></asp:TextBox>
                                    <br/>
                        <asp:DropDownListID="sex" runat="server">
                            <asp:ListItemText="女">女</asp:ListItem>
                            <asp:ListItemText="男">男</asp:ListItem>
                        </asp:DropDownList>
                        <asp:DropDownListID="MinZu" runat="server" DataSourceID="SqlDataSource1"DataTextField="民族"DataValueField="民族编号">
                        </asp:DropDownList>
                                    <asp:SqlDataSourceID="SqlDataSource1"runat="server" ConnectionString="<%$ConnectionStrings:SJKLJ%>" SelectCommand="SELECT * FROM [民族编号表]"></asp:SqlDataSource>
                        <asp:DropDownListID="JiGuan" runat="server" DataSourceID="SqlDataSource2"DataTextField="籍贯"DataValueField="籍贯编号"  >
                        </asp:DropDownList> 
                                    <asp:SqlDataSourceID="SqlDataSource2"runat="server" ConnectionString="<%$ConnectionStrings:SJKLJ%>" SelectCommand="SELECT * FROM [籍贯编号表]"></asp:SqlDataSource>
                                    <br/>
                        <asp:DropDownListID="ZhengZhiMianMao"runat="server" DataSourceID="SqlDataSource3" DataTextField="政治面貌"DataValueField="政治面貌编号" >
                        </asp:DropDownList>
                                    <asp:SqlDataSourceID="SqlDataSource3"runat="server"  ConnectionString="<%$ ConnectionStrings:SJKLJ%>" SelectCommand="SELECT * FROM [政治面貌表]"></asp:SqlDataSource>
                                    <asp:DropDownListID="banji" runat="server" DataSourceID="SqlDataSource5"DataTextField="班级名称"DataValueField="班级编号" >
                                    </asp:DropDownList>
                                    <asp:SqlDataSourceID="SqlDataSource5"runat="server"   ConnectionString="<%$ ConnectionStrings:SJKLJ%>" SelectCommand="SELECT [班级编号],[班级名称]FROM [班级信息]"></asp:SqlDataSource>
                                    <br/>  </asp:Panel>
                        <asp:ButtonID="Button4" runat="server" Text="添加角色信息"OnClick="Button4_Click"/>
                                    <br/>
                                <asp:ButtonID="Button5" runat="server" Text="确认修改"OnClick="Button5_Click"/> 
                           </td>
                        </tr> 
                   </table>
                   <asp:GridViewID="GridView1" runat="server" Height="209px"Width="871px" ForeColor="White"   style="text-align:center;margin-top: 0px;" OnRowDeleting="GridView1_RowDeleting"  OnSelectedIndexChanged="GridView1_SelectedIndexChanged1"ShowHeaderWhenEmpty="True"       >
                      
                        <Columns>
                            <asp:CommandField  ShowDeleteButton="True"DeleteText="删除此行"ButtonType="Button"/>
                                
                            <asp:CommandFieldShowSelectButton="True"SelectText="选定更改"ButtonType="Button"/>
                                
                        </Columns>
                        <SelectedRowStyleForeColor="Aqua" />
                   </asp:GridView>
                   <br/>
                   
               </asp:View> <asp:ViewID="View2" runat="server">
                   <asp:LabelID="Label13" runat="server" ForeColor="#66FFFF"></asp:Label>
                   <asp:FormViewID="FormView2" runat="server" DataSourceID="SqlDataSource9"DefaultMode="Edit"ForeColor="White" Width="301px" OnItemUpdated="FormView2_ItemUpdated" DataKeyNames="课序号"AllowPaging="True">
                        <EditItemTemplate>
                            课序号:
                            <asp:LabelID="课序号Label1"runat="server" Text='<%# Eval("课序号") %>'/>
                             
                           <br/>上课时间天:
                            <asp:TextBoxID="上课时间天TextBox"runat="server" Text='<%# Bind("上课时间天") %>'Height="16px" Width="22px"></asp:TextBox>
                             <spanstyle="color:#FF0000">必填</span>
                                <br/>
                            上课时间节: <asp:TextBoxID="上课时间节TextBox"runat="server" Text='<%# Bind("上课时间节") %>'></asp:TextBox> 
                             <spanstyle="color:#FF0000">必填</span>
                            <br/>
                            上课地点:
                            <asp:TextBoxID="上课地点TextBox"runat="server" Text='<%# Bind("上课地点") %>'/>
                           <spanstyle="color:#FF0000">必填</span><br />
                            考试时间:
                            <asp:TextBoxID="考试时间TextBox"runat="server"   Text='<%# Bind("考试时间") %>'  />
                            <br/>
                            考试地点:
                            <asp:TextBoxID="考试地点TextBox"runat="server" Text='<%# Bind("考试地点") %>'/>
                            <br/>
                            <br/>
                            <asp:Button  ID="Button13UpdateButton"runat="server" CausesValidation="True" CommandName="Update" Text="更改"/>
                        </EditItemTemplate>
                        <PagerStyleFont-Bold="True" Font-Size="Large" ForeColor="Aqua" />
                   </asp:FormView>
                   <asp:ButtonID="GridView5_JinRuGengGaiButton13"runat="server" Text="显示更改页面"OnClick="GridView5_JinRuGengGaiButton13_Click"/>
                   <asp:GridViewID="GridView5" runat="server" AutoGenerateColumns="False"DataSourceID="SqlDataSource9"Height="143px" Width="740px" ForeColor="White" style="margin-right:31px">
                        <Columns>
                            <asp:BoundFieldDataField="课序号"HeaderText="课序号"InsertVisible="False"ReadOnly="True" SortExpression="课序号"/>
                            <asp:BoundFieldDataField="课程名称"HeaderText="课程名称"SortExpression="课程名称"/>
                            <asp:BoundFieldDataField="上课时间天"HeaderText="上课时间天"SortExpression="上课时间天"/>
                            <asp:BoundFieldDataField="上课时间节"HeaderText="上课时间节"SortExpression="上课时间节"/>
                            <asp:BoundFieldDataField="上课地点"HeaderText="上课地点"SortExpression="上课地点"/>
                            <asp:BoundFieldDataField="考试时间"HeaderText="考试时间"SortExpression="考试时间"/>
                            <asp:BoundFieldDataField="考试地点"HeaderText="考试地点"SortExpression="考试地点"/>
                            <asp:BoundFieldDataField="教师编号"HeaderText="教师编号"SortExpression="教师编号"/>
                            <asp:BoundFieldDataField="姓名"HeaderText="姓名"SortExpression="姓名"/>
                        </Columns>
                   </asp:GridView>
                   <asp:SqlDataSourceID="SqlDataSource9"runat="server"  ConnectionString="<%$ ConnectionStrings:SJKLJ%>"
                         SelectCommand="SELECT课程表.课序号,课程信息.课程名称,课程表.上课时间天,课程表.上课时间节,课程表.上课地点,课程表.考试时间,课程表.考试地点,老师信息.教师编号,老师信息.姓名FROM课程表INNER JOIN 课程信息ON 课程表.课程编号=课程信息.课程编号INNER JOIN老师信息ON 课程信息.教师编号=老师信息.教师编号"
                        UpdateCommand="UPDATE课程表SET上课时间天= @上课时间天,上课时间节= @上课时间节,上课地点= @上课地点,考试时间= @考试时间,考试地点= @考试地点WHERE (课序号= @课序号)">
                   </asp:SqlDataSource>
                </asp:View>
               <asp:ViewID="View3" runat="server"> 
                   <tablestyle="width:100%;"><tr>
                            <tdclass="auto-style18"> <asp:DropDownListID="课程名称1DropDownList16"runat="server" DataSourceID="SqlDataSource10" DataTextField="课程名称"DataValueField="课程名称"></asp:DropDownList>
                   <asp:SqlDataSourceID="SqlDataSource10"runat="server"  ConnectionString="<%$ ConnectionStrings:SJKLJ%>" SelectCommand="SELECT DISTINCT课程名称FROM 课程信息"></asp:SqlDataSource>
                   <asp:ButtonID="Button14" runat="server" Text="按课程名查询"OnClick="Button14_Click"/>
                                <asp:LabelID="Label14" runat="server" Text=""></asp:Label>
                            </td>
                            <td> 
                                <asp:LabelID="Label15" runat="server" ForeColor="#66FFFF"Text=""></asp:Label>
                            </td>
                            <td> </td>
                        </tr>
                        <tr>
                            <tdclass="auto-style18"><asp:GridViewID="GridView6" runat="server" ForeColor="White">
                   </asp:GridView></td>
                            <td>
                                <asp:ChartID="Chart1" runat="server" Palette="BrightPastel"imagetype="Png"  BackSecondaryColor="White" BackGradientStyle="HorizontalCenter" BorderWidth="2" backcolor="#D3DFF0"BorderColor="26, 59, 105">
                                    <Titles>
                                    <asp:TitleFont="微软雅黑,16pt"Name="Title1" Text="分数分布统计表"></asp:Title>
                                    </Titles>
                        <Series>
                            <asp:SeriesName="Series1" ChartType="Bubble" MarkerSize="8" MarkerStyle="Circle">
                            </asp:Series>
                        </Series>
                         <ChartAreas>
                             <asp:ChartAreaName="ChartArea1" BorderColor="64, 64, 64, 64" BackSecondaryColor="Transparent" BackColor="64, 165, 191, 228" ShadowColor="Transparent" BackGradientStyle="TopBottom" Area3DStyle-LightStyle="Realistic" >
                             </asp:ChartArea>
                        </ChartAreas>
                                    <BorderSkinSkinStyle="Sunken"/>
                    </asp:Chart></td>
                            <td> </td>
                        </tr>
                        <tr>
                            <tdclass="auto-style18"> </td>
                            <td> </td>
                            <td> </td>
                        </tr>
                   </table>
               </asp:View>
               <asp:ViewID="View4" runat="server"><asp:PanelID="Panel1" runat="server" Height="125px"style="margin-left:152px;margin-top: 0px"Width="795px">
                  <divstyle="height:62px;width: 498px; margin-left:213px"><asp:LabelID="Label2" runat="server" ForeColor="Aqua"Font-Size="XX-Large"></asp:Label></div>
                   <br/>
                    
                        <asp:LabelID="Label1" runat="server" ForeColor="White"></asp:Label><spanstyle="color:#FFFFFF">时间从</span><asp:DropDownListID="DropDownList1"runat="server" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"AutoPostBack="True">
                            <asp:ListItem>2015</asp:ListItem>
                            <asp:ListItem>2016</asp:ListItem>
                            <asp:ListItem>2017</asp:ListItem>
                            <asp:ListItem>2018</asp:ListItem>
                            <asp:ListItem>2019</asp:ListItem>
                        </asp:DropDownList>
                     <spanstyle="color:#FFFFFF">年</span><asp:DropDownListID="DropDownList2"runat="server" OnSelectedIndexChanged="DropDownList2_SelectedIndexChanged"AutoPostBack="True">
                            <asp:ListItem>1</asp:ListItem>
                            <asp:ListItem>2</asp:ListItem>
                            <asp:ListItem>3</asp:ListItem>
                            <asp:ListItem>4</asp:ListItem>
                            <asp:ListItem>5</asp:ListItem>
                            <asp:ListItem>6</asp:ListItem>
                           <asp:ListItem>7</asp:ListItem>
                            <asp:ListItem>8</asp:ListItem>
                            <asp:ListItem>9</asp:ListItem>
                            <asp:ListItem>10</asp:ListItem>
                            <asp:ListItem>11</asp:ListItem>
                            <asp:ListItem>12</asp:ListItem>
                        </asp:DropDownList>
                      <spanstyle="color:#FFFFFF">月</span><asp:DropDownListID="DropDownList3"runat="server"  ></asp:DropDownList>
                      <spanstyle="color:#FFFFFF">日</span><asp:DropDownListID="DropDownList4"runat="server" > </asp:DropDownList>
                      <spanstyle="color:#FFFFFF">时</span><asp:DropDownListID="DropDownList5"runat="server" ></asp:DropDownList>
                      <spanstyle="color:#FFFFFF">分<br/>       到</span><asp:DropDownListID="DropDownList6"runat="server" OnSelectedIndexChanged="DropDownList6_SelectedIndexChanged"AutoPostBack="True"></asp:DropDownList>
                      <spanstyle="color:#FFFFFF">年</span><asp:DropDownListID="DropDownList7"runat="server" OnSelectedIndexChanged="DropDownList6_SelectedIndexChanged"AutoPostBack="True"><asp:ListItem>1</asp:ListItem>
                            <asp:ListItem>2</asp:ListItem>
                            <asp:ListItem>3</asp:ListItem>
                            <asp:ListItem>4</asp:ListItem>
                            <asp:ListItem>5</asp:ListItem>
                            <asp:ListItem>6</asp:ListItem>
                            <asp:ListItem>7</asp:ListItem>
                            <asp:ListItem>8</asp:ListItem>
                            <asp:ListItem>9</asp:ListItem>
                            <asp:ListItem>10</asp:ListItem>
                            <asp:ListItem>11</asp:ListItem>
                            <asp:ListItem>12</asp:ListItem></asp:DropDownList>
                      <spanstyle="color:#FFFFFF">月</span><asp:DropDownListID="DropDownList8"runat="server"></asp:DropDownList>
                      <spanstyle="color:#FFFFFF">日</span><asp:DropDownListID="DropDownList9"runat="server">  </asp:DropDownList>
                      <spanstyle="color:#FFFFFF">时</span><asp:DropDownListID="DropDownList10"runat="server"></asp:DropDownList>
                   <spanstyle="color:#FFFFFF">分</span>
                        <asp:ButtonID="Button2" runat="server" Text="确认开课时间"OnClick="Button2_Click" />
                        <asp:ButtonID="Button3" runat="server" Text="终止开课"OnClick="Button3_Click"/>
                   </asp:Panel></asp:View>
               <asp:ViewID="View5" runat="server"><asp:PanelID="Panel2" runat="server" Height="134px">
                    <asp:ButtonID="Button7" runat="server" Text="人数达标录入课程和学生"Width="186px" OnClick="Button7_Click" />
                   <asp:ButtonID="Button8" runat="server" Text="不符合要求删除"OnClick="Button8_Click"/><asp:LabelID="Label6" runat="server" Text=" "ForeColor="Red"></asp:Label>
                   <asp:GridViewID="GridView2" runat="server" ForeColor="White"Height="137px" style="text-align:center"Width="657px" ShowHeaderWhenEmpty="True">
                      
                        <Columns>
                            <asp:TemplateField HeaderText="已选人数">
                                <ItemTemplate>
                                    <asp:LabelID="Label7" runat="server" Text=""></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                   </asp:GridView>
                      </asp:Panel></asp:View>
               <asp:ViewID="View6" runat="server">
                   <tablestyle="width:64%;height: 105px;">
                        <tr>
                            <tdclass="auto-style16" > 
                                <asp:PanelID="Panel7" runat="server"><table>
                                <tr>
                                    <td><span style="color:#FFFFFF">系名</span></td>
                                    <td >
                                        <asp:TextBoxID="TextBox5" runat="server" Height="16px"Width="162px"></asp:TextBox>
                                    </td>
                                </tr><tr>
                                    <td> </td>
                                    <td>
                                        <asp:ButtonID="Button9" runat="server" Text="增加"OnClick="Button9_Click"/>
                                    </td>
                                </tr>
                            </table>
                                </asp:Panel>
                            </td>
                            <tdclass="auto-style17"><asp:LabelID="Label8" runat="server" ForeColor="White"style="text-align:left"></asp:Label>
                                <asp:PanelID="Panel8" runat="server">  <table >
                                <tr>
                                    <td><span style="color:#FFFFFF">系名</span></td>
                                    <td >
                                        <asp:TextBoxID="gaiT" runat="server" Height="16px"Width="162px"></asp:TextBox>
                                    </td>
                                </tr><tr>
                                   <td> </td>
                                    <td>
                                        <asp:ButtonID="gai" runat="server" Text="更改"ForeColor="#FF3300"OnClick="gai_Click"/>
                                        <asp:ButtonID="Button10" runat="server" Text="返回"OnClick="Button10_Click"/>
                                    </td>
                                </tr>
                            </table>
                                </asp:Panel>
                                </td>
                        </tr>
                   </table>
                   <asp:GridViewID="GridView3" runat="server" DataSourceID="SqlDataSource4"OnSelectedIndexChanged="GridView3SelectedChanger3"AllowPaging="True"AllowSorting="True"ForeColor="White" style="margin-left:132px"Width="481px">
                        <Columns>
                            <asp:CommandFieldShowSelectButton="True"ButtonType="Button"SelectText="选定"/>
                        </Columns>
                        <SelectedRowStyleForeColor="Red" />
                   </asp:GridView>
               </asp:View>
               <asp:ViewID="View7" runat="server"> <asp:LabelID="Label12" runat="server" Text=""Font-Size="XX-Large"ForeColor="Red"></asp:Label><asp:PanelID="Panel5" runat="server" Width="295px"style="margin-top:0px">
                   
                    
                   <tablestyle="width:143%;">
                                <tr>
                                    <tdstyle="color:#FFFFFF">班级编号</td>
                                    <td>
                                        <asp:LabelID="Label9" runat="server" ForeColor="White"></asp:Label>
                                    </td>
                                    <td> </td>
                                </tr>
                                 <tr>
                                    <tdstyle="color:#FFFFFF">班级人数</td>
                                    <td>
                                       <asp:LabelID="Label10" runat="server" ForeColor="White"Text=""></asp:Label>
                                    </td>
                                    <td>
                                     </td>
                                </tr>
                               <tr>
                                    <tdstyle="color:#FFFFFF">年级</td>
                                    <td>
                                        <asp:TextBoxID="TextBox6" runat="server"></asp:TextBox>
                                    </td>
                                    <td> </td>
                                </tr>
                                 <tr>
                                    <tdstyle="color:#FFFFFF">班级名称</td>
                                    <td>
                                        <asp:TextBoxID="TextBox1" runat="server"></asp:TextBox>
                                    </td>
                                    <td> </td>
                                </tr>
                                <tr>
                                    <tdstyle="color:#FFFFFF">辅导员</td>
                                    <td>
                                        <asp:DropDownListID="DropDownList13"runat="server" DataSourceID="SqlDataSource7" DataTextField="姓名"DataValueField="教师编号"OnSelectedIndexChanged="DropDownList13_SelectedIndexChanged" >
                                        </asp:DropDownList>
                                        <asp:LabelID="Label11" runat="server" ForeColor="White" ></asp:Label>
                                        <asp:SqlDataSourceID="SqlDataSource7"runat="server"   ConnectionString="<%$ ConnectionStrings:SJKLJ%>" SelectCommand="SELECT老师信息.教师编号+老师信息_1.姓名AS '姓名',老师信息_1.教师编号FROM老师信息INNER JOIN 老师信息AS 老师信息_1ON老师信息.教师编号=老师信息_1.教师编号"></asp:SqlDataSource>
                                    </td>
                                    <td> </td>
                                </tr>
                                <tr>
                                    <tdstyle="color:#FFFFFF">系名</td>
                                    <td>
                                        <asp:DropDownListID="DropDownList12"runat="server" DataSourceID="SqlDataSource4" DataTextField="系名"DataValueField="院系编号">
                                        </asp:DropDownList>
                                    </td>
                                    <td> </td>
                                </tr>
                                <tr>
                                    <td>
                                    </td>
                                    <td>
                                        <asp:ButtonID="Button11" runat="server" Text="确认修改"OnClick="Button11_Click"/>
                                    </td>
                                    <td>
                                        <asp:ButtonID="Button12" runat="server" Text="返回"OnClick="Button12_Click"/>
                                    </td>
                                </tr>
                            </table></asp:Panel> 
                                        <asp:FormViewID="FormView1" runat="server" DataKeyNames="班级编号" Height="144px" Width="236px" DefaultMode="Insert"ForeColor="White" DataSourceID="SqlDataSource8" OnItemInserted="FormView1_ItemInserted1" >
                                         
                                            <InsertItemTemplate>
                                               班级编号:
                                               <asp:TextBoxID="班级编号TextBox"runat="server" Text='<%# Bind("班级编号") %>'Height="16px" Width="80px" />
                                               <spanstyle="color:#FF3300">必填</span>
                                               <br/>
                                                年级:
                                               <asp:TextBoxID="年级TextBox"runat="server" Height="16px" Text='<%# Bind("年级") %>' Width="51px"/>
                                               <spanstyle="color:#FF3300">必填</span>
                                                <br/>
                                               班级名称:
                                               <asp:TextBoxID="班级名称TextBox"runat="server" Text='<%# Bind("班级名称") %>'/>
                                                <br/>
                                               班级人数: <asp:TextBoxID="班级人数TextBox2"runat="server" Text='<%# Bind("班级人数") %>'Height="16px" Width="40px"></asp:TextBox>
                                               <spanstyle="color:#FF3300">必填</span>
                                               <br/>
                                               教师编号:
                                               <asp:DropDownListID="DropDownList15"runat="server" DataSourceID="SqlDataSource7" DataTextField="姓名"DataValueField="教师编号"SelectedValue='<%# Bind("教师编号") %>'>
                                               </asp:DropDownList>
                                               <br/>
                                               院系编号:
                                               <asp:DropDownListID="DropDownList14"runat="server" DataSourceID="SqlDataSource4" DataTextField="系名"DataValueField="院系编号"SelectedValue='<%# Bind("院系编号") %>'Width="139px" >
                                                </asp:DropDownList>
                                               <br/>
                                               <asp:ButtonID="InsertButton" runat="server" CausesValidation="True"CommandName="Insert"Text="插入"   />
                                                  
                                            </InsertItemTemplate>
                                        </asp:FormView>
                   <asp:SqlDataSourceID="SqlDataSource8"runat="server"   ConnectionString="<%$ ConnectionStrings:SJKLJ%>" InsertCommand="INSERT INTO班级信息(班级编号,年级,班级名称,班级人数,教师编号,院系编号)VALUES (@班级编号,@年级,@班级名称,@班级人数,@教师编号,@院系编号)"  ></asp:SqlDataSource>
                   <asp:GridViewID="GridView4" runat="server" AutoGenerateColumns="False"DataKeyNames="班级编号"DataSourceID="SqlDataSource6"Height="210px" Width="715px" ForeColor="White"OnSelectedIndexChanged="GridView4SlectedChanged"AllowPaging="True">
                        <Columns>
                            <asp:BoundFieldDataField="班级编号"HeaderText="班级编号"ReadOnly="True" SortExpression="班级编号"/>
                            <asp:BoundFieldDataField="年级"HeaderText="年级"SortExpression="年级"/>
                            <asp:BoundFieldDataField="班级名称"HeaderText="班级名称"SortExpression="班级名称"/>
                            <asp:BoundFieldDataField="班级人数"HeaderText="班级人数"SortExpression="班级人数"/>
                            <asp:BoundFieldDataField="辅导员"HeaderText="辅导员"SortExpression="辅导员"/>
                           <asp:BoundFieldDataField="系名"HeaderText="系名"SortExpression="系名"/>
                            <asp:CommandFieldShowSelectButton="True"ButtonType="Button"SelectText="选定"/>
                        </Columns>
                        <SelectedRowStyleForeColor="#66FFFF"/>
                   </asp:GridView>
                   <asp:SqlDataSourceID="SqlDataSource6"runat="server"   ConnectionString="<%$ ConnectionStrings:SJKLJ%>" SelectCommand="SELECT * FROM [班级信息视图]"></asp:SqlDataSource>
                </asp:View>
               <asp:ViewID="View8" runat="server"></asp:View>
               <asp:ViewID="View9" runat="server">
                   <asp:DropDownListID="课程tDropDownList16"runat="server" DataSourceID="SqlDataSource10" DataTextField="课程名称"DataValueField="课程名称"></asp:DropDownList><asp:ButtonID="Button13" runat="server" Text="按课程查询"OnClick="Button13_Click"/>
                   <asp:DropDownListID="老师DropDownList17"runat="server" DataSourceID="SqlDataSource7" DataTextField="姓名"DataValueField="教师编号"></asp:DropDownList><asp:ButtonID="Button15" runat="server" Text="按老师查询"OnClick="Button15_Click"/>
                   <asp:DropDownListID="学生DropDownList16"runat="server" DataSourceID="SqlDataSource11" DataTextField="姓名"DataValueField="学号"></asp:DropDownList>
                   <asp:SqlDataSourceID="SqlDataSource11"runat="server"   ConnectionString="<%$ ConnectionStrings:SJKLJ%>" SelectCommand="SELECT学生信息_1.学号+学生信息_1.姓名AS '姓名',学生信息.学号FROM学生信息INNER JOIN 学生信息AS 学生信息_1ON学生信息.学号=学生信息_1.学号"></asp:SqlDataSource>
                   <asp:ButtonID="Button16" runat="server" Text="按学生查询"OnClick="Button16_Click"/>
                   <asp:GridViewID="GridView7" runat="server" ForeColor="White"AllowPaging="True"ShowHeaderWhenEmpty="True">
                   </asp:GridView>
               </asp:View>
               <asp:ViewID="View10" runat="server"></asp:View>
            </asp:MultiView>
        </td> 
             </tr>
</table>
    </form>  
</body>
</html>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;
using System.Drawing;
public partialclass MAIN : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if ((string)Session["userRole"] !="管理员")
           Response.Redirect("Login.aspx");
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
       Response.Redirect("Login.aspx");
    }
    protected void XinXiaLa(int i,int ccount,DropDownList D)
    {
        for (;i < ccount; )
        {
           i++;
           D.Items.Add(new ListItem(i.ToString(), i.ToString()));
        }
    }
    protected void YueDeTianShu(int yearr, int month,DropDownList DDL,int dday)
    {
        int dayss = 31;
        switch (month)
        {
            case 4:
            case 6:
            case 9:
            case 11: dayss = 30;
                break;
            case 2:
               {
                   if (yearr % 4 == 0 && yearr %100 != 0 || yearr % 400 == 0) dayss = 29;else dayss = 28;/*四年一闰百年不闰四百年再闰*/
                   break;
               }
        }
        if(dday!=dayss)
        {
           DDL.Items.Clear();
           XinXiaLa(0,dayss, DDL);
        }
    }
    protected void GridVeww1111(string Biao,string XinLie,string whereChan,GridView GGGGW)
    {
        SqlConnection LianJieChuan =new SqlConnection(ConfigurationManager.ConnectionStrings["SJKLJ"].ConnectionString);
        SqlDataAdapter ShiPeiQi =new SqlDataAdapter();
       ShiPeiQi.SelectCommand = LianJieChuan.CreateCommand();
       ShiPeiQi.SelectCommand.CommandText="SELECT"+XinLie+"FROM "+Biao+whereChan;
        DataSet ShuJuJi =new DataSet();
       LianJieChuan.Open();
       ShiPeiQi.Fill(ShuJuJi);
       LianJieChuan.Close();
       GGGGW.DataSource = ShuJuJi;
       GGGGW.DataBind();
    }
    protected void YIXUANRENSHU(GridView gw)
    {
        SqlConnection cnn =new SqlConnection(ConfigurationManager.ConnectionStrings["SJKLJ"].ConnectionString);
        SqlCommand cmd = cnn.CreateCommand();
       cnn.Open();
        for (int i = 0; i < gw.Rows.Count; i++)
        {
           cmd.CommandText = "select count(学号) from选课表 where选课表.课程编号="+gw.Rows[i].Cells[1].Text.ToString();
           ((Label)gw.Rows[i].FindControl("Label7")).Text=cmd.ExecuteScalar().ToString();
        }
       cnn.Close();
    }
    protected void TreeView1_SelectedNodeChanged1(object sender,EventArgs e)
    {
        int i=int.Parse(TreeView1.SelectedValue.ToString());
        if (i== 3)
        {
           MultiView1.ActiveViewIndex = i;
           Label2.Visible = false;
           DropDownList5.Items.Clear();
           DropDownList10.Items.Clear();
           DropDownList4.Items.Clear();
           DropDownList9.Items.Clear();
           XinXiaLa(-1, 59, DropDownList5);/*分*/
           XinXiaLa(-1, 59, DropDownList10);/*分*/
           XinXiaLa(-1, 23, DropDownList4);/*时*/
           XinXiaLa(-1, 23, DropDownList9);/*时*/
           DropDownList1_SelectedIndexChanged(null,null);
           DropDownList6_SelectedIndexChanged(null,null);
            if (TreeView1.SelectedNode.Text.ToString() =="开课时间设定") { Label1.Text ="开课"; Button2.Text ="确认开课时间"; Button3.Text ="终止开课"; }
            else if(TreeView1.SelectedNode.Text.ToString() == "选课时间设定") { Label1.Text ="选课"; Button2.Text ="确认选课时间"; Button3.Text ="终止选课"; }
        }
        else if (i == 0)
        {
           MultiView1.ActiveViewIndex = 0; Label3.Text = "学号:"; Button4.Visible = Panel6.Visible =true; Panel3.Visible = YongHuMing.Visible = banji.Visible =true; Label5.Visible = Button5.Visible = false; Label4.Text=YongHuMing.Text = "";
           GridVeww1111("学生信息 ","学号,密码,姓名,性别,身份证号,民族编号表.民族,籍贯,政治面貌表.政治面貌,班级名称 ", ",民族编号表,政治面貌表,班级信息,籍贯编号表 where  民族编号表.民族编号=学生信息.民族编号 and 学生信息.班级编号=班级信息.班级编号 and 学生信息.政治面貌编号=政治面貌表.政治面貌编号 and学生信息.籍贯编号=籍贯编号表.籍贯编号", GridView1);
        }
        else if (i == 1)
        {
           MultiView1.ActiveViewIndex = 0; Label3.Text = "教师编号:"; Panel6.Visible = banji.Visible =false; Panel3.Visible = Button4.Visible = YongHuMing.Visible =true; Label5.Visible = Button5.Visible = false; Label4.Text=YongHuMing.Text = "";
           GridVeww1111("老师信息 ","教师编号,密码,姓名,性别,身份证号,民族编号表.民族,籍贯,政治面貌表.政治面貌 ", ",民族编号表,政治面貌表,籍贯编号表 where  民族编号表.民族编号=老师信息.民族编号  and 老师信息.政治面貌编号=政治面貌表.政治面貌编号 and老师信息.籍贯编号=籍贯编号表.籍贯编号", GridView1);
        }
        else if (i == 2)
        {
            MultiView1.ActiveViewIndex = 0;Label3.Text = "登入名:";YongHuMing.Visible = Panel4.Visible =true;Label5.Visible = Button5.Visible = Panel6.Visible = Panel3.Visible =false;Label4.Text= YongHuMing.Text = "";
           GridVeww1111("管理员 ","登入名,密码 ","", GridView1);
        }
        else if (i == 4)
        {
           GridVeww1111("课程信息","课程编号,课程名称,教师编号,院系编号,学分,人数 as '开课人数' "," where NOT EXISTS(SELECT 课程表.课程编号 from课程表 WHERE课程信息.课程编号 =课程表.课程编号)", GridView2);
           YIXUANRENSHU(GridView2);MultiView1.ActiveViewIndex = 4;
        }
        else if (i == 5)
        {
           Panel7.Visible = true;Panel8.Visible =false; Label8.Text = ""; MultiView1.ActiveViewIndex = 5;
        }
        else if (i == 6)
        {
           Panel5.Visible = false;MultiView1.ActiveViewIndex = 6; Label12.Text =""; FormView1.Visible = true;
        }
        else if (i == 7)
        {
           Label13.Text = ""; MultiView1.ActiveViewIndex = 1; FormView2.Visible =false; GridView5_JinRuGengGaiButton13.Text = "显示更改页面";
        }
        else if (i == 8)
        {
            MultiView1.ActiveViewIndex = 2; 
        }
        else if (i == 10) {MultiView1.ActiveViewIndex = 8; }
    } 
    protected void DropDownList2_SelectedIndexChanged(object sender,EventArgs e)
    { 
       YueDeTianShu(int.Parse(DropDownList1.SelectedValue.ToString()),int.Parse(DropDownList2.SelectedValue.ToString()), DropDownList3,DropDownList3.Items.Count);
    }
    protected void DropDownList1_SelectedIndexChanged(object sender,EventArgs e)
    {
       DropDownList6.Items.Clear();
       XinXiaLa(int.Parse(DropDownList1.SelectedValue.ToString())- 1,int.Parse(DropDownList1.SelectedValue.ToString())+1,DropDownList6);
       YueDeTianShu(int.Parse(DropDownList1.SelectedValue.ToString()),int.Parse(DropDownList2.SelectedValue.ToString()), DropDownList3,DropDownList3.Items.Count);
    }
    protected void DropDownList6_SelectedIndexChanged(object sender,EventArgs e)
    {
       YueDeTianShu(int.Parse(DropDownList6.SelectedValue.ToString()),int.Parse(DropDownList7.SelectedValue.ToString()), DropDownList8,DropDownList8.Items.Count);
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        string ZhongZhiML="update开课时间表 set提示信息='否' where项目='";
        if (Button3.Text == "终止开课")  ZhongZhiML +=1; else ZhongZhiML += 2;
       ZhongZhiML += "'";
        SqlConnection cnn =new SqlConnection(ConfigurationManager.ConnectionStrings["SJKLJ"].ConnectionString);
        SqlCommand cmd = cnn.CreateCommand();
       cmd.CommandText = ZhongZhiML;
       cnn.Open();
        if (cmd.ExecuteNonQuery() == 1) Label2.Text = Label1.Text+"终止成功";
       cnn.Close();
       Label2.Visible = true;
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        string t1 =  DropDownList1.Text.ToString()+"-" +DropDownList2.Text.ToString() + "-" + DropDownList3.Text.ToString() + "" + DropDownList4.Text.ToString() +":" + DropDownList5.Text.ToString()+":00";
        string t2 =  DropDownList6.Text.ToString()+"-" +DropDownList7.Text.ToString() + "-" + DropDownList8.Text.ToString() + "" + DropDownList9.Text.ToString() +":" + DropDownList10.Text.ToString() + ":00";
        DateTime t11 =Convert.ToDateTime(t1);
        DateTime t22 =Convert.ToDateTime(t2);
        DateTime nowtime=new DateTime();
       nowtime=System.DateTime.Now;
        if (t22 > t11 && t22> nowtime)
        {
            int t = 2;
            if (Button2.Text == "确认开课时间") t = 1;
            SqlConnection cnn =new SqlConnection(ConfigurationManager.ConnectionStrings["SJKLJ"].ConnectionString);
            SqlCommand cmd =cnn.CreateCommand();
            cmd.CommandText = " update 开课时间表 set起始时间='" + t1 +"' ,结束时间='" + t2 +"',提示信息='是'  where 项目=" + t;
            cnn.Open();
            if (cmd.ExecuteNonQuery() == 1)Label2.Text = Label1.Text +"时间从" + t1 +"到" + t2 +"设置成功";
            else Label2.Text =Label1.Text +"时间设置失败";
            cnn.Close();
        }
        else { Label2.Text = "时间设置有误"; }
        Label2.Visible = true;
       
    }
   
    protected void Button4_Click(object sender, EventArgs e)
    {
        string inserts = "insert into ";
            switch(Label3.Text.ToString())  {
               case "学号:": { inserts = inserts+"学生信息(学号,密码,姓名,性别,身份证号,籍贯编号,政治面貌编号,民族编号,班级编号) "
                   + "values('" +YongHuMing.Text.ToString() +"','" + MiMa.Text.ToString() + "','" + MingZi.Text.ToString() + "','" + sex.SelectedValue +"','"
                   + TextBox4.Text.ToString()+"',"+JiGuan.SelectedValue.ToString()+","+ZhengZhiMianMao.SelectedValue.ToString()+","
                   +MinZu.SelectedValue.ToString()+",'"+banji.SelectedValue.ToString()+"')";
               }
                   break;
               case "教师编号:":
                    {
                        inserts = inserts + "老师信息(教师编号,密码,姓名,性别,身份证号,籍贯编号,政治面貌编号,民族编号) "
                            + "values('" + YongHuMing.Text.ToString() + "','" + MiMa.Text.ToString() + "','" + MingZi.Text.ToString() +"','" + sex.SelectedValue+"','"
                            +TextBox4.Text.ToString() + "'," + JiGuan.SelectedValue.ToString() + "," + ZhengZhiMianMao.SelectedValue.ToString() + ","
                            +MinZu.SelectedValue.ToString() + ")";
                   }
                    break;
               case "登入名:":
                   {
                        inserts = inserts + "管理员(登入名,密码) "
                            + "values('" + YongHuMing.Text.ToString() + "','" + MiMa.Text.ToString() + "')";
                    }
                   break;
            }
            SqlConnection cnn =new SqlConnection(ConfigurationManager.ConnectionStrings["SJKLJ"].ConnectionString);
            SqlCommand insertcmd =new SqlCommand(inserts,cnn);
           cnn.Open();
            if (insertcmd.ExecuteNonQuery() == 1) Label4.Text ="添加成功!^-^!";
            else Label4.Text = "添加失败!-^-!";
               cnn.Close();
               TreeView1_SelectedNodeChanged1(null,null);
    }  
    protected void Button5_Click(object sender, EventArgs e)
    {
       Label5.Visible = false;
       YongHuMing.Visible=true;
        string ceshi = "";
        switch (Label3.Text.ToString())
        {
            case "学号:":
               { ceshi = "update学生信息 set密码='" + MiMa.Text.ToString() +"',姓名='" + MingZi.Text.ToString() +"',性别='" + sex.SelectedValue.ToString()
                   + "',身份证号=" +TextBox4.Text.ToString() +",民族编号=" + MinZu.SelectedValue.ToString() +",籍贯编号=" + JiGuan.SelectedValue.ToString()
                   + ",政治面貌编号=" + ZhengZhiMianMao.SelectedValue.ToString() +",班级编号='" + banji.SelectedValue.ToString()+"' where 学号='" +Label5.Text.ToString() +"'";
               }
               break;
            case "教师编号:":
               {
                   ceshi = "update老师信息 set密码='" + MiMa.Text.ToString() +"',姓名='" + MingZi.Text.ToString() +"',性别='" + sex.SelectedValue.ToString()
                        + "',身份证号=" + TextBox4.Text.ToString() +",民族编号=" + MinZu.SelectedValue.ToString() +",籍贯编号=" + JiGuan.SelectedValue.ToString()
                        + ",政治面貌编号=" + ZhengZhiMianMao.SelectedValue.ToString()  +" where 教师编号='" + Label5.Text.ToString() +"'";
               }
               break;
            case "登入名:": {ceshi ="update 管理员 set密码=" + MiMa.Text.ToString() +"where登入名='" + Label5.Text.ToString() + "'"; }
               break;
        }
         SqlConnection cnn =new SqlConnection(ConfigurationManager.ConnectionStrings["SJKLJ"].ConnectionString);
        SqlCommand cmd = cnn.CreateCommand();
       cmd.CommandText = ceshi;
       cnn.Open();
        if (cmd.ExecuteNonQuery() == 1) Label4.Text ="更新成功!^-^!";
        else Label4.Text = "更新失败!-^-!";
           cnn.Close();
       TreeView1_SelectedNodeChanged1(null,null);
    }
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        string strr = "";
        if (Session["userNumb"].ToString()== GridView1.Rows[e.RowIndex].Cells[2].Text.ToString()) { Label4.Text ="当前用户正在使用!不允许删除";return; }
        if (TreeView1.SelectedNode.Text.ToString() =="学生信息") { strr ="delete from 学生信息 where学号='" + GridView1.Rows[e.RowIndex].Cells[2].Text.ToString() +"'"; }
        else if(TreeView1.SelectedNode.Text.ToString() == "老师信息") { strr ="delete from 老师信息 where教师编号='" + GridView1.Rows[e.RowIndex].Cells[2].Text.ToString() +"'"; }
        else { strr = strr = "delete from 管理员 where登入名='" + GridView1.Rows[e.RowIndex].Cells[2].Text.ToString() +"'"; }
        SqlConnection lianjie =new SqlConnection(ConfigurationManager.ConnectionStrings["SJKLJ"].ConnectionString);
        SqlCommand cmd = lianjie.CreateCommand();
       cmd.CommandText = strr;
       lianjie.Open();
        if (cmd.ExecuteNonQuery() == 1) Label4.Text ="删除成功!^-^!";
        else Label4.Text = "删除失败!-^-!";
       lianjie.Close();
       TreeView1_SelectedNodeChanged1(null,null);
    } 
protected void GridView1_SelectedIndexChanged1(object sender,EventArgs e)
{
        GridViewRow row = GridView1.SelectedRow;
       YongHuMing.Visible = false;
       Label5.Text = row.Cells[2].Text.ToString();
       MiMa.Text = row.Cells[3].Text.ToString();
       Label5.Visible = true;
       Button4.Visible = false;
       Button5.Visible = true;
        switch (Label3.Text.ToString())
        {
            case "学号:":
            case "教师编号:":
               MingZi.Text = row.Cells[4].Text.ToString();
               TextBox4.Text = row.Cells[6].Text.ToString();
               break;
 
        }
}
protected int Insertttt(string BG, string valuesss )
{
    SqlConnection cnn =new SqlConnection(ConfigurationManager.ConnectionStrings["SJKLJ"].ConnectionString);
    SqlCommand CMD = cnn.CreateCommand();
   CMD.CommandText = "insert into " + BG +" values(" +valuesss + ") " ;
   cnn.Open();
    int flag=0;
    flag =CMD.ExecuteNonQuery();
   cnn.Close();
    return flag;
}
protected int Delelelelt(string BBG, string whereee)
{
    SqlConnection cnn =new SqlConnection(ConfigurationManager.ConnectionStrings["SJKLJ"].ConnectionString);
    SqlCommand CMD = cnn.CreateCommand();
   CMD.CommandText = "delete from  " + BBG +" where "+whereee;
   cnn.Open();
    int flag = 0;
    flag =CMD.ExecuteNonQuery();
   cnn.Close();
    return flag;
}
protected void Button6_Click(object sender, EventArgs e)
{
   DropDownList11.SelectedValue.ToString();
   GridVeww1111("学生信息 ","学号,密码,姓名,性别,身份证号,民族编号表.民族,籍贯,政治面貌表.政治面貌,班级名称 ",
        ",民族编号表,政治面貌表,班级信息,籍贯编号表 where  民族编号表.民族编号=学生信息.民族编号 and 学生信息.班级编号=班级信息.班级编号 and 学生信息.政治面貌编号=政治面貌表.政治面貌编号 and学生信息.籍贯编号=籍贯编号表.籍贯编号"
        + " and 班级信息.院系编号=" + DropDownList11.SelectedValue.ToString(), GridView1);
}
protected void Button7_Click(object sender, EventArgs e)
{
    string strr="";
    for(inti=0,j=0,goal=0;i<GridView2.Rows.Count;i++)
    {
        int.TryParse(((Label)GridView2.Rows[i].FindControl("Label7")).Text.ToString(),out j);
        int.TryParse(GridView2.Rows[i].Cells[6].Text.ToString(),out goal);
        if(j>=goal&&goal>0)
        {
           strr = GridView2.Rows[i].Cells[1].Text.ToString();
            if (Insertttt("课程表(课程编号,上课时间天,上课时间节,上课地点)","'" + strr + "',30,50,'待定'" ) == 1)
               Label6.Text = "成功导入课程";
            SqlConnection cnn =new SqlConnection(ConfigurationManager.ConnectionStrings["SJKLJ"].ConnectionString);
            SqlCommand cmd = cnn.CreateCommand();
           cmd.CommandText = "select学号 from选课表 where课程编号=" + strr;
           cnn.Open();
            SqlDataReader readd = cmd.ExecuteReader();
            int mm=0;
            int ccount = 0;
            for (;ccount < goal; ccount++)
            {
               if (readd.Read())
               {
                   mm+=Insertttt("成绩表(学号,课程编号)","'" + readd.GetString(0) + "'," + strr );
               }
            }
           readd.Close();
            cnn.Close();
            if (mm + 1 == ccount) Label6.Text +=",并成功导入成绩表";
            else Label6.Text += ",成绩表导入失败";
           Delelelelt("选课表"," 课程编号=" + strr);
        }
       
   }TreeView1_SelectedNodeChanged1(null,null);
   
}
protected void Button8_Click(object sender, EventArgs e)
{
    for (int i = 0, j = 0, goal = 0; i <GridView2.Rows.Count; i++)
    {
        int.TryParse(((Label)GridView2.Rows[i].FindControl("Label7")).Text.ToString(),out j);
        int.TryParse(GridView2.Rows[i].Cells[6].Text.ToString(),out goal);
        if (!(j >= goal && goal > 0))
        {
           Delelelelt("选课表"," 课程编号=" + GridView2.Rows[i].Cells[1].Text.ToString());
           Delelelelt("课程信息","课程编号=" + GridView2.Rows[i].Cells[1].Text.ToString());
        }
    }
   Label6.Text = " 不符要求课程信息与选课表信息均已删除";
   TreeView1_SelectedNodeChanged1(null,null);
}
protected void GridView3SelectedChanger3(object sender,EventArgs e)
{
   Panel8.Visible = true;
   Panel7.Visible = false;
   gaiT.Text=GridView3.SelectedRow.Cells[2].Text.ToString();
}
protected int Updatedate(string BGG, string A_B, string tiaojian)
{
    SqlConnection cnn =new SqlConnection(ConfigurationManager.ConnectionStrings["SJKLJ"].ConnectionString);
    SqlCommand CMD = cnn.CreateCommand();
   CMD.CommandText = "update " + BGG +" set " + A_B +" where  "+tiaojian;
   cnn.Open();
    int flag = 0;
    flag =CMD.ExecuteNonQuery();
   cnn.Close();
    return flag;
}
protected void Button9_Click(object sender, EventArgs e)
{
   string str =TextBox5.Text.Trim();
   if (Insertttt("院系表(系名)","'" + str + "'") == 1)
   {
      Label8.Text = "增加【" + str +"】成功";
      GridView3.DataBind();
   }
   else Label8.Text = "增加【" + str +"】失败";
 
}
protected void gai_Click(object sender, EventArgs e)
{
    if (Updatedate("院系表","系名='" + gaiT.Text.Trim() +"'", "院系编号=" +GridView3.SelectedRow.Cells[1].Text.ToString()) == 1)
    {
       Label8.Text = "更改成功";
       GridView3.DataBind();/*在asp页面我已经绑定了datasourceid就不用datasource,这两个实现实时更新*/
    }
    else Label8.Text = "更改失败"; 
}
protected void Button10_Click(object sender, EventArgs e)
{
   Panel7.Visible = true;
   Panel8.Visible = false; 
}
protected string ReturnCountSelectedtedted(string BBGG,string shenme, string yaoqiu)
{
    string shumu="0";
    SqlConnection lian =new SqlConnection(ConfigurationManager.ConnectionStrings["SJKLJ"].ConnectionString);
    SqlCommand cmd = lian.CreateCommand();
   cmd.CommandText = "select count(" + shenme +") from " + BBGG + " where " + yaoqiu;
   lian.Open();
   shumu=cmd.ExecuteScalar().ToString();
   lian.Close();
    return shumu;
}
protected void GridView4SlectedChanged(object sender,EventArgs e)
{
    string classnum=GridView4.SelectedRow.Cells[0].Text.ToString();
   Label9.Text=classnum;
   TextBox6.Text = GridView4.SelectedRow.Cells[1].Text.ToString();
   TextBox1.Text = GridView4.SelectedRow.Cells[2].Text.ToString();
   Label10.Text=ReturnCountSelectedtedted("学生信息","学号","班级编号=" + classnum);
   FormView1.Visible = false;
    Panel5.Visible= true;
}
protected void Button12_Click(object sender, EventArgs e)
{
   Panel5.Visible = false;
   FormView1.Visible = true;
   GridView4.SelectedIndex = -1; /*取消选定行*/
   Label12.Text = "";
}
protected void Button11_Click(object sender, EventArgs e)
{
    if (Updatedate("班级信息","年级='" + TextBox6.Text.ToString() +"',班级名称='" + TextBox1.Text.ToString() +"',班级人数="
        +Label10.Text.ToString() + ",教师编号='" + DropDownList13.SelectedValue.ToString() +
        "',院系编号=" + DropDownList12.SelectedValue.ToString(),"班级编号='" + Label9.Text.ToString() +"'") == 1)
   {Label12.Text = "更改成功";GridView4.DataBind();}
    else Label12.Text = "更改失败";
}
protected void DropDownList13_SelectedIndexChanged(object sender,EventArgs e)
{
   Label11.Text = DropDownList13.SelectedValue.ToString();
}
protected void FormView1_ItemInserted1(object sender,FormViewInsertedEventArgs e)
{
     if (e.Exception == null)
    {
      /* Use the AffectedRows property to determine whether the
        record was inserted. Sometimes an error might occur that
        doesnot raise an exception, but prevents the insert
       operation from completing.*/
      if (e.AffectedRows == 1)
      {
         Label12.Text = "插入成功!\n Record inserted successfully.";
              GridView4.DataBind();
      }
      else
      {
         Label12.Text = "插入过程出错\n An error occurred during the insert operation.";
 
        /* Use the KeepInInsertMode property to remain in insert mode*/
        /* when an error occurs during the insert operation.*/
       e.KeepInInsertMode = true;
      }
    }
    else
    {
      /*Insert the code to handle the exception.*/
       Label12.Text = "输入格式有误!请重新输入!";/*e.Exception.Message;*/
 
      /* Use the ExceptionHandled property to indicate that the */
      /* exception has already been handled.*/
     e.ExceptionHandled = true;
     e.KeepInInsertMode = true;
    }
   
}
protected void FormView2_ItemUpdated(object sender,FormViewUpdatedEventArgs e)
{
    /*Use the Exception property to determine whether an exception
     occurredduring the update operation.*/
    if (e.Exception == null)
    {
        /* Sometimes an error might occur that does not raise an
        //exception, but prevents the update operation from
        //completing. Use the AffectedRows property to determine
        //whether the record was actually updated. */
        if (e.AffectedRows == 1)
        {
            /* Use the Keys property to get the value of the key field.*/
            String keyFieldValue = e.Keys["课序号"].ToString();/*声明标量,前aspx要datakeyname*/
 
            /* Display a confirmation message.*/
           Label13.Text = "修改成功!Record " + keyFieldValue +
             " updated successfully. ";
           GridView5.DataBind();
        }
        else
        {
            /*Display an error message.*/
           Label13.Text = "更新过程出错\n An error occurred during the update operation.";
            /*When an error occurs, keep the FormView
           // control in edit mode.*/
           e.KeepInEditMode = true;
        }
    }
    else
    {
        /*/ Insert the code to handle the exception.*/
       Label13.Text = "输入格式错误";/* e.Exception.Message;*/
        /*/ Use the ExceptionHandled property to indicate that the
        //exception has already been handled.*/
       e.ExceptionHandled = true;
       e.KeepInEditMode = true;
    }
}
protected void GridView5_JinRuGengGaiButton13_Click(object sender,EventArgs e)
{
    if (GridView5_JinRuGengGaiButton13.Text =="显示更改页面")
    { 
        FormView2.Visible= true;
       GridView5_JinRuGengGaiButton13.Text = "隐藏更改页面";
    }
    else
    {   FormView2.Visible = false;
       GridView5_JinRuGengGaiButton13.Text = "显示更改页面";
    }
   
}
protected void Button14_Click(object sender, EventArgs e)
{
    string[] fenshua=newstring[9];
   fenshua[8] = "0";
      /* https: //msdn.microsoft.com/zh-cn/library/yy6y35y8(v=vs.110).aspx */
    SqlConnection lian =new SqlConnection(ConfigurationManager.ConnectionStrings["SJKLJ"].ConnectionString);
    SqlCommand minglingchuan = lian.CreateCommand();
   minglingchuan.CommandText = "成绩按课程名查询";
   minglingchuan.CommandType = CommandType.StoredProcedure;
    SqlParameter parem =new SqlParameter();
   parem.ParameterName = "@coursename";
   parem.SqlDbType = SqlDbType.NVarChar;
   parem.Direction = ParameterDirection.Input;
   parem.Value=课程名称1DropDownList16.SelectedValue.ToString();
   minglingchuan.Parameters.Add(parem);
   lian.Open();
    SqlDataReader reader=minglingchuan.ExecuteReader();
    /*http: //www.cnblogs.com/suguoqiang/archive/2013/01/16/2862945.html*/
    for ( int i = 0; reader.HasRows; )
    {
       reader.Read();
       fenshua[i++] = reader[0].ToString();
       reader.NextResult();
    }
    /* reader.Read();
   fenshua[0] = reader[0].ToString();
   reader.NextResult();
   reader.Read();
   fenshua[1] = reader[0].ToString();
   reader.NextResult();
   reader.Read();
   fenshua[2] = reader[0].ToString();
   reader.NextResult();
   reader.Read();
   fenshua[3] = reader[0].ToString();
   reader.NextResult();
   reader.Read();
   fenshua[4] = reader[0].ToString();
   reader.NextResult();
   reader.Read();
   fenshua[5] = reader[0].ToString();
   reader.NextResult();
   reader.Read();
   fenshua[6] = reader[0].ToString();
   reader.NextResult();
   reader.Read();
   fenshua[7] = reader[0].ToString();*/
   reader.Close();
   lian.Close();
    double ccountt = 0;
    double.TryParse(fenshua[8].ToString(),outccountt);
    if (ccountt == 0) { Label15.Text ="当前课程成绩未录入"; }
    else
    {
        double j = 0;
        double.TryParse(fenshua[7].ToString(),out j);
        string[] x_ming = { "0~59", "60~69", "70~79", "80~89", "90~100" };
        DataTable 统计图表格 =new DataTable();
        统计图表格.Columns.Add("fenshufanwei");
        统计图表格.Columns.Add("area_data");
        for (int i = 3; i < 8; )
        {
            DataRow hang = 统计图表格.NewRow();
           hang["area_data"] =x_ming[7 - i];
           hang["fenshufanwei"] =fenshua[i++];
            统计图表格.Rows.Add(hang);
        }
       Label15.Text = "平均成绩:" + fenshua[0] +";\n 最高成绩:" + fenshua[1] +";\n 最低成绩:" + fenshua[2] +";\n 及格率:" + ((ccountt - j) / ccountt).ToString();
       Chart1.DataSource = 统计图表格;
       Chart1.Series["Series1"].ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Line;//设置图表类型
       Chart1.Series[0].XValueMember = "area_data";//X轴数据成员列
       Chart1.Series[0].YValueMembers = "fenshufanwei";//Y轴数据成员列
       Chart1.ChartAreas["ChartArea1"].AxisX.Title ="人数";//X轴标题
       Chart1.ChartAreas["ChartArea1"].AxisX.TitleAlignment =StringAlignment.Far;//设置x轴标题的名称所在位置位远
       Chart1.ChartAreas["ChartArea1"].AxisY.Title ="分数范围";//X轴标题
       Chart1.ChartAreas["ChartArea1"].AxisY.TitleAlignment =StringAlignment.Far;/*设置Y轴标题的名称所在位置位远,命名空间System.Drawing
                                                                                *详情https://msdn.microsoft.com/zh-SG/library/system.drawing.stringformat.alignment(v=vs.80)*/
       Chart1.ChartAreas["ChartArea1"].AxisX.Interval = 1;//X轴数据的间距
       Chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled =false;//不显示竖着的分割线
       Chart1.Series[0].IsValueShownAsLabel = true;//显示坐标值
       GridVeww1111(" 学生成绩视图 "," * ", " where 课程名称='" + 课程名称1DropDownList16.SelectedValue.ToString() +"'order by 成绩 desc", GridView6);
    }
}
protected void Button16_Click(object sender, EventArgs e)
{
   GridVeww1111(" 选课表 ,课程信息"," 选课表.学号,课程信息.* ", " where 选课表.课程编号=课程信息.课程编号 and 学号='" + 学生DropDownList16.SelectedValue.ToString() +"'", GridView7);
}
protected void Button15_Click(object sender, EventArgs e)
{
   GridVeww1111(" 选课表 ,课程信息"," 选课表.学号,课程信息.*"," where 选课表.课程编号=课程信息.课程编号 and 教师编号='" + 老师DropDownList17.SelectedValue.ToString() +"'", GridView7);
}
protected void Button13_Click(object sender, EventArgs e)
{
   GridVeww1111(" 选课表 ,课程信息"," 选课表.学号,课程信息.* ", " where 选课表.课程编号=课程信息.课程编号 and 课程名称='" + 课程tDropDownList16.SelectedValue.ToString() +"'", GridView7);
}
}


<?xmlversion="1.0"?>
<!--
  For moreinformation on how to configure your ASP.NET application, please visit
 http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <appSettings>
    <addkey="ChartImageHandler"value="storage=file;timeout=20;dir=c:\TempImageFiles\;" />
  </appSettings>
  <connectionStrings>
    <addname="SJKLJ"connectionString="Data Source=hp-pc;Initial Catalog=database2015;UserID=sqluser一;Password=sqltest123"/>
  </connectionStrings>
  <system.web>
    <pages>
      <controls>
        <addtagPrefix="asp"namespace="System.Web.UI.DataVisualization.Charting"
          assembly="System.Web.DataVisualization, Version=4.0.0.0,Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      </controls>
    </pages>
    <httpHandlers>
      <addpath="Reserved.ReportViewerWebControl.axd"verb="*"type="Microsoft.Reporting.WebForms.HttpHandler,Microsoft.ReportViewer.WebForms, Version=11.0.0.0,Culture=neutral, PublicKeyToken=89845dcd8080cc91"
        validate="false" />
      <addpath="ChartImg.axd"verb="GET,HEAD,POST"type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler,System.Web.DataVisualization, Version=4.0.0.0,Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        validate="false" />
    </httpHandlers>
    <compilationdebug="true"targetFramework="4.0">
      <assemblies>
        <addassembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0,Culture=neutral, PublicKeyToken=89845DCD8080CC91"/>
        <addassembly="Microsoft.ReportViewer.Common, Version=11.0.0.0,Culture=neutral, PublicKeyToken=89845DCD8080CC91"/>
        <addassembly="Microsoft.Build.Framework, Version=4.0.0.0,Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
        <addassembly="System.Web.DataVisualization, Version=4.0.0.0,Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      </assemblies>
      <buildProviders>
        <addextension=".rdlc"type="Microsoft.Reporting.RdlBuildProvider,Microsoft.ReportViewer.WebForms, Version=11.0.0.0,Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
      </buildProviders>
    </compilation>
  </system.web>
  <system.webServer>
    <validationvalidateIntegratedModeConfiguration="false" />
    <handlers>
      <removename="ChartImageHandler"/>
      <addname="ReportViewerWebControlHandler"preCondition="integratedMode"
        verb="*"path="Reserved.ReportViewerWebControl.axd"type="Microsoft.Reporting.WebForms.HttpHandler,Microsoft.ReportViewer.WebForms, Version=11.0.0.0,Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
      <addname="ChartImageHandler"preCondition="integratedMode"verb="GET,HEAD,POST"
        path="ChartImg.axd"type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler,System.Web.DataVisualization, Version=4.0.0.0,Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    </handlers>
  </system.webServer>
</configuration>



  • 2
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
一、选课系统源码描述 这是一款功能比较完整的选课系统源码,比较具有学习的价值, 该源码可以给做课程设计或者毕业设计的朋友们提供一些参考, 感兴趣的朋友可以下载看看啊。   二、系统分析 在本系统中,有三类用户:系统管理员,教师和学生。三种不同的用户所具有的操作权限以及操作内容均不一样。 本选课系统给予教师很大的自主权,系统管理员只负责向系统中添加学生和教师的个人信息以及教学楼教室信息。系统管理员不参与开设课程、选择课程等,一切均由教师、学生等录网站自行完成。系统管理员设置一个选课时间段,在到达时间段以前,教师可以开设课程;到达时间段以后,学生可以登陆网站选择课程。 教师用户登陆网站后可以开设课程,为自己的课程编辑上课时间和地点,当系统中出现时间地点冲突的时候,系统向教师用户报告并推荐一个时间地点。每门课程可以是必修或则选修,教师为每门课程设置一个学分,并可以在课程结束后给予分数,如果学生及格,学生将获得该课程的学分。 对于学生用户,每个学生除了必须选择必修课程外,至少还要选择两门选修课程,学生可以对自己选课信息锁定,以免不小心被修改。当时候超过选课时段后,系统自动锁定学生的选课课程。系统可以根据学生的选课信息,生成一份学生自己的课表。课程结束后学生可登录网站查询成绩与学分。 根据上面的要求,从操作功能上可以分为两个类:一个是通用操作,主要实现用户的登录注销和修改密码等;另一种是为不同用户定制不同操作。   三、功能介绍 该源码主要包括管理员、教师、学生三大角色具体功能如下: (1)系统管理员 设置选课时间段:系统管理员通过此项功能设置选课时段,只有在选课时间段里,学生才可以选择课程,超过次时间段,学生选课信息被自动所定,不得修改。 录入学生与教师个人信息:通过此项功能可以实现对教师和学生的个人信息添加删除。 录入教学楼教室信息:通过此项功能可以把学校里所有的教学楼教室的信息录入到系统中,以便教师在开设课程时候设置上课的教室。 (2)教师用户 显示和修改个人信息:教师用户登录系统后,可以查看和修改教师的个人信息,如姓名,电话,E-mail地址等。 开设课程:教师用户登录系统后,可以开设课程,可以设置该课程为必修课程或则选修课程可以设置该课程的最大人数。教师还可以为该课程设置一个前导课程,若学生没有学习或则选择前导课程则不能选择该课程。 编辑课程上课时间:教师在开设了课程后,可以灵活地设置上课时间和地点。 给学生分数:课程结束后,教师用户登录系统,可以为学过课程的学生给予相应的成绩,若及格,给予学生学分。 (3)学生用户 显示和修改个人信息:学生登录系统后,可以查看和修改学生的个人信息,如姓名,性别,电话等。 查看必修课程:学生登录后,可以查看所有的必修课程。查看该课程的信息,上课时间地点,开课教师信息等。 选择选修课程:学生登录系统后,在所有选修课程中可以选择至少两门选修课程。同时可以查看相关信息。 锁定选课信息:学生登录系统,确定了所选课程后,可以锁定自己的选课信息,以防被别人或则自己不小心修改。 查看最终选课信息:学生登录系统后,可列出已选择的课程,若选课信息未被锁定,则可以退选,若所选课程少于两门,系统会提示选择的课程少于两门。 查看学分和成绩课程结束后,学生登录系统可查看自己学习课程的成绩和已获的学分。   四、注意事项 1、学生、教师和管理员的默认帐号分别为:011、6、admin,密码均为51aspx。 2、开发环境为Visual Studio 2010,数据库为SQL Server 2005,数据库文件在DB_51aspx文件夹中,使用.net 2.0开发。 3、默认数据库连接字符串在webconfig配置文件中修改。 4、该源码仅适合毕业设计或者课程设计使用以及学习交流使用。   五、更新记录 1、更新日期:2014-12-09 12:00:00 2、更新内容: 1、vs版本升级为vs2010,数据库版本更新为sql2005,框架升级为2.0.       相关阅读 同类推荐:站长常用源码

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值