Test plan incomplete, basic compaints support

This commit is contained in:
Dimitar Byalkov
2023-06-09 02:57:45 +02:00
parent 53c42a35d8
commit d8e185757d
32 changed files with 1294 additions and 42 deletions

View File

@@ -0,0 +1,237 @@
namespace WinForms
{
partial class ComplaintForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
lblTitle = new Label();
tbTitle = new TextBox();
lblDescription = new Label();
tbDescription = new TextBox();
lblPublishDate = new Label();
btnSave = new Button();
dtpPublishDate = new DateTimePicker();
lblAuthor = new Label();
lblComments = new Label();
listBox1 = new ListBox();
btnViewComment = new Button();
btnEditComment = new Button();
btnDeleteComment = new Button();
btnCreateComment = new Button();
cbStatus = new ComboBox();
cbSeverity = new ComboBox();
SuspendLayout();
//
// lblTitle
//
lblTitle.AutoSize = true;
lblTitle.Location = new Point(12, 9);
lblTitle.Name = "lblTitle";
lblTitle.Size = new Size(32, 15);
lblTitle.TabIndex = 0;
lblTitle.Text = "Title:";
//
// tbTitle
//
tbTitle.Location = new Point(94, 6);
tbTitle.Name = "tbTitle";
tbTitle.Size = new Size(405, 23);
tbTitle.TabIndex = 1;
//
// lblDescription
//
lblDescription.AutoSize = true;
lblDescription.Location = new Point(12, 38);
lblDescription.Name = "lblDescription";
lblDescription.Size = new Size(70, 15);
lblDescription.TabIndex = 2;
lblDescription.Text = "Description:";
//
// tbDescription
//
tbDescription.Location = new Point(94, 35);
tbDescription.Multiline = true;
tbDescription.Name = "tbDescription";
tbDescription.Size = new Size(405, 112);
tbDescription.TabIndex = 3;
//
// lblPublishDate
//
lblPublishDate.AutoSize = true;
lblPublishDate.Location = new Point(12, 159);
lblPublishDate.Name = "lblPublishDate";
lblPublishDate.Size = new Size(76, 15);
lblPublishDate.TabIndex = 4;
lblPublishDate.Text = "Publish Date:";
//
// btnSave
//
btnSave.Location = new Point(424, 180);
btnSave.Name = "btnSave";
btnSave.Size = new Size(75, 23);
btnSave.TabIndex = 6;
btnSave.Text = "Save changes";
btnSave.UseVisualStyleBackColor = true;
btnSave.Click += btnSave_Click;
//
// dtpPublishDate
//
dtpPublishDate.Location = new Point(94, 153);
dtpPublishDate.Name = "dtpPublishDate";
dtpPublishDate.Size = new Size(151, 23);
dtpPublishDate.TabIndex = 9;
//
// lblAuthor
//
lblAuthor.AutoSize = true;
lblAuthor.Location = new Point(12, 184);
lblAuthor.Name = "lblAuthor";
lblAuthor.Size = new Size(70, 15);
lblAuthor.TabIndex = 10;
lblAuthor.Text = "Created by: ";
//
// lblComments
//
lblComments.AutoSize = true;
lblComments.Location = new Point(12, 209);
lblComments.Name = "lblComments";
lblComments.Size = new Size(66, 15);
lblComments.TabIndex = 11;
lblComments.Text = "Comments";
//
// listBox1
//
listBox1.FormattingEnabled = true;
listBox1.ItemHeight = 15;
listBox1.Location = new Point(12, 227);
listBox1.Name = "listBox1";
listBox1.Size = new Size(399, 154);
listBox1.TabIndex = 12;
//
// btnViewComment
//
btnViewComment.Location = new Point(424, 271);
btnViewComment.Name = "btnViewComment";
btnViewComment.Size = new Size(75, 23);
btnViewComment.TabIndex = 13;
btnViewComment.Text = "View";
btnViewComment.UseVisualStyleBackColor = true;
btnViewComment.Click += btnViewComment_Click;
//
// btnEditComment
//
btnEditComment.Location = new Point(424, 300);
btnEditComment.Name = "btnEditComment";
btnEditComment.Size = new Size(75, 23);
btnEditComment.TabIndex = 14;
btnEditComment.Text = "Edit";
btnEditComment.UseVisualStyleBackColor = true;
btnEditComment.Click += btnEditComment_Click;
//
// btnDeleteComment
//
btnDeleteComment.Location = new Point(424, 329);
btnDeleteComment.Name = "btnDeleteComment";
btnDeleteComment.Size = new Size(75, 23);
btnDeleteComment.TabIndex = 15;
btnDeleteComment.Text = "Delete";
btnDeleteComment.UseVisualStyleBackColor = true;
btnDeleteComment.Click += btnDeleteComment_Click;
//
// btnCreateComment
//
btnCreateComment.Location = new Point(424, 358);
btnCreateComment.Name = "btnCreateComment";
btnCreateComment.Size = new Size(75, 23);
btnCreateComment.TabIndex = 16;
btnCreateComment.Text = "New";
btnCreateComment.UseVisualStyleBackColor = true;
btnCreateComment.Click += btnCreateComment_Click;
//
// cbStatus
//
cbStatus.FormattingEnabled = true;
cbStatus.Location = new Point(251, 153);
cbStatus.Name = "cbStatus";
cbStatus.Size = new Size(121, 23);
cbStatus.TabIndex = 17;
//
// cbSeverity
//
cbSeverity.FormattingEnabled = true;
cbSeverity.Location = new Point(378, 153);
cbSeverity.Name = "cbSeverity";
cbSeverity.Size = new Size(121, 23);
cbSeverity.TabIndex = 18;
//
// ComplaintForm
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(511, 400);
Controls.Add(cbSeverity);
Controls.Add(cbStatus);
Controls.Add(btnCreateComment);
Controls.Add(btnDeleteComment);
Controls.Add(btnEditComment);
Controls.Add(btnViewComment);
Controls.Add(listBox1);
Controls.Add(lblComments);
Controls.Add(lblAuthor);
Controls.Add(dtpPublishDate);
Controls.Add(btnSave);
Controls.Add(lblPublishDate);
Controls.Add(tbDescription);
Controls.Add(lblDescription);
Controls.Add(tbTitle);
Controls.Add(lblTitle);
Name = "ComplaintForm";
Text = "Complaint";
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label lblTitle;
private TextBox tbTitle;
private Label lblDescription;
private TextBox tbDescription;
private Label lblPublishDate;
private Button btnSave;
private DateTimePicker dtpPublishDate;
private Label lblAuthor;
private Label lblComments;
private ListBox listBox1;
private Button btnViewComment;
private Button btnEditComment;
private Button btnDeleteComment;
private Button btnCreateComment;
private ComboBox cbStatus;
private ComboBox cbSeverity;
}
}

View File

@@ -0,0 +1,149 @@
using Data;
using Logic;
using Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WinForms
{
public partial class ComplaintForm : Form
{
Complaint complaint;
User currentUser;
public ComplaintForm(Complaint? complaint, bool readOnly, User currentUser)
{
InitializeComponent();
this.complaint = complaint;
this.currentUser = currentUser;
dtpPublishDate.Enabled = false;
foreach (var item in Enum.GetValues(typeof(ComplaintStatus)))
{
cbStatus.Items.Add(item);
}
foreach (var item in Enum.GetValues(typeof(ComplaintSeverity)))
{
cbSeverity.Items.Add(item);
}
if (readOnly)
{
btnSave.Enabled = false;
tbTitle.Enabled = false;
tbDescription.Enabled = false;
cbStatus.Enabled = false;
cbSeverity.Enabled = false;
}
if (complaint != null)
{
tbTitle.Text = complaint.Title;
lblAuthor.Text = $"Created by: {complaint.Author.Name}";
tbDescription.Text = complaint.Description;
dtpPublishDate.Value = complaint.PublishDate;
cbStatus.SelectedIndex = (int)complaint.Status;
cbSeverity.SelectedIndex = (int)complaint.Severity;
RefreshComments();
}
else
{
btnCreateComment.Enabled = false;
btnDeleteComment.Enabled = false;
btnEditComment.Enabled = false;
btnViewComment.Enabled = false;
}
if (currentUser != null)
{
lblAuthor.Text = $"Created by: {currentUser.Name}";
}
}
private void btnSave_Click(object sender, EventArgs e)
{
ComplaintManager complaintManager = new ComplaintManager(new ComplaintRepository());
if (string.IsNullOrEmpty(tbTitle.Text))
{
MessageBox.Show("Please enter a title");
return;
}
if (this.complaint == null)
{
complaintManager.CreateComplaint(tbTitle.Text, tbDescription.Text, currentUser, dtpPublishDate.Value, (ComplaintStatus)cbStatus.SelectedIndex, (ComplaintSeverity)cbSeverity.SelectedIndex);
}
else
{
complaintManager.UpdateComplaint(complaint.ID, tbTitle.Text, tbDescription.Text, (ComplaintStatus)cbStatus.SelectedIndex, (ComplaintSeverity)cbSeverity.SelectedIndex);
}
this.DialogResult = DialogResult.OK;
}
private void btnViewComment_Click(object sender, EventArgs e)
{
if (listBox1.SelectedIndex == -1)
{
MessageBox.Show("Please select an item from the list");
}
else
{
CommentForm form = new CommentForm((Comment)listBox1.SelectedItem, true, currentUser);
form.ShowDialog();
RefreshComments();
}
}
private void btnEditComment_Click(object sender, EventArgs e)
{
if (listBox1.SelectedIndex == -1)
{
MessageBox.Show("Please select an item from the list");
}
else
{
CommentForm form = new CommentForm((Comment)listBox1.SelectedItem, false, currentUser);
form.ShowDialog();
RefreshComments();
}
}
private void btnDeleteComment_Click(object sender, EventArgs e)
{
if (listBox1.SelectedIndex == -1)
{
MessageBox.Show("Please select an item from the list");
}
else
{
Comment currentComment = (Comment)listBox1.SelectedItem;
if (MessageBox.Show($"Are you sure you want to delete\n{currentComment.Title}\nCreated at {currentComment.PublishDate.ToString("g")} by {currentComment.Author.Name}",
"Delete announcement", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
CommentManager commentManager = new CommentManager(new CommentRepository());
commentManager.DeleteCommentOnAnnouncement(currentComment.ID, complaint.ID);
}
RefreshComments();
}
}
private void btnCreateComment_Click(object sender, EventArgs e)
{
CommentForm form = new CommentForm(null, false, currentUser, true, complaint.ID);
form.ShowDialog();
RefreshComments();
}
private void RefreshComments()
{
listBox1.Items.Clear();
foreach (var item in complaint.Responses)
{
listBox1.Items.Add(item);
}
}
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -38,17 +38,26 @@
tpUsers = new TabPage();
panelUserFunctions = new Panel();
tpAnnouncements = new TabPage();
lbAnnouncements = new ListBox();
panel1 = new Panel();
panelAnnouncementsFunctions = new Panel();
btnNewAnnouncement = new Button();
btnDeleteAnnouncement = new Button();
btnViewAnnouncement = new Button();
btnEditAnnouncement = new Button();
lbAnnouncements = new ListBox();
tpComplaints = new TabPage();
tpEvents = new TabPage();
lbComplaints = new ListBox();
panelComplaintFunctions = new Panel();
btnArchiveComplaint = new Button();
btnViewComplaint = new Button();
btnEditComplaint = new Button();
tabControl1.SuspendLayout();
tpUsers.SuspendLayout();
panelUserFunctions.SuspendLayout();
tpAnnouncements.SuspendLayout();
panel1.SuspendLayout();
panelAnnouncementsFunctions.SuspendLayout();
tpComplaints.SuspendLayout();
panelComplaintFunctions.SuspendLayout();
SuspendLayout();
//
// lblUserStatus
@@ -116,6 +125,8 @@
//
tabControl1.Controls.Add(tpUsers);
tabControl1.Controls.Add(tpAnnouncements);
tabControl1.Controls.Add(tpComplaints);
tabControl1.Controls.Add(tpEvents);
tabControl1.Dock = DockStyle.Fill;
tabControl1.Location = new Point(0, 0);
tabControl1.Name = "tabControl1";
@@ -149,7 +160,7 @@
//
// tpAnnouncements
//
tpAnnouncements.Controls.Add(panel1);
tpAnnouncements.Controls.Add(panelAnnouncementsFunctions);
tpAnnouncements.Controls.Add(lbAnnouncements);
tpAnnouncements.Location = new Point(4, 24);
tpAnnouncements.Name = "tpAnnouncements";
@@ -159,27 +170,17 @@
tpAnnouncements.Text = "Announcements";
tpAnnouncements.UseVisualStyleBackColor = true;
//
// lbAnnouncements
// panelAnnouncementsFunctions
//
lbAnnouncements.Dock = DockStyle.Fill;
lbAnnouncements.FormattingEnabled = true;
lbAnnouncements.ItemHeight = 15;
lbAnnouncements.Location = new Point(3, 3);
lbAnnouncements.Name = "lbAnnouncements";
lbAnnouncements.Size = new Size(717, 334);
lbAnnouncements.TabIndex = 0;
//
// panel1
//
panel1.Controls.Add(btnNewAnnouncement);
panel1.Controls.Add(btnDeleteAnnouncement);
panel1.Controls.Add(btnViewAnnouncement);
panel1.Controls.Add(btnEditAnnouncement);
panel1.Dock = DockStyle.Bottom;
panel1.Location = new Point(3, 298);
panel1.Name = "panel1";
panel1.Size = new Size(717, 39);
panel1.TabIndex = 7;
panelAnnouncementsFunctions.Controls.Add(btnNewAnnouncement);
panelAnnouncementsFunctions.Controls.Add(btnDeleteAnnouncement);
panelAnnouncementsFunctions.Controls.Add(btnViewAnnouncement);
panelAnnouncementsFunctions.Controls.Add(btnEditAnnouncement);
panelAnnouncementsFunctions.Dock = DockStyle.Bottom;
panelAnnouncementsFunctions.Location = new Point(3, 298);
panelAnnouncementsFunctions.Name = "panelAnnouncementsFunctions";
panelAnnouncementsFunctions.Size = new Size(717, 39);
panelAnnouncementsFunctions.TabIndex = 7;
//
// btnNewAnnouncement
//
@@ -221,6 +222,87 @@
btnEditAnnouncement.UseVisualStyleBackColor = true;
btnEditAnnouncement.Click += btnEditAnnouncement_Click;
//
// lbAnnouncements
//
lbAnnouncements.Dock = DockStyle.Fill;
lbAnnouncements.FormattingEnabled = true;
lbAnnouncements.ItemHeight = 15;
lbAnnouncements.Location = new Point(3, 3);
lbAnnouncements.Name = "lbAnnouncements";
lbAnnouncements.Size = new Size(717, 334);
lbAnnouncements.TabIndex = 0;
//
// tpComplaints
//
tpComplaints.Controls.Add(panelComplaintFunctions);
tpComplaints.Controls.Add(lbComplaints);
tpComplaints.Location = new Point(4, 24);
tpComplaints.Name = "tpComplaints";
tpComplaints.Size = new Size(723, 340);
tpComplaints.TabIndex = 2;
tpComplaints.Text = "Complaints";
tpComplaints.UseVisualStyleBackColor = true;
//
// tpEvents
//
tpEvents.Location = new Point(4, 24);
tpEvents.Name = "tpEvents";
tpEvents.Size = new Size(723, 340);
tpEvents.TabIndex = 3;
tpEvents.Text = "Events";
tpEvents.UseVisualStyleBackColor = true;
//
// lbComplaints
//
lbComplaints.Dock = DockStyle.Top;
lbComplaints.FormattingEnabled = true;
lbComplaints.ItemHeight = 15;
lbComplaints.Location = new Point(0, 0);
lbComplaints.Name = "lbComplaints";
lbComplaints.Size = new Size(723, 289);
lbComplaints.TabIndex = 0;
//
// panelComplaintFunctions
//
panelComplaintFunctions.Controls.Add(btnArchiveComplaint);
panelComplaintFunctions.Controls.Add(btnViewComplaint);
panelComplaintFunctions.Controls.Add(btnEditComplaint);
panelComplaintFunctions.Dock = DockStyle.Bottom;
panelComplaintFunctions.Location = new Point(0, 285);
panelComplaintFunctions.Name = "panelComplaintFunctions";
panelComplaintFunctions.Size = new Size(723, 55);
panelComplaintFunctions.TabIndex = 1;
//
// btnArchiveComplaint
//
btnArchiveComplaint.Location = new Point(8, 10);
btnArchiveComplaint.Name = "btnArchiveComplaint";
btnArchiveComplaint.Size = new Size(75, 23);
btnArchiveComplaint.TabIndex = 7;
btnArchiveComplaint.Text = "Archive";
btnArchiveComplaint.UseVisualStyleBackColor = true;
btnArchiveComplaint.Click += btnArchiveComplaint_Click;
//
// btnViewComplaint
//
btnViewComplaint.Location = new Point(170, 10);
btnViewComplaint.Name = "btnViewComplaint";
btnViewComplaint.Size = new Size(75, 23);
btnViewComplaint.TabIndex = 9;
btnViewComplaint.Text = "View";
btnViewComplaint.UseVisualStyleBackColor = true;
btnViewComplaint.Click += btnViewComplaint_Click;
//
// btnEditComplaint
//
btnEditComplaint.Location = new Point(89, 10);
btnEditComplaint.Name = "btnEditComplaint";
btnEditComplaint.Size = new Size(75, 23);
btnEditComplaint.TabIndex = 8;
btnEditComplaint.Text = "Edit";
btnEditComplaint.UseVisualStyleBackColor = true;
btnEditComplaint.Click += btnEditComplaint_Click;
//
// Dashboard
//
AutoScaleDimensions = new SizeF(7F, 15F);
@@ -235,7 +317,9 @@
tpUsers.ResumeLayout(false);
panelUserFunctions.ResumeLayout(false);
tpAnnouncements.ResumeLayout(false);
panel1.ResumeLayout(false);
panelAnnouncementsFunctions.ResumeLayout(false);
tpComplaints.ResumeLayout(false);
panelComplaintFunctions.ResumeLayout(false);
ResumeLayout(false);
PerformLayout();
}
@@ -252,11 +336,18 @@
private TabPage tpUsers;
private TabPage tpAnnouncements;
private Panel panelUserFunctions;
private Panel panel1;
private Panel panelAnnouncementsFunctions;
private Button btnNewAnnouncement;
private Button btnDeleteAnnouncement;
private Button btnViewAnnouncement;
private Button btnEditAnnouncement;
private ListBox lbAnnouncements;
private TabPage tpComplaints;
private Panel panelComplaintFunctions;
private ListBox lbComplaints;
private TabPage tpEvents;
private Button btnArchiveComplaint;
private Button btnViewComplaint;
private Button btnEditComplaint;
}
}

View File

@@ -31,6 +31,7 @@ namespace WinForms
btnNewAnnouncement.Enabled = false;
btnDeleteAnnouncement.Enabled = false;
btnEditAnnouncement.Enabled = true;
btnEditComplaint.Enabled = false;
}
else if (user.Role == UserRole.ADMIN)
{
@@ -40,6 +41,7 @@ namespace WinForms
btnNewAnnouncement.Enabled = true;
btnDeleteAnnouncement.Enabled = true;
btnEditAnnouncement.Enabled = true;
btnEditComplaint.Enabled = true;
}
else
{
@@ -49,6 +51,7 @@ namespace WinForms
btnNewAnnouncement.Enabled = false;
btnDeleteAnnouncement.Enabled = false;
btnEditAnnouncement.Enabled = false;
btnEditComplaint.Enabled = false;
}
RefreshLists();
}
@@ -120,6 +123,12 @@ namespace WinForms
{
lbAnnouncements.Items.Add(announcement);
}
ComplaintManager complaintManager = new ComplaintManager(new ComplaintRepository());
lbComplaints.Items.Clear();
foreach (Complaint complaint in complaintManager.GetAllComplaints())
{
lbComplaints.Items.Add(complaint);
}
}
private void Dashboard_FormClosed(object sender, FormClosedEventArgs e)
@@ -180,5 +189,52 @@ namespace WinForms
RefreshLists();
}
}
private void btnArchiveComplaint_Click(object sender, EventArgs e)
{
if (lbComplaints.SelectedIndex == -1)
{
MessageBox.Show("Please select an item from the list");
}
else
{
Complaint currentComplaint = (Complaint)lbComplaints.SelectedItem;
if (MessageBox.Show($"Are you sure you want to archive\n{currentComplaint.Title}\nCreated at {currentComplaint.PublishDate.ToString("g")} by {currentComplaint.Author.Name}",
"Archive complaint", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
AnnouncementManager announcementManager = new AnnouncementManager(new AnnouncementRepository());
announcementManager.DeleteAnnouncement(currentComplaint.ID);
}
RefreshLists();
}
}
private void btnEditComplaint_Click(object sender, EventArgs e)
{
if (lbComplaints.SelectedIndex == -1)
{
MessageBox.Show("Please select an item from the list");
}
else
{
ComplaintForm complaintForm = new ComplaintForm((Complaint)lbComplaints.SelectedItem, false, user);
complaintForm.ShowDialog();
RefreshLists();
}
}
private void btnViewComplaint_Click(object sender, EventArgs e)
{
if (lbComplaints.SelectedIndex == -1)
{
MessageBox.Show("Please select an item from the list");
}
else
{
ComplaintForm complaintForm = new ComplaintForm((Complaint)lbComplaints.SelectedItem, true, user);
complaintForm.ShowDialog();
RefreshLists();
}
}
}
}

View File

@@ -1,4 +1,64 @@
<root>
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">

View File

@@ -19,6 +19,10 @@ namespace WinForms
{
MessageBox.Show("Wrong username or password", "Login failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
/*else if (user.Role == UserRole.TENANT)
{
MessageBox.Show("This application is for the management. Please use the web portal", "Access denied", MessageBoxButtons.OK, MessageBoxIcon.Error);
}*/
else
{
Dashboard dashboard = new Dashboard(this, user);

View File

@@ -16,6 +16,9 @@
</ItemGroup>
<ItemGroup>
<Compile Update="ComplaintForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Update="AnnouncementForm.cs">
<SubType>Form</SubType>
</Compile>