diff --git a/StudentHouseDashboard/Data/ComplaintRepository.cs b/StudentHouseDashboard/Data/ComplaintRepository.cs index f7b03ca..d1d4eed 100644 --- a/StudentHouseDashboard/Data/ComplaintRepository.cs +++ b/StudentHouseDashboard/Data/ComplaintRepository.cs @@ -144,7 +144,7 @@ namespace Data var writer = cmd.ExecuteNonQuery(); if (writer == -1) { - throw new DatabaseOperationException("Database error: Complaint not created"); + throw new DatabaseOperationException("Database error: Complaint not updated"); } } } diff --git a/StudentHouseDashboard/Data/EventRepository.cs b/StudentHouseDashboard/Data/EventRepository.cs new file mode 100644 index 0000000..60f0b25 --- /dev/null +++ b/StudentHouseDashboard/Data/EventRepository.cs @@ -0,0 +1,147 @@ +using Logic; +using Logic.Exceptions; +using Models; +using System; +using System.Collections.Generic; +using System.Data.SqlClient; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Data +{ + public class EventRepository : IEventRepository + { + public Event CreateEvent(string title, string description, User author, DateTime publishDate, DateTime startDate, DateTime endDate) + { + using (SqlConnection conn = SqlConnectionHelper.CreateConnection()) + { + string sql = "INSERT INTO Events (Author, Description, Title, PublishDate, StartDate, EndDate) VALUES (@author, @desc, @title, @date, @start, @end) " + + "SELECT SCOPE_IDENTITY();"; + SqlCommand cmd = new SqlCommand(sql, conn); + cmd.Parameters.AddWithValue("@author", author.ID); + cmd.Parameters.AddWithValue("@desc", description); + cmd.Parameters.AddWithValue("@title", title); + cmd.Parameters.AddWithValue("@date", publishDate); + cmd.Parameters.AddWithValue("@start", startDate); + cmd.Parameters.AddWithValue("@end", endDate); + int newId = Convert.ToInt32(cmd.ExecuteScalar()); + if (newId == 0) + { + throw new DatabaseOperationException("Database error: Event not created"); + } + else + { + return GetEventById(newId); + } + } + } + + public void DeleteEvent(int id) + { + using (SqlConnection conn = SqlConnectionHelper.CreateConnection()) + { + string sql = "DELETE FROM Events WHERE Id = @id;"; + SqlCommand cmd = new SqlCommand(sql, conn); + cmd.Parameters.AddWithValue("@id", id); + int writer = cmd.ExecuteNonQuery(); + if (writer != 1) + { + throw new DatabaseOperationException("Database error: Event not deleted"); + } + } + } + + public List GetAllCurrentEvents() + { + List events = new List(); + UserRepository userRepository = new UserRepository(); + using (SqlConnection conn = SqlConnectionHelper.CreateConnection()) + { + string sql = "SELECT * FROM Events WHERE StartDate >= CURRENT_TIMESTAMP;"; + SqlCommand cmd = new SqlCommand(sql, conn); + var reader = cmd.ExecuteReader(); + + while (reader.Read()) + { + Event @event = new Event(Convert.ToInt32(reader["ID"]), + userRepository.GetUserById(Convert.ToInt32(reader["Author"])), + reader["Description"].ToString(), reader["Title"].ToString(), + (DateTime)reader["PublishDate"], (DateTime)reader["StartDate"], + (DateTime)reader["EndDate"]); + // ID, Name, Password, Role + events.Add(@event); + } + conn.Close(); + } + return events; + } + + public List GetAllEvents() + { + List events = new List(); + UserRepository userRepository = new UserRepository(); + using (SqlConnection conn = SqlConnectionHelper.CreateConnection()) + { + string sql = "SELECT * FROM Events;"; + SqlCommand cmd = new SqlCommand(sql, conn); + var reader = cmd.ExecuteReader(); + + while (reader.Read()) + { + Event @event = new Event(Convert.ToInt32(reader["ID"]), + userRepository.GetUserById(Convert.ToInt32(reader["Author"])), + reader["Description"].ToString(), reader["Title"].ToString(), + (DateTime)reader["PublishDate"], (DateTime)reader["StartDate"], + (DateTime)reader["EndDate"]); + // ID, Name, Password, Role + events.Add(@event); + } + conn.Close(); + } + return events; + } + + public Event GetEventById(int id) + { + UserRepository userRepository = new UserRepository(); + using (SqlConnection conn = SqlConnectionHelper.CreateConnection()) + { + string sql = "SELECT * FROM Events WHERE ID = @id;"; + SqlCommand cmd = new SqlCommand(sql, conn); + cmd.Parameters.AddWithValue("id", id); + var reader = cmd.ExecuteReader(); + reader.Read(); + Event @event = new Event(Convert.ToInt32(reader["ID"]), + userRepository.GetUserById(Convert.ToInt32(reader["Author"])), + reader["Description"].ToString(), reader["Title"].ToString(), + (DateTime)reader["PublishDate"], (DateTime)reader["StartDate"], + (DateTime)reader["EndDate"]); + conn.Close(); + return @event; + } + } + + public void UpdateEvent(int id, string title, string description, DateTime startDate, DateTime endDate) + { + using (SqlConnection conn = SqlConnectionHelper.CreateConnection()) + { + string sql = "UPDATE Events " + + "SET Description = @desc, Title = @title, StartDate = @start, EndDate = @end " + + "WHERE ID = @id " + + "SELECT SCOPE_IDENTITY();"; + SqlCommand cmd = new SqlCommand(sql, conn); + cmd.Parameters.AddWithValue("@id", id); + cmd.Parameters.AddWithValue("@desc", description); + cmd.Parameters.AddWithValue("@title", title); + cmd.Parameters.AddWithValue("@status", startDate); + cmd.Parameters.AddWithValue("@severity", endDate); + var writer = cmd.ExecuteNonQuery(); + if (writer == -1) + { + throw new DatabaseOperationException("Database error: Event not updated"); + } + } + } + } +} diff --git a/StudentHouseDashboard/Logic/EventManager.cs b/StudentHouseDashboard/Logic/EventManager.cs new file mode 100644 index 0000000..79847f2 --- /dev/null +++ b/StudentHouseDashboard/Logic/EventManager.cs @@ -0,0 +1,42 @@ +using Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Logic +{ + public class EventManager + { + private IEventRepository eventRepository; + public EventManager(IEventRepository eventRepository) + { + this.eventRepository = eventRepository; + } + public List GetAllEvents() + { + return eventRepository.GetAllEvents(); + } + public List GetAllCurrentEvents() + { + return eventRepository.GetAllCurrentEvents(); + } + public Event GetEventById(int id) + { + return eventRepository.GetEventById(id); + } + public Event CreateEvent(string title, string description, User author, DateTime publishDate, DateTime startDate, DateTime endDate) + { + return eventRepository.CreateEvent(title, description, author, publishDate, startDate, endDate); + } + public void UpdateEvent(int id, string title, string description, DateTime startDate, DateTime endDate) + { + eventRepository.UpdateEvent(id, title, description, startDate, endDate); + } + public void DeleteEvent(int id) + { + eventRepository.DeleteEvent(id); + } + } +} diff --git a/StudentHouseDashboard/Logic/IEventRepository.cs b/StudentHouseDashboard/Logic/IEventRepository.cs new file mode 100644 index 0000000..aae4bd9 --- /dev/null +++ b/StudentHouseDashboard/Logic/IEventRepository.cs @@ -0,0 +1,20 @@ +using Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Logic +{ + public interface IEventRepository + { + public List GetAllEvents(); + public List GetAllCurrentEvents(); + public Event GetEventById(int id); + public Event CreateEvent(string title, string description, User author, DateTime publishDate, DateTime startDate, DateTime endDate); + public void UpdateEvent(int id, string title, string description, DateTime startDate, DateTime endDate); + public void DeleteEvent(int id); + } +} + \ No newline at end of file diff --git a/StudentHouseDashboard/Models/Event.cs b/StudentHouseDashboard/Models/Event.cs index 2474992..8e83f5f 100644 --- a/StudentHouseDashboard/Models/Event.cs +++ b/StudentHouseDashboard/Models/Event.cs @@ -7,6 +7,10 @@ namespace Models { public class Event : GenericMessage { + public Event() + { + + } public Event(int id, User author, string description, string title, DateTime publishDate, DateTime startDate, DateTime endDate) : base(id, author, description, title, publishDate) { StartDate = startDate; @@ -22,5 +26,9 @@ namespace Models { get;set; } + public override string ToString() + { + return $"({StartDate.ToString("g")} - {EndDate.ToString("g")}; {Author.Name}) {Title}"; + } } } \ No newline at end of file diff --git a/StudentHouseDashboard/WebApp/Pages/Index.cshtml b/StudentHouseDashboard/WebApp/Pages/Index.cshtml index 4079123..e160478 100644 --- a/StudentHouseDashboard/WebApp/Pages/Index.cshtml +++ b/StudentHouseDashboard/WebApp/Pages/Index.cshtml @@ -17,6 +17,7 @@ { Announcements Complaints + Events } diff --git a/StudentHouseDashboard/WebApp/Program.cs b/StudentHouseDashboard/WebApp/Program.cs index 06e2107..d49db10 100644 --- a/StudentHouseDashboard/WebApp/Program.cs +++ b/StudentHouseDashboard/WebApp/Program.cs @@ -22,6 +22,7 @@ namespace WebApp builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); + builder.Services.AddScoped(); var app = builder.Build(); diff --git a/StudentHouseDashboard/WinForms/AnnouncementForm.resx b/StudentHouseDashboard/WinForms/AnnouncementForm.resx index f298a7b..a395bff 100644 --- a/StudentHouseDashboard/WinForms/AnnouncementForm.resx +++ b/StudentHouseDashboard/WinForms/AnnouncementForm.resx @@ -1,4 +1,64 @@ - + + + diff --git a/StudentHouseDashboard/WinForms/Dashboard.Designer.cs b/StudentHouseDashboard/WinForms/Dashboard.Designer.cs index d998d26..944964f 100644 --- a/StudentHouseDashboard/WinForms/Dashboard.Designer.cs +++ b/StudentHouseDashboard/WinForms/Dashboard.Designer.cs @@ -52,6 +52,12 @@ lbComplaints = new ListBox(); tpEvents = new TabPage(); btnLogout = new Button(); + panel1 = new Panel(); + btnNewEvent = new Button(); + btnDeleteEvent = new Button(); + btnViewEvent = new Button(); + btnEditEvent = new Button(); + lbEvents = new ListBox(); tabControl1.SuspendLayout(); tpUsers.SuspendLayout(); panelUserFunctions.SuspendLayout(); @@ -59,6 +65,8 @@ panelAnnouncementsFunctions.SuspendLayout(); tpComplaints.SuspendLayout(); panelComplaintFunctions.SuspendLayout(); + tpEvents.SuspendLayout(); + panel1.SuspendLayout(); SuspendLayout(); // // lblUserStatus @@ -297,6 +305,8 @@ // // tpEvents // + tpEvents.Controls.Add(panel1); + tpEvents.Controls.Add(lbEvents); tpEvents.Location = new Point(4, 24); tpEvents.Name = "tpEvents"; tpEvents.Size = new Size(723, 340); @@ -314,6 +324,68 @@ btnLogout.UseVisualStyleBackColor = true; btnLogout.Click += btnLogout_Click; // + // panel1 + // + panel1.Controls.Add(btnNewEvent); + panel1.Controls.Add(btnDeleteEvent); + panel1.Controls.Add(btnViewEvent); + panel1.Controls.Add(btnEditEvent); + panel1.Dock = DockStyle.Bottom; + panel1.Location = new Point(0, 301); + panel1.Name = "panel1"; + panel1.Size = new Size(723, 39); + panel1.TabIndex = 8; + // + // btnNewEvent + // + btnNewEvent.Location = new Point(3, 3); + btnNewEvent.Name = "btnNewEvent"; + btnNewEvent.Size = new Size(75, 23); + btnNewEvent.TabIndex = 2; + btnNewEvent.Text = "New"; + btnNewEvent.UseVisualStyleBackColor = true; + btnNewEvent.Click += btnNewEvent_Click; + // + // btnDeleteEvent + // + btnDeleteEvent.Location = new Point(84, 3); + btnDeleteEvent.Name = "btnDeleteEvent"; + btnDeleteEvent.Size = new Size(75, 23); + btnDeleteEvent.TabIndex = 3; + btnDeleteEvent.Text = "Delete"; + btnDeleteEvent.UseVisualStyleBackColor = true; + btnDeleteEvent.Click += btnDeleteEvent_Click; + // + // btnViewEvent + // + btnViewEvent.Location = new Point(246, 3); + btnViewEvent.Name = "btnViewEvent"; + btnViewEvent.Size = new Size(75, 23); + btnViewEvent.TabIndex = 5; + btnViewEvent.Text = "View"; + btnViewEvent.UseVisualStyleBackColor = true; + btnViewEvent.Click += btnViewEvent_Click; + // + // btnEditEvent + // + btnEditEvent.Location = new Point(165, 3); + btnEditEvent.Name = "btnEditEvent"; + btnEditEvent.Size = new Size(75, 23); + btnEditEvent.TabIndex = 4; + btnEditEvent.Text = "Edit"; + btnEditEvent.UseVisualStyleBackColor = true; + btnEditEvent.Click += btnEditEvent_Click; + // + // lbEvents + // + lbEvents.Dock = DockStyle.Top; + lbEvents.FormattingEnabled = true; + lbEvents.ItemHeight = 15; + lbEvents.Location = new Point(0, 0); + lbEvents.Name = "lbEvents"; + lbEvents.Size = new Size(723, 304); + lbEvents.TabIndex = 9; + // // Dashboard // AutoScaleDimensions = new SizeF(7F, 15F); @@ -332,6 +404,8 @@ panelAnnouncementsFunctions.ResumeLayout(false); tpComplaints.ResumeLayout(false); panelComplaintFunctions.ResumeLayout(false); + tpEvents.ResumeLayout(false); + panel1.ResumeLayout(false); ResumeLayout(false); PerformLayout(); } @@ -362,5 +436,11 @@ private Button btnViewComplaint; private Button btnEditComplaint; private Button btnLogout; + private Panel panel1; + private Button btnNewEvent; + private Button btnDeleteEvent; + private Button btnViewEvent; + private Button btnEditEvent; + private ListBox lbEvents; } } \ No newline at end of file diff --git a/StudentHouseDashboard/WinForms/Dashboard.cs b/StudentHouseDashboard/WinForms/Dashboard.cs index edf60b9..8c15d25 100644 --- a/StudentHouseDashboard/WinForms/Dashboard.cs +++ b/StudentHouseDashboard/WinForms/Dashboard.cs @@ -129,6 +129,12 @@ namespace WinForms { lbComplaints.Items.Add(complaint); } + EventManager eventManager = new EventManager(new EventRepository()); + lbEvents.Items.Clear(); + foreach (Event @event in eventManager.GetAllEvents()) + { + lbEvents.Items.Add(@event); + } } private void Dashboard_FormClosed(object sender, FormClosedEventArgs e) @@ -244,5 +250,59 @@ namespace WinForms Close(); } } + + private void btnNewEvent_Click(object sender, EventArgs e) + { + EventForm eventForm = new EventForm(null, false, user); + eventForm.ShowDialog(); + RefreshLists(); + } + + private void btnDeleteEvent_Click(object sender, EventArgs e) + { + if (lbEvents.SelectedIndex == -1) + { + MessageBox.Show("Please select an item from the list"); + } + else + { + Event currentEvent = (Event)lbEvents.SelectedItem; + if (MessageBox.Show($"Are you sure you want to delete\n{currentEvent.Title}\nCreated at {currentEvent.PublishDate.ToString("g")} by {currentEvent.Author.Name}", + "Delete announcement", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + EventManager eventManager = new EventManager(new EventRepository()); + eventManager.DeleteEvent(currentEvent.ID); + } + RefreshLists(); + } + } + + private void btnEditEvent_Click(object sender, EventArgs e) + { + if (lbEvents.SelectedIndex == -1) + { + MessageBox.Show("Please select an item from the list"); + } + else + { + EventForm eventForm = new EventForm((Event)lbEvents.SelectedItem, false, user); + eventForm.ShowDialog(); + RefreshLists(); + } + } + + private void btnViewEvent_Click(object sender, EventArgs e) + { + if (lbEvents.SelectedIndex == -1) + { + MessageBox.Show("Please select an item from the list"); + } + else + { + EventForm eventForm = new EventForm((Event)lbEvents.SelectedItem, true, user); + eventForm.ShowDialog(); + RefreshLists(); + } + } } } diff --git a/StudentHouseDashboard/WinForms/EventForm.Designer.cs b/StudentHouseDashboard/WinForms/EventForm.Designer.cs new file mode 100644 index 0000000..d8f53eb --- /dev/null +++ b/StudentHouseDashboard/WinForms/EventForm.Designer.cs @@ -0,0 +1,189 @@ +namespace WinForms +{ + partial class EventForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + 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(); + lblStart = new Label(); + dtpStartDate = new DateTimePicker(); + lblEnd = new Label(); + dtpEndDate = new DateTimePicker(); + 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(75, 15); + lblPublishDate.TabIndex = 4; + lblPublishDate.Text = "Publish date:"; + // + // btnSave + // + btnSave.Location = new Point(424, 212); + 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.CustomFormat = "dd-MM-yyyy hh:mm"; + dtpPublishDate.Format = DateTimePickerFormat.Custom; + dtpPublishDate.Location = new Point(94, 153); + dtpPublishDate.Name = "dtpPublishDate"; + dtpPublishDate.Size = new Size(141, 23); + dtpPublishDate.TabIndex = 9; + // + // lblAuthor + // + lblAuthor.AutoSize = true; + lblAuthor.Location = new Point(241, 159); + lblAuthor.Name = "lblAuthor"; + lblAuthor.Size = new Size(70, 15); + lblAuthor.TabIndex = 10; + lblAuthor.Text = "Created by: "; + // + // lblStart + // + lblStart.AutoSize = true; + lblStart.Location = new Point(12, 188); + lblStart.Name = "lblStart"; + lblStart.Size = new Size(60, 15); + lblStart.TabIndex = 11; + lblStart.Text = "Start date:"; + // + // dtpStartDate + // + dtpStartDate.CustomFormat = "dd-MM-yyyy hh:mm"; + dtpStartDate.Format = DateTimePickerFormat.Custom; + dtpStartDate.Location = new Point(94, 182); + dtpStartDate.Name = "dtpStartDate"; + dtpStartDate.Size = new Size(141, 23); + dtpStartDate.TabIndex = 12; + // + // lblEnd + // + lblEnd.AutoSize = true; + lblEnd.Location = new Point(241, 188); + lblEnd.Name = "lblEnd"; + lblEnd.Size = new Size(56, 15); + lblEnd.TabIndex = 13; + lblEnd.Text = "End date:"; + // + // dtpEndDate + // + dtpEndDate.CustomFormat = "dd-MM-yyyy hh:mm"; + dtpEndDate.Format = DateTimePickerFormat.Custom; + dtpEndDate.Location = new Point(303, 183); + dtpEndDate.Name = "dtpEndDate"; + dtpEndDate.Size = new Size(141, 23); + dtpEndDate.TabIndex = 14; + // + // EventForm + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(511, 246); + Controls.Add(dtpEndDate); + Controls.Add(lblEnd); + Controls.Add(dtpStartDate); + Controls.Add(lblStart); + 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 = "EventForm"; + Text = "Event"; + 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 lblStart; + private DateTimePicker dtpStartDate; + private Label lblEnd; + private DateTimePicker dtpEndDate; + } +} \ No newline at end of file diff --git a/StudentHouseDashboard/WinForms/EventForm.cs b/StudentHouseDashboard/WinForms/EventForm.cs new file mode 100644 index 0000000..2bca789 --- /dev/null +++ b/StudentHouseDashboard/WinForms/EventForm.cs @@ -0,0 +1,69 @@ +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 EventForm : Form + { + Event @event; + User currentUser; + public EventForm(Event? @event, bool readOnly, User currentUser) + { + InitializeComponent(); + this.@event = @event; + this.currentUser = currentUser; + + dtpPublishDate.Enabled = false; + if (readOnly) + { + btnSave.Enabled = false; + tbTitle.Enabled = false; + tbDescription.Enabled = false; + dtpStartDate.Enabled = false; + dtpEndDate.Enabled = false; + } + if (@event != null) + { + tbTitle.Text = @event.Title; + lblAuthor.Text = $"Created by: {@event.Author.Name}"; + tbDescription.Text = @event.Description; + dtpPublishDate.Value = @event.PublishDate; + dtpStartDate.Value = @event.EndDate; + } + if (currentUser != null) + { + lblAuthor.Text = $"Created by: {currentUser.Name}"; + } + } + + private void btnSave_Click(object sender, EventArgs e) + { + EventManager eventManager = new EventManager(new EventRepository()); + if (string.IsNullOrEmpty(tbTitle.Text)) + { + MessageBox.Show("Please enter a title"); + return; + } + + if (this.@event == null) + { + eventManager.CreateEvent(tbTitle.Text, tbDescription.Text, currentUser, dtpPublishDate.Value, dtpStartDate.Value, dtpEndDate.Value); + } + else + { + eventManager.UpdateEvent(@event.ID, tbTitle.Text, tbDescription.Text, dtpStartDate.Value, dtpEndDate.Value); + } + this.DialogResult = DialogResult.OK; + } + } +} diff --git a/StudentHouseDashboard/WinForms/EventForm.resx b/StudentHouseDashboard/WinForms/EventForm.resx new file mode 100644 index 0000000..a395bff --- /dev/null +++ b/StudentHouseDashboard/WinForms/EventForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/StudentHouseDashboard/WinForms/WinForms.csproj b/StudentHouseDashboard/WinForms/WinForms.csproj index b78d006..dc340a6 100644 --- a/StudentHouseDashboard/WinForms/WinForms.csproj +++ b/StudentHouseDashboard/WinForms/WinForms.csproj @@ -16,6 +16,9 @@ + + Form + Form diff --git a/docs/dbdiagram.png b/docs/dbdiagram.png index 47b23f5..42151dd 100644 Binary files a/docs/dbdiagram.png and b/docs/dbdiagram.png differ diff --git a/docs/testplan.docx b/docs/testplan.docx index a7f4716..a425f4f 100644 Binary files a/docs/testplan.docx and b/docs/testplan.docx differ diff --git a/table.sql b/table.sql index 35da05c..66a6bf4 100644 --- a/table.sql +++ b/table.sql @@ -81,4 +81,15 @@ CREATE TABLE ComplaintsComments ( ComplaintID INT FOREIGN KEY REFERENCES Complaints(ID) NOT NULL, CommentID INT FOREIGN KEY REFERENCES Comments(ID) NOT NULL ) +GO + +CREATE TABLE Events ( + ID INT PRIMARY KEY IDENTITY NOT NULL, + [Author] INT FOREIGN KEY REFERENCES Users(ID) NOT NULL, + [Description] NVARCHAR(MAX), + [Title] NVARCHAR(255) NOT NULL, + [PublishDate] DATETIME NOT NULL, + [StartDate] DATETIME NOT NULL, + [EndDate] DATETIME NOT NULL +) GO \ No newline at end of file