コード例 #1
0
ファイル: CourseDA.cs プロジェクト: haripradhan/LMS
        /// <summary>
        /// Saves an Course in the database.
        /// </summary>
        /// <param name="myCourse">The Course to store.</param>
        /// <returns>The new Course id if the Course is new in the database or the existing ID when an record was updated.</returns>
        public static int Save(Course myCourse)
        {
            int result = 0;
            using (SqlConnection myConnection = new SqlConnection(AppSettings.ConnectionString))
            {
                SqlCommand myCommand = new SqlCommand("spSaveCourse", myConnection);
                myCommand.CommandType = CommandType.StoredProcedure;
                myCommand.Parameters.AddWithValue("@CourseID", myCourse.CourseId);
                myCommand.Parameters.AddWithValue("@CName", myCourse.CName);
                myCommand.Parameters.AddWithValue("@CreditHours", myCourse.CreditHours);
                myCommand.Parameters.AddWithValue("@Level", myCourse.Level);
                myCommand.Parameters.AddWithValue("@Semester", myCourse.Semester);
                myCommand.Parameters.AddWithValue("@Year", myCourse.Year);
                myCommand.Parameters.AddWithValue("@DNo", myCourse.DNo);
                myCommand.Parameters.AddWithValue("@IID", myCourse.IId);

                DbParameter retValue = myCommand.CreateParameter();
                retValue.Direction = ParameterDirection.ReturnValue;
                myCommand.Parameters.Add(retValue);

                myConnection.Open();
                myCommand.ExecuteNonQuery();
                result = Convert.ToInt32(retValue.Value);
                myConnection.Close();
            }
            return result;
        }
コード例 #2
0
ファイル: CourseDA.cs プロジェクト: haripradhan/LMS
 /// <summary>
 /// Creates an instance of Course from the data record in the database.
 /// </summary>
 /// <param name="myRecord">Single row of record.</param>
 /// <returns>An Course.</returns>
 private static Course FillRecord(IDataRecord myRecord)
 {
     Course myCourse = new Course();
     myCourse.CourseId = myRecord.GetString(myRecord.GetOrdinal("CourseID"));
     myCourse.CName = myRecord.GetString(myRecord.GetOrdinal("CName"));
     //myCourse.CreditHours = myRecord.GetFloat(myRecord.GetOrdinal("CreditHours"));
     //myCourse.Level = myRecord.GetInt32(myRecord.GetOrdinal("Level"));
     //myCourse.Semester = myRecord.GetString(myRecord.GetOrdinal("Semester"));
     //myCourse.Year = myRecord.GetString(myRecord.GetOrdinal("Year"));
     //myCourse.DNo = myRecord.GetInt32(myRecord.GetOrdinal("DNo"));
     //myCourse.IId = myRecord.GetString(myRecord.GetOrdinal("IID"));
     myCourse.Instructor.FName = myRecord.GetString(myRecord.GetOrdinal("FName"));
     myCourse.Instructor.MI = myRecord.GetString(myRecord.GetOrdinal("MI"));
     myCourse.Instructor.LName = myRecord.GetString(myRecord.GetOrdinal("LName"));
     return myCourse;
 }
コード例 #3
0
ファイル: CourseController.cs プロジェクト: haripradhan/LMS
 public static int Save(Course myCourse)
 {
     return CourseDA.Save(myCourse);
 }