Admin can delete homework

This commit is contained in:
Tim Young 2017-07-31 11:44:42 -05:00
parent 60881f8dcf
commit cc6b5321d6
3 changed files with 152 additions and 117 deletions

View File

@ -36,23 +36,24 @@
this.lblUsername = new System.Windows.Forms.Label();
this.tbUsername = new System.Windows.Forms.TextBox();
this.TabClasswork = new System.Windows.Forms.TabPage();
this.tvClasswork = new System.Windows.Forms.TreeView();
this.btnExit = new System.Windows.Forms.Button();
this.tcTreeData = new System.Windows.Forms.TabControl();
this.tabClass = new System.Windows.Forms.TabPage();
this.TabHomework = new System.Windows.Forms.TabPage();
this.TabStudent = new System.Windows.Forms.TabPage();
this.tbHWClass = new System.Windows.Forms.TextBox();
this.tbHWName = new System.Windows.Forms.TextBox();
this.tbHWDescription = new System.Windows.Forms.TextBox();
this.lblHWClass = new System.Windows.Forms.Label();
this.lblHWName = new System.Windows.Forms.Label();
this.lblHWDescription = new System.Windows.Forms.Label();
this.dtpHWDue = new System.Windows.Forms.DateTimePicker();
this.lblHWDue = new System.Windows.Forms.Label();
this.tbHWSubmitted = new System.Windows.Forms.TextBox();
this.lblHWSubmitted = new System.Windows.Forms.Label();
this.btnImportStudents = new System.Windows.Forms.Button();
this.TabHomework = new System.Windows.Forms.TabPage();
this.lblHWSubmitted = new System.Windows.Forms.Label();
this.tbHWSubmitted = new System.Windows.Forms.TextBox();
this.lblHWDue = new System.Windows.Forms.Label();
this.dtpHWDue = new System.Windows.Forms.DateTimePicker();
this.lblHWDescription = new System.Windows.Forms.Label();
this.lblHWName = new System.Windows.Forms.Label();
this.lblHWClass = new System.Windows.Forms.Label();
this.tbHWDescription = new System.Windows.Forms.TextBox();
this.tbHWName = new System.Windows.Forms.TextBox();
this.tbHWClass = new System.Windows.Forms.TextBox();
this.TabStudent = new System.Windows.Forms.TabPage();
this.tvClasswork = new System.Windows.Forms.TreeView();
this.btnExit = new System.Windows.Forms.Button();
this.btnHWDelete = new System.Windows.Forms.Button();
this.tcTabControl.SuspendLayout();
this.TabProfile.SuspendLayout();
this.TabClasswork.SuspendLayout();
@ -145,27 +146,6 @@
this.TabClasswork.Text = "Classwork";
this.TabClasswork.UseVisualStyleBackColor = true;
//
// tvClasswork
//
this.tvClasswork.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.tvClasswork.Location = new System.Drawing.Point(6, 6);
this.tvClasswork.Name = "tvClasswork";
this.tvClasswork.Size = new System.Drawing.Size(131, 239);
this.tvClasswork.TabIndex = 0;
this.tvClasswork.Click += new System.EventHandler(this.tvClasswork_Click);
//
// btnExit
//
this.btnExit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnExit.Location = new System.Drawing.Point(351, 298);
this.btnExit.Name = "btnExit";
this.btnExit.Size = new System.Drawing.Size(75, 23);
this.btnExit.TabIndex = 1;
this.btnExit.Text = "Exit";
this.btnExit.UseVisualStyleBackColor = true;
this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
//
// tcTreeData
//
this.tcTreeData.Controls.Add(this.tabClass);
@ -188,8 +168,18 @@
this.tabClass.Text = "Class";
this.tabClass.UseVisualStyleBackColor = true;
//
// btnImportStudents
//
this.btnImportStudents.Location = new System.Drawing.Point(6, 6);
this.btnImportStudents.Name = "btnImportStudents";
this.btnImportStudents.Size = new System.Drawing.Size(164, 23);
this.btnImportStudents.TabIndex = 0;
this.btnImportStudents.Text = "Import Students";
this.btnImportStudents.UseVisualStyleBackColor = true;
//
// TabHomework
//
this.TabHomework.Controls.Add(this.btnHWDelete);
this.TabHomework.Controls.Add(this.lblHWSubmitted);
this.TabHomework.Controls.Add(this.tbHWSubmitted);
this.TabHomework.Controls.Add(this.lblHWDue);
@ -208,71 +198,21 @@
this.TabHomework.Text = "Homework";
this.TabHomework.UseVisualStyleBackColor = true;
//
// TabStudent
// lblHWSubmitted
//
this.TabStudent.Location = new System.Drawing.Point(4, 25);
this.TabStudent.Name = "TabStudent";
this.TabStudent.Padding = new System.Windows.Forms.Padding(3);
this.TabStudent.Size = new System.Drawing.Size(256, 206);
this.TabStudent.TabIndex = 2;
this.TabStudent.Text = "Student";
this.TabStudent.UseVisualStyleBackColor = true;
this.lblHWSubmitted.AutoSize = true;
this.lblHWSubmitted.Location = new System.Drawing.Point(6, 125);
this.lblHWSubmitted.Name = "lblHWSubmitted";
this.lblHWSubmitted.Size = new System.Drawing.Size(71, 17);
this.lblHWSubmitted.TabIndex = 9;
this.lblHWSubmitted.Text = "Submitted";
//
// tbHWClass
// tbHWSubmitted
//
this.tbHWClass.Location = new System.Drawing.Point(131, 6);
this.tbHWClass.Name = "tbHWClass";
this.tbHWClass.Size = new System.Drawing.Size(100, 22);
this.tbHWClass.TabIndex = 0;
//
// tbHWName
//
this.tbHWName.Location = new System.Drawing.Point(131, 36);
this.tbHWName.Name = "tbHWName";
this.tbHWName.Size = new System.Drawing.Size(100, 22);
this.tbHWName.TabIndex = 1;
//
// tbHWDescription
//
this.tbHWDescription.Location = new System.Drawing.Point(131, 64);
this.tbHWDescription.Name = "tbHWDescription";
this.tbHWDescription.Size = new System.Drawing.Size(100, 22);
this.tbHWDescription.TabIndex = 2;
//
// lblHWClass
//
this.lblHWClass.AutoSize = true;
this.lblHWClass.Location = new System.Drawing.Point(6, 9);
this.lblHWClass.Name = "lblHWClass";
this.lblHWClass.Size = new System.Drawing.Size(42, 17);
this.lblHWClass.TabIndex = 3;
this.lblHWClass.Text = "Class";
//
// lblHWName
//
this.lblHWName.AutoSize = true;
this.lblHWName.Location = new System.Drawing.Point(6, 36);
this.lblHWName.Name = "lblHWName";
this.lblHWName.Size = new System.Drawing.Size(45, 17);
this.lblHWName.TabIndex = 4;
this.lblHWName.Text = "Name";
//
// lblHWDescription
//
this.lblHWDescription.AutoSize = true;
this.lblHWDescription.Location = new System.Drawing.Point(6, 64);
this.lblHWDescription.Name = "lblHWDescription";
this.lblHWDescription.Size = new System.Drawing.Size(79, 17);
this.lblHWDescription.TabIndex = 5;
this.lblHWDescription.Text = "Description";
//
// dtpHWDue
//
this.dtpHWDue.Format = System.Windows.Forms.DateTimePickerFormat.Short;
this.dtpHWDue.Location = new System.Drawing.Point(91, 92);
this.dtpHWDue.Name = "dtpHWDue";
this.dtpHWDue.Size = new System.Drawing.Size(140, 22);
this.dtpHWDue.TabIndex = 6;
this.tbHWSubmitted.Location = new System.Drawing.Point(91, 120);
this.tbHWSubmitted.Name = "tbHWSubmitted";
this.tbHWSubmitted.Size = new System.Drawing.Size(140, 22);
this.tbHWSubmitted.TabIndex = 8;
//
// lblHWDue
//
@ -283,30 +223,102 @@
this.lblHWDue.TabIndex = 7;
this.lblHWDue.Text = "Due";
//
// tbHWSubmitted
// dtpHWDue
//
this.tbHWSubmitted.Location = new System.Drawing.Point(91, 120);
this.tbHWSubmitted.Name = "tbHWSubmitted";
this.tbHWSubmitted.Size = new System.Drawing.Size(140, 22);
this.tbHWSubmitted.TabIndex = 8;
this.dtpHWDue.Format = System.Windows.Forms.DateTimePickerFormat.Short;
this.dtpHWDue.Location = new System.Drawing.Point(91, 92);
this.dtpHWDue.Name = "dtpHWDue";
this.dtpHWDue.Size = new System.Drawing.Size(140, 22);
this.dtpHWDue.TabIndex = 6;
//
// lblHWSubmitted
// lblHWDescription
//
this.lblHWSubmitted.AutoSize = true;
this.lblHWSubmitted.Location = new System.Drawing.Point(6, 125);
this.lblHWSubmitted.Name = "lblHWSubmitted";
this.lblHWSubmitted.Size = new System.Drawing.Size(71, 17);
this.lblHWSubmitted.TabIndex = 9;
this.lblHWSubmitted.Text = "Submitted";
this.lblHWDescription.AutoSize = true;
this.lblHWDescription.Location = new System.Drawing.Point(6, 64);
this.lblHWDescription.Name = "lblHWDescription";
this.lblHWDescription.Size = new System.Drawing.Size(79, 17);
this.lblHWDescription.TabIndex = 5;
this.lblHWDescription.Text = "Description";
//
// btnImportStudents
// lblHWName
//
this.btnImportStudents.Location = new System.Drawing.Point(6, 6);
this.btnImportStudents.Name = "btnImportStudents";
this.btnImportStudents.Size = new System.Drawing.Size(164, 23);
this.btnImportStudents.TabIndex = 0;
this.btnImportStudents.Text = "Import Students";
this.btnImportStudents.UseVisualStyleBackColor = true;
this.lblHWName.AutoSize = true;
this.lblHWName.Location = new System.Drawing.Point(6, 36);
this.lblHWName.Name = "lblHWName";
this.lblHWName.Size = new System.Drawing.Size(45, 17);
this.lblHWName.TabIndex = 4;
this.lblHWName.Text = "Name";
//
// lblHWClass
//
this.lblHWClass.AutoSize = true;
this.lblHWClass.Location = new System.Drawing.Point(6, 9);
this.lblHWClass.Name = "lblHWClass";
this.lblHWClass.Size = new System.Drawing.Size(42, 17);
this.lblHWClass.TabIndex = 3;
this.lblHWClass.Text = "Class";
//
// tbHWDescription
//
this.tbHWDescription.Location = new System.Drawing.Point(131, 64);
this.tbHWDescription.Name = "tbHWDescription";
this.tbHWDescription.Size = new System.Drawing.Size(100, 22);
this.tbHWDescription.TabIndex = 2;
//
// tbHWName
//
this.tbHWName.Location = new System.Drawing.Point(131, 36);
this.tbHWName.Name = "tbHWName";
this.tbHWName.Size = new System.Drawing.Size(100, 22);
this.tbHWName.TabIndex = 1;
//
// tbHWClass
//
this.tbHWClass.Location = new System.Drawing.Point(131, 6);
this.tbHWClass.Name = "tbHWClass";
this.tbHWClass.Size = new System.Drawing.Size(100, 22);
this.tbHWClass.TabIndex = 0;
//
// TabStudent
//
this.TabStudent.Location = new System.Drawing.Point(4, 25);
this.TabStudent.Name = "TabStudent";
this.TabStudent.Padding = new System.Windows.Forms.Padding(3);
this.TabStudent.Size = new System.Drawing.Size(256, 206);
this.TabStudent.TabIndex = 2;
this.TabStudent.Text = "Student";
this.TabStudent.UseVisualStyleBackColor = true;
//
// tvClasswork
//
this.tvClasswork.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.tvClasswork.Location = new System.Drawing.Point(6, 6);
this.tvClasswork.Name = "tvClasswork";
this.tvClasswork.Size = new System.Drawing.Size(131, 239);
this.tvClasswork.TabIndex = 0;
this.tvClasswork.Click += new System.EventHandler(this.tvClasswork_Click);
//
// btnExit
//
this.btnExit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnExit.Location = new System.Drawing.Point(351, 298);
this.btnExit.Name = "btnExit";
this.btnExit.Size = new System.Drawing.Size(75, 23);
this.btnExit.TabIndex = 1;
this.btnExit.Text = "Exit";
this.btnExit.UseVisualStyleBackColor = true;
this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
//
// btnHWDelete
//
this.btnHWDelete.Location = new System.Drawing.Point(175, 177);
this.btnHWDelete.Name = "btnHWDelete";
this.btnHWDelete.Size = new System.Drawing.Size(75, 23);
this.btnHWDelete.TabIndex = 10;
this.btnHWDelete.Text = "Delete";
this.btnHWDelete.UseVisualStyleBackColor = true;
this.btnHWDelete.Click += new System.EventHandler(this.btnHWDelete_Click);
//
// PersonProfileForm
//
@ -357,5 +369,6 @@
private System.Windows.Forms.Label lblHWDue;
private System.Windows.Forms.DateTimePicker dtpHWDue;
private System.Windows.Forms.Button btnImportStudents;
private System.Windows.Forms.Button btnHWDelete;
}
}

View File

@ -296,6 +296,7 @@ namespace EduNetworkBuilder
tbHWSubmitted.Visible = false;
dtpHWDue.Visible = false;
lblHWDue.Visible = false;
btnHWDelete.Visible = false;
return;
}
tbHWClass.Text = ViewedSchoolwork.Class;
@ -316,7 +317,24 @@ namespace EduNetworkBuilder
}
if (ViewedSchoolwork.DueDate < dtpHWDue.MinDate) ViewedSchoolwork.DueDate = dtpHWDue.MinDate;
dtpHWDue.Value = ViewedSchoolwork.DueDate;
}
if(CurrentUser != null && CurrentUser.isAdmin)
btnHWDelete.Visible = true; //Only the teacher can delete the homework
}
private void btnHWDelete_Click(object sender, EventArgs e)
{
if (ViewedSchoolwork == null) return;
if (CurrentUser != null && CurrentUser.isAdmin)//Only the teacher can delete the homework
{
DialogResult Sure = MessageBox.Show(NB.Translate("PPF_ConfirmHWDelete"), "", MessageBoxButtons.YesNoCancel);
if (Sure == DialogResult.Yes)
{
CurrentUser.Projects.Remove(ViewedSchoolwork);
ViewedSchoolwork = null;
UpdateFormFromUser();
UpdateFormFromSchoolwork();
}
}
}
}
}

View File

@ -1761,4 +1761,8 @@
<value>Students</value>
<comment>PPF_Students=Students</comment>
</data>
<data name="PPF_ConfirmHWDelete" xml:space="preserve">
<value>Are you sure you want to delete this homework?</value>
<comment>PPF_ConfirmHWDelete = Are you sure you want to delete this homework?</comment>
</data>
</root>