Example #1
0
        internal bool AddNewCourse(AddCourse course)
        {
            bool isAdded = false;

            isAdded = dal.AddNewCourse(course);
            return(isAdded);
        }
        protected void btnAddCourse_Click(object sender, EventArgs e)
        {
            AddCourse course = new AddCourse();

            course.courseRubric = ddlRubric.SelectedValue;
            course.className    = txtCourseName.Text;
            course.courseNumber = int.Parse(txtNumber.Text);
            course.units        = int.Parse(ddlUnits.SelectedItem.Text);
            course.CourseType   = ddlCourseType.SelectedValue;
            course.Year         = DateTime.Now.Year;
            course.DeptName     = ddlDept.SelectedValue;
            bool isAdded = bizl.AddNewCourse(course);

            if (isAdded)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "Message", "<script>alert('New Course" + course.className + "added successfully!!!')</script>");
                txtNumber.Text              = "";
                txtCourseName.Text          = "";
                txt_year.Text               = string.Empty;
                ddlCourseType.SelectedIndex = 0;
                ddlDept.SelectedIndex       = 0;
                ddlRubric.SelectedIndex     = 0;
                ddlSem.SelectedIndex        = 0;
                ddlUnits.SelectedIndex      = 0;
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "Message", "<script>alert('New Course addition unsuccessfully!!!')</script>");
            }
        }
        internal bool AddNewCourse(AddCourse course)
        {
            bool isAdded = false;

            MyConnection.Open();
            try
            {
                SqlCommand insertCommand = new SqlCommand("uspAddNewCourse", MyConnection);
                insertCommand.CommandType = CommandType.StoredProcedure;
                insertCommand.Parameters.AddWithValue("@ipvRubric", course.courseRubric);
                insertCommand.Parameters.AddWithValue("@ipvCoursenumber", course.courseNumber);
                insertCommand.Parameters.AddWithValue("@ipvCoursename", course.className);
                insertCommand.Parameters.AddWithValue("@ipvUnits", course.units);
                insertCommand.Parameters.AddWithValue("@ipvCourseType", course.CourseType);
                insertCommand.Parameters.AddWithValue("@ipvDeptName", course.DeptName);
                insertCommand.Parameters.AddWithValue("@ipvYear", course.Year);

                int count = insertCommand.ExecuteNonQuery();
                if (count > 0)
                {
                    isAdded = true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
            }
            return(isAdded);
        }