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

📄 student_electchoosecourse.aspx.cs

📁 该系统是一个集成多功能的信息管理系统
💻 CS
📖 第 1 页 / 共 3 页
字号:
                        string courseName1 = GridView1.Rows[m].Cells[2].Text.ToString();
                        string courseName2 = GridView1.Rows[n].Cells[2].Text.ToString();
                        SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["strcon"]);
                        con.Open();

                        string capacity11 = GridView1.Rows[m].Cells[9].Text.ToString();
                        string capacity22 = GridView1.Rows[n].Cells[9].Text.ToString();
                        int capacity1 = Math.Abs(Convert.ToInt32(capacity11));
                        int capacity2 = Math.Abs(Convert.ToInt32(capacity22));
                        string choosed11 = GridView1.Rows[m].Cells[10].Text.ToString();
                        string choosed22 = GridView1.Rows[n].Cells[10].Text.ToString();
                        int choosed1 = Math.Abs(Convert.ToInt32(choosed11));
                        int choosed2 = Math.Abs(Convert.ToInt32(choosed22));
                        choosed1++;
                        choosed2++;
                        string remain11 = GridView1.Rows[m].Cells[11].Text.ToString();
                        string remain22 = GridView1.Rows[n].Cells[11].Text.ToString();
                        int remain1 = Math.Abs(Convert.ToInt32(remain11));
                        int remain2 = Math.Abs(Convert.ToInt32(remain22));
                        remain1--;
                        remain2--;
                        SqlCommand scd1 = new SqlCommand("select count(*) from ts_xs_stdChooseCoursesInfo where courseName = '" + courseName1 + "'", con);
                        int sdSQL1 = Convert.ToInt32(scd1.ExecuteScalar());
                        SqlCommand scd2 = new SqlCommand("select count(*) from ts_xs_stdChooseCoursesInfo where courseName = '" + courseName2 + "'", con);
                        int sdSQL2 = Convert.ToInt32(scd2.ExecuteScalar());
                        if (sdSQL1 <= 0 && sdSQL2 <= 0)
                        {
                            SqlCommand sdm1 = new SqlCommand("select courseCode from ts_xs_chooseCoursesInfo where courseName = '" + courseName1 + "'and courseStudyYear = '" + Session["currentlyStudyYear"].ToString() + "'and courseSemester = '" + Convert.ToInt32(Session["currentlySemester"]) + "'", con);
                            
                            string courseCodem = Convert.ToString(sdm1.ExecuteScalar());
                            SqlCommand sdn1 = new SqlCommand("select courseCode from ts_xs_chooseCoursesInfo where courseName = '" + courseName2 + "'and courseStudyYear = '" + Session["currentlyStudyYear"].ToString() + "'and courseSemester = '" + Convert.ToInt32(Session["currentlySemester"]) + "'", con);
                            string courseCoden = Convert.ToString(sdn1.ExecuteScalar());
                            SqlCommand sdm2 = new SqlCommand("select teacherCode from ts_xs_chooseCoursesInfo where courseName = '" + courseName1 + "'and courseStudyYear = '" + Session["currentlyStudyYear"].ToString() + "'and courseSemester = '" + Convert.ToInt32(Session["currentlySemester"]) + "'", con);
                           
                            string teacherCodem = Convert.ToString(sdm2.ExecuteScalar());
                            SqlCommand sdn2 = new SqlCommand("select teacherCode from ts_xs_chooseCoursesInfo where courseName = '" + courseName2 + "'and courseStudyYear = '" + Session["currentlyStudyYear"].ToString() + "'and courseSemester = '" + Convert.ToInt32(Session["currentlySemester"]) + "'", con);
                            string teacherCoden = Convert.ToString(sdn2.ExecuteScalar());
                            SqlCommand sdm3 = new SqlCommand("select teacherName from ts_xs_chooseCoursesInfo where courseName = '" + courseName1 + "'and courseStudyYear = '" + Session["currentlyStudyYear"].ToString() + "'and courseSemester = '" + Convert.ToInt32(Session["currentlySemester"]) + "'", con);
                            
                            string teacherNamem = Convert.ToString(sdm3.ExecuteScalar());
                            SqlCommand sdn3 = new SqlCommand("select teacherName from ts_xs_chooseCoursesInfo where courseName = '" + courseName2 + "'and courseStudyYear = '" + Session["currentlyStudyYear"].ToString() + "'and courseSemester = '" + Convert.ToInt32(Session["currentlySemester"]) + "'", con);
                            string teacherNamen = Convert.ToString(sdn3.ExecuteScalar());
                            SqlCommand sdm4 = new SqlCommand("select courseTime from ts_xs_chooseCoursesInfo where courseName = '" + courseName1 + "'and courseStudyYear = '" + Session["currentlyStudyYear"].ToString() + "'and courseSemester = '" + Convert.ToInt32(Session["currentlySemester"]) + "'", con);
                            
                            string courseTimem = Convert.ToString(sdm4.ExecuteScalar());
                            SqlCommand sdn4 = new SqlCommand("select courseTime from ts_xs_chooseCoursesInfo where courseName = '" + courseName2 + "'and courseStudyYear = '" + Session["currentlyStudyYear"].ToString() + "'and courseSemester = '" + Convert.ToInt32(Session["currentlySemester"]) + "'", con);
                            string courseTimen = Convert.ToString(sdn4.ExecuteScalar());
                            SqlCommand sdm5 = new SqlCommand("select coursePlace from ts_xs_chooseCoursesInfo where courseName = '" + courseName1 + "'and courseStudyYear = '" + Session["currentlyStudyYear"].ToString() + "'and courseSemester = '" + Convert.ToInt32(Session["currentlySemester"]) + "'", con);
                            
                            string coursePlacem = Convert.ToString(sdm5.ExecuteScalar());
                            SqlCommand sdn5 = new SqlCommand("select coursePlace from ts_xs_chooseCoursesInfo where courseName = '" + courseName2 + "'and courseStudyYear = '" + Session["currentlyStudyYear"].ToString() + "'and courseSemester = '" + Convert.ToInt32(Session["currentlySemester"]) + "'", con);
                            string coursePlacen = Convert.ToString(sdn5.ExecuteScalar());
                            SqlCommand sdm6 = new SqlCommand("select creditHour from ts_xs_chooseCoursesInfo where courseName = '" + courseName1 + "'and courseStudyYear = '" + Session["currentlyStudyYear"].ToString() + "'and courseSemester = '" + Convert.ToInt32(Session["currentlySemester"]) + "'", con);
                            
                            int creditHourm = Convert.ToInt32(sdm6.ExecuteScalar());
                            SqlCommand sdn6 = new SqlCommand("select creditHour from ts_xs_chooseCoursesInfo where courseName = '" + courseName2 + "'and courseStudyYear = '" + Session["currentlyStudyYear"].ToString() + "'and courseSemester = '" + Convert.ToInt32(Session["currentlySemester"]) + "'", con);
                            int creditHourn = Convert.ToInt32(sdn6.ExecuteScalar());
                            SqlCommand sdm7 = new SqlCommand("select weekPeriod from ts_xs_chooseCoursesInfo where courseName = '" + courseName1 + "'and courseStudyYear = '" + Session["currentlyStudyYear"].ToString() + "'and courseSemester = '" + Convert.ToInt32(Session["currentlySemester"]) + "'", con);
                            
                            int weekPeriodm = Convert.ToInt32(sdm7.ExecuteScalar());
                            SqlCommand sdn7 = new SqlCommand("select weekPeriod from ts_xs_chooseCoursesInfo where courseName = '" + courseName2 + "'and courseStudyYear = '" + Session["currentlyStudyYear"].ToString() + "'and courseSemester = '" + Convert.ToInt32(Session["currentlySemester"]) + "'", con);
                            int weekPeriodn = Convert.ToInt32(sdn7.ExecuteScalar());
                            SqlCommand sdm8 = new SqlCommand("select weekDateFrom from ts_xs_chooseCoursesInfo where courseName = '" + courseName1 + "'and courseStudyYear = '" + Session["currentlyStudyYear"].ToString() + "'and courseSemester = '" + Convert.ToInt32(Session["currentlySemester"]) + "'", con);
                            
                            string weekDateFromm = Convert.ToString(sdm8.ExecuteScalar());
                            SqlCommand sdn8 = new SqlCommand("select weekDateFrom from ts_xs_chooseCoursesInfo where courseName = '" + courseName2 + "'and courseStudyYear = '" + Session["currentlyStudyYear"].ToString() + "'and courseSemester = '" + Convert.ToInt32(Session["currentlySemester"]) + "'", con);
                            string weekDateFromn = Convert.ToString(sdn8.ExecuteScalar());
                            SqlCommand sdm9 = new SqlCommand("select remark from ts_xs_chooseCoursesInfo where courseName = '" + courseName1 + "'and courseStudyYear = '" + Session["currentlyStudyYear"].ToString() + "'and courseSemester = '" + Convert.ToInt32(Session["currentlySemester"]) + "'", con);
                            
                            string remarkm = Convert.ToString(sdm9.ExecuteScalar());
                            SqlCommand sdn9 = new SqlCommand("select remark from ts_xs_chooseCoursesInfo where courseName = '" + courseName2 + "'and courseStudyYear = '" + Session["currentlyStudyYear"].ToString() + "'and courseSemester = '" + Convert.ToInt32(Session["currentlySemester"]) + "'", con);
                            string remarkn = Convert.ToString(sdn9.ExecuteScalar());
                            SqlCommand sdm10 = new SqlCommand("select courseProperty from ts_xs_chooseCoursesInfo where courseName = '" + courseName1 + "'and courseStudyYear = '" + Session["currentlyStudyYear"].ToString() + "'and courseSemester = '" + Convert.ToInt32(Session["currentlySemester"]) + "'", con);
                            
                            string coursePropertym = Convert.ToString(sdm10.ExecuteScalar());
                            SqlCommand sdn10 = new SqlCommand("select courseProperty from ts_xs_chooseCoursesInfo where courseName = '" + courseName2 + "'and courseStudyYear = '" + Session["currentlyStudyYear"].ToString() + "'and courseSemester = '" + Convert.ToInt32(Session["currentlySemester"]) + "'", con);
                            string coursePropertyn = Convert.ToString(sdn10.ExecuteScalar());
                            SqlCommand sdm11 = new SqlCommand("select schoolArea from ts_xs_chooseCoursesInfo where courseName = '" + courseName1 + "'and courseStudyYear = '" + Session["currentlyStudyYear"].ToString() + "'and courseSemester = '" + Convert.ToInt32(Session["currentlySemester"]) + "'", con);
                            
                            string schoolAream = Convert.ToString(sdm11.ExecuteScalar());
                            SqlCommand sdn11 = new SqlCommand("select schoolArea from ts_xs_chooseCoursesInfo where courseName = '" + courseName2 + "'and courseStudyYear = '" + Session["currentlyStudyYear"].ToString() + "'and courseSemester = '" + Convert.ToInt32(Session["currentlySemester"]) + "'", con);
                            string schoolArean = Convert.ToString(sdn11.ExecuteScalar());
                            SqlCommand sdm12 = new SqlCommand("select courseCollege from ts_xs_chooseCoursesInfo where courseName = '" + courseName1 + "'and courseStudyYear = '" + Session["currentlyStudyYear"].ToString() + "'and courseSemester = '" + Convert.ToInt32(Session["currentlySemester"]) + "'", con);
                            
                            string courseCollegem = Convert.ToString(sdm12.ExecuteScalar());
                            SqlCommand sdn12 = new SqlCommand("select courseCollege from ts_xs_chooseCoursesInfo where courseName = '" + courseName2 + "'and courseStudyYear = '" + Session["currentlyStudyYear"].ToString() + "'and courseSemester = '" + Convert.ToInt32(Session["currentlySemester"]) + "'", con);
                            string courseCollegen = Convert.ToString(sdn12.ExecuteScalar());
                            string SQL = "insert into ts_xs_stdChooseCoursesInfo (studyNumber,studentName,IDcardNumber,college,speciality,teachedClass,adminClass,courseCode,ifChoose,ifTeachingMaterial,courseName,teacherCode,teacherName,courseTime,coursePlace,creditHour,weekPeriod,weekDateFrom,remark,courseProperty,schoolArea,courseCollege,courseStudyYear,courseSemester,chooseDate) values('" + Session["stdUserName"].ToString() + "','" + Session["stdName"].ToString() + "','" + Session["stdIDcardNumber"].ToString() + "','"+ Session["stdCollege"].ToString() +"','" + Session["stdSpeciality"].ToString() + "','" + Session["stdTeachedClass"].ToString() + "','" + Session["stdAdminClass"] + "','" + courseCodem + "','" + Convert.ToInt32(Session["currentlySemester"]) + "','" + p + "','" + courseName1 + "','" + teacherCodem + "','" + teacherNamem + "','" + courseTimem + "','" + coursePlacem + "','" + creditHourm + "','" + weekPeriodm + "','" + weekDateFromm + "','" + remarkm + "','" + coursePropertym + "','" + schoolAream + "','" + courseCollegem + "','" + Session["currentlyStudyYear"].ToString() + "','" + Convert.ToInt32(Session["currentlySemester"]) + "','"+ System.DateTime.Now.ToString() +"')";
                            string SQL1 = "update ts_xs_chooseCoursesInfo set choosed=  '" + choosed1 + "' where courseName='" + courseName1 + "' and courseStudyYear = '" + Session["currentlyStudyYear"].ToString() + "' and courseSemester ='" + Convert.ToInt32(Session["currentlySemester"]) + "'";
                            string SQL2 = "update ts_xs_chooseCoursesInfo set remain=  '" + remain1 + "' where courseName='" + courseName1 + "' and courseStudyYear = '" + Session["currentlyStudyYear"].ToString() + "' and courseSemester ='" + Convert.ToInt32(Session["currentlySemester"]) + "'";
                            string SQL3 = "insert into ts_xs_stdChooseCoursesInfo (studyNumber,studnetName,IDcardNumber,college,speciality,teachedClass,adminClass,courseCode,ifChoose,ifTeachingMaterial,courseName,teacherCode,teacherName,courseTime,coursePlace,creditHour,weekPeriod,weekDateFrom,remark,courseProperty,schoolArea,courseCollege,courseStudyYear,courseSemester,chooseDate) values('" + Session["stdUserName"].ToString() + "','" + Session["stdName"].ToString() + "','" + Session["stdIDcardNumber"].ToString() + "','" + Session["stdCollege"].ToString() + "','" + Session["stdSpeciality"].ToString() + "','" + Session["stdTeachedClass"].ToString() + "','" + Session["stdAdminClass"] + "','" + courseCoden + "','" + Convert.ToInt32(Session["currentlySemester"]) + "','" + q + "','" + courseName2 + "','" + teacherCoden + "','" + teacherNamen + "','" + courseTimen + "','" + coursePlacen + "','" + creditHourn + "','" + weekPeriodn + "','" + weekDateFromn + "','" + remarkn + "','" + coursePropertyn + "','" + schoolArean + "','" + courseCollegen + "','" + Session["currentlyStudyYear"].ToString() + "','" + Convert.ToInt32(Session["currentlySemester"]) + "','" + System.DateTime.Now.ToString() + "')";
                            string SQL4 = "update ts_xs_chooseCoursesInfo set choosed=  '" + choosed2 + "' where courseName='" + courseName2 + "' and courseStudyYear = '" + Session["currentlyStudyYear"].ToString() + "' and courseSemester ='" + Convert.ToInt32(Session["currentlySemester"]) + "'";
                            string SQL5 = "update ts_xs_chooseCoursesInfo set remain=  '" + remain2 + "' where courseName='" + courseName2 + "' and courseStudyYear = '" + Session["currentlyStudyYear"].ToString() + "' and courseSemester ='" + Convert.ToInt32(Session["currentlySemester"]) + "'";
                            if (bc.ExecSQL(SQL) && bc.ExecSQL(SQL1) && bc.ExecSQL(SQL2) && bc.ExecSQL(SQL3) && bc.ExecSQL(SQL4) && bc.ExecSQL(SQL5))
                            {
                                con.Close();
                                this.bind1();
                                this.bind2();
                                this.bind3();
                                Response.Write("<script>alert('你已成功选择这两门选修课!')</script>");
                                
                            }
                            else
                            {
                                con.Close();
                                Response.Write("<script>alert('数据提交不成功!系统忙!请稍后再试!');history.back()</script>");
                                
                            }
                            
                        }
                    }
                }
            }
            else
            {
                Response.Write("<script>alert('你已经选择了多于两门选修课,每次只能选择两门选修课!');history.back()</script>");
            }
        }
    }

    protected void GridView2_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["strcon"]);
        con.Open();
        string id = GridView2.DataKeys[e.RowIndex].Value.ToString();
        SqlCommand scd = new SqlCommand("delete  from ts_xs_stdChooseCoursesInfo where id= '"+ id +"'", con);
        scd.ExecuteNonQuery();
        con.Close();
        Response.Write("<script>alert('" + id + "')</script>");
        this.bind2();
        this.bind3();
    }

    protected void GridView2_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
}

⌨️ 快捷键说明

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