コード例 #1
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (inpputVal() == false)
            {
                return;
            }

            string clear = "";
            Course course = new Course(int.Parse(txtCRN.Text), txtTitle.Text, int.Parse(ddDepartment.SelectedValue), ddSemester.SelectedValue, txtSectionNum.Text, txtProfessor.Text, ddTimeCode.SelectedValue, ddDayCode.SelectedValue, int.Parse(ddCreditHours.SelectedValue), int.Parse(txtMaxSeats.Text));
            course.SaveCourse();
            Page.ClientScript.RegisterStartupScript(this.GetType(), "Scripts", "<script>alert('Your course has been added successfully:)');</script>");
            txtCRN.Text = clear;
            txtMaxSeats.Text = clear;
            txtProfessor.Text = clear;
            txtSectionNum.Text = clear;
            txtTitle.Text = clear;
            //  Response.Redirect("NewCoursePage.aspx");
        }
コード例 #2
0
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            string title = "";
            string name = ddStudentSelect.SelectedItem.Text;
            int studentID = int.Parse(ddStudentSelect.SelectedValue);
            int checkedBoxCount = 0;
            for (int row = 0; row < gvCourses.Rows.Count; row++)
            {
                CheckBox CBox;
                CBox = (CheckBox)gvCourses.Rows[row].FindControl("cbSelectCourse");

                if (CBox.Checked)
                {

                  //  string courseCRN = gvCourses.Rows[row].Cells[1].Text;
                    int crn = int.Parse(gvCourses.Rows[row].Cells[1].Text);
                    float price = 1000 * int.Parse(gvCourses.Rows[row].Cells[9].Text);
                    title = gvCourses.Rows[row].Cells[2].Text;
                    Course c = new Course(crn, title, int.Parse(gvCourses.Rows[row].Cells[3].Text), gvCourses.Rows[row].Cells[4].Text, gvCourses.Rows[row].Cells[5].Text, gvCourses.Rows[row].Cells[6].Text, gvCourses.Rows[row].Cells[7].Text, gvCourses.Rows[row].Cells[8].Text, int.Parse(gvCourses.Rows[row].Cells[9].Text), int.Parse(gvCourses.Rows[row].Cells[11].Text));
                    SqlCommand command = new SqlCommand();
                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = "CourseRegistration";
                    command.Parameters.AddWithValue("@CRN", crn);
                    command.Parameters.AddWithValue("@StudentID", studentID);
                    command.Parameters.AddWithValue("@Name", name);
                    command.Parameters.AddWithValue("@Title", title);
                    command.Parameters.AddWithValue("@Price", price);
                    DBConnect DB = new DBConnect();
                    DB.DoUpdateUsingCmdObj(command);
                    if (c.DecrementSeats() == -1)
                    {
                        gvCourses.Rows[row].Cells[0].Enabled = false;
                    }
                    c.DecrementSeats();
                    rebind();

                    checkedBoxCount++;
                }
            }
        }