Basic announcements added
This commit is contained in:
165
StudentHouseDashboard/WinForms/AnnouncementForm.Designer.cs
generated
Normal file
165
StudentHouseDashboard/WinForms/AnnouncementForm.Designer.cs
generated
Normal file
@@ -0,0 +1,165 @@
|
||||
namespace WinForms
|
||||
{
|
||||
partial class AnnouncementForm
|
||||
{
|
||||
/// <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();
|
||||
ckbImportant = new CheckBox();
|
||||
ckbSticky = new CheckBox();
|
||||
dtpPublishDate = new DateTimePicker();
|
||||
lblAuthor = new Label();
|
||||
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;
|
||||
//
|
||||
// ckbImportant
|
||||
//
|
||||
ckbImportant.AutoSize = true;
|
||||
ckbImportant.Location = new Point(300, 155);
|
||||
ckbImportant.Name = "ckbImportant";
|
||||
ckbImportant.Size = new Size(79, 19);
|
||||
ckbImportant.TabIndex = 7;
|
||||
ckbImportant.Text = "Important";
|
||||
ckbImportant.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// ckbSticky
|
||||
//
|
||||
ckbSticky.AutoSize = true;
|
||||
ckbSticky.Location = new Point(385, 155);
|
||||
ckbSticky.Name = "ckbSticky";
|
||||
ckbSticky.Size = new Size(78, 19);
|
||||
ckbSticky.TabIndex = 8;
|
||||
ckbSticky.Text = "Pin to top";
|
||||
ckbSticky.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// dtpPublishDate
|
||||
//
|
||||
dtpPublishDate.Location = new Point(94, 153);
|
||||
dtpPublishDate.Name = "dtpPublishDate";
|
||||
dtpPublishDate.Size = new Size(200, 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: ";
|
||||
//
|
||||
// AnnouncementForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(511, 216);
|
||||
Controls.Add(lblAuthor);
|
||||
Controls.Add(dtpPublishDate);
|
||||
Controls.Add(ckbSticky);
|
||||
Controls.Add(ckbImportant);
|
||||
Controls.Add(btnSave);
|
||||
Controls.Add(lblPublishDate);
|
||||
Controls.Add(tbDescription);
|
||||
Controls.Add(lblDescription);
|
||||
Controls.Add(tbTitle);
|
||||
Controls.Add(lblTitle);
|
||||
Name = "AnnouncementForm";
|
||||
Text = "Announcement";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label lblTitle;
|
||||
private TextBox tbTitle;
|
||||
private Label lblDescription;
|
||||
private TextBox tbDescription;
|
||||
private Label lblPublishDate;
|
||||
private Button btnSave;
|
||||
private CheckBox ckbImportant;
|
||||
private CheckBox ckbSticky;
|
||||
private DateTimePicker dtpPublishDate;
|
||||
private Label lblAuthor;
|
||||
}
|
||||
}
|
69
StudentHouseDashboard/WinForms/AnnouncementForm.cs
Normal file
69
StudentHouseDashboard/WinForms/AnnouncementForm.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
using StudentHouseDashboard.Managers;
|
||||
using StudentHouseDashboard.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 AnnouncementForm : Form
|
||||
{
|
||||
Announcement announcement;
|
||||
User currentUser;
|
||||
public AnnouncementForm(Announcement? announcement, bool readOnly, User? currentUser)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.announcement = announcement;
|
||||
this.currentUser = currentUser;
|
||||
if (readOnly)
|
||||
{
|
||||
btnSave.Enabled = false;
|
||||
tbTitle.Enabled = false;
|
||||
tbDescription.Enabled = false;
|
||||
dtpPublishDate.Enabled = false;
|
||||
ckbImportant.Enabled = false;
|
||||
ckbSticky.Enabled = false;
|
||||
}
|
||||
if (announcement != null)
|
||||
{
|
||||
tbTitle.Text = announcement.Title;
|
||||
lblAuthor.Text = $"Created by: {announcement.Author.Name}";
|
||||
tbDescription.Text = announcement.Description;
|
||||
dtpPublishDate.Value = announcement.PublishDate;
|
||||
ckbImportant.Checked = announcement.IsImportant;
|
||||
ckbSticky.Checked = announcement.IsSticky;
|
||||
}
|
||||
if (currentUser != null)
|
||||
{
|
||||
lblAuthor.Text = $"Created by: {currentUser.Name}";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void btnSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
AnnouncementManager announcementManager = new AnnouncementManager();
|
||||
if (string.IsNullOrEmpty(tbTitle.Text))
|
||||
{
|
||||
MessageBox.Show("Please enter a title");
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.announcement == null)
|
||||
{
|
||||
announcementManager.CreateAnnouncement(tbTitle.Text, tbDescription.Text, currentUser, dtpPublishDate.Value, ckbImportant.Checked, ckbSticky.Checked);
|
||||
}
|
||||
else
|
||||
{
|
||||
announcementManager.UpdateAnnouncement(announcement.ID, tbTitle.Text, tbDescription.Text, currentUser, dtpPublishDate.Value, ckbImportant.Checked, ckbSticky.Checked);
|
||||
}
|
||||
this.DialogResult = DialogResult.OK;
|
||||
}
|
||||
}
|
||||
}
|
60
StudentHouseDashboard/WinForms/AnnouncementForm.resx
Normal file
60
StudentHouseDashboard/WinForms/AnnouncementForm.resx
Normal file
@@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<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>
|
172
StudentHouseDashboard/WinForms/Dashboard.Designer.cs
generated
172
StudentHouseDashboard/WinForms/Dashboard.Designer.cs
generated
@@ -34,80 +34,208 @@
|
||||
btnDeleteUser = new Button();
|
||||
btnUpdateUser = new Button();
|
||||
btnViewUser = new Button();
|
||||
tabControl1 = new TabControl();
|
||||
tpUsers = new TabPage();
|
||||
panelUserFunctions = new Panel();
|
||||
tpAnnouncements = new TabPage();
|
||||
lbAnnouncements = new ListBox();
|
||||
panel1 = new Panel();
|
||||
btnNewAnnouncement = new Button();
|
||||
btnDeleteAnnouncement = new Button();
|
||||
btnViewAnnouncement = new Button();
|
||||
btnEditAnnouncement = new Button();
|
||||
tabControl1.SuspendLayout();
|
||||
tpUsers.SuspendLayout();
|
||||
panelUserFunctions.SuspendLayout();
|
||||
tpAnnouncements.SuspendLayout();
|
||||
panel1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// lblUserStatus
|
||||
//
|
||||
lblUserStatus.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
lblUserStatus.AutoSize = true;
|
||||
lblUserStatus.Location = new Point(13, 18);
|
||||
lblUserStatus.Location = new Point(396, 4);
|
||||
lblUserStatus.Name = "lblUserStatus";
|
||||
lblUserStatus.Size = new Size(80, 15);
|
||||
lblUserStatus.TabIndex = 0;
|
||||
lblUserStatus.Text = "Logged in as: ";
|
||||
lblUserStatus.TextAlign = ContentAlignment.TopRight;
|
||||
//
|
||||
// lbUsers
|
||||
//
|
||||
lbUsers.Dock = DockStyle.Fill;
|
||||
lbUsers.FormattingEnabled = true;
|
||||
lbUsers.ItemHeight = 15;
|
||||
lbUsers.Location = new Point(13, 86);
|
||||
lbUsers.Location = new Point(3, 3);
|
||||
lbUsers.Name = "lbUsers";
|
||||
lbUsers.Size = new Size(318, 154);
|
||||
lbUsers.Size = new Size(717, 334);
|
||||
lbUsers.TabIndex = 1;
|
||||
//
|
||||
// btnCreateUser
|
||||
//
|
||||
btnCreateUser.Location = new Point(13, 257);
|
||||
btnCreateUser.Location = new Point(3, 3);
|
||||
btnCreateUser.Name = "btnCreateUser";
|
||||
btnCreateUser.Size = new Size(75, 23);
|
||||
btnCreateUser.TabIndex = 2;
|
||||
btnCreateUser.Text = "New User";
|
||||
btnCreateUser.Text = "New";
|
||||
btnCreateUser.UseVisualStyleBackColor = true;
|
||||
btnCreateUser.Click += btnCreateUser_Click;
|
||||
//
|
||||
// btnDeleteUser
|
||||
//
|
||||
btnDeleteUser.Location = new Point(94, 257);
|
||||
btnDeleteUser.Location = new Point(84, 3);
|
||||
btnDeleteUser.Name = "btnDeleteUser";
|
||||
btnDeleteUser.Size = new Size(75, 23);
|
||||
btnDeleteUser.TabIndex = 3;
|
||||
btnDeleteUser.Text = "Delete User";
|
||||
btnDeleteUser.Text = "Delete";
|
||||
btnDeleteUser.UseVisualStyleBackColor = true;
|
||||
btnDeleteUser.Click += btnDeleteUser_Click;
|
||||
//
|
||||
// btnUpdateUser
|
||||
//
|
||||
btnUpdateUser.Location = new Point(175, 257);
|
||||
btnUpdateUser.Location = new Point(165, 3);
|
||||
btnUpdateUser.Name = "btnUpdateUser";
|
||||
btnUpdateUser.Size = new Size(75, 23);
|
||||
btnUpdateUser.TabIndex = 4;
|
||||
btnUpdateUser.Text = "Edit User";
|
||||
btnUpdateUser.Text = "Edit";
|
||||
btnUpdateUser.UseVisualStyleBackColor = true;
|
||||
btnUpdateUser.Click += btnUpdateUser_Click;
|
||||
//
|
||||
// btnViewUser
|
||||
//
|
||||
btnViewUser.Location = new Point(256, 257);
|
||||
btnViewUser.Location = new Point(246, 3);
|
||||
btnViewUser.Name = "btnViewUser";
|
||||
btnViewUser.Size = new Size(75, 23);
|
||||
btnViewUser.TabIndex = 5;
|
||||
btnViewUser.Text = "View User";
|
||||
btnViewUser.Text = "View";
|
||||
btnViewUser.UseVisualStyleBackColor = true;
|
||||
btnViewUser.Click += btnViewUser_Click;
|
||||
//
|
||||
// tabControl1
|
||||
//
|
||||
tabControl1.Controls.Add(tpUsers);
|
||||
tabControl1.Controls.Add(tpAnnouncements);
|
||||
tabControl1.Dock = DockStyle.Fill;
|
||||
tabControl1.Location = new Point(0, 0);
|
||||
tabControl1.Name = "tabControl1";
|
||||
tabControl1.SelectedIndex = 0;
|
||||
tabControl1.Size = new Size(731, 368);
|
||||
tabControl1.TabIndex = 6;
|
||||
//
|
||||
// tpUsers
|
||||
//
|
||||
tpUsers.Controls.Add(panelUserFunctions);
|
||||
tpUsers.Controls.Add(lbUsers);
|
||||
tpUsers.Location = new Point(4, 24);
|
||||
tpUsers.Name = "tpUsers";
|
||||
tpUsers.Padding = new Padding(3);
|
||||
tpUsers.Size = new Size(723, 340);
|
||||
tpUsers.TabIndex = 0;
|
||||
tpUsers.Text = "Users";
|
||||
tpUsers.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// panelUserFunctions
|
||||
//
|
||||
panelUserFunctions.Controls.Add(btnCreateUser);
|
||||
panelUserFunctions.Controls.Add(btnDeleteUser);
|
||||
panelUserFunctions.Controls.Add(btnViewUser);
|
||||
panelUserFunctions.Controls.Add(btnUpdateUser);
|
||||
panelUserFunctions.Dock = DockStyle.Bottom;
|
||||
panelUserFunctions.Location = new Point(3, 298);
|
||||
panelUserFunctions.Name = "panelUserFunctions";
|
||||
panelUserFunctions.Size = new Size(717, 39);
|
||||
panelUserFunctions.TabIndex = 6;
|
||||
//
|
||||
// tpAnnouncements
|
||||
//
|
||||
tpAnnouncements.Controls.Add(panel1);
|
||||
tpAnnouncements.Controls.Add(lbAnnouncements);
|
||||
tpAnnouncements.Location = new Point(4, 24);
|
||||
tpAnnouncements.Name = "tpAnnouncements";
|
||||
tpAnnouncements.Padding = new Padding(3);
|
||||
tpAnnouncements.Size = new Size(723, 340);
|
||||
tpAnnouncements.TabIndex = 1;
|
||||
tpAnnouncements.Text = "Announcements";
|
||||
tpAnnouncements.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// 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;
|
||||
//
|
||||
// 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;
|
||||
//
|
||||
// btnNewAnnouncement
|
||||
//
|
||||
btnNewAnnouncement.Location = new Point(3, 3);
|
||||
btnNewAnnouncement.Name = "btnNewAnnouncement";
|
||||
btnNewAnnouncement.Size = new Size(75, 23);
|
||||
btnNewAnnouncement.TabIndex = 2;
|
||||
btnNewAnnouncement.Text = "New";
|
||||
btnNewAnnouncement.UseVisualStyleBackColor = true;
|
||||
btnNewAnnouncement.Click += btnNewAnnouncement_Click;
|
||||
//
|
||||
// btnDeleteAnnouncement
|
||||
//
|
||||
btnDeleteAnnouncement.Location = new Point(84, 3);
|
||||
btnDeleteAnnouncement.Name = "btnDeleteAnnouncement";
|
||||
btnDeleteAnnouncement.Size = new Size(75, 23);
|
||||
btnDeleteAnnouncement.TabIndex = 3;
|
||||
btnDeleteAnnouncement.Text = "Delete";
|
||||
btnDeleteAnnouncement.UseVisualStyleBackColor = true;
|
||||
btnDeleteAnnouncement.Click += btnDeleteAnnouncement_Click;
|
||||
//
|
||||
// btnViewAnnouncement
|
||||
//
|
||||
btnViewAnnouncement.Location = new Point(246, 3);
|
||||
btnViewAnnouncement.Name = "btnViewAnnouncement";
|
||||
btnViewAnnouncement.Size = new Size(75, 23);
|
||||
btnViewAnnouncement.TabIndex = 5;
|
||||
btnViewAnnouncement.Text = "View";
|
||||
btnViewAnnouncement.UseVisualStyleBackColor = true;
|
||||
btnViewAnnouncement.Click += btnViewAnnouncement_Click;
|
||||
//
|
||||
// btnEditAnnouncement
|
||||
//
|
||||
btnEditAnnouncement.Location = new Point(165, 3);
|
||||
btnEditAnnouncement.Name = "btnEditAnnouncement";
|
||||
btnEditAnnouncement.Size = new Size(75, 23);
|
||||
btnEditAnnouncement.TabIndex = 4;
|
||||
btnEditAnnouncement.Text = "Edit";
|
||||
btnEditAnnouncement.UseVisualStyleBackColor = true;
|
||||
btnEditAnnouncement.Click += btnEditAnnouncement_Click;
|
||||
//
|
||||
// Dashboard
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(359, 302);
|
||||
Controls.Add(btnViewUser);
|
||||
Controls.Add(btnUpdateUser);
|
||||
Controls.Add(btnDeleteUser);
|
||||
Controls.Add(btnCreateUser);
|
||||
Controls.Add(lbUsers);
|
||||
ClientSize = new Size(731, 368);
|
||||
Controls.Add(lblUserStatus);
|
||||
Controls.Add(tabControl1);
|
||||
Name = "Dashboard";
|
||||
Text = "Dashboard";
|
||||
FormClosed += Dashboard_FormClosed;
|
||||
tabControl1.ResumeLayout(false);
|
||||
tpUsers.ResumeLayout(false);
|
||||
panelUserFunctions.ResumeLayout(false);
|
||||
tpAnnouncements.ResumeLayout(false);
|
||||
panel1.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
@@ -120,5 +248,15 @@
|
||||
private Button btnDeleteUser;
|
||||
private Button btnUpdateUser;
|
||||
private Button btnViewUser;
|
||||
private TabControl tabControl1;
|
||||
private TabPage tpUsers;
|
||||
private TabPage tpAnnouncements;
|
||||
private Panel panelUserFunctions;
|
||||
private Panel panel1;
|
||||
private Button btnNewAnnouncement;
|
||||
private Button btnDeleteAnnouncement;
|
||||
private Button btnViewAnnouncement;
|
||||
private Button btnEditAnnouncement;
|
||||
private ListBox lbAnnouncements;
|
||||
}
|
||||
}
|
@@ -15,9 +15,11 @@ namespace WinForms
|
||||
public partial class Dashboard : Form
|
||||
{
|
||||
Login loginForm;
|
||||
User user;
|
||||
public Dashboard(Login loginForm, User user)
|
||||
{
|
||||
this.loginForm = loginForm;
|
||||
this.user = user;
|
||||
InitializeComponent();
|
||||
lblUserStatus.Text = $"Logged in as: {user.Role} {user.Name}";
|
||||
if (user.Role == UserRole.MANAGER)
|
||||
@@ -25,18 +27,27 @@ namespace WinForms
|
||||
btnCreateUser.Enabled = false;
|
||||
btnDeleteUser.Enabled = false;
|
||||
btnUpdateUser.Enabled = true;
|
||||
btnNewAnnouncement.Enabled = false;
|
||||
btnDeleteAnnouncement.Enabled = false;
|
||||
btnEditAnnouncement.Enabled = true;
|
||||
}
|
||||
else if (user.Role == UserRole.ADMIN)
|
||||
{
|
||||
btnCreateUser.Enabled = true;
|
||||
btnDeleteUser.Enabled = true;
|
||||
btnUpdateUser.Enabled = true;
|
||||
btnNewAnnouncement.Enabled = true;
|
||||
btnDeleteAnnouncement.Enabled = true;
|
||||
btnEditAnnouncement.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
btnCreateUser.Enabled = false;
|
||||
btnDeleteUser.Enabled = false;
|
||||
btnUpdateUser.Enabled = false;
|
||||
btnNewAnnouncement.Enabled = false;
|
||||
btnDeleteAnnouncement.Enabled = false;
|
||||
btnEditAnnouncement.Enabled = false;
|
||||
}
|
||||
RefreshLists();
|
||||
}
|
||||
@@ -81,11 +92,50 @@ namespace WinForms
|
||||
{
|
||||
lbUsers.Items.Add(_user);
|
||||
}
|
||||
AnnouncementManager announcementManager = new AnnouncementManager();
|
||||
lbAnnouncements.Items.Clear();
|
||||
foreach (Announcement announcement in announcementManager.GetAllAnnouncements())
|
||||
{
|
||||
lbAnnouncements.Items.Add(announcement);
|
||||
}
|
||||
}
|
||||
|
||||
private void Dashboard_FormClosed(object sender, FormClosedEventArgs e)
|
||||
{
|
||||
loginForm.Show();
|
||||
}
|
||||
|
||||
private void btnNewAnnouncement_Click(object sender, EventArgs e)
|
||||
{
|
||||
AnnouncementForm announcementForm = new AnnouncementForm(null, false, user);
|
||||
announcementForm.ShowDialog();
|
||||
RefreshLists();
|
||||
}
|
||||
|
||||
private void btnDeleteAnnouncement_Click(object sender, EventArgs e)
|
||||
{
|
||||
Announcement currentAnnouncement = (Announcement)lbAnnouncements.SelectedItem;
|
||||
if (MessageBox.Show($"Are you sure you want to delete\n{currentAnnouncement.Title}\nCreated at {currentAnnouncement.PublishDate.ToString("g")} by {currentAnnouncement.Author.Name}",
|
||||
"Delete announcement", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
AnnouncementManager announcementManager = new AnnouncementManager();
|
||||
announcementManager.DeleteAnnouncement(currentAnnouncement.ID);
|
||||
}
|
||||
RefreshLists();
|
||||
}
|
||||
|
||||
private void btnEditAnnouncement_Click(object sender, EventArgs e)
|
||||
{
|
||||
AnnouncementForm announcementForm = new AnnouncementForm((Announcement)lbAnnouncements.SelectedItem, false, null);
|
||||
announcementForm.ShowDialog();
|
||||
RefreshLists();
|
||||
}
|
||||
|
||||
private void btnViewAnnouncement_Click(object sender, EventArgs e)
|
||||
{
|
||||
AnnouncementForm announcementForm = new AnnouncementForm((Announcement)lbAnnouncements.SelectedItem, true, null);
|
||||
announcementForm.ShowDialog();
|
||||
RefreshLists();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -12,4 +12,10 @@
|
||||
<ProjectReference Include="..\HouseData\StudentHouseDashboard.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="AnnouncementForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
Reference in New Issue
Block a user