예제 #1
0
        public bool addconstraint(constraints addthis)
        {
            SqlConnection con        = new SqlConnection(constring);
            SqlCommand    newcommand = new SqlCommand("INSERT INTO dbo.Constraints (StartTime,EndTime,Day,CourseID,LecturerID,Lecture_type,ClassID,CourseName,LecturerName,Year,Semester) VALUES (@StartTime,@EndTime,@Day,@CourseID,@LecturerID,@Lecture_type,@ClassID,@CourseName,@LecturerName,@Year,@Semester)", con);

            newcommand.Parameters.Add("@StartTime", addthis.getStart());
            newcommand.Parameters.Add("@EndTime", addthis.getEnd());
            newcommand.Parameters.Add("@Day", addthis.getday());
            newcommand.Parameters.Add("@CourseID", addthis.getcourseid());
            newcommand.Parameters.Add("@LecturerID", addthis.getlecturerid());
            newcommand.Parameters.Add("@Lecture_type", addthis.gettype());
            newcommand.Parameters.Add("@ClassID", addthis.getclassroom());
            newcommand.Parameters.Add("@CourseName", addthis.getcoursename());
            newcommand.Parameters.Add("@LecturerName", addthis.getlecturer());
            newcommand.Parameters.Add("@Year", addthis.getyear());
            newcommand.Parameters.Add("@Semester", addthis.getsemester());
            con.Open();
            if (con.State == System.Data.ConnectionState.Open)
            {
                newcommand.ExecuteNonQuery();
                con.Close();
                return(true);
            }
            return(false);
        }