⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 student_electchoosecourse.aspx.cs

📁 该系统是一个集成多功能的信息管理系统
💻 CS
📖 第 1 页 / 共 3 页
字号:
/// <summary>
/// 哈尔滨师范大学教务系统开发
/// 作者:易继勇
/// 邮箱:yijiyong100@163.com
/// qq:610068468
/// 哈尔滨师范大学教务平台图片展示地址:http://photo.sina.com.cn/yijiyong100
/// 如果您有什么问题,将您的问题发送至邮箱yijiyong100@163.com,欢迎大家和我交流讨论,多多希望您提出您宝贵的意见!
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class student_student_electChooseCourse : System.Web.UI.Page
{
    BaseClass bc = new BaseClass();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Convert.ToString(Session["stdUserName"]) == "")
        {
            Response.Write("<script language=javascript>location='../TS_login.aspx'</script>");
            return;
        }
        if (!IsPostBack)
        {
            this.Label1.Text = Session["stdUserName"].ToString();
            this.Label2.Text = Session["stdName"].ToString();
            this.Label3.Text = Session["stdSpeciality"].ToString();
            this.Label4.Text = Session["stdCollege"].ToString();
            this.Label5.Text = Session["stdTeachedClass"].ToString();
            this.Label6.Text = Session["stdAdminClass"].ToString();
            this.bind1();
            this.bind2();
            this.bind3();
        }
        
    }

    public void bind1()
    {
        Session["currentlyStudyYear"].ToString();
        Convert.ToInt32(Session["currentlySemester"]);
        SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["strcon"]);
        con.Open();
        SqlDataAdapter sda = new SqlDataAdapter("select * from ts_xs_chooseCoursesInfo where courseStudyYear = '" + Session["currentlyStudyYear"].ToString() + "'and courseSemester ='"+ Convert.ToInt32(Session["currentlySemester"]) + "' order by id", con);
        DataSet ds = new DataSet();
        sda.Fill(ds, "ts_xs_chooseCoursesInfo");
        GridView1.DataSource = ds.Tables["ts_xs_chooseCoursesInfo"];
        GridView1.DataKeyNames = new string[] { "id" };
        GridView1.DataBind();
        con.Close();
    }

    public void bind2()
    {
        SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["strcon"]);
        con.Open();
        SqlDataAdapter sda = new SqlDataAdapter("select * from ts_xs_stdChooseCoursesInfo where courseStudyYear ='" + Session["currentlyStudyYear"].ToString() + "'and courseSemester = '" + Convert.ToInt32(Session["currentlySemester"]) + "'and studyNumber = '" + Session["stdUserName"].ToString() + "' order by id", con);
        DataSet ds = new DataSet();
        sda.Fill(ds, "ts_xs_stdChooseCoursesInfo");
        GridView2.DataSource = ds.Tables["ts_xs_stdChooseCoursesInfo"];
        GridView2.DataKeyNames = new string[] { "id" };
        
        GridView2.DataBind();
        con.Close();
       
        
    }

    public void bind3()
    {
        SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["strcon"]);
        con.Open();
        SqlDataAdapter sda = new SqlDataAdapter("select * from ts_xs_stdChooseCoursesInfo where courseStudyYear ='" + Session["currentlyStudyYear"].ToString() + "'and courseSemester = '" + Convert.ToInt32(Session["currentlySemester"]) + "'and studyNumber = '" + Session["stdUserName"].ToString() + "' order by id", con);
        DataSet ds = new DataSet();
        sda.Fill(ds, "ts_xs_stdChooseCoursesInfo");
        GridView3.DataSource = ds.Tables["ts_xs_stdChooseCoursesInfo"];
        GridView3.DataKeyNames = new string[] { "id" };
        GridView3.DataBind();
        con.Close();
    }

    protected void submit_Click(object sender, EventArgs e)
    {
        int checkedCount1 = 0;
        int chechedCount2 = 0;
        int uncheckedCount1 = 0;
        int uncheckedCount2 = 0;
        int[] a = new int[200];
        int[] b = new int[200];
        for (int i = 0; i <= 199; i++)
        {
            a[i] = b[i] = 0;
        }
        int rowsNumber = GridView1.Rows.Count;
        for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
        {
            CheckBox cbox1 = (CheckBox)GridView1.Rows[i].FindControl("CheckBox1");
            CheckBox cbox2 = (CheckBox)GridView1.Rows[i].FindControl("CheckBox2");
            if (cbox1.Checked == true)
            {
                checkedCount1++;
                a[i] = i + 1;
            }
            else
            {
                uncheckedCount1++;
            }
            if (cbox2.Checked == true)
            {
                chechedCount2++;
                b[i] = i + 1;
            }
            else
            {
                uncheckedCount2++;
            }
        }

        if (checkedCount1 > 2)
        {
            Response.Write("<script>alert('每次最多只能选择两门选修课!');history.back()</script>");
        }
        if (uncheckedCount1 == rowsNumber)
        {
            Response.Write("<script>alert('你还没有选择你所要选择的选修课!');history.back()</script>");
        }
        else
        {
            SqlConnection constr = new SqlConnection(ConfigurationManager.AppSettings["strcon"]);
            constr.Open();
            SqlCommand cmd = new SqlCommand("select count(*) from ts_xs_stdChooseCoursesInfo where studyNumber ='" + Session["stdUserName"] + "' and courseStudyYear = '" + Session["currentlyStudyYear"].ToString() + "'and courseSemester = '" + Convert.ToInt32(Session["currentlySemester"]) + "'", constr);
            int dbcount = Convert.ToInt32(cmd.ExecuteScalar());
            constr.Close();
            int totalcount = dbcount + checkedCount1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -