From 17a4c4edb0eb7cbd82907fee9945ba10480abe23 Mon Sep 17 00:00:00 2001 From: Fionn Date: Tue, 10 Jan 2023 06:33:15 +0100 Subject: [PATCH] add initial appointmentsmanager --- AppointmentsManager/Appointments.sql | 51 ++++ .../AppointmentsLib/AppointmentsLib.csproj | 11 + .../AppointmentsLib/Database.cs | 41 ++++ .../AppointmentsLib/Models/Appointment.cs | 94 +++++++ .../AppointmentsLib/Models/Company.cs | 87 +++++++ .../AppointmentsLib/Models/Contact.cs | 134 ++++++++++ .../AppointmentsLib/Models/PhoneType.cs | 85 +++++++ .../AppointmentsLib/Models/Postal.cs | 85 +++++++ .../AppointmentsLib/Models/Salutation.cs | 85 +++++++ AppointmentsManager/AppointmentsLib/Test.cs | 12 + AppointmentsManager/AppointmentsManager.sln | 31 +++ .../AppointmentsUi/AppointmentsUi.csproj | 29 +++ .../AppointmentsUi/MainForm.Designer.cs | 230 ++++++++++++++++++ .../AppointmentsUi/MainForm.cs | 60 +++++ .../AppointmentsUi/MainForm.resx | 127 ++++++++++ AppointmentsManager/AppointmentsUi/Program.cs | 39 +++ .../Properties/Resources.Designer.cs | 63 +++++ .../AppointmentsUi/Properties/Resources.resx | 120 +++++++++ .../Views/CompanyList.Designer.cs | 93 +++++++ .../AppointmentsUi/Views/CompanyList.cs | 59 +++++ .../AppointmentsUi/Views/CompanyList.resx | 60 +++++ .../Views/EmptyPage.Designer.cs | 61 +++++ .../AppointmentsUi/Views/EmptyPage.cs | 20 ++ .../AppointmentsUi/Views/EmptyPage.resx | 60 +++++ 24 files changed, 1737 insertions(+) create mode 100644 AppointmentsManager/Appointments.sql create mode 100644 AppointmentsManager/AppointmentsLib/AppointmentsLib.csproj create mode 100644 AppointmentsManager/AppointmentsLib/Database.cs create mode 100644 AppointmentsManager/AppointmentsLib/Models/Appointment.cs create mode 100644 AppointmentsManager/AppointmentsLib/Models/Company.cs create mode 100644 AppointmentsManager/AppointmentsLib/Models/Contact.cs create mode 100644 AppointmentsManager/AppointmentsLib/Models/PhoneType.cs create mode 100644 AppointmentsManager/AppointmentsLib/Models/Postal.cs create mode 100644 AppointmentsManager/AppointmentsLib/Models/Salutation.cs create mode 100644 AppointmentsManager/AppointmentsLib/Test.cs create mode 100644 AppointmentsManager/AppointmentsManager.sln create mode 100644 AppointmentsManager/AppointmentsUi/AppointmentsUi.csproj create mode 100644 AppointmentsManager/AppointmentsUi/MainForm.Designer.cs create mode 100644 AppointmentsManager/AppointmentsUi/MainForm.cs create mode 100644 AppointmentsManager/AppointmentsUi/MainForm.resx create mode 100644 AppointmentsManager/AppointmentsUi/Program.cs create mode 100644 AppointmentsManager/AppointmentsUi/Properties/Resources.Designer.cs create mode 100644 AppointmentsManager/AppointmentsUi/Properties/Resources.resx create mode 100644 AppointmentsManager/AppointmentsUi/Views/CompanyList.Designer.cs create mode 100644 AppointmentsManager/AppointmentsUi/Views/CompanyList.cs create mode 100644 AppointmentsManager/AppointmentsUi/Views/CompanyList.resx create mode 100644 AppointmentsManager/AppointmentsUi/Views/EmptyPage.Designer.cs create mode 100644 AppointmentsManager/AppointmentsUi/Views/EmptyPage.cs create mode 100644 AppointmentsManager/AppointmentsUi/Views/EmptyPage.resx diff --git a/AppointmentsManager/Appointments.sql b/AppointmentsManager/Appointments.sql new file mode 100644 index 0000000..0b7000d --- /dev/null +++ b/AppointmentsManager/Appointments.sql @@ -0,0 +1,51 @@ +-- create table for Salutation +create table Salutation ( + salutationId int NOT NULL auto_increment PRIMARY KEY, + label varchar(255) +); + +-- create table for Postal +create table Postal ( + postalId int NOT NULL auto_increment PRIMARY KEY, + label varchar(255) +); + +-- create table for PhoneType +create table PhoneType ( + phoneTypeId int NOT NULL auto_increment PRIMARY KEY, + label varchar(255) +); + +-- create table for Company +create table Company ( + companyId int NOT NULL auto_increment PRIMARY KEY, + label varchar(255) +); + +-- Contact Table +create table Contact ( + contactId int NOT NULL auto_increment PRIMARY KEY, + salutationId int, + firstname varchar(255), + surname varchar(255), + street varchar(255), + postalId int, + phone varchar(255), + phoneTypeId int, + mobil varchar(255), + companyId int, + department varchar(255), + CONSTRAINT FK_Contact_Salutation FOREIGN KEY (salutationId) REFERENCES Salutation(salutationId), + CONSTRAINT FK_Contact_Postal FOREIGN KEY (postalId) REFERENCES Postal(postalId), + CONSTRAINT FK_Contact_PhoneType FOREIGN KEY (phoneTypeId) REFERENCES PhoneType(phoneTypeId), + CONSTRAINT FK_Contact_Company FOREIGN KEY (companyId) REFERENCES Company(companyId) +); + +-- Appointments Table +create table Appointment ( + appointmentId int NOT NULL auto_increment PRIMARY KEY, + contactId int, + time date, + description varchar(255), + FOREIGN KEY (contactId) REFERENCES Contact(contactId) +); \ No newline at end of file diff --git a/AppointmentsManager/AppointmentsLib/AppointmentsLib.csproj b/AppointmentsManager/AppointmentsLib/AppointmentsLib.csproj new file mode 100644 index 0000000..b51638f --- /dev/null +++ b/AppointmentsManager/AppointmentsLib/AppointmentsLib.csproj @@ -0,0 +1,11 @@ + + + + net5.0 + + + + + + + diff --git a/AppointmentsManager/AppointmentsLib/Database.cs b/AppointmentsManager/AppointmentsLib/Database.cs new file mode 100644 index 0000000..0a35cc0 --- /dev/null +++ b/AppointmentsManager/AppointmentsLib/Database.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using MySqlConnector; + +namespace AppointmentsLib +{ + public static class Database + { + private static MySqlConnection mysqlConnection; + + public static bool Connect(string server, int port, string database, string username, string password) + { + string connectionString = $"Server={server};Port={port};User id={username};Password={password};Database={database}"; + + mysqlConnection = new MySqlConnection(connectionString); + + try { + mysqlConnection.Open(); + + Console.WriteLine("db connected"); + + return true; + } catch(Exception e) { + Console.WriteLine("db connection failed"); + + Console.WriteLine(e); + + return false; + } + } + + internal static MySqlCommand Execute(string command) + { + return new MySqlCommand(command, mysqlConnection); + } + } +} diff --git a/AppointmentsManager/AppointmentsLib/Models/Appointment.cs b/AppointmentsManager/AppointmentsLib/Models/Appointment.cs new file mode 100644 index 0000000..a610d88 --- /dev/null +++ b/AppointmentsManager/AppointmentsLib/Models/Appointment.cs @@ -0,0 +1,94 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AppointmentsLib.Models +{ + public class Appointment + { + public readonly int AppointmentId; + public Contact Contact; + public DateTime Time; + public string Description; + + internal Appointment(int appointmentId, int contactId, string time, string description) + { + AppointmentId = appointmentId; + Contact = Contact.GetContactById(contactId); + Time = DateTime.Parse(time); + Description = description; + } + + public static IEnumerable GetAppointments() + { + var reader = Database.Execute("SELECT appointmentId, contactId, time, description FROM Appointment;").ExecuteReader(); + + List appointments = new(); + + while (reader.Read()) + { + appointments.Add(new Appointment(reader.GetInt32(0), reader.GetInt32(1), reader.GetString(2), reader.GetString(3))); + } + + reader.Close(); + return appointments; + } + + public static Appointment GetAppointmentById(int appointmentId) + { + var cmd = Database.Execute($"SELECT appointmentId, contactId, time, description FROM Appointment WHERE appointmentId = @id;"); + + cmd.Parameters.AddWithValue("id", appointmentId); + + var reader = cmd.ExecuteReader(); + + while (reader.Read()) + { + var appointment = new Appointment(reader.GetInt32(0), reader.GetInt32(1), reader.GetString(2), reader.GetString(3)); + reader.Close(); + return appointment; + } + + throw new Exception("salutation does not exist"); + } + + public static Appointment Create(int contactId, DateTime time, string description) + { + var cmd = Database.Execute($"INSERT INTO Appointment (contactId, time, description) VALUES (@contact, @time, @description)"); + + cmd.Parameters.AddWithValue("contact", contactId); + cmd.Parameters.AddWithValue("time", time); + cmd.Parameters.AddWithValue("description", description); + + cmd.ExecuteNonQuery(); + + int appointmentId = (int)cmd.LastInsertedId; + + return new Appointment(appointmentId, contactId, time.ToString(), description); + } + + public void Save() + { + var cmd = Database.Execute("UPDATE Appointment SET contactId = @contact, time = @time, description = @description WHERE appointmentId = @id"); + + cmd.Parameters.AddWithValue("contact", Contact.ContactId); + cmd.Parameters.AddWithValue("time", Time); + cmd.Parameters.AddWithValue("description", Description); + + cmd.Parameters.AddWithValue("id", AppointmentId); + + cmd.ExecuteNonQuery(); + } + + public void Delete() + { + var cmd = Database.Execute("DELETE FROM Appointment WHERE appointmentId = @id"); + + cmd.Parameters.AddWithValue("id", AppointmentId); + + cmd.ExecuteNonQuery(); + } + } +} diff --git a/AppointmentsManager/AppointmentsLib/Models/Company.cs b/AppointmentsManager/AppointmentsLib/Models/Company.cs new file mode 100644 index 0000000..75f06fa --- /dev/null +++ b/AppointmentsManager/AppointmentsLib/Models/Company.cs @@ -0,0 +1,87 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using MySqlConnector; + +namespace AppointmentsLib.Models +{ + public class Company + { + public readonly int CompanyId; + public string Label; + + internal Company(int companyId, string label) + { + CompanyId = companyId; + Label = label; + } + + public static IEnumerable GetCompanies() + { + var reader = Database.Execute("SELECT companyId, label FROM Company;").ExecuteReader(); + + List companies = new(); + + while (reader.Read()) + { + companies.Add(new Company(reader.GetInt32(0), reader.GetString(1))); + } + + reader.Close(); + return companies; + } + + public static Company GetCompanyById(int companyId) + { + var cmd = Database.Execute($"SELECT companyId, label FROM Company WHERE companyId = @id;"); + + cmd.Parameters.AddWithValue("id", companyId); + + var reader = cmd.ExecuteReader(); + + while (reader.Read()) + { + var company = new Company(reader.GetInt32(0), reader.GetString(1)); + reader.Close(); + return company; + } + + throw new Exception("company does not exist"); + } + + public static Company Create(string label) + { + var cmd = Database.Execute($"INSERT INTO Company (label) VALUES (@label)"); + + cmd.Parameters.AddWithValue("label", label); + + cmd.ExecuteNonQuery(); + + int companyId = (int)cmd.LastInsertedId; + + return new Company(companyId, label); + } + + public void Save() + { + var cmd = Database.Execute("UPDATE Company SET label = @label WHERE companyId = @companyId"); + + cmd.Parameters.AddWithValue("label", Label); + cmd.Parameters.AddWithValue("companyId", CompanyId); + + cmd.ExecuteNonQuery(); + } + + public void Delete() + { + var cmd = Database.Execute("DELETE FROM Company WHERE companyId = @companyId"); + + cmd.Parameters.AddWithValue("companyId", CompanyId); + + cmd.ExecuteNonQuery(); + } + } +} diff --git a/AppointmentsManager/AppointmentsLib/Models/Contact.cs b/AppointmentsManager/AppointmentsLib/Models/Contact.cs new file mode 100644 index 0000000..1bea7be --- /dev/null +++ b/AppointmentsManager/AppointmentsLib/Models/Contact.cs @@ -0,0 +1,134 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AppointmentsLib.Models +{ + public class Contact + { + private static string primaryKey = "contactId"; + private static List fields = new() + { + "salutationId", + "firstname", + "surname", + "street", + "postalId", + "phone", + "phoneTypeId", + "mobil", + "companyId", + "department" + }; + + public readonly int ContactId; + public Salutation Salutation; + public string FirstName; + public string LastName; + public string Street; + public Postal Postal; + public string Phone; + public PhoneType PhoneType; + public string Mobil; + public Company Company; + public string Department; + + internal Contact(int contactId, int salutationId, string firstName, string lastName, string street, int postalId, string phone, int phoneTypeId, string mobil, int companyId, string department) + { + ContactId = contactId; + FirstName = firstName; + LastName = lastName; + Street = street; + Phone = phone; + Mobil = mobil; + Department = department; + + Company = Company.GetCompanyById(companyId); + } + + public static IEnumerable GetContacts() + { + var reader = Database.Execute($"SELECT {primaryKey}, {string.Join(", ", fields.ToArray())} FROM Contact;").ExecuteReader(); + + List contacts = new(); + + while (reader.Read()) + { + contacts.Add(new Contact(reader.GetInt32(0), reader.GetInt32(1), reader.GetString(2), reader.GetString(3), reader.GetString(4), reader.GetInt32(4), reader.GetString(5), reader.GetInt32(6), reader.GetString(7), reader.GetInt32(8), reader.GetString(9))); + } + + reader.Close(); + return contacts; + } + + public static Contact GetContactById(int contactId) + { + var cmd = Database.Execute($"SELECT {primaryKey}, {string.Join(", ", fields.ToArray())} FROM Contact WHERE {primaryKey} = @id;"); + + cmd.Parameters.AddWithValue("id", contactId); + + var reader = cmd.ExecuteReader(); + + while (reader.Read()) + { + var contact = new Contact(reader.GetInt32(0), reader.GetInt32(1), reader.GetString(2), reader.GetString(3), reader.GetString(4), reader.GetInt32(4), reader.GetString(5), reader.GetInt32(6), reader.GetString(7), reader.GetInt32(8), reader.GetString(9)); + reader.Close(); + return contact; + } + + throw new Exception("contact does not exist"); + } + + public static Contact Create(int salutationId, string firstName, string lastName, string street, int postalId, string phone, int phoneTypeId, string mobil, int companyId, string department) + { + var cmd = Database.Execute($"INSERT INTO Contact ({string.Join(", ", fields.ToArray())}) VALUES ({string.Join(", ", fields.Select(delegate(string name) { return $"@{name}"; }).ToArray())})"); + + cmd.Parameters.AddWithValue("salutationId", salutationId); + cmd.Parameters.AddWithValue("firstname", firstName); + cmd.Parameters.AddWithValue("surname", lastName); + cmd.Parameters.AddWithValue("street", street); + cmd.Parameters.AddWithValue("postalId", postalId); + cmd.Parameters.AddWithValue("phone", phone); + cmd.Parameters.AddWithValue("phoneTypeId", phoneTypeId); + cmd.Parameters.AddWithValue("mobil", mobil); + cmd.Parameters.AddWithValue("companyId", companyId); + cmd.Parameters.AddWithValue("department", department); + + cmd.ExecuteNonQuery(); + + int contactId = (int)cmd.LastInsertedId; + + return new Contact(contactId, salutationId, firstName, lastName, street, postalId, phone, phoneTypeId, mobil, companyId, department); + } + + public void Save() + { + var cmd = Database.Execute($"UPDATE Company SET {string.Join(", ", fields.Select(delegate(string name) { return $"@{name}"; }).ToArray())} WHERE {primaryKey} = @id"); + + cmd.Parameters.AddWithValue("id", ContactId); + cmd.Parameters.AddWithValue("salutationId", Salutation.SalutationId); // Salutation.salutationId + cmd.Parameters.AddWithValue("firstname", FirstName); + cmd.Parameters.AddWithValue("surname", LastName); + cmd.Parameters.AddWithValue("street", Street); + cmd.Parameters.AddWithValue("postalId", Postal.PostalId); // Postal.postalId + cmd.Parameters.AddWithValue("phone", Phone); + cmd.Parameters.AddWithValue("phoneTypeId", PhoneType.PhoneTypeId); // PhoneType.phoneTypeId + cmd.Parameters.AddWithValue("mobil", Mobil); + cmd.Parameters.AddWithValue("companyId", Company.CompanyId); + cmd.Parameters.AddWithValue("department", Department); + + cmd.ExecuteNonQuery(); + } + + public void Delete() + { + var cmd = Database.Execute($"DELETE FROM Contact WHERE {primaryKey} = @id"); + + cmd.Parameters.AddWithValue("id", ContactId); + + cmd.ExecuteNonQuery(); + } + } +} diff --git a/AppointmentsManager/AppointmentsLib/Models/PhoneType.cs b/AppointmentsManager/AppointmentsLib/Models/PhoneType.cs new file mode 100644 index 0000000..6f6821b --- /dev/null +++ b/AppointmentsManager/AppointmentsLib/Models/PhoneType.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AppointmentsLib.Models +{ + public class PhoneType + { + public readonly int PhoneTypeId; + public string Label; + + internal PhoneType(int phoneTypeId, string label) + { + PhoneTypeId = phoneTypeId; + Label = label; + } + + public static IEnumerable GetPhoneTypes() + { + var reader = Database.Execute("SELECT phoneTypeId, label FROM PhoneType;").ExecuteReader(); + + List phoneTypes = new(); + + while (reader.Read()) + { + phoneTypes.Add(new PhoneType(reader.GetInt32(0), reader.GetString(1))); + } + + reader.Close(); + return phoneTypes; + } + + public static PhoneType GetPhoneTypeById(int companyId) + { + var cmd = Database.Execute($"SELECT phoneTypeId, label FROM PhoneType WHERE phoneTypeId = @id;"); + + cmd.Parameters.AddWithValue("id", companyId); + + var reader = cmd.ExecuteReader(); + + while (reader.Read()) + { + var phoneType = new PhoneType(reader.GetInt32(0), reader.GetString(1)); + reader.Close(); + return phoneType; + } + + throw new Exception("phonetype does not exist"); + } + + public static PhoneType Create(string label) + { + var cmd = Database.Execute($"INSERT INTO PhoneType (label) VALUES (@label)"); + + cmd.Parameters.AddWithValue("label", label); + + cmd.ExecuteNonQuery(); + + int phoneTypeId = (int)cmd.LastInsertedId; + + return new PhoneType(phoneTypeId, label); + } + + public void Save() + { + var cmd = Database.Execute("UPDATE PhoneType SET label = @label WHERE phoneTypeId = @id"); + + cmd.Parameters.AddWithValue("label", Label); + cmd.Parameters.AddWithValue("id", PhoneTypeId); + + cmd.ExecuteNonQuery(); + } + + public void Delete() + { + var cmd = Database.Execute("DELETE FROM PhoneType WHERE phoneTypeId = @id"); + + cmd.Parameters.AddWithValue("id", PhoneTypeId); + + cmd.ExecuteNonQuery(); + } + } +} diff --git a/AppointmentsManager/AppointmentsLib/Models/Postal.cs b/AppointmentsManager/AppointmentsLib/Models/Postal.cs new file mode 100644 index 0000000..1d02128 --- /dev/null +++ b/AppointmentsManager/AppointmentsLib/Models/Postal.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AppointmentsLib.Models +{ + public class Postal + { + public readonly int PostalId; + public string Label; + + internal Postal(int postalId, string label) + { + PostalId = postalId; + Label = label; + } + + public static IEnumerable GetPostals() + { + var reader = Database.Execute("SELECT postalId, label FROM Postal;").ExecuteReader(); + + List postals = new(); + + while (reader.Read()) + { + postals.Add(new Postal(reader.GetInt32(0), reader.GetString(1))); + } + + reader.Close(); + return postals; + } + + public static Postal GetPostalById(int postalId) + { + var cmd = Database.Execute($"SELECT postalId, label FROM Postal WHERE postalId = @id;"); + + cmd.Parameters.AddWithValue("id", postalId); + + var reader = cmd.ExecuteReader(); + + while (reader.Read()) + { + var postal = new Postal(reader.GetInt32(0), reader.GetString(1)); + reader.Close(); + return postal; + } + + throw new Exception("postal does not exist"); + } + + public static Postal Create(string label) + { + var cmd = Database.Execute($"INSERT INTO Postal (label) VALUES (@label)"); + + cmd.Parameters.AddWithValue("label", label); + + cmd.ExecuteNonQuery(); + + int postalId = (int)cmd.LastInsertedId; + + return new Postal(postalId, label); + } + + public void Save() + { + var cmd = Database.Execute("UPDATE Postal SET label = @label WHERE postalId = @id"); + + cmd.Parameters.AddWithValue("label", Label); + cmd.Parameters.AddWithValue("id", PostalId); + + cmd.ExecuteNonQuery(); + } + + public void Delete() + { + var cmd = Database.Execute("DELETE FROM Postal WHERE postalId = @id"); + + cmd.Parameters.AddWithValue("id", PostalId); + + cmd.ExecuteNonQuery(); + } + } +} diff --git a/AppointmentsManager/AppointmentsLib/Models/Salutation.cs b/AppointmentsManager/AppointmentsLib/Models/Salutation.cs new file mode 100644 index 0000000..183b568 --- /dev/null +++ b/AppointmentsManager/AppointmentsLib/Models/Salutation.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AppointmentsLib.Models +{ + public class Salutation + { + public readonly int SalutationId; + public string Label; + + internal Salutation(int salutationId, string label) + { + SalutationId = salutationId; + Label = label; + } + + public static IEnumerable GetSalutations() + { + var reader = Database.Execute("SELECT salutationId, label FROM Salutation;").ExecuteReader(); + + List salutations = new(); + + while (reader.Read()) + { + salutations.Add(new Salutation(reader.GetInt32(0), reader.GetString(1))); + } + + reader.Close(); + return salutations; + } + + public static Salutation GetSalutationById(int salutationId) + { + var cmd = Database.Execute($"SELECT salutationId, label FROM Salutation WHERE salutationId = @id;"); + + cmd.Parameters.AddWithValue("id", salutationId); + + var reader = cmd.ExecuteReader(); + + while (reader.Read()) + { + var salutation = new Salutation(reader.GetInt32(0), reader.GetString(1)); + reader.Close(); + return salutation; + } + + throw new Exception("salutation does not exist"); + } + + public static Salutation Create(string label) + { + var cmd = Database.Execute($"INSERT INTO Salutation (label) VALUES (@label)"); + + cmd.Parameters.AddWithValue("label", label); + + cmd.ExecuteNonQuery(); + + int salutationId = (int)cmd.LastInsertedId; + + return new Salutation(salutationId, label); + } + + public void Save() + { + var cmd = Database.Execute("UPDATE Salutation SET label = @label WHERE salutationId = @id"); + + cmd.Parameters.AddWithValue("label", Label); + cmd.Parameters.AddWithValue("id", SalutationId); + + cmd.ExecuteNonQuery(); + } + + public void Delete() + { + var cmd = Database.Execute("DELETE FROM Salutation WHERE salutationId = @id"); + + cmd.Parameters.AddWithValue("id", SalutationId); + + cmd.ExecuteNonQuery(); + } + } +} diff --git a/AppointmentsManager/AppointmentsLib/Test.cs b/AppointmentsManager/AppointmentsLib/Test.cs new file mode 100644 index 0000000..72ab02b --- /dev/null +++ b/AppointmentsManager/AppointmentsLib/Test.cs @@ -0,0 +1,12 @@ +using System; + +namespace AppointmentsLib +{ + public class Test + { + public static int TestFunction() + { + return 1; + } + } +} diff --git a/AppointmentsManager/AppointmentsManager.sln b/AppointmentsManager/AppointmentsManager.sln new file mode 100644 index 0000000..bd35449 --- /dev/null +++ b/AppointmentsManager/AppointmentsManager.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.32413.511 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AppointmentsUi", "AppointmentsUi\AppointmentsUi.csproj", "{7C572F8A-D342-4741-9021-C849546F1F72}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AppointmentsLib", "AppointmentsLib\AppointmentsLib.csproj", "{4763CEC7-B805-4699-B635-481112F2E2BC}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7C572F8A-D342-4741-9021-C849546F1F72}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7C572F8A-D342-4741-9021-C849546F1F72}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7C572F8A-D342-4741-9021-C849546F1F72}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7C572F8A-D342-4741-9021-C849546F1F72}.Release|Any CPU.Build.0 = Release|Any CPU + {4763CEC7-B805-4699-B635-481112F2E2BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4763CEC7-B805-4699-B635-481112F2E2BC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4763CEC7-B805-4699-B635-481112F2E2BC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4763CEC7-B805-4699-B635-481112F2E2BC}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {2E10E48F-FBF3-4049-9CBA-F5F10D7F3992} + EndGlobalSection +EndGlobal diff --git a/AppointmentsManager/AppointmentsUi/AppointmentsUi.csproj b/AppointmentsManager/AppointmentsUi/AppointmentsUi.csproj new file mode 100644 index 0000000..7694a42 --- /dev/null +++ b/AppointmentsManager/AppointmentsUi/AppointmentsUi.csproj @@ -0,0 +1,29 @@ + + + + WinExe + net5.0-windows + enable + true + + + + + + + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + \ No newline at end of file diff --git a/AppointmentsManager/AppointmentsUi/MainForm.Designer.cs b/AppointmentsManager/AppointmentsUi/MainForm.Designer.cs new file mode 100644 index 0000000..2e44e34 --- /dev/null +++ b/AppointmentsManager/AppointmentsUi/MainForm.Designer.cs @@ -0,0 +1,230 @@ + +namespace AppointmentsUi +{ + partial class MainForm + { + /// + /// 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() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); + this.toolstrip = new System.Windows.Forms.ToolStrip(); + this.tooltipAppointsmentsButton = new System.Windows.Forms.ToolStripSplitButton(); + this.toolstripAppointsmentsAddNewButton = new System.Windows.Forms.ToolStripMenuItem(); + this.toolstripContactsButton = new System.Windows.Forms.ToolStripSplitButton(); + this.toolstripContactsAddNewButton = new System.Windows.Forms.ToolStripMenuItem(); + this.toolstripCompaniesButton = new System.Windows.Forms.ToolStripSplitButton(); + this.toolstripCompaniesAddNewButton = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSplitButton1 = new System.Windows.Forms.ToolStripSplitButton(); + this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.toolstripSalutationsButton = new System.Windows.Forms.ToolStripSplitButton(); + this.toolstripSalutationsAddNewButton = new System.Windows.Forms.ToolStripMenuItem(); + this.toolstripPostalsButton = new System.Windows.Forms.ToolStripSplitButton(); + this.toolstripPostalsAddNewButton = new System.Windows.Forms.ToolStripMenuItem(); + this.toolstripAboutButton = new System.Windows.Forms.ToolStripButton(); + this.embeddingContainer = new System.Windows.Forms.Panel(); + this.toolstrip.SuspendLayout(); + this.SuspendLayout(); + // + // toolstrip + // + this.toolstrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.tooltipAppointsmentsButton, + this.toolstripContactsButton, + this.toolstripCompaniesButton, + this.toolStripSplitButton1, + this.toolstripSalutationsButton, + this.toolstripPostalsButton, + this.toolstripAboutButton}); + this.toolstrip.Location = new System.Drawing.Point(0, 0); + this.toolstrip.Name = "toolstrip"; + this.toolstrip.Size = new System.Drawing.Size(800, 25); + this.toolstrip.TabIndex = 0; + this.toolstrip.Text = "toolstrip"; + // + // tooltipAppointsmentsButton + // + this.tooltipAppointsmentsButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.tooltipAppointsmentsButton.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolstripAppointsmentsAddNewButton}); + this.tooltipAppointsmentsButton.Image = ((System.Drawing.Image)(resources.GetObject("tooltipAppointsmentsButton.Image"))); + this.tooltipAppointsmentsButton.ImageTransparentColor = System.Drawing.Color.Magenta; + this.tooltipAppointsmentsButton.Name = "tooltipAppointsmentsButton"; + this.tooltipAppointsmentsButton.Size = new System.Drawing.Size(99, 22); + this.tooltipAppointsmentsButton.Text = "Appointments"; + this.tooltipAppointsmentsButton.ButtonClick += new System.EventHandler(this.tooltipAppointsmentsButton_ButtonClick); + // + // toolstripAppointsmentsAddNewButton + // + this.toolstripAppointsmentsAddNewButton.Name = "toolstripAppointsmentsAddNewButton"; + this.toolstripAppointsmentsAddNewButton.Size = new System.Drawing.Size(121, 22); + this.toolstripAppointsmentsAddNewButton.Text = "Add new"; + this.toolstripAppointsmentsAddNewButton.Click += new System.EventHandler(this.toolstripAppointsmentsAddNewButton_Click); + // + // toolstripContactsButton + // + this.toolstripContactsButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.toolstripContactsButton.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolstripContactsAddNewButton}); + this.toolstripContactsButton.Image = ((System.Drawing.Image)(resources.GetObject("toolstripContactsButton.Image"))); + this.toolstripContactsButton.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolstripContactsButton.Name = "toolstripContactsButton"; + this.toolstripContactsButton.Size = new System.Drawing.Size(70, 22); + this.toolstripContactsButton.Text = "Contacts"; + this.toolstripContactsButton.ButtonClick += new System.EventHandler(this.toolstripContactsButton_ButtonClick); + // + // toolstripContactsAddNewButton + // + this.toolstripContactsAddNewButton.Name = "toolstripContactsAddNewButton"; + this.toolstripContactsAddNewButton.Size = new System.Drawing.Size(121, 22); + this.toolstripContactsAddNewButton.Text = "Add new"; + this.toolstripContactsAddNewButton.Click += new System.EventHandler(this.toolstripContactsAddNewButton_Click); + // + // toolstripCompaniesButton + // + this.toolstripCompaniesButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.toolstripCompaniesButton.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolstripCompaniesAddNewButton}); + this.toolstripCompaniesButton.Image = ((System.Drawing.Image)(resources.GetObject("toolstripCompaniesButton.Image"))); + this.toolstripCompaniesButton.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolstripCompaniesButton.Name = "toolstripCompaniesButton"; + this.toolstripCompaniesButton.Size = new System.Drawing.Size(83, 22); + this.toolstripCompaniesButton.Text = "Companies"; + this.toolstripCompaniesButton.ButtonClick += new System.EventHandler(this.toolstripCompaniesButton_ButtonClick); + // + // toolstripCompaniesAddNewButton + // + this.toolstripCompaniesAddNewButton.Name = "toolstripCompaniesAddNewButton"; + this.toolstripCompaniesAddNewButton.Size = new System.Drawing.Size(180, 22); + this.toolstripCompaniesAddNewButton.Text = "Add new"; + // + // toolStripSplitButton1 + // + this.toolStripSplitButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.toolStripSplitButton1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripMenuItem1}); + this.toolStripSplitButton1.Image = ((System.Drawing.Image)(resources.GetObject("toolStripSplitButton1.Image"))); + this.toolStripSplitButton1.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripSplitButton1.Name = "toolStripSplitButton1"; + this.toolStripSplitButton1.Size = new System.Drawing.Size(86, 22); + this.toolStripSplitButton1.Text = "PhoneTypes"; + // + // toolStripMenuItem1 + // + this.toolStripMenuItem1.Name = "toolStripMenuItem1"; + this.toolStripMenuItem1.Size = new System.Drawing.Size(121, 22); + this.toolStripMenuItem1.Text = "Add new"; + // + // toolstripSalutationsButton + // + this.toolstripSalutationsButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.toolstripSalutationsButton.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolstripSalutationsAddNewButton}); + this.toolstripSalutationsButton.Image = ((System.Drawing.Image)(resources.GetObject("toolstripSalutationsButton.Image"))); + this.toolstripSalutationsButton.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolstripSalutationsButton.Name = "toolstripSalutationsButton"; + this.toolstripSalutationsButton.Size = new System.Drawing.Size(81, 22); + this.toolstripSalutationsButton.Text = "Salutations"; + // + // toolstripSalutationsAddNewButton + // + this.toolstripSalutationsAddNewButton.Name = "toolstripSalutationsAddNewButton"; + this.toolstripSalutationsAddNewButton.Size = new System.Drawing.Size(121, 22); + this.toolstripSalutationsAddNewButton.Text = "Add new"; + // + // toolstripPostalsButton + // + this.toolstripPostalsButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.toolstripPostalsButton.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolstripPostalsAddNewButton}); + this.toolstripPostalsButton.Image = ((System.Drawing.Image)(resources.GetObject("toolstripPostalsButton.Image"))); + this.toolstripPostalsButton.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolstripPostalsButton.Name = "toolstripPostalsButton"; + this.toolstripPostalsButton.Size = new System.Drawing.Size(60, 22); + this.toolstripPostalsButton.Text = "Postals"; + // + // toolstripPostalsAddNewButton + // + this.toolstripPostalsAddNewButton.Name = "toolstripPostalsAddNewButton"; + this.toolstripPostalsAddNewButton.Size = new System.Drawing.Size(121, 22); + this.toolstripPostalsAddNewButton.Text = "Add new"; + // + // toolstripAboutButton + // + this.toolstripAboutButton.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right; + this.toolstripAboutButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.toolstripAboutButton.Image = ((System.Drawing.Image)(resources.GetObject("toolstripAboutButton.Image"))); + this.toolstripAboutButton.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolstripAboutButton.Name = "toolstripAboutButton"; + this.toolstripAboutButton.Size = new System.Drawing.Size(44, 22); + this.toolstripAboutButton.Text = "About"; + this.toolstripAboutButton.Click += new System.EventHandler(this.toolstripAboutButton_Click); + // + // embeddingContainer + // + this.embeddingContainer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.embeddingContainer.BackColor = System.Drawing.SystemColors.Control; + this.embeddingContainer.Location = new System.Drawing.Point(12, 28); + this.embeddingContainer.Name = "embeddingContainer"; + this.embeddingContainer.Size = new System.Drawing.Size(776, 410); + this.embeddingContainer.TabIndex = 1; + // + // MainForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.embeddingContainer); + this.Controls.Add(this.toolstrip); + this.Name = "MainForm"; + this.Text = "AppointmentsUi"; + this.toolstrip.ResumeLayout(false); + this.toolstrip.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.ToolStrip toolstrip; + private System.Windows.Forms.ToolStripSplitButton tooltipAppointsmentsButton; + private System.Windows.Forms.ToolStripMenuItem toolstripAppointsmentsAddNewButton; + private System.Windows.Forms.ToolStripSplitButton toolstripContactsButton; + private System.Windows.Forms.ToolStripMenuItem toolstripContactsAddNewButton; + private System.Windows.Forms.ToolStripSplitButton toolstripCompaniesButton; + private System.Windows.Forms.ToolStripMenuItem toolstripCompaniesAddNewButton; + private System.Windows.Forms.ToolStripSplitButton toolStripSplitButton1; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1; + private System.Windows.Forms.ToolStripSplitButton toolstripSalutationsButton; + private System.Windows.Forms.ToolStripMenuItem toolstripSalutationsAddNewButton; + private System.Windows.Forms.ToolStripSplitButton toolstripPostalsButton; + private System.Windows.Forms.ToolStripMenuItem toolstripPostalsAddNewButton; + private System.Windows.Forms.ToolStripButton toolstripAboutButton; + private System.Windows.Forms.Panel embeddingContainer; + } +} diff --git a/AppointmentsManager/AppointmentsUi/MainForm.cs b/AppointmentsManager/AppointmentsUi/MainForm.cs new file mode 100644 index 0000000..0435833 --- /dev/null +++ b/AppointmentsManager/AppointmentsUi/MainForm.cs @@ -0,0 +1,60 @@ +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 AppointmentsUi +{ + public partial class MainForm : Form + { + public MainForm() + { + InitializeComponent(); + + EmbedForm(); + } + + internal void EmbedForm() where T : Form, new() + { + T embedded = new T() { TopLevel = false, TopMost = true, FormBorderStyle = FormBorderStyle.None, Dock = DockStyle.Fill, AutoSize = false, Parent = this }; + embeddingContainer.Controls.Clear(); + embeddingContainer.Controls.Add(embedded); + embedded.Show(); + } + + private void toolstripAboutButton_Click(object sender, EventArgs e) + { + MessageBox.Show("vewry guud program mehd by finno"); + } + + private void tooltipAppointsmentsButton_ButtonClick(object sender, EventArgs e) + { + MessageBox.Show("appointments button click"); + } + + private void toolstripAppointsmentsAddNewButton_Click(object sender, EventArgs e) + { + MessageBox.Show("appointments add button click"); + } + + private void toolstripContactsButton_ButtonClick(object sender, EventArgs e) + { + MessageBox.Show("contacts button click"); + } + + private void toolstripContactsAddNewButton_Click(object sender, EventArgs e) + { + MessageBox.Show("contacts add button click"); + } + + private void toolstripCompaniesButton_ButtonClick(object sender, EventArgs e) + { + EmbedForm(); + } + } +} diff --git a/AppointmentsManager/AppointmentsUi/MainForm.resx b/AppointmentsManager/AppointmentsUi/MainForm.resx new file mode 100644 index 0000000..d5fb90b --- /dev/null +++ b/AppointmentsManager/AppointmentsUi/MainForm.resx @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + 17, 17 + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACRSURBVDhPY/j27dt/SjDYACcnJ7IwigEf3n8kCZNswPNb + J/+f6DYF0yA+yQac6Db5f6hWCmwIiE+mC0wIu2DS2Vf/F1x6DefjwlgNyNr34r/0wkdgTMgQDAOQNRNj + CIoBOg0rMTTDMLIhIHbriZeYBmDTiIxBGkEYxge5liQDsGGQqykyAISpZwAlmIEywMAAAAc1/Jwvt6sN + AAAAAElFTkSuQmCC + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACRSURBVDhPY/j27dt/SjDYACcnJ7IwigEf3n8kCZNswPNb + J/+f6DYF0yA+yQac6Db5f6hWCmwIiE+mC0wIu2DS2Vf/F1x6DefjwlgNyNr34r/0wkdgTMgQDAOQNRNj + CIoBOg0rMTTDMLIhIHbriZeYBmDTiIxBGkEYxge5liQDsGGQqykyAISpZwAlmIEywMAAAAc1/Jwvt6sN + AAAAAElFTkSuQmCC + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACRSURBVDhPY/j27dt/SjDYACcnJ7IwigEf3n8kCZNswPNb + J/+f6DYF0yA+yQac6Db5f6hWCmwIiE+mC0wIu2DS2Vf/F1x6DefjwlgNyNr34r/0wkdgTMgQDAOQNRNj + CIoBOg0rMTTDMLIhIHbriZeYBmDTiIxBGkEYxge5liQDsGGQqykyAISpZwAlmIEywMAAAAc1/Jwvt6sN + AAAAAElFTkSuQmCC + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACRSURBVDhPY/j27dt/SjDYACcnJ7IwigEf3n8kCZNswPNb + J/+f6DYF0yA+yQac6Db5f6hWCmwIiE+mC0wIu2DS2Vf/F1x6DefjwlgNyNr34r/0wkdgTMgQDAOQNRNj + CIoBOg0rMTTDMLIhIHbriZeYBmDTiIxBGkEYxge5liQDsGGQqykyAISpZwAlmIEywMAAAAc1/Jwvt6sN + AAAAAElFTkSuQmCC + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACRSURBVDhPY/j27dt/SjDYACcnJ7IwigEf3n8kCZNswPNb + J/+f6DYF0yA+yQac6Db5f6hWCmwIiE+mC0wIu2DS2Vf/F1x6DefjwlgNyNr34r/0wkdgTMgQDAOQNRNj + CIoBOg0rMTTDMLIhIHbriZeYBmDTiIxBGkEYxge5liQDsGGQqykyAISpZwAlmIEywMAAAAc1/Jwvt6sN + AAAAAElFTkSuQmCC + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACRSURBVDhPY/j27dt/SjDYACcnJ7IwigEf3n8kCZNswPNb + J/+f6DYF0yA+yQac6Db5f6hWCmwIiE+mC0wIu2DS2Vf/F1x6DefjwlgNyNr34r/0wkdgTMgQDAOQNRNj + CIoBOg0rMTTDMLIhIHbriZeYBmDTiIxBGkEYxge5liQDsGGQqykyAISpZwAlmIEywMAAAAc1/Jwvt6sN + AAAAAElFTkSuQmCC + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACRSURBVDhPY/j27dt/SjDYACcnJ7IwigEf3n8kCZNswPNb + J/+f6DYF0yA+yQac6Db5f6hWCmwIiE+mC0wIu2DS2Vf/F1x6DefjwlgNyNr34r/0wkdgTMgQDAOQNRNj + CIoBOg0rMTTDMLIhIHbriZeYBmDTiIxBGkEYxge5liQDsGGQqykyAISpZwAlmIEywMAAAAc1/Jwvt6sN + AAAAAElFTkSuQmCC + + + \ No newline at end of file diff --git a/AppointmentsManager/AppointmentsUi/Program.cs b/AppointmentsManager/AppointmentsUi/Program.cs new file mode 100644 index 0000000..5dec773 --- /dev/null +++ b/AppointmentsManager/AppointmentsUi/Program.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace AppointmentsUi +{ + static class Program + { + public static MainForm mainForm = new(); + + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + + Application.SetHighDpiMode(HighDpiMode.SystemAware); + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + + bool dbConnectionSuccessful = AppointmentsLib.Database.Connect("docker01.solidstage.icu", 3306, "school", "school", "aaa"); + + if(!dbConnectionSuccessful) + { + MessageBox.Show("Database connection failed, exiting..."); + + return; + } else + { + //MessageBox.Show("Database connected successfully"); + } + + Application.Run(mainForm); + } + } +} diff --git a/AppointmentsManager/AppointmentsUi/Properties/Resources.Designer.cs b/AppointmentsManager/AppointmentsUi/Properties/Resources.Designer.cs new file mode 100644 index 0000000..59516ba --- /dev/null +++ b/AppointmentsManager/AppointmentsUi/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace AppointmentsUi.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AppointmentsUi.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/AppointmentsManager/AppointmentsUi/Properties/Resources.resx b/AppointmentsManager/AppointmentsUi/Properties/Resources.resx new file mode 100644 index 0000000..29dcb1b --- /dev/null +++ b/AppointmentsManager/AppointmentsUi/Properties/Resources.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/AppointmentsManager/AppointmentsUi/Views/CompanyList.Designer.cs b/AppointmentsManager/AppointmentsUi/Views/CompanyList.Designer.cs new file mode 100644 index 0000000..c414bfe --- /dev/null +++ b/AppointmentsManager/AppointmentsUi/Views/CompanyList.Designer.cs @@ -0,0 +1,93 @@ + +namespace AppointmentsUi.Views +{ + partial class CompanyList + { + /// + /// 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() + { + this.tableLayoutPanelCompanies = new System.Windows.Forms.TableLayoutPanel(); + this.labelCompaniesHeader = new System.Windows.Forms.Label(); + this.buttonAddNewCompany = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // tableLayoutPanelCompanies + // + this.tableLayoutPanelCompanies.BackColor = System.Drawing.SystemColors.ControlDark; + this.tableLayoutPanelCompanies.ColumnCount = 4; + this.tableLayoutPanelCompanies.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanelCompanies.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanelCompanies.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanelCompanies.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanelCompanies.Location = new System.Drawing.Point(-1, 29); + this.tableLayoutPanelCompanies.Name = "tableLayoutPanelCompanies"; + this.tableLayoutPanelCompanies.RowCount = 1; + this.tableLayoutPanelCompanies.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanelCompanies.Size = new System.Drawing.Size(802, 423); + this.tableLayoutPanelCompanies.TabIndex = 0; + // + // labelCompaniesHeader + // + this.labelCompaniesHeader.AutoSize = true; + this.labelCompaniesHeader.Location = new System.Drawing.Point(-1, 4); + this.labelCompaniesHeader.Name = "labelCompaniesHeader"; + this.labelCompaniesHeader.Size = new System.Drawing.Size(67, 15); + this.labelCompaniesHeader.TabIndex = 1; + this.labelCompaniesHeader.Text = "Companies"; + // + // buttonAddNewCompany + // + this.buttonAddNewCompany.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonAddNewCompany.Location = new System.Drawing.Point(725, 0); + this.buttonAddNewCompany.Name = "buttonAddNewCompany"; + this.buttonAddNewCompany.Size = new System.Drawing.Size(75, 23); + this.buttonAddNewCompany.TabIndex = 2; + this.buttonAddNewCompany.Text = "Add new"; + this.buttonAddNewCompany.UseVisualStyleBackColor = true; + this.buttonAddNewCompany.Click += new System.EventHandler(this.buttonAddNewCompany_Click); + // + // CompanyList + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.buttonAddNewCompany); + this.Controls.Add(this.labelCompaniesHeader); + this.Controls.Add(this.tableLayoutPanelCompanies); + this.Name = "CompanyList"; + this.Text = "CompanyList"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TableLayoutPanel tableLayoutPanelCompanies; + private System.Windows.Forms.Label labelCompaniesHeader; + private System.Windows.Forms.Button buttonAddNewCompany; + } +} \ No newline at end of file diff --git a/AppointmentsManager/AppointmentsUi/Views/CompanyList.cs b/AppointmentsManager/AppointmentsUi/Views/CompanyList.cs new file mode 100644 index 0000000..62c7117 --- /dev/null +++ b/AppointmentsManager/AppointmentsUi/Views/CompanyList.cs @@ -0,0 +1,59 @@ +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 AppointmentsUi.Views +{ + public partial class CompanyList : Form + { + public CompanyList() + { + InitializeComponent(); + + var companies = AppointmentsLib.Models.Company.GetCompanies(); + + for(int i = 0; i < companies.Count(); i++) + { + var company = companies.ElementAt(i); + + var labelCompanyId = new Label() { Text = company.CompanyId.ToString(), AutoSize = true, TextAlign = ContentAlignment.MiddleCenter }; + var textboxCompanyName = new TextBox() { Text = company.Label, AutoSize = true }; + var buttonApplyChanges = new Button() { Text = "Apply" }; + var buttonDelete = new Button() { Text = "Delete" }; + + buttonApplyChanges.Click += new EventHandler(delegate (object sender, EventArgs e) { + company.Save(); + Program.mainForm.EmbedForm(); + }); + buttonDelete.Click += new EventHandler(delegate (object sender, EventArgs e) { + var res = MessageBox.Show($"Are you sure to delete the company\n{company.Label}\n?", "Delete company?", MessageBoxButtons.YesNo); + if (res == DialogResult.Yes) + { + company.Delete(); + Program.mainForm.EmbedForm(); + } + }); + textboxCompanyName.TextChanged += new EventHandler(delegate (object sender, EventArgs e) { + company.Label = textboxCompanyName.Text; + }); + + tableLayoutPanelCompanies.Controls.Add(labelCompanyId, 0, 1 + i); + tableLayoutPanelCompanies.Controls.Add(textboxCompanyName, 1, 1 + i); + tableLayoutPanelCompanies.Controls.Add(buttonApplyChanges, 2, 1 + i); + tableLayoutPanelCompanies.Controls.Add(buttonDelete, 3, 1 + i); + } + } + + private void buttonAddNewCompany_Click(object sender, EventArgs e) + { + AppointmentsLib.Models.Company.Create("New company"); + Program.mainForm.EmbedForm(); + } + } +} diff --git a/AppointmentsManager/AppointmentsUi/Views/CompanyList.resx b/AppointmentsManager/AppointmentsUi/Views/CompanyList.resx new file mode 100644 index 0000000..b5ae26c --- /dev/null +++ b/AppointmentsManager/AppointmentsUi/Views/CompanyList.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/AppointmentsManager/AppointmentsUi/Views/EmptyPage.Designer.cs b/AppointmentsManager/AppointmentsUi/Views/EmptyPage.Designer.cs new file mode 100644 index 0000000..313bd2e --- /dev/null +++ b/AppointmentsManager/AppointmentsUi/Views/EmptyPage.Designer.cs @@ -0,0 +1,61 @@ + +namespace AppointmentsUi.Views +{ + partial class EmptyPage + { + /// + /// 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() + { + this.noPageSelectedLabel = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // noPageSelectedLabel + // + this.noPageSelectedLabel.Dock = System.Windows.Forms.DockStyle.Fill; + this.noPageSelectedLabel.Location = new System.Drawing.Point(0, 0); + this.noPageSelectedLabel.Name = "noPageSelectedLabel"; + this.noPageSelectedLabel.Size = new System.Drawing.Size(800, 450); + this.noPageSelectedLabel.TabIndex = 0; + this.noPageSelectedLabel.Text = "No Page selected..."; + this.noPageSelectedLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // EmptyPage + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.noPageSelectedLabel); + this.Name = "EmptyPage"; + this.Text = "EmptyPage"; + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Label noPageSelectedLabel; + } +} \ No newline at end of file diff --git a/AppointmentsManager/AppointmentsUi/Views/EmptyPage.cs b/AppointmentsManager/AppointmentsUi/Views/EmptyPage.cs new file mode 100644 index 0000000..bd70317 --- /dev/null +++ b/AppointmentsManager/AppointmentsUi/Views/EmptyPage.cs @@ -0,0 +1,20 @@ +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 AppointmentsUi.Views +{ + public partial class EmptyPage : Form + { + public EmptyPage() + { + InitializeComponent(); + } + } +} diff --git a/AppointmentsManager/AppointmentsUi/Views/EmptyPage.resx b/AppointmentsManager/AppointmentsUi/Views/EmptyPage.resx new file mode 100644 index 0000000..b5ae26c --- /dev/null +++ b/AppointmentsManager/AppointmentsUi/Views/EmptyPage.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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