protected void Button2_Click(object sender, EventArgs e)
    {//删除一个学科组,先将组内的学科设为待定组
     // string sql2 = "select subjectGroupNo,subjectGroupName from gcgSubjectGroup";
     //string sql1 = "select subjectno from gcgSubject where subjectGroupNo in (select subjectGroupNo from gcgSubjectGroup where subjectGroupName = @subjectGroupName)";

        string subjectGroupNo = DropDownList1.SelectedValue;

        DBManipulation dbm  = new DBManipulation();
        string         sql1 = "select subjectGroupNo from gcgSubjectGroup where subjectGroupName = '待定'";
        Object         o    = dbm.ExecuteScalar(sql1, null);
        string         subjectGroup_DefalutNo = o.ToString();
        string         sql2 = "select subjectno from gcgSubject where subjectGroupNo ='" + subjectGroupNo + "'";
        DataSet        ds   = dbm.ExecuteQueryOffLine(sql2, null);
        DataTable      t    = ds.Tables["defaultTable"];

        foreach (DataRow r in t.Rows)
        {
            string          subjectno = r["subjectno"].ToString();
            string          sql3      = "update gcgSubject set subjectGroupNo = @subjectGroupNo where subjectno = @subjectno";
            ParameterStruct p1        = new ParameterStruct("@subjectGroupNo", subjectGroup_DefalutNo);
            ParameterStruct p2        = new ParameterStruct("@subjectno", subjectno);
            ArrayList       p         = new ArrayList();
            p.Add(p1);
            p.Add(p2);
            dbm.ExecuteNonQuery(sql3, p);
        }

        string sql = "delete from gcgSubjectGroup where subjectGroupNo = '" + subjectGroupNo + "'";

        dbm.ExecuteNonQuery(sql, null);
        setItem_deleteDropDownList();//为删除下拉框提供新的数据
        this.Page_Load(this, null);
    }
Example #2
0
    protected void Button_submit_Click(object sender, EventArgs e)
    {
        //点击此按钮,清除该学科组收到的所有反馈信息

        /*create table gcgFeedBack(  --排课组内部专用表
         *  class_id char(4) not null,
         *      CourseNo char(3) not null,
         *      TeacherNo char(8) not null,
         *      primary key(class_id,CourseNo)
         * )*/
        string         subjectGroupName = Label_SubjectGroup.Text;
        string         sql0             = "select subjectGroupNo from gcgSubjectGroup where subjectGroupName ='" + subjectGroupName + "'";
        DBManipulation dbm = new DBManipulation();
        Object         o   = dbm.ExecuteScalar(sql0, null);

        if (o == null)
        {
            //说明没有这个学科组
            System.Web.UI.ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Button6_Click", "alert('没有该学科组存在!')", true);
            //实际上是不可能的
            return;//不再查询数据
        }
        string subjectGroupNo = o.ToString();

        dbm.Close();
        string          sql1   = "select CourseNo from gcgSubject,gcgCourse where gcgCourse.SubjectNo = gcgSubject.subjectno and Grade = @Grade and subjectGroupNo = @subjectGroupNo";
        ParameterStruct p1     = new ParameterStruct("@Grade", DropDownList_Grade.SelectedValue);
        ParameterStruct p2     = new ParameterStruct("@subjectGroupNo", subjectGroupNo);
        ArrayList       pList1 = new ArrayList();

        pList1.Add(p1);
        pList1.Add(p2);
        SqlDataReader dr           = dbm.ExecuteQueryOnLine(sql1, pList1);
        ArrayList     courseNoList = new ArrayList();

        while (dr.Read())
        {
            courseNoList.Add(dr.GetString(0));
        }
        dr.Close();
        foreach (string courseno in courseNoList)
        {
            string sql_deletefromGcgFeedBack = "delete from gcgFeedBack where CourseNo = '" + courseno + "'";
            dbm.ExecuteNonQuery(sql_deletefromGcgFeedBack, null);
        }
        //如果发现反馈表中已经没有了记录,那么就直接删掉,神不知鬼不觉~
        string sql_checkgcgFeedBack = "select * from gcgFeedBack";
        object isEmpty = dbm.ExecuteScalar(sql_checkgcgFeedBack, null);

        if (isEmpty == null)
        {
            //没有反馈记录了
            string sql_droptable = "drop table gcgFeedBack";
            dbm.ExecuteNonQuery(sql_droptable, null);
        }
        dbm.Close();
        System.Web.UI.ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Button6_Click", "alert('已清除反馈信息!')", true);
        CreateTable();
    }
    protected void ButtonDelete_Click(object sender, EventArgs e)
    {
        Button b        = (Button)sender;
        string ButtonID = b.ID;
        int    i;

        for (i = 0; i < ButtonLists.Count; i++)
        {
            Button b1 = (Button)ButtonLists[i];
            if (ButtonID.Equals(b1.ID))
            {
                break;
            }
        }
        TableCell      t          = (TableCell)TableCellLists[i];
        string         courseName = t.Text;
        string         grade      = DropDownList_Grade.SelectedValue;
        string         sql1       = "select subjectno from gcgSubject where subjectname ='" + courseName + "'";
        DBManipulation dbm        = new DBManipulation();
        Object         o          = dbm.ExecuteScalar(sql1, null);

        if (o != null)
        {
            string subjectno = o.ToString();
            string sql2      = "delete from gcgCourse where SubjectNo ='" + subjectno + "' and Grade ='" + grade + "'";
            dbm.ExecuteNonQuery(sql2, null);
        }
        dbm.Close();
        SetItemForChoosableCourse();
        this.Page_Load(this, null);
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        //点击增加科目
        //从年级已知,科目号和科目名已知,默认课时为0
        string grade     = DropDownList_Grade.SelectedValue;
        string subjectno = DropDownList2.SelectedValue;

        if (subjectno == "")  //当下拉框已经没有可增加科目时,按钮点击无效
        {
            return;
        }
        string          CourseNo       = grade + subjectno;
        string          courseCount    = "0";
        DBManipulation  dbm            = new DBManipulation();
        string          sql2           = "insert into gcgCourse values(@CourseNo,@SubjectNo,@Grade,@CourseTime)";
        ParameterStruct p3             = new ParameterStruct("@CourseNo", CourseNo + "");
        ParameterStruct p4             = new ParameterStruct("@SubjectNo", subjectno);
        ParameterStruct p5             = new ParameterStruct("@Grade", grade + "");
        ParameterStruct p6             = new ParameterStruct("@CourseTime", courseCount + "");
        ArrayList       parameterList2 = new ArrayList();

        parameterList2.Add(p3);
        parameterList2.Add(p4);
        parameterList2.Add(p5);
        parameterList2.Add(p6);
        dbm.ExecuteNonQuery(sql2, parameterList2);
        dbm.Close();
        SetItemForChoosableCourse();
        this.Page_Load(this, null);
        // Response.Redirect("classTimesArrange.aspx");
    }
    protected void Button_submit_Click(object sender, EventArgs e)
    {   //点击确认,提交课时安排
        //通过 TableCellLists  DropDownLists获得每一条记录的科目名以及课时,通过DropDownList_Grade获得年级
        //步骤:一条一条来看,如果原先有课时安排的,就更新,没有的,就插入
        string         grade = DropDownList_Grade.SelectedValue;
        DBManipulation dbm   = new DBManipulation();

        // Response.Write("<script>alert('有新"+ HasNewCourse+" ')</script>");
        for (int i = 0; i < DropDownLists.Count; i++)
        {
            //步骤一:查询这门科目是否有过旧的课时安排记录
            //注意:一开始没有学科,所以要通过按钮增加学科,此时会保证所有记录都有初始课时分布,所以提交按钮仅仅需要将这些记录更新就行了
            TableCell    tc          = (TableCell)TableCellLists[i];
            DropDownList ddl         = (DropDownList)DropDownLists[i];
            string       courseName  = tc.Text;           //获得科目名
            string       courseCount = ddl.SelectedValue; //获得新的分配课时

            string          SearchSql      = "select CourseNo from gcgCourse,gcgSubject where gcgSubject.subjectno = gcgCourse.SubjectNo and Grade = @Grade and subjectname = @subjectname";
            ParameterStruct p1             = new ParameterStruct("@Grade", grade);
            ParameterStruct p2             = new ParameterStruct("@subjectname", courseName);
            ArrayList       parameterList1 = new ArrayList();
            parameterList1.Add(p1);
            parameterList1.Add(p2);
            Object o        = dbm.ExecuteScalar(SearchSql, parameterList1);
            string CourseNo = o.ToString();
            string sql4     = "update gcgCourse set CourseTime = " + courseCount + " where CourseNo = " + CourseNo;
            dbm.ExecuteNonQuery(sql4, null);
        }
        dbm.Close();
        System.Web.UI.ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Button6_Click", "alert('提交已完成!')", true);
    }
    protected void Button_AddSubjectGroup_Click(object sender, EventArgs e)
    {//增加学科组
        string         subjectGroupName = TextBox_SubjectGroup.Text;
        string         subjectGroupId;
        DBManipulation dbm = new DBManipulation();
        string         sql1 = "select subjectGroupNo from gcgSubjectGroup order by subjectGroupNo";
        DataSet        ds_subjectGroup = dbm.ExecuteQueryOffLine(sql1, null);
        int            i = 0, j;
        bool           mark = true; //一个标志量

        for (i = 1; i < 90; i++)    //学科组号仅有2位
        {
            mark = true;
            for (j = 0; j < ds_subjectGroup.Tables["defaultTable"].Rows.Count; j++)
            {
                string str = ds_subjectGroup.Tables["defaultTable"].Rows[j]["subjectGroupNo"].ToString();
                char[] ch  = str.ToCharArray();
                if (ch[0] == '0')
                {
                    str = ch[1] + "";
                }
                if (i == int.Parse(str))
                {
                    mark = false;
                    break;
                }
            }
            if (mark)  //如果没有任何一个id相等,那么这个就是可用id
            {
                break;
            }
        }
        if (i < 10)
        {
            subjectGroupId = "0" + i;
        }
        else
        {
            Response.Write("<script>alert('i > 10')</script>");
            subjectGroupId = i + "";
        }
        string          sql2          = "insert into gcgSubjectGroup values(@subjectGroupNo,@subjectGroupName,null)";
        ParameterStruct p1            = new ParameterStruct("@subjectGroupNo", subjectGroupId);
        ParameterStruct p2            = new ParameterStruct("@subjectGroupName", subjectGroupName);
        ArrayList       parameterlist = new ArrayList();

        parameterlist.Add(p1);
        parameterlist.Add(p2);
        debug1.Text = subjectGroupId;
        debug2.Text = subjectGroupName;
        dbm.ExecuteNonQuery(sql2, parameterlist);
        CreateTableDynamicly();       //生成表
        setItemsForSelectGroup();     //为每一个科目的可选学科组下拉框准备数据
        setItem_deleteDropDownList(); //为删除下拉框生成数据
        TextBox_SubjectGroup.Text = "";
    }
Example #7
0
    /*
     * protected override void OnLoad(EventArgs e)
     * {
     *
     * }
     */
    protected void Page_Load(object sender, EventArgs e)
    {
        //外部添加局部刷新控件
        ScriptManager1.RegisterAsyncPostBackControl(this.DropDownList_Grade);
        ScriptManager1.RegisterAsyncPostBackControl(this.DropDownList_semester);
        ScriptManager1.RegisterAsyncPostBackControl(this.DropDownList_year);
        if (!IsPostBack)
        {
            if (!(LoginAndPermissionChecking.LoginChecking()))
            {
                Response.Redirect("/ErrorPage/error_NotLogin.aspx");
            }
            if (!(LoginAndPermissionChecking.PermissionChecking(PermissionEnum.EducationDean)))
            {
                Response.Redirect("/ErrorPage/error_DeniedPermission.aspx");
            }
            //首先先检查是否有gcgFeedBack这张表,如果不存在就新建
            string         sql_LookForgcgFeedBack = "select * from sysobjects where name = 'gcgFeedBack' and xtype = 'U'";
            DBManipulation dbm = new DBManipulation();
            object         o   = dbm.ExecuteScalar(sql_LookForgcgFeedBack, null);
            if (o == null)
            {
                string sql_CreategcgFeedBack = "create table gcgFeedBack(" +
                                               "class_id char(4) not null," +
                                               "CourseNo char(3) not null," +
                                               "TeacherNo char(8) not null," +
                                               "primary key(class_id, CourseNo)" +
                                               ")";
                dbm.ExecuteNonQuery(sql_CreategcgFeedBack, null);
            }

            /*create table gcgFeedBack(  --排课组内部专用表
             *      class_id char(4) not null,
             *      CourseNo char(3) not null,
             *      TeacherNo char(8) not null,
             *      primary key(class_id,CourseNo)
             * )*/
            //页面第一次载入之前,要查询gcgFeedBack授课安排反馈表,看看是不是还有未确认的反馈信息
            string sql = "select class_id,CourseNo from gcgFeedBack";
            // DBManipulation dbm = new DBManipulation();
            SqlDataReader dr = dbm.ExecuteQueryOnLine(sql, null);
            while (dr.Read())
            {
                string buttonName = dr.GetString(0) + dr.GetString(1);
                //Session[buttonName] = "nameRedButton";//我们使用Session保存有意见的老师安排的css样式
                Session[buttonName] = "aspTableCellBrown2";//把原先红色的恢复成黑色
            }
            dr.Close();
            dbm.Close();
        }

        createtable(GetSemesterNo());
    }
Example #8
0
    protected void ButtonForFeedBack_onClick(object sender, EventArgs e)
    {
        MyButton button     = (MyButton)sender;
        string   buttonName = button.Class_id + button.CourseNo1;


        if (Session[buttonName] == null || Session[buttonName].ToString().Equals("aspTableCell"))
        {
            Session[buttonName] = "aspTableCellBrown2";//用session记录这个Button被点击过
            //插入反馈记录

            /*create table gcgFeedBack(
             *      class_id char(4) not null,
             *      CourseNo char(3) not null,
             *      TeacherNo char(8) not null,
             *      primary key(class_id,CourseNo)
             * )*/
            string          sql         = "insert into gcgFeedBack values(@class_id,@CourseNo,@TeacherNo)";
            ParameterStruct p_classid   = new ParameterStruct("@class_id", button.Class_id);
            ParameterStruct p_courseno  = new ParameterStruct("@CourseNo", button.CourseNo1);
            ParameterStruct p_teacherno = new ParameterStruct("@TeacherNo", button.TeacherNo1);
            ArrayList       plist       = new ArrayList();
            plist.Add(p_classid);
            plist.Add(p_courseno);
            plist.Add(p_teacherno);
            DBManipulation dbm = new DBManipulation();
            try {
                dbm.ExecuteNonQuery(sql, plist);
            }
            catch (Exception)
            {
            }
        }
        else
        {
            Session[buttonName] = "aspTableCell";
            string          sql        = "delete from gcgFeedBack where class_id = @class_id and CourseNo = @CourseNo";
            ParameterStruct p_classid  = new ParameterStruct("@class_id", button.Class_id);
            ParameterStruct p_courseno = new ParameterStruct("@CourseNo", button.CourseNo1);
            //ParameterStruct p_teacherno = new ParameterStruct("@TeacherNo", button.TeacherNo1);
            ArrayList plist = new ArrayList();
            plist.Add(p_classid);
            plist.Add(p_courseno);
            //plist.Add(p_teacherno);
            DBManipulation dbm = new DBManipulation();
            dbm.ExecuteNonQuery(sql, plist);
            // Session.Remove(name);
        }
        createtable(GetSemesterNo());
    }
    protected void ButtonSubmit_Click(object sender, EventArgs e)
    {
        string         subjectGroupNo;
        string         subjectNo;
        DBManipulation dbm = new DBManipulation();

        for (int i = 0; i < TableCellLists.Count; i++)
        {
            TableCell    c = (TableCell)TableCellLists[i];
            DropDownList d = (DropDownList)DropDownLists[i];
            subjectNo      = (string)SubjectnoLists[i];
            subjectGroupNo = d.SelectedValue;
            string          sql           = "update gcgSubject set subjectGroupNo = @subjectGroupNo where subjectno = @subjectno";
            ParameterStruct p1            = new ParameterStruct("@subjectGroupNo", subjectGroupNo);
            ParameterStruct p2            = new ParameterStruct("@subjectno", subjectNo);
            ArrayList       parameterlist = new ArrayList();
            parameterlist.Add(p1);
            parameterlist.Add(p2);
            dbm.ExecuteNonQuery(sql, parameterlist);
        }
        System.Web.UI.ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Button6_Click", "alert('修改已完成!')", true);
    }
Example #10
0
    protected void Button_SubmitSchedule_Click(object sender, EventArgs e)
    {
        if (Cache["auto"] == null)
        {
            System.Web.UI.ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Button6_Click", "alert('请先生成课表。')", true);
            //Response.Write("<script>alert('请先生成课表。')</script>");
            return;
        }
        string lessonTableName = "LessonTable" + DropDownList_Grade.SelectedValue;

        if (Cache[lessonTableName] == null)
        {
            System.Web.UI.ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Button6_Click", "alert('请先生成课表。')", true);
            return;
        }
        string dict_CourseNo_SubjectName_Name = "dict_CourseNo_SubjectName" + DropDownList_Grade.SelectedValue;

        if (Cache[dict_CourseNo_SubjectName_Name] == null)
        {
            System.Web.UI.ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Button6_Click", "alert('请先生成课表。')", true);
            return;
        }
        string dict_SubjectName_CourseNo_Name = "dict_SubjectName_CourseNo" + DropDownList_Grade.SelectedValue;

        if (Cache[dict_SubjectName_CourseNo_Name] == null)
        {
            System.Web.UI.ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Button6_Click", "alert('请先生成课表。')", true);
            return;
        }
        string dict_ClassName_ClassNo_Name = "dict_ClassName_ClassNo" + DropDownList_Grade.SelectedValue;

        if (Cache[dict_ClassName_ClassNo_Name] == null)
        {
            System.Web.UI.ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Button6_Click", "alert('请先生成课表。')", true);
            return;
        }

        Dictionary <string, string> dict_SubjectName_CourseNo = (Dictionary <string, string>)Cache[dict_SubjectName_CourseNo_Name];
        Dictionary <string, string> dict_CourseNo_SubjectName = (Dictionary <string, string>)Cache[dict_CourseNo_SubjectName_Name];
        Dictionary <string, string> dict_ClassName_ClassNo    = (Dictionary <string, string>)Cache[dict_ClassName_ClassNo_Name];

        Tea[,] Lessontable = (Tea[, ])Cache[lessonTableName];
        //以上已获得某一个年级的全部课表,老师号-科目名映射,学科号-科目名映射,班级名和班级号映射

        /*
         *   create table gcgLectureForm(--授课安排表
         *          LectureNo char(7) primary key,--授课安排编号
         *          SemesterNo char(6),--学期号,蕴含年份和上下学期信息
         *          TeacherNo char(8),--教师工号
         *          CourseNo char(3) foreign key references gcgcourse(CourseNo),--学科编号
         *          ClassNo char(4)--班级编号
         *  )
         *  create table gcgLesson(--课表
         *          LectureNo char(7) foreign key references gcgLectureForm(LectureNo),--授课安排编号
         *          --ClassRoomNo char(*)
         *          Timeid char(4) foreign key references gcgSchedule(Timeid),--时间段编号
         *          primary key(LectureNo,Timeid)--表级主码
         *  )
         */
        string          sql_forSemester = "select MAX(SemesterNo) from gcgLectureForm ";
        DBManipulation  dbm             = new DBManipulation();
        object          o          = dbm.ExecuteScalar(sql_forSemester, null);
        string          semesterNo = o.ToString();
        string          grade      = DropDownList_Grade.SelectedValue;
        string          sql_deleteTheSameSemesterRecord = "delete from gcgLesson where LectureNo in ( select LectureNo from gcgLectureForm,temp_class where gcgLectureForm.ClassNo = temp_class.class_id and class_grade = @Grade and SemesterNo = @SemesterNo)";
        ParameterStruct p_grade = new ParameterStruct("@Grade", grade);
        ParameterStruct p_seme  = new ParameterStruct("@SemesterNo", semesterNo);
        ArrayList       palist  = new ArrayList();

        palist.Add(p_grade);
        palist.Add(p_seme);

        dbm.ExecuteNonQuery(sql_deleteTheSameSemesterRecord, palist);

        /*string sql_MappingClassNameAndClassNo =
         * "    select class_name,class_id
         *      from temp_class,(
         *          select distinct ClassNo
         *              from gcgLectureForm
         *                  where SemesterNo = (
         *                      select MAX(SemesterNo)
         *                          from gcgLectureForm)) AS temp
         *      where class_id = ClassNo and class_grade = '" + DropDownList_Grade.SelectedValue + "'";
         */
        string        sql_forClassNo = "select class_id from temp_class,(select distinct ClassNo from gcgLectureForm where SemesterNo = (select MAX(SemesterNo) from gcgLectureForm)) AS temp where class_id = ClassNo and class_grade = '" + DropDownList_Grade.SelectedValue + "'";
        ArrayList     classlist      = new ArrayList();
        SqlDataReader dr             = dbm.ExecuteQueryOnLine(sql_forClassNo, null);

        while (dr.Read())
        {
            classlist.Add(dr.GetString(0));
        }
        dr.Close();
        for (int i = 0; i < classlist.Count; i++)
        {//一个一个班的写入
            //[,]Lessontable一行就存放了一个班的所有记录
            Tea[]    classTable  = new Tea[Lessontable.GetLength(1) + 1];
            string[] courseTable = new string[Lessontable.GetLength(1) + 1];
            for (int t = 0; t < 40; t++)
            {
                classTable[t] = Lessontable[i + 1, t + 1];               //取到某一个班40节课的所有教师工号
                string subjectname = dict_CourseNo_SubjectName[classTable[t].cno];
                courseTable[t] = dict_SubjectName_CourseNo[subjectname]; //取到这四十节课的学科号
            }
            for (int t = 0; t < 40; t++)
            {
                //classlist[i-1]就是对应的班级号
                string          sql_forLectureID = "select LectureNo from gcgLectureForm where SemesterNo = @SemesterNo and ClassNo = @ClassNo and CourseNo = @CourseNo";
                ParameterStruct p_semester       = new ParameterStruct("@SemesterNo", semesterNo);
                ParameterStruct p_classNo        = new ParameterStruct("@ClassNo", (string)classlist[i]);//第i个班级的班级号
                ParameterStruct p_courseNo       = new ParameterStruct("@CourseNo", courseTable[t]);
                ArrayList       plist            = new ArrayList();
                plist.Add(p_semester); plist.Add(p_classNo); plist.Add(p_courseNo);
                Object lectureID = dbm.ExecuteScalar(sql_forLectureID, plist);
                //string Timeid1 = grade + week + "0" + "1";
                string Time_part1 = DropDownList_Grade.SelectedValue;
                int    week       = 0;
                string Time_part3;
                int    temp = t + 1;
                if (temp % 8 == 0)
                {
                    week       = temp / 8;
                    Time_part3 = "0" + 8;
                }
                else
                {
                    week       = temp / 8 + 1;
                    Time_part3 = "0" + (temp - (week - 1) * 8);
                }
                string Time_part2 = week + "";

                // string Time_part3 = "0" + (t - (t / 8) * 8);

                string          sql_insert  = "insert into gcgLesson values(@lectureID,@TimeID)";
                ParameterStruct p_LectureID = new ParameterStruct("@lectureID", lectureID.ToString());
                ParameterStruct p_timeID    = new ParameterStruct("@TimeID", Time_part1 + Time_part2 + Time_part3);//第i个班级的班级号
                ArrayList       plist1      = new ArrayList();
                plist1.Add(p_LectureID);
                plist1.Add(p_timeID);
                dbm.ExecuteNonQuery(sql_insert, plist1);
            }
        }
        dbm.Close();
        System.Web.UI.ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Button6_Click", "alert('课表已保存!')", true);
    }
    protected void Update()
    {
        // Response.Write("<script>alert('nihao')</script>");
        int             i;
        ArrayList       startTime = new ArrayList();
        ArrayList       endTime   = new ArrayList();
        DBManipulation  dbm       = new DBManipulation();
        string          grade     = DropDownList_Grade.SelectedValue;
        string          week      = DropDownList_Week.SelectedValue;
        string          sql1      = "delete from gcgSchedule where Grade = @Grade and DayNo =@DayNo";
        ParameterStruct p1        = new ParameterStruct("@Grade", grade);
        ParameterStruct p2        = new ParameterStruct("@DayNo", week);
        ArrayList       plist1    = new ArrayList();

        plist1.Add(p1);
        plist1.Add(p2);
        dbm.ExecuteNonQuery(sql1, plist1);

        string starttime1 = TextBox_11.Text;
        string endtime1   = TextBox_12.Text;
        string Timeid1    = grade + week + "0" + "1";

        string[] stime1 = starttime1.Split(':');
        string[] etime1 = endtime1.Split(':');
        string   sql11  = "insert into gcgSchedule values('" + Timeid1 + "'," + week + "," + grade + "," + 1 + "," + stime1[0] + "," + etime1[0] + "," + stime1[1] + "," + etime1[1] + ")";

        dbm.ExecuteNonQuery(sql11, null);

        string starttime2 = TextBox_21.Text;
        string endtime2   = TextBox_22.Text;
        string Timeid2    = grade + week + "0" + "2";

        string[] stime2 = starttime2.Split(':');
        string[] etime2 = endtime2.Split(':');
        string   sql112 = "insert into gcgSchedule values('" + Timeid2 + "'," + week + "," + grade + "," + 1 + "," + stime2[0] + "," + etime2[0] + "," + stime2[1] + "," + etime2[1] + ")";

        dbm.ExecuteNonQuery(sql112, null);

        string starttime3 = TextBox_31.Text;
        string endtime3   = TextBox_32.Text;
        string Timeid3    = grade + week + "0" + "3";

        string[] stime3 = starttime3.Split(':');
        string[] etime3 = endtime3.Split(':');
        string   sql113 = "insert into gcgSchedule values('" + Timeid3 + "'," + week + "," + grade + "," + 1 + "," + stime3[0] + "," + etime3[0] + "," + stime3[1] + "," + etime3[1] + ")";

        dbm.ExecuteNonQuery(sql113, null);

        string starttime4 = TextBox_41.Text;
        string endtime4   = TextBox_42.Text;
        string Timeid4    = grade + week + "0" + "4";

        string[] stime4 = starttime4.Split(':');
        string[] etime4 = endtime4.Split(':');
        string   sql114 = "insert into gcgSchedule values('" + Timeid4 + "'," + week + "," + grade + "," + 1 + "," + stime4[0] + "," + etime4[0] + "," + stime4[1] + "," + etime4[1] + ")";

        dbm.ExecuteNonQuery(sql114, null);


        string starttime5 = TextBox_51.Text;
        string endtime5   = TextBox_52.Text;
        string Timeid5    = grade + week + "0" + "5";

        string[] stime5 = starttime5.Split(':');
        string[] etime5 = endtime5.Split(':');
        string   sql115 = "insert into gcgSchedule values('" + Timeid5 + "'," + week + "," + grade + "," + 1 + "," + stime5[0] + "," + etime5[0] + "," + stime5[1] + "," + etime5[1] + ")";

        dbm.ExecuteNonQuery(sql115, null);

        string starttime6 = TextBox_61.Text;
        string endtime6   = TextBox_62.Text;
        string Timeid6    = grade + week + "0" + "6";

        string[] stime6 = starttime5.Split(':');
        string[] etime6 = endtime6.Split(':');
        string   sql116 = "insert into gcgSchedule values('" + Timeid6 + "'," + week + "," + grade + "," + 1 + "," + stime6[0] + "," + etime6[0] + "," + stime6[1] + "," + etime6[1] + ")";

        dbm.ExecuteNonQuery(sql116, null);

        string starttime7 = TextBox_71.Text;
        string endtime7   = TextBox_72.Text;
        string Timeid7    = grade + week + "0" + "7";

        string[] stime7 = starttime6.Split(':');
        string[] etime7 = endtime7.Split(':');
        string   sql117 = "insert into gcgSchedule values('" + Timeid7 + "'," + week + "," + grade + "," + 1 + "," + stime7[0] + "," + etime7[0] + "," + stime7[1] + "," + etime7[1] + ")";

        dbm.ExecuteNonQuery(sql117, null);

        string starttime8 = TextBox_81.Text;
        string endtime8   = TextBox_82.Text;
        string Timeid8    = grade + week + "0" + "8";

        string[] stime8 = starttime7.Split(':');
        string[] etime8 = endtime8.Split(':');
        string   sql118 = "insert into gcgSchedule values('" + Timeid8 + "'," + week + "," + grade + "," + 1 + "," + stime8[0] + "," + etime8[0] + "," + stime8[1] + "," + etime8[1] + ")";

        dbm.ExecuteNonQuery(sql118, null);
    }
    protected void Button_submit_Click(object sender, EventArgs e)
    {
        //点击确认按钮,写入数据库
        //首先检查是否该年级该门学科所有班级都已经分配了老师,如果没有,则不允许插入,并弹窗提醒
        foreach (DropDownList d in DropDownList_select)
        {
            if (d.SelectedValue == "-1")
            {
                System.Web.UI.ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Button6_Click", "alert('尚未完成所有班级的教师安排!')", true);
                return;
            }
        }
        //  Response.Write("<script>alert('aaa')</script>");
        string year       = DropDownList_year.SelectedValue;
        string semester   = DropDownList_semester.SelectedValue;
        string semesterNo = year + semester;
        //得到学期号
        DBManipulation dbm        = new DBManipulation();
        string         sql1       = "select class_id,class_name from temp_class where class_grade = '" + DropDownList_Grade.SelectedValue + "'";
        DataSet        ds_class   = dbm.ExecuteQueryOffLine(sql1, null);
        DataTable      classTable = ds_class.Tables["defaultTable"];

        for (int i = 0; i < TableCellList_class.Count; i++)
        {
            TableCell tc        = (TableCell)TableCellList_class[i];
            string    className = tc.Text;
            string    classNo   = "";
            //查询班级编号
            foreach (DataRow r in classTable.Rows)
            {
                if (className.Equals(r["class_name"].ToString()))
                {
                    classNo = r["class_id"].ToString();
                    break;
                }
            }
            DropDownList d         = (DropDownList)DropDownList_select[i];
            string       TeacherNo = d.SelectedValue;

            /*
             * if (TeacherNo.Equals("-1")) {//如果教师号为-1,说明还没有安排老师,不写入
             *  continue;
             * }
             */
            //得到教师工号
            string courseNo = DropDownList_Course.SelectedValue;
            //得到学科号

            /*主码,前2位代表年份,一位代表年级+学期(初一1,2 初二3,4 初三5,6),2位代表班级,2位代表学科*/
            string LectureNo_part1 = year.Substring(2);
            string LectureNo_part2 = "";
            switch (DropDownList_Grade.SelectedValue)
            {
            case "1":
            {
                if (DropDownList_semester.SelectedValue.Equals("01"))
                {
                    LectureNo_part2 = "1";
                }
                else
                {
                    LectureNo_part2 = "2";
                }
                break;
            }

            case "2":
            {
                if (DropDownList_semester.SelectedValue.Equals("01"))
                {
                    LectureNo_part2 = "3";
                }
                else
                {
                    LectureNo_part2 = "4";
                }
                break;
            }

            case "3":
            {
                if (DropDownList_semester.SelectedValue.Equals("01"))
                {
                    LectureNo_part2 = "5";
                }
                else
                {
                    LectureNo_part2 = "6";
                }
                break;
            }
            }
            /*主码,前2位代表年份,一位代表年级+学期(初一1,2 初二3,4 初三5,6),2位代表班级,2位代表学科*/
            string LectureNo_part3 = classNo.Substring(2);
            string LectureNo_part4 = courseNo.Substring(1);
            string LectureNo       = LectureNo_part1 + LectureNo_part2 + LectureNo_part3 + LectureNo_part4;
            //得到授课记录主码
            //查询gcgLectureForm看是不是已经记录了这条记录,如果存在,则删除
            string sql3 = "select * from gcgLectureForm where LectureNo ='" + LectureNo + "'";
            Object o    = dbm.ExecuteScalar(sql3, null);
            if (o != null)
            {
                string sql4 = "delete from gcgLectureForm where LectureNo ='" + LectureNo + "'";
                dbm.ExecuteNonQuery(sql4, null);
            }

            /*create table gcgLectureForm(--授课安排表
             *  LectureNo char(7) primary key,--授课安排编号
             *  SemesterNo char(6),--学期号   201601
             *  TeacherNo char(8),--教师工号
             *  CourseNo char(3) ,--学科编号
             *  ClassNo char(4)--班级编号
             * )*/
            string          sql2   = "insert into gcgLectureForm values(@LectureNo,@SemesterNo,@TeacherNo,@CourseNo,@ClassNo)";
            ParameterStruct p1     = new ParameterStruct("@LectureNo", LectureNo);
            ParameterStruct p2     = new ParameterStruct("@SemesterNo", semesterNo);
            ParameterStruct p3     = new ParameterStruct("@TeacherNo", TeacherNo);
            ParameterStruct p4     = new ParameterStruct("@CourseNo", courseNo);
            ParameterStruct p5     = new ParameterStruct("@ClassNo", classNo);
            ArrayList       plist1 = new ArrayList();
            plist1.Add(p1);
            plist1.Add(p2);
            plist1.Add(p3);
            plist1.Add(p4);
            plist1.Add(p5);
            dbm.ExecuteNonQuery(sql2, plist1);
        }
        System.Web.UI.ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Button6_Click", "alert('修改已完成!')", true);
    }