private int SaveAssignmentToDatabase(StoredProcType procType)
        {
            int          retID = 0;
            DatabaseCall dbc   = null;

            switch (procType)
            {
            case StoredProcType.New:
                dbc = new DatabaseCall("Assignments_AddNewAssignment", DBCallType.Execute);
                dbc.AddOutputParameter("@AssignmentID");
                dbc.AddOutputParameter("@CourseAssignmentID");
                break;

            case StoredProcType.Update:
                dbc = new DatabaseCall("Assignments_UpdateExistingAssignment", DBCallType.Execute);
                dbc.AddParameter("@AssignmentID", this.AssignmentID);
                break;

            default:
                throw new Exception("Invalid Stored Procedure");
            }

            dbc.AddParameter("@ShortName", this.ShortName);
            dbc.AddNTextParameter("@Description", this.Description);
            dbc.AddParameter("@LastUpdatedDate", this.LastUpdatedDate);
            dbc.AddParameter("@LastUpdatedUserID", this.LastUpdatedUserID);
            dbc.AddParameter("@StarterProjectFlag", this.StarterProjectFlag);
            dbc.AddParameter("@MakeFile", this.MakeFile);
            dbc.AddParameter("@CompilerType", this.CompilerType);
            dbc.AddParameter("@CourseID", this.CourseID);
            dbc.AddParameter("@DueDate", this.DueDate);
            dbc.AddParameter("@MultipleSubmitsFlag", this.MultipleSubmitsFlag);
            dbc.AddParameter("@SendReminders", this.SendReminders);
            dbc.AddParameter("@AutoGradeFlag", this.AutoGradeFlag);
            dbc.AddParameter("@InputFile", this.InputFile);              // set to either DBNull or String Valu);
            dbc.AddParameter("@OutputFile", this.OutputFile);            // set to either DBNull or String Valu);
            dbc.AddParameter("@GradeType", this.GradeType);
            dbc.AddParameter("@AutoCompileFlag", this.AutoCompileFlag);
            dbc.AddParameter("@AssignmentURL", this.AssignmentURL);               // set to either DBNull or String Valu);
            dbc.AddParameter("@CommandLineArgs", this.CommandLineArgs);
            dbc.AddParameter("@SendPastDue", this.SendPastDue);
            dbc.AddParameter("@SendNewProject", this.SendNewProject);
            dbc.AddParameter("@SendUpdatedProject", this.SendUpdatedProject);
            dbc.AddParameter("@PastDueWarningDays", this.PastDueWarningDays);
            dbc.AddParameter("@ReminderWarningDays", this.ReminderWarningDays);

            dbc.Execute();

            if (procType == StoredProcType.New)
            {
                retID = Convert.ToInt32(dbc.GetOutputParam("@AssignmentID"));
                _courseAssignmentID = Convert.ToInt32(dbc.GetOutputParam("@CourseAssignmentID"));
            }

            return(retID);
        }
        private void SaveToDatabase(StoredProcType procType)
        {
            DatabaseCall dbc;

            switch (procType)
            {
            case StoredProcType.New:

                dbc = new DatabaseCall("StudentAssignments_AddNewAssignment", DBCallType.Execute);
                dbc.AddOutputParameter("@UserAssignmentID");
                break;

            case StoredProcType.Update:
                dbc = new DatabaseCall("StudentAssignments_UpdateExistingAssignment", DBCallType.Execute);
                break;

            default:
                throw new Exception("Invalid Stored Procedure");
            }

            dbc.AddParameter("@UserID", this._userID);
            dbc.AddParameter("@AssignmentID", this._assignmentID);
            dbc.AddParameter("@LastSubmitDate", this._lastSubmitDate);
            dbc.AddParameter("@LastUpdatedDate", this._lastUpdatedDate);
            dbc.AddParameter("@OverallGrade", this._overallGrade);
            dbc.AddNTextParameter("@GradeComments", this._gradeComments);
            dbc.AddParameter("@AutoCompileStatus", this._autoCompileStatus);
            dbc.AddParameter("@AutoGradeStatus", this._autoGradeStatus);
            dbc.AddNTextParameter("@BuildDetails", this._buildDetails);
            dbc.AddNTextParameter("@CheckDetails", this._checkDetails);
            dbc.AddParameter("@BuildResultCode", this._buildResultCode);
            dbc.AddParameter("@CheckResultCode", this._checkResultCode);

            dbc.Execute();

            if (procType == StoredProcType.New)
            {
                this._userAssignmentID = Convert.ToInt32(dbc.GetOutputParam("@UserAssignmentID"));
            }
        }
        private int saveUserToDatabase(StoredProcType sprocType)
        {
            DatabaseCall dbc;
            int          retID = 0;

            if (sprocType == StoredProcType.Create)
            {
                dbc = new DatabaseCall("Users_CreateNew", DBCallType.Execute);
                dbc.AddOutputParameter("@UserID");
            }
            else if (sprocType == StoredProcType.Update)
            {
                dbc = new DatabaseCall("Users_UpdateExisting", DBCallType.Execute);
                dbc.AddParameter("@UserID", _userID);
            }
            else
            {
                throw new Exception("Unknown Stored Procedure Type");
            }

            dbc.AddParameter("@LastName", _lastName);
            dbc.AddParameter("FirstName", _firstName);
            dbc.AddParameter("@MiddleName", _middleName);
            dbc.AddParameter("@Email", _emailAddress);
            dbc.AddParameter("@UniversityIdentifier", _universityID);
            dbc.AddParameter("@UserName", _username);
            dbc.AddParameter("@Password", _password);
            dbc.AddParameter("@LastUpdatedDate", _lastUpdatedDate);
            dbc.AddParameter("@LastUpdatedUserID", _lastUpdatedUserID);
            dbc.AddParameter("@ChangedPassword", _changedPassword);

            dbc.Execute();
            if (sprocType == StoredProcType.Create)
            {
                retID        = Convert.ToInt32(dbc.GetOutputParam("@UserID"));
                this._userID = retID;
            }

            return(retID);
        }