示例#1
0
        public AdjustmentForm(Adjustment a)
        {
            Cancelled = true; // fail closed rather than open

            GraderAdjustment = a;

            InitializeComponent();

            pointAdjustmentNumericUpDown.Value = GraderAdjustment.PointAdjustment;

            commentTextBox.Text = GraderAdjustment.Comment;
        }
示例#2
0
 public bool AddAdjustment(int assignmentID, int studentID, Adjustment adjustment)
 {
     string query = String.Format("INSERT INTO {0} (", tables.Adjustment.TableName);
     query += String.Format("{0}, ", tables.Adjustment.StudentID);
     query += String.Format("{0}, ", tables.Adjustment.AssignmentID);
     query += String.Format("{0}", tables.Adjustment.PointAdjustment);
     if (adjustment.Comment != string.Empty)
     {
         query += String.Format(", {0}", tables.Adjustment.Comment);
     }
     query += ") VALUES (";
     query += String.Format("@{0}, ", tables.Adjustment.StudentID);
     query += String.Format("@{0}, ", tables.Adjustment.AssignmentID);
     query += String.Format("@{0}", tables.Adjustment.PointAdjustment);
     if (adjustment.Comment != string.Empty)
     {
         query += String.Format(", @{0}", tables.Adjustment.Comment);
     }
     query += ");";
     OleDbCommand insert = new OleDbCommand(query, dbConnection);
     insert.Parameters.Add(new OleDbParameter("@" + tables.Adjustment.StudentID, OleDbType.Integer)).Value = studentID;
     insert.Parameters.Add(new OleDbParameter("@" + tables.Adjustment.AssignmentID, OleDbType.Integer)).Value = assignmentID;
     insert.Parameters.Add(new OleDbParameter("@" + tables.Adjustment.PointAdjustment, OleDbType.Integer)).Value = adjustment.PointAdjustment;
     if (adjustment.Comment != string.Empty)
     {
         insert.Parameters.Add(new OleDbParameter("@" + tables.Adjustment.Comment, OleDbType.VarChar)).Value = adjustment.Comment;
     }
     try
     {
         insert.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         Debug.WriteLine("Could not insert response.");
         return false;
     }
     return true;
 }
示例#3
0
 public bool UpdateAdjustment(int assignmentID, int studentID, Adjustment adjustment)
 {
     string query = String.Format("UPDATE {0} SET ", tables.Adjustment.TableName);
     query += String.Format("{0} = @{0}, ", tables.Adjustment.StudentID);
     query += String.Format("{0} = @{0}, ", tables.Adjustment.AssignmentID);
     query += String.Format("{0} = @{0}", tables.Adjustment.PointAdjustment);
     if (adjustment.Comment != string.Empty)
     {
         query += String.Format(", {0} = @{0}", tables.Adjustment.Comment);
     }
     query += String.Format(" WHERE {0} = @{0};", tables.Adjustment.AdjustmentID);
     OleDbCommand update = new OleDbCommand(query, dbConnection);
     update.Parameters.Add(new OleDbParameter("@" + tables.Adjustment.StudentID, OleDbType.Integer)).Value = studentID;
     update.Parameters.Add(new OleDbParameter("@" + tables.Adjustment.AssignmentID, OleDbType.Integer)).Value = assignmentID;
     update.Parameters.Add(new OleDbParameter("@" + tables.Adjustment.PointAdjustment, OleDbType.Integer)).Value = adjustment.PointAdjustment;
     if (adjustment.Comment != string.Empty)
     {
         update.Parameters.Add(new OleDbParameter("@" + tables.Adjustment.Comment, OleDbType.VarChar)).Value = adjustment.Comment;
     }
     update.Parameters.Add(new OleDbParameter("@" + tables.Adjustment.AdjustmentID, OleDbType.Integer)).Value = adjustment.AdjustmentID;
     if (update.ExecuteNonQuery() == 1)
     { // we only want to affect one row
         return true;
     }
     else
     {
         return false;
     }
 }