public void UpdateTimeZoneRule(int ruleID, SqlString WrittenName, int offsetmins, int year_start, int year_end, int StartTimeOfDay, int StartDayOfWeek, int StartWeek, int StartMonth, int EndTimeOfDay, int EndDayOfWeek, int EndWeek, int EndMonth, out bool error ) { error = false; SqlParameter prmError = StoredProcedure.CreateOutputParam("@Error", SqlDbType.Bit); prmError.Direction = ParameterDirection.Output; using (StoredProcedure sp = new StoredProcedure("prcTimeZoneRule_update", StoredProcedure.CreateInputParam("@RuleID", SqlDbType.Int, ruleID), StoredProcedure.CreateInputParam("@WrittenName", SqlDbType.NVarChar, 60, WrittenName), StoredProcedure.CreateInputParam("@OffsetDaylight", SqlDbType.Int, offsetmins), StoredProcedure.CreateInputParam("@year_start", SqlDbType.Int, year_start), StoredProcedure.CreateInputParam("@year_end", SqlDbType.Int, year_end), StoredProcedure.CreateInputParam("@StartTimeOfDay", SqlDbType.Int, StartTimeOfDay), StoredProcedure.CreateInputParam("@day_start", SqlDbType.Int, StartDayOfWeek), StoredProcedure.CreateInputParam("@week_start", SqlDbType.Int, StartWeek), StoredProcedure.CreateInputParam("@StartMonth", SqlDbType.Int, StartMonth), StoredProcedure.CreateInputParam("@EndTimeOfDay", SqlDbType.Int, EndTimeOfDay), StoredProcedure.CreateInputParam("@EndDayOfWeek", SqlDbType.Int, EndDayOfWeek), StoredProcedure.CreateInputParam("@EndWeek", SqlDbType.Int, EndWeek), StoredProcedure.CreateInputParam("@EndMonth", SqlDbType.Int, EndMonth), prmError ) ) { sp.ExecuteNonQuery(); error = (bool)prmError.Value; } }
} // Update /// <summary> /// Creates a course. /// </summary> /// <remarks> /// Assumptions: None /// Notes: /// Author: Gavin Buddis /// Date: 03/03/2004 /// Changes: /// </remarks> /// <param name="name">Name of the course</param> /// <param name="notes">Notes for this course</param> /// <param name="active">Is this course active</param> /// <param name="createdByUserID">Id of the user creatig this course</param> public int Create(string name, string notes, bool active, int createdByUserID) { int intCourseID = 0; SqlParameter paramKey = StoredProcedure.CreateOutputParam("@intCourseID", SqlDbType.Int, 4, intCourseID); using (StoredProcedure sp = new StoredProcedure("prcCourse_Create", paramKey, StoredProcedure.CreateInputParam("@name", SqlDbType.NVarChar, 100, name), StoredProcedure.CreateInputParam("@notes", SqlDbType.NVarChar, 1000, notes), StoredProcedure.CreateInputParam("@active", SqlDbType.Bit, active), StoredProcedure.CreateInputParam("@userID", SqlDbType.Int, createdByUserID) )) { SqlDataReader rdr = sp.ExecuteReader(); int intErrorNumber; // Holds the error number return from the stored procedure. string strErrorMessage; // Holds the error message return from the stored procedure. //1. Get the response. rdr.Read(); intErrorNumber = rdr.GetInt32(0); strErrorMessage = rdr.GetString(1); //2. Close the reader. rdr.Close(); //4. Throw the required exception if error number is not 0. switch (intErrorNumber) { case 0: // Succeeded. { intCourseID = (int)paramKey.Value; return(intCourseID); } case 4: // Unique constraint. { throw new UniqueViolationException(String.Format(ResourceManager.GetString("prcCourse_Create.4"), name)); } case 5: // Parameter Exception. { throw new ParameterException(strErrorMessage); } case 6: // Permission Denied. { throw new PermissionDeniedException(strErrorMessage); } default: // Whatever is left. { throw new BusinessServiceException(strErrorMessage); } } } } // Create