diff --git a/ITServiceManager/ITServiceManager/Entities/Appointment.cs b/ITServiceManager/ITServiceManager/Entities/Appointment.cs new file mode 100644 index 0000000..281c7e0 --- /dev/null +++ b/ITServiceManager/ITServiceManager/Entities/Appointment.cs @@ -0,0 +1,22 @@ +namespace ITServiceManager.Entities; + +public class Appointment +{ + public int Id { get; private set; } + public int EmployeeId { get; private set; } + public int OrderId { get; private set; } + public DateTime StartDate { get; private set; } + public DateTime? EndDate { get; private set; } + + public static Appointment CreateOperation(int id, int orderId, int employeeId, DateTime appointmentStartDate, DateTime appointmentEndDate) + { + return new Appointment + { + Id = id, + EmployeeId = employeeId, + OrderId = orderId, + StartDate = appointmentStartDate, + EndDate = appointmentEndDate + }; + } +} diff --git a/ITServiceManager/ITServiceManager/Entities/Company.cs b/ITServiceManager/ITServiceManager/Entities/Company.cs new file mode 100644 index 0000000..0ed7118 --- /dev/null +++ b/ITServiceManager/ITServiceManager/Entities/Company.cs @@ -0,0 +1,19 @@ +namespace ITServiceManager.Entities; + +public class Company +{ + public int Id { get; private set; } + public string Name { get; private set; } = string.Empty; + + public string Address { get; private set; } = string.Empty; + + public static Company CreateEntity(int id, string companyName, string addres) + { + return new Company + { + Id = id, + Name = companyName, + Address = addres + }; + } +} diff --git a/ITServiceManager/ITServiceManager/Entities/Employee.cs b/ITServiceManager/ITServiceManager/Entities/Employee.cs new file mode 100644 index 0000000..98290e6 --- /dev/null +++ b/ITServiceManager/ITServiceManager/Entities/Employee.cs @@ -0,0 +1,22 @@ +using ITServiceManager.Entities.Enums; + +namespace ITServiceManager.Entities; + +public class Employee +{ + public int Id { get; private set; } + public string FirstName { get; private set; } = string.Empty; + public string LastName { get; private set; } = string.Empty; + public EmployeePost? Position { get; private set; } + + public static Employee CreateEntity(int id, string employeeFirstName, string employeeLastName, EmployeePost employeePosition) + { + return new Employee + { + Id = id, + FirstName = employeeFirstName, + LastName = employeeLastName, + Position = employeePosition + }; + } +} diff --git a/ITServiceManager/ITServiceManager/Entities/Enums/EmployeePost.cs b/ITServiceManager/ITServiceManager/Entities/Enums/EmployeePost.cs new file mode 100644 index 0000000..462647b --- /dev/null +++ b/ITServiceManager/ITServiceManager/Entities/Enums/EmployeePost.cs @@ -0,0 +1,12 @@ +namespace ITServiceManager.Entities.Enums; + +public enum EmployeePost +{ + None = 0, + Junior = 1, + Middle = 2, + Senior = 3, + Lead = 4, + Manager = 5, + Director = 6 +} diff --git a/ITServiceManager/ITServiceManager/Entities/Enums/ServiceType.cs b/ITServiceManager/ITServiceManager/Entities/Enums/ServiceType.cs new file mode 100644 index 0000000..c7151cc --- /dev/null +++ b/ITServiceManager/ITServiceManager/Entities/Enums/ServiceType.cs @@ -0,0 +1,12 @@ +namespace ITServiceManager.Entities.Enums; + +[Flags] +public enum ServiceType +{ + None = 0, + Maintenance = 1, + Development = 2, + Testing = 4, + Support = 8, + Consulting = 16 +} diff --git a/ITServiceManager/ITServiceManager/Entities/Order.cs b/ITServiceManager/ITServiceManager/Entities/Order.cs new file mode 100644 index 0000000..44ea53a --- /dev/null +++ b/ITServiceManager/ITServiceManager/Entities/Order.cs @@ -0,0 +1,23 @@ +namespace ITServiceManager.Entities; + +public class Order +{ + public int Id { get; private set; } + public int CompanyId { get; private set; } + public DateTime OrderDate { get; private set; } + public decimal OrderPrice { get; private set; } + + public IEnumerable OrderService { get; private set; } = []; + + public static Order CreateOperation(int id, int companyId, decimal orderPrice, IEnumerable orderService) + { + return new Order + { + Id = id, + CompanyId = companyId, + OrderDate = DateTime.Now, + OrderPrice = orderPrice, + OrderService = orderService + }; + } +} diff --git a/ITServiceManager/ITServiceManager/Entities/OrderService.cs b/ITServiceManager/ITServiceManager/Entities/OrderService.cs new file mode 100644 index 0000000..68457f1 --- /dev/null +++ b/ITServiceManager/ITServiceManager/Entities/OrderService.cs @@ -0,0 +1,22 @@ +namespace ITServiceManager.Entities; + +public class OrderService +{ + public int Id { get; private set; } + public int OrderId { get; private set; } + public int ServiceId { get; private set; } + public int Quantity { get; private set; } + public DateTime ExecutionDate { get; private set; } + + public static OrderService CreateOperation(int id, int orderId, int serviceId, int serviceQuantity, DateTime executionDate) + { + return new OrderService + { + Id = id, + OrderId = orderId, + ServiceId = serviceId, + Quantity = serviceQuantity, + ExecutionDate = executionDate + }; + } +} diff --git a/ITServiceManager/ITServiceManager/Entities/Service.cs b/ITServiceManager/ITServiceManager/Entities/Service.cs new file mode 100644 index 0000000..f7a841c --- /dev/null +++ b/ITServiceManager/ITServiceManager/Entities/Service.cs @@ -0,0 +1,22 @@ +using ITServiceManager.Entities.Enums; + +namespace ITServiceManager.Entities; + +public class Service +{ + public int Id { get; private set; } + public ServiceType ServiceType { get; private set; } + public string ServiceName { get; private set; } = string.Empty; + public string Description { get; private set; } = string.Empty; + + public static Service CreateEntity(int id, ServiceType type, string name, string description) + { + return new Service + { + Id = id, + ServiceType = type, + ServiceName = name, + Description = description + }; + } +} diff --git a/ITServiceManager/ITServiceManager/Form1.Designer.cs b/ITServiceManager/ITServiceManager/Form1.Designer.cs deleted file mode 100644 index 70770e6..0000000 --- a/ITServiceManager/ITServiceManager/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace ITServiceManager -{ - partial class Form1 - { - /// - /// 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.components = new System.ComponentModel.Container(); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Text = "Form1"; - } - - #endregion - } -} diff --git a/ITServiceManager/ITServiceManager/Form1.cs b/ITServiceManager/ITServiceManager/Form1.cs deleted file mode 100644 index 98dc9ff..0000000 --- a/ITServiceManager/ITServiceManager/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace ITServiceManager -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} diff --git a/ITServiceManager/ITServiceManager/FormItCompany.Designer.cs b/ITServiceManager/ITServiceManager/FormItCompany.Designer.cs new file mode 100644 index 0000000..fac54ef --- /dev/null +++ b/ITServiceManager/ITServiceManager/FormItCompany.Designer.cs @@ -0,0 +1,137 @@ +namespace ITServiceManager +{ + partial class FormItCompany + { + /// + /// 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() + { + menuStrip1 = new MenuStrip(); + справочникиToolStripMenuItem = new ToolStripMenuItem(); + компанииToolStripMenuItem = new ToolStripMenuItem(); + сотрудникиToolStripMenuItem = new ToolStripMenuItem(); + услугиToolStripMenuItem = new ToolStripMenuItem(); + операцииToolStripMenuItem = new ToolStripMenuItem(); + заказыToolStripMenuItem = new ToolStripMenuItem(); + назначениеСотрудниковToolStripMenuItem = new ToolStripMenuItem(); + отчетыToolStripMenuItem = new ToolStripMenuItem(); + menuStrip1.SuspendLayout(); + SuspendLayout(); + // + // menuStrip1 + // + menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, операцииToolStripMenuItem, отчетыToolStripMenuItem }); + menuStrip1.Location = new Point(0, 0); + menuStrip1.Name = "menuStrip1"; + menuStrip1.Size = new Size(784, 24); + menuStrip1.TabIndex = 0; + menuStrip1.Text = "menuStrip1"; + // + // справочникиToolStripMenuItem + // + справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компанииToolStripMenuItem, сотрудникиToolStripMenuItem, услугиToolStripMenuItem }); + справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; + справочникиToolStripMenuItem.Size = new Size(94, 20); + справочникиToolStripMenuItem.Text = "Справочники"; + // + // компанииToolStripMenuItem + // + компанииToolStripMenuItem.Name = "компанииToolStripMenuItem"; + компанииToolStripMenuItem.Size = new Size(180, 22); + компанииToolStripMenuItem.Text = "Компании"; + компанииToolStripMenuItem.Click += CompaniesToolStripMenuItem_Click; + // + // сотрудникиToolStripMenuItem + // + сотрудникиToolStripMenuItem.Name = "сотрудникиToolStripMenuItem"; + сотрудникиToolStripMenuItem.Size = new Size(180, 22); + сотрудникиToolStripMenuItem.Text = "Сотрудники"; + сотрудникиToolStripMenuItem.Click += EmployeesToolStripMenuItem_Click; + // + // услугиToolStripMenuItem + // + услугиToolStripMenuItem.Name = "услугиToolStripMenuItem"; + услугиToolStripMenuItem.Size = new Size(180, 22); + услугиToolStripMenuItem.Text = "Услуги"; + услугиToolStripMenuItem.Click += ServicesToolStripMenuItem_Click; + // + // операцииToolStripMenuItem + // + операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { заказыToolStripMenuItem, назначениеСотрудниковToolStripMenuItem }); + операцииToolStripMenuItem.Name = "операцииToolStripMenuItem"; + операцииToolStripMenuItem.Size = new Size(75, 20); + операцииToolStripMenuItem.Text = "Операции"; + // + // заказыToolStripMenuItem + // + заказыToolStripMenuItem.Name = "заказыToolStripMenuItem"; + заказыToolStripMenuItem.Size = new Size(213, 22); + заказыToolStripMenuItem.Text = "Заказы"; + заказыToolStripMenuItem.Click += OrdersToolStripMenuItem_Click; + // + // назначениеСотрудниковToolStripMenuItem + // + назначениеСотрудниковToolStripMenuItem.Name = "назначениеСотрудниковToolStripMenuItem"; + назначениеСотрудниковToolStripMenuItem.Size = new Size(213, 22); + назначениеСотрудниковToolStripMenuItem.Text = "Назначение сотрудников"; + назначениеСотрудниковToolStripMenuItem.Click += AppointmentsToolStripMenuItem_Click; + // + // отчетыToolStripMenuItem + // + отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; + отчетыToolStripMenuItem.Size = new Size(60, 20); + отчетыToolStripMenuItem.Text = "Отчеты"; + // + // FormItCompany + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + BackgroundImage = Properties.Resources.company; + BackgroundImageLayout = ImageLayout.Stretch; + ClientSize = new Size(784, 411); + Controls.Add(menuStrip1); + MainMenuStrip = menuStrip1; + Name = "FormItCompany"; + StartPosition = FormStartPosition.CenterScreen; + Text = "IT компания"; + menuStrip1.ResumeLayout(false); + menuStrip1.PerformLayout(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private MenuStrip menuStrip1; + private ToolStripMenuItem справочникиToolStripMenuItem; + private ToolStripMenuItem компанииToolStripMenuItem; + private ToolStripMenuItem сотрудникиToolStripMenuItem; + private ToolStripMenuItem услугиToolStripMenuItem; + private ToolStripMenuItem операцииToolStripMenuItem; + private ToolStripMenuItem заказыToolStripMenuItem; + private ToolStripMenuItem назначениеСотрудниковToolStripMenuItem; + private ToolStripMenuItem отчетыToolStripMenuItem; + } +} diff --git a/ITServiceManager/ITServiceManager/FormItCompany.cs b/ITServiceManager/ITServiceManager/FormItCompany.cs new file mode 100644 index 0000000..f2eb569 --- /dev/null +++ b/ITServiceManager/ITServiceManager/FormItCompany.cs @@ -0,0 +1,76 @@ +using ITServiceManager.Forms; +using Unity; + +namespace ITServiceManager +{ + public partial class FormItCompany : Form + { + private readonly IUnityContainer _container; + public FormItCompany(IUnityContainer container) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + } + + private void CompaniesToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void EmployeesToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ServicesToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + + private void OrdersToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void AppointmentsToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } +} diff --git a/ITServiceManager/ITServiceManager/FormItCompany.resx b/ITServiceManager/ITServiceManager/FormItCompany.resx new file mode 100644 index 0000000..a0623c8 --- /dev/null +++ b/ITServiceManager/ITServiceManager/FormItCompany.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + \ No newline at end of file diff --git a/ITServiceManager/ITServiceManager/Forms/FormAppointment.Designer.cs b/ITServiceManager/ITServiceManager/Forms/FormAppointment.Designer.cs new file mode 100644 index 0000000..b76d94c --- /dev/null +++ b/ITServiceManager/ITServiceManager/Forms/FormAppointment.Designer.cs @@ -0,0 +1,167 @@ +namespace ITServiceManager.Forms +{ + partial class FormAppointment + { + /// + /// 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() + { + label1 = new Label(); + label2 = new Label(); + comboBoxEmployee = new ComboBox(); + comboBoxOrder = new ComboBox(); + dateTimePickerStart = new DateTimePicker(); + label3 = new Label(); + label4 = new Label(); + buttonCancel = new Button(); + buttonAdd = new Button(); + dateTimePickerEnd = new DateTimePicker(); + SuspendLayout(); + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(46, 46); + label1.Name = "label1"; + label1.Size = new Size(40, 15); + label1.TabIndex = 0; + label1.Text = "Заказ:"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(46, 141); + label2.Name = "label2"; + label2.Size = new Size(69, 15); + label2.TabIndex = 1; + label2.Text = "Сотрудник:"; + // + // comboBoxEmployee + // + comboBoxEmployee.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxEmployee.FormattingEnabled = true; + comboBoxEmployee.Location = new Point(214, 138); + comboBoxEmployee.Name = "comboBoxEmployee"; + comboBoxEmployee.Size = new Size(207, 23); + comboBoxEmployee.TabIndex = 2; + // + // comboBoxOrder + // + comboBoxOrder.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxOrder.FormattingEnabled = true; + comboBoxOrder.Location = new Point(214, 46); + comboBoxOrder.Name = "comboBoxOrder"; + comboBoxOrder.Size = new Size(207, 23); + comboBoxOrder.TabIndex = 3; + // + // dateTimePickerStart + // + dateTimePickerStart.ImeMode = ImeMode.Disable; + dateTimePickerStart.Location = new Point(214, 228); + dateTimePickerStart.Name = "dateTimePickerStart"; + dateTimePickerStart.Size = new Size(207, 23); + dateTimePickerStart.TabIndex = 4; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(46, 234); + label3.Name = "label3"; + label3.Size = new Size(149, 15); + label3.TabIndex = 5; + label3.Text = "Дата назначения на заказ:"; + // + // label4 + // + label4.AutoSize = true; + label4.Location = new Point(46, 328); + label4.Name = "label4"; + label4.Size = new Size(95, 15); + label4.TabIndex = 6; + label4.Text = "Дата окончания"; + // + // buttonCancel + // + buttonCancel.Location = new Point(285, 442); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(112, 28); + buttonCancel.TabIndex = 9; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // buttonAdd + // + buttonAdd.Location = new Point(59, 442); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(112, 28); + buttonAdd.TabIndex = 8; + buttonAdd.Text = "Добавить"; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // dateTimePickerEnd + // + dateTimePickerEnd.ImeMode = ImeMode.Disable; + dateTimePickerEnd.Location = new Point(214, 328); + dateTimePickerEnd.Name = "dateTimePickerEnd"; + dateTimePickerEnd.Size = new Size(207, 23); + dateTimePickerEnd.TabIndex = 10; + // + // FormAppointment + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(476, 505); + Controls.Add(dateTimePickerEnd); + Controls.Add(buttonCancel); + Controls.Add(buttonAdd); + Controls.Add(label4); + Controls.Add(label3); + Controls.Add(dateTimePickerStart); + Controls.Add(comboBoxOrder); + Controls.Add(comboBoxEmployee); + Controls.Add(label2); + Controls.Add(label1); + Name = "FormAppointment"; + Text = "Назначение"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label label1; + private Label label2; + private ComboBox comboBoxEmployee; + private ComboBox comboBoxOrder; + private DateTimePicker dateTimePickerStart; + private Label label3; + private Label label4; + private Button buttonCancel; + private Button buttonAdd; + private DateTimePicker dateTimePickerEnd; + } +} \ No newline at end of file diff --git a/ITServiceManager/ITServiceManager/Forms/FormAppointment.cs b/ITServiceManager/ITServiceManager/Forms/FormAppointment.cs new file mode 100644 index 0000000..6bf2274 --- /dev/null +++ b/ITServiceManager/ITServiceManager/Forms/FormAppointment.cs @@ -0,0 +1,75 @@ +using ITServiceManager.Entities; +using ITServiceManager.Repositories; + +namespace ITServiceManager.Forms; + +public partial class FormAppointment : Form +{ + private readonly IAppointmentRepository _appointmentRepository; + private int? _appointmentId; + public int Id + { + set + { + try + { + var appointment = + _appointmentRepository.ReadAppointmentById(value); + if (appointment == null) + { + throw new + InvalidDataException(nameof(appointment)); + } + comboBoxEmployee.SelectedIndex = appointment.EmployeeId; + comboBoxOrder.SelectedIndex = appointment.OrderId; + _appointmentId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + public FormAppointment(IAppointmentRepository appointmentRepository, IEmployeeRepository employeeRepository, IOrderRepository orderRepository) + { + InitializeComponent(); + _appointmentRepository = appointmentRepository ?? + throw new ArgumentNullException(nameof(appointmentRepository)); + + comboBoxOrder.DataSource = orderRepository.ReadOrders(); + comboBoxOrder.DisplayMember = "Name"; + comboBoxOrder.ValueMember = "Id"; + + comboBoxEmployee.DataSource = employeeRepository.ReadEmployees(); + comboBoxEmployee.DisplayMember = "Name"; + comboBoxEmployee.ValueMember = "Id"; + } + private void ButtonAdd_Click(object sender, EventArgs e) + { + try + { + if (comboBoxEmployee.SelectedIndex < 0 || comboBoxOrder.SelectedIndex < 0 || dateTimePickerStart.CustomFormat != " ") + { + throw new Exception("Имеются незаполненные поля"); + } + if (_appointmentId.HasValue) + { + _appointmentRepository.UpdateAppointment(CreateAppointment(_appointmentId.Value)); + } + else + { + _appointmentRepository.CreateAppointment(CreateAppointment(0)); + } + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + private Appointment CreateAppointment(int id) => Appointment.CreateOperation(id, comboBoxOrder.SelectedIndex, comboBoxEmployee.SelectedIndex, Convert.ToDateTime(dateTimePickerStart) , + Convert.ToDateTime(dateTimePickerEnd)); +} diff --git a/ITServiceManager/ITServiceManager/Form1.resx b/ITServiceManager/ITServiceManager/Forms/FormAppointment.resx similarity index 93% rename from ITServiceManager/ITServiceManager/Form1.resx rename to ITServiceManager/ITServiceManager/Forms/FormAppointment.resx index 1af7de1..af32865 100644 --- a/ITServiceManager/ITServiceManager/Form1.resx +++ b/ITServiceManager/ITServiceManager/Forms/FormAppointment.resx @@ -1,17 +1,17 @@  - diff --git a/ITServiceManager/ITServiceManager/Forms/FormAppointments.Designer.cs b/ITServiceManager/ITServiceManager/Forms/FormAppointments.Designer.cs new file mode 100644 index 0000000..1bf330d --- /dev/null +++ b/ITServiceManager/ITServiceManager/Forms/FormAppointments.Designer.cs @@ -0,0 +1,112 @@ +namespace ITServiceManager.Forms +{ + partial class FormAppointments + { + /// + /// 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() + { + dataGridView = new DataGridView(); + panel = new Panel(); + buttonUpdate = new Button(); + buttonAdd = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + panel.SuspendLayout(); + SuspendLayout(); + // + // dataGridView + // + dataGridView.AllowUserToAddRows = false; + dataGridView.AllowUserToDeleteRows = false; + dataGridView.AllowUserToResizeColumns = false; + dataGridView.AllowUserToResizeRows = false; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Dock = DockStyle.Fill; + dataGridView.Location = new Point(0, 0); + dataGridView.MultiSelect = false; + dataGridView.Name = "dataGridView"; + dataGridView.ReadOnly = true; + dataGridView.RowHeadersVisible = false; + dataGridView.RowHeadersWidth = 51; + dataGridView.RowTemplate.Height = 25; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(652, 450); + dataGridView.TabIndex = 2; + // + // panel + // + panel.Controls.Add(buttonUpdate); + panel.Controls.Add(buttonAdd); + panel.Dock = DockStyle.Right; + panel.Location = new Point(652, 0); + panel.Name = "panel"; + panel.Size = new Size(148, 450); + panel.TabIndex = 3; + // + // buttonUpdate + // + buttonUpdate.BackgroundImage = Properties.Resources.edit; + buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpdate.Location = new Point(33, 269); + buttonUpdate.Name = "buttonUpdate"; + buttonUpdate.Size = new Size(81, 80); + buttonUpdate.TabIndex = 2; + buttonUpdate.UseVisualStyleBackColor = true; + buttonUpdate.Click += ButtonUpd_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.plus; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(33, 43); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(81, 71); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // FormAppointments + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(dataGridView); + Controls.Add(panel); + Name = "FormAppointments"; + Text = "Назначения"; + Load += FormAppointments_Load; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + panel.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridView; + private Panel panel; + private Button buttonUpdate; + private Button buttonAdd; + } +} \ No newline at end of file diff --git a/ITServiceManager/ITServiceManager/Forms/FormAppointments.cs b/ITServiceManager/ITServiceManager/Forms/FormAppointments.cs new file mode 100644 index 0000000..495394b --- /dev/null +++ b/ITServiceManager/ITServiceManager/Forms/FormAppointments.cs @@ -0,0 +1,71 @@ +using ITServiceManager.Repositories; +using Unity; + +namespace ITServiceManager.Forms; + +public partial class FormAppointments : Form +{ + private readonly IUnityContainer _container; + private readonly IAppointmentRepository _appointmentRepository; + public FormAppointments(IUnityContainer container, IAppointmentRepository appointmentRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _appointmentRepository = appointmentRepository ?? throw new ArgumentNullException(nameof(appointmentRepository)); + } + private void FormAppointments_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + try + { + var form = _container.Resolve(); + form.Id = findId; + form.ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при изменении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void LoadList() => dataGridView.DataSource = _appointmentRepository.ReadAppointments(); + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridView.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + return true; + } +} + diff --git a/ITServiceManager/ITServiceManager/Forms/FormAppointments.resx b/ITServiceManager/ITServiceManager/Forms/FormAppointments.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ITServiceManager/ITServiceManager/Forms/FormAppointments.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/ITServiceManager/ITServiceManager/Forms/FormCompanies.Designer.cs b/ITServiceManager/ITServiceManager/Forms/FormCompanies.Designer.cs new file mode 100644 index 0000000..b5d5c1d --- /dev/null +++ b/ITServiceManager/ITServiceManager/Forms/FormCompanies.Designer.cs @@ -0,0 +1,127 @@ +namespace ITServiceManager.Forms +{ + partial class FormCompanies + { + /// + /// 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() + { + panel = new Panel(); + buttonUpdate = new Button(); + buttonRemove = new Button(); + buttonAdd = new Button(); + dataGridView = new DataGridView(); + panel.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // panel + // + panel.Controls.Add(buttonUpdate); + panel.Controls.Add(buttonRemove); + panel.Controls.Add(buttonAdd); + panel.Dock = DockStyle.Right; + panel.Location = new Point(652, 0); + panel.Name = "panel"; + panel.Size = new Size(148, 450); + panel.TabIndex = 1; + // + // buttonUpdate + // + buttonUpdate.BackgroundImage = Properties.Resources.edit; + buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpdate.Location = new Point(36, 249); + buttonUpdate.Name = "buttonUpdate"; + buttonUpdate.Size = new Size(78, 80); + buttonUpdate.TabIndex = 2; + buttonUpdate.UseVisualStyleBackColor = true; + buttonUpdate.Click += ButtonUpdate_Click; + // + // buttonRemove + // + buttonRemove.BackgroundImage = Properties.Resources.minus; + buttonRemove.BackgroundImageLayout = ImageLayout.Stretch; + buttonRemove.Location = new Point(36, 141); + buttonRemove.Name = "buttonRemove"; + buttonRemove.Size = new Size(75, 76); + buttonRemove.TabIndex = 1; + buttonRemove.UseVisualStyleBackColor = true; + buttonRemove.Click += ButtonRemove_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.plus; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(33, 43); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(81, 71); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // dataGridView + // + dataGridView.AllowUserToAddRows = false; + dataGridView.AllowUserToDeleteRows = false; + dataGridView.AllowUserToResizeColumns = false; + dataGridView.AllowUserToResizeRows = false; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Dock = DockStyle.Fill; + dataGridView.Location = new Point(0, 0); + dataGridView.MultiSelect = false; + dataGridView.Name = "dataGridView"; + dataGridView.ReadOnly = true; + dataGridView.RowHeadersVisible = false; + dataGridView.RowHeadersWidth = 51; + dataGridView.RowTemplate.Height = 25; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(652, 450); + dataGridView.TabIndex = 1; + // + // FormCompanies + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(dataGridView); + Controls.Add(panel); + Name = "FormCompanies"; + StartPosition = FormStartPosition.CenterParent; + Text = "Компании"; + Load += FormCompanies_Load; + panel.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel; + private Button buttonRemove; + private Button buttonAdd; + private Button buttonUpdate; + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/ITServiceManager/ITServiceManager/Forms/FormCompanies.cs b/ITServiceManager/ITServiceManager/Forms/FormCompanies.cs new file mode 100644 index 0000000..45dd806 --- /dev/null +++ b/ITServiceManager/ITServiceManager/Forms/FormCompanies.cs @@ -0,0 +1,92 @@ +using ITServiceManager.Repositories; +using Unity; + +namespace ITServiceManager.Forms; + +public partial class FormCompanies : Form +{ + private readonly IUnityContainer _container; + private readonly ICompanyRepository _companyRepository; + + public FormCompanies(IUnityContainer container, ICompanyRepository companyRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _companyRepository = companyRepository ?? throw new ArgumentNullException(nameof(companyRepository)); + } + private void FormCompanies_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonRemove_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + try + { + _companyRepository.DeleteCompany(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonUpdate_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + try + { + var form = _container.Resolve(); + form.Id = findId; + form.ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void LoadList() => dataGridView.DataSource = _companyRepository.ReadCompanies(); + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridView.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + return true; + } + +} diff --git a/ITServiceManager/ITServiceManager/Forms/FormCompanies.resx b/ITServiceManager/ITServiceManager/Forms/FormCompanies.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ITServiceManager/ITServiceManager/Forms/FormCompanies.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/ITServiceManager/ITServiceManager/Forms/FormCompany.Designer.cs b/ITServiceManager/ITServiceManager/Forms/FormCompany.Designer.cs new file mode 100644 index 0000000..2e245ed --- /dev/null +++ b/ITServiceManager/ITServiceManager/Forms/FormCompany.Designer.cs @@ -0,0 +1,118 @@ +namespace ITServiceManager.Forms +{ + partial class FormCompany + { + /// + /// 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() + { + labelName = new Label(); + textBoxName = new TextBox(); + buttonAdd = new Button(); + buttonCancel = new Button(); + labelAddres = new Label(); + textBoxAddress = new TextBox(); + SuspendLayout(); + // + // labelName + // + labelName.AutoSize = true; + labelName.Location = new Point(89, 101); + labelName.Name = "labelName"; + labelName.Size = new Size(118, 15); + labelName.TabIndex = 0; + labelName.Text = "Название компании"; + // + // textBoxName + // + textBoxName.Location = new Point(268, 98); + textBoxName.Name = "textBoxName"; + textBoxName.Size = new Size(200, 23); + textBoxName.TabIndex = 1; + // + // buttonAdd + // + buttonAdd.Location = new Point(95, 238); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(112, 28); + buttonAdd.TabIndex = 2; + buttonAdd.Text = "Добавить"; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(321, 238); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(112, 28); + buttonCancel.TabIndex = 3; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // labelAddres + // + labelAddres.AutoSize = true; + labelAddres.Location = new Point(106, 146); + labelAddres.Name = "labelAddres"; + labelAddres.Size = new Size(105, 15); + labelAddres.TabIndex = 4; + labelAddres.Text = "Адресс компании"; + // + // textBoxAddress + // + textBoxAddress.Location = new Point(268, 141); + textBoxAddress.Name = "textBoxAddress"; + textBoxAddress.Size = new Size(200, 23); + textBoxAddress.TabIndex = 5; + // + // FormCompany + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(570, 306); + Controls.Add(textBoxAddress); + Controls.Add(labelAddres); + Controls.Add(buttonCancel); + Controls.Add(buttonAdd); + Controls.Add(textBoxName); + Controls.Add(labelName); + Name = "FormCompany"; + StartPosition = FormStartPosition.CenterParent; + Text = "Компания"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelName; + private TextBox textBoxName; + private Button buttonAdd; + private Button buttonCancel; + private Label labelAddres; + private TextBox textBoxAddress; + } +} \ No newline at end of file diff --git a/ITServiceManager/ITServiceManager/Forms/FormCompany.cs b/ITServiceManager/ITServiceManager/Forms/FormCompany.cs new file mode 100644 index 0000000..c41a7c6 --- /dev/null +++ b/ITServiceManager/ITServiceManager/Forms/FormCompany.cs @@ -0,0 +1,64 @@ +using ITServiceManager.Entities; +using ITServiceManager.Repositories; + +namespace ITServiceManager.Forms; + +public partial class FormCompany : Form +{ + private readonly ICompanyRepository _companyRepository; + private int? _companyId; + public int Id + { + set + { + try + { + var company = _companyRepository.ReadCompanyById(value); + if (company == null) + { + throw new InvalidDataException(nameof(company)); + } + textBoxName.Text = company.Name; + textBoxAddress.Text = company.Address; + _companyId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + public FormCompany(ICompanyRepository companyRepository) + { + InitializeComponent(); + _companyRepository = companyRepository ?? throw new ArgumentNullException(nameof(companyRepository)); + } + + private void ButtonAdd_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxName.Text) || string.IsNullOrWhiteSpace(textBoxAddress.Text)) + { + throw new Exception("Имеются незаполненные поля"); + } + if (_companyId.HasValue) + { + _companyRepository.UpdateCompany(CreateCompany(_companyId.Value)); + } + else + { + _companyRepository.CreateCompany(CreateCompany(0)); + } + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + private Company CreateCompany(int id) => Company.CreateEntity(id, textBoxName.Text, textBoxAddress.Text); + +} diff --git a/ITServiceManager/ITServiceManager/Forms/FormCompany.resx b/ITServiceManager/ITServiceManager/Forms/FormCompany.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ITServiceManager/ITServiceManager/Forms/FormCompany.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/ITServiceManager/ITServiceManager/Forms/FormEmployee.Designer.cs b/ITServiceManager/ITServiceManager/Forms/FormEmployee.Designer.cs new file mode 100644 index 0000000..b4c05ec --- /dev/null +++ b/ITServiceManager/ITServiceManager/Forms/FormEmployee.Designer.cs @@ -0,0 +1,142 @@ +namespace ITServiceManager.Forms +{ + partial class FormEmployee + { + /// + /// 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() + { + buttonCancel = new Button(); + buttonAdd = new Button(); + textBoxFirstName = new TextBox(); + labelFirstName = new Label(); + comboBoxPost = new ComboBox(); + labelLastName = new Label(); + textBoxLastName = new TextBox(); + labelPosition = new Label(); + SuspendLayout(); + // + // buttonCancel + // + buttonCancel.Location = new Point(320, 247); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(112, 28); + buttonCancel.TabIndex = 7; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // buttonAdd + // + buttonAdd.Location = new Point(86, 247); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(112, 28); + buttonAdd.TabIndex = 6; + buttonAdd.Text = "Добавить"; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // textBoxFirstName + // + textBoxFirstName.Location = new Point(265, 59); + textBoxFirstName.Name = "textBoxFirstName"; + textBoxFirstName.Size = new Size(176, 23); + textBoxFirstName.TabIndex = 5; + // + // labelFirstName + // + labelFirstName.AutoSize = true; + labelFirstName.Location = new Point(86, 62); + labelFirstName.Name = "labelFirstName"; + labelFirstName.Size = new Size(97, 15); + labelFirstName.TabIndex = 4; + labelFirstName.Text = "Имя сотрудника"; + // + // comboBoxPost + // + comboBoxPost.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxPost.FormattingEnabled = true; + comboBoxPost.Location = new Point(265, 168); + comboBoxPost.Name = "comboBoxPost"; + comboBoxPost.Size = new Size(176, 23); + comboBoxPost.TabIndex = 8; + // + // labelLastName + // + labelLastName.AutoSize = true; + labelLastName.Location = new Point(86, 115); + labelLastName.Name = "labelLastName"; + labelLastName.Size = new Size(124, 15); + labelLastName.TabIndex = 9; + labelLastName.Text = "Фамилия сотрудника"; + // + // textBoxLastName + // + textBoxLastName.Location = new Point(265, 115); + textBoxLastName.Name = "textBoxLastName"; + textBoxLastName.Size = new Size(176, 23); + textBoxLastName.TabIndex = 10; + // + // labelPosition + // + labelPosition.AutoSize = true; + labelPosition.Location = new Point(86, 171); + labelPosition.Name = "labelPosition"; + labelPosition.Size = new Size(135, 15); + labelPosition.TabIndex = 11; + labelPosition.Text = "Должность сотрудника"; + // + // FormEmployee + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(526, 287); + Controls.Add(labelPosition); + Controls.Add(textBoxLastName); + Controls.Add(labelLastName); + Controls.Add(comboBoxPost); + Controls.Add(buttonCancel); + Controls.Add(buttonAdd); + Controls.Add(textBoxFirstName); + Controls.Add(labelFirstName); + Name = "FormEmployee"; + StartPosition = FormStartPosition.CenterScreen; + Text = "Сотрудник"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Button buttonCancel; + private Button buttonAdd; + private TextBox textBoxFirstName; + private Label labelFirstName; + private ComboBox comboBoxPost; + private Label labelLastName; + private TextBox textBoxLastName; + private Label labelPosition; + } +} \ No newline at end of file diff --git a/ITServiceManager/ITServiceManager/Forms/FormEmployee.cs b/ITServiceManager/ITServiceManager/Forms/FormEmployee.cs new file mode 100644 index 0000000..6383220 --- /dev/null +++ b/ITServiceManager/ITServiceManager/Forms/FormEmployee.cs @@ -0,0 +1,74 @@ +using ITServiceManager.Entities; +using ITServiceManager.Entities.Enums; +using ITServiceManager.Repositories; +namespace ITServiceManager.Forms; + +public partial class FormEmployee : Form +{ + private readonly IEmployeeRepository _employeeRepository; + private int? _employeeId; + public int Id + { + set + { + try + { + var employee = + _employeeRepository.ReadEmployeeById(value); + if (employee == null) + { + throw new + InvalidDataException(nameof(employee)); + } + textBoxFirstName.Text = employee.FirstName; + textBoxLastName.Text = employee.LastName; + comboBoxPost.SelectedItem = + employee.Position; + _employeeId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + public FormEmployee(IEmployeeRepository employeeRepository) + { + InitializeComponent(); + _employeeRepository = employeeRepository ?? + throw new + ArgumentNullException(nameof(employeeRepository)); + comboBoxPost.DataSource = + Enum.GetValues(typeof(EmployeePost)); + } + private void ButtonAdd_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxFirstName.Text) || + string.IsNullOrWhiteSpace(textBoxLastName.Text) + || + comboBoxPost.SelectedIndex < 1) + { + throw new Exception("Имеются незаполненные поля"); + } + if (_employeeId.HasValue) + { + _employeeRepository.UpdateEmployee(CreateEmployee(_employeeId.Value)); + } + else + { + _employeeRepository.CreateEmployee(CreateEmployee(0)); + } + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + private Employee CreateEmployee(int id) => Employee.CreateEntity(id, textBoxFirstName.Text, textBoxLastName.Text, (EmployeePost)comboBoxPost.SelectedItem!); +} diff --git a/ITServiceManager/ITServiceManager/Forms/FormEmployee.resx b/ITServiceManager/ITServiceManager/Forms/FormEmployee.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ITServiceManager/ITServiceManager/Forms/FormEmployee.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/ITServiceManager/ITServiceManager/Forms/FormEmployees.Designer.cs b/ITServiceManager/ITServiceManager/Forms/FormEmployees.Designer.cs new file mode 100644 index 0000000..9dc53e0 --- /dev/null +++ b/ITServiceManager/ITServiceManager/Forms/FormEmployees.Designer.cs @@ -0,0 +1,128 @@ +namespace ITServiceManager.Forms +{ + partial class FormEmployees + { + /// + /// 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() + { + panel = new Panel(); + buttonUpdate = new Button(); + buttonRemove = new Button(); + buttonAdd = new Button(); + dataGridView = new DataGridView(); + panel.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // panel + // + panel.Controls.Add(buttonUpdate); + panel.Controls.Add(buttonRemove); + panel.Controls.Add(buttonAdd); + panel.Dock = DockStyle.Right; + panel.Location = new Point(652, 0); + panel.Name = "panel"; + panel.Size = new Size(148, 450); + panel.TabIndex = 2; + // + // buttonUpdate + // + buttonUpdate.BackgroundImage = Properties.Resources.edit; + buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpdate.Location = new Point(36, 249); + buttonUpdate.Name = "buttonUpdate"; + buttonUpdate.Size = new Size(78, 80); + buttonUpdate.TabIndex = 2; + buttonUpdate.UseVisualStyleBackColor = true; + buttonUpdate.Click += ButtonUpd_Click; + // + // buttonRemove + // + buttonRemove.BackgroundImage = Properties.Resources.minus; + buttonRemove.BackgroundImageLayout = ImageLayout.Stretch; + buttonRemove.Location = new Point(36, 141); + buttonRemove.Name = "buttonRemove"; + buttonRemove.Size = new Size(75, 76); + buttonRemove.TabIndex = 1; + buttonRemove.UseVisualStyleBackColor = true; + buttonRemove.Click += ButtonDel_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.plus; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(33, 43); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(81, 71); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // dataGridView + // + dataGridView.AllowUserToAddRows = false; + dataGridView.AllowUserToDeleteRows = false; + dataGridView.AllowUserToResizeColumns = false; + dataGridView.AllowUserToResizeRows = false; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Dock = DockStyle.Fill; + dataGridView.Location = new Point(0, 0); + dataGridView.MultiSelect = false; + dataGridView.Name = "dataGridView"; + dataGridView.ReadOnly = true; + dataGridView.RowHeadersVisible = false; + dataGridView.RowHeadersWidth = 51; + dataGridView.RowTemplate.Height = 25; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(652, 450); + dataGridView.TabIndex = 3; + // + // FormEmployees + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(dataGridView); + Controls.Add(panel); + Margin = new Padding(3, 2, 3, 2); + Name = "FormEmployees"; + StartPosition = FormStartPosition.CenterScreen; + Text = "Сотрудники"; + Load += FormEmployees_Load; + panel.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel; + private Button buttonUpdate; + private Button buttonRemove; + private Button buttonAdd; + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/ITServiceManager/ITServiceManager/Forms/FormEmployees.cs b/ITServiceManager/ITServiceManager/Forms/FormEmployees.cs new file mode 100644 index 0000000..5179d52 --- /dev/null +++ b/ITServiceManager/ITServiceManager/Forms/FormEmployees.cs @@ -0,0 +1,105 @@ +using ITServiceManager.Repositories; +using Unity; + +namespace ITServiceManager.Forms; + +public partial class FormEmployees : Form +{ + private readonly IUnityContainer _container; + private readonly IEmployeeRepository _employeeRepository; + public FormEmployees(IUnityContainer container, IEmployeeRepository + employeeRepository) + { + InitializeComponent(); + _container = container ?? + throw new ArgumentNullException(nameof(container)); + _employeeRepository = employeeRepository ?? + throw new + ArgumentNullException(nameof(employeeRepository)); + } + private void FormEmployees_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + try + { + var form = _container.Resolve(); + form.Id = findId; + form.ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при изменении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonDel_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + if (MessageBox.Show("Удалить запись?", "Удаление", + MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + try + { + _employeeRepository.DeleteEmployee(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void LoadList() => dataGridView.DataSource = + _employeeRepository.ReadEmployees(); + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridView.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + return true; + } + +} diff --git a/ITServiceManager/ITServiceManager/Forms/FormEmployees.resx b/ITServiceManager/ITServiceManager/Forms/FormEmployees.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ITServiceManager/ITServiceManager/Forms/FormEmployees.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/ITServiceManager/ITServiceManager/Forms/FormOrder.Designer.cs b/ITServiceManager/ITServiceManager/Forms/FormOrder.Designer.cs new file mode 100644 index 0000000..e756c3a --- /dev/null +++ b/ITServiceManager/ITServiceManager/Forms/FormOrder.Designer.cs @@ -0,0 +1,177 @@ +namespace ITServiceManager.Forms +{ + partial class FormOrder + { + /// + /// 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() + { + DataGridViewCellStyle dataGridViewCellStyle1 = new DataGridViewCellStyle(); + dataGridView = new DataGridView(); + ColumnService = new DataGridViewComboBoxColumn(); + ColumnQuantity = new DataGridViewTextBoxColumn(); + ColumnExecutionDate = new DataGridViewTextBoxColumn(); + buttonCancel = new Button(); + buttonAdd = new Button(); + label1 = new Label(); + comboBoxCompany = new ComboBox(); + label2 = new Label(); + numericUpDownPrice = new NumericUpDown(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownPrice).BeginInit(); + SuspendLayout(); + // + // dataGridView + // + dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnService, ColumnQuantity, ColumnExecutionDate }); + dataGridView.Location = new Point(14, 309); + dataGridView.Margin = new Padding(3, 4, 3, 4); + dataGridView.MultiSelect = false; + dataGridView.Name = "dataGridView"; + dataGridView.RowHeadersWidth = 51; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(562, 351); + dataGridView.TabIndex = 1; + // + // ColumnService + // + ColumnService.HeaderText = "Услуга"; + ColumnService.MinimumWidth = 6; + ColumnService.Name = "ColumnService"; + // + // ColumnQuantity + // + ColumnQuantity.HeaderText = "Количество"; + ColumnQuantity.MinimumWidth = 6; + ColumnQuantity.Name = "ColumnQuantity"; + // + // ColumnExecutionDate + // + dataGridViewCellStyle1.Format = "F"; + dataGridViewCellStyle1.NullValue = null; + ColumnExecutionDate.DefaultCellStyle = dataGridViewCellStyle1; + ColumnExecutionDate.HeaderText = "Срок"; + ColumnExecutionDate.MinimumWidth = 6; + ColumnExecutionDate.Name = "ColumnExecutionDate"; + // + // buttonCancel + // + buttonCancel.Location = new Point(366, 685); + buttonCancel.Margin = new Padding(3, 4, 3, 4); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(128, 37); + buttonCancel.TabIndex = 9; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // buttonAdd + // + buttonAdd.Location = new Point(73, 685); + buttonAdd.Margin = new Padding(3, 4, 3, 4); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(128, 37); + buttonAdd.TabIndex = 8; + buttonAdd.Text = "Добавить"; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(59, 60); + label1.Name = "label1"; + label1.Size = new Size(81, 20); + label1.TabIndex = 10; + label1.Text = "Компания"; + // + // comboBoxCompany + // + comboBoxCompany.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxCompany.FormattingEnabled = true; + comboBoxCompany.Location = new Point(207, 56); + comboBoxCompany.Margin = new Padding(3, 4, 3, 4); + comboBoxCompany.Name = "comboBoxCompany"; + comboBoxCompany.Size = new Size(274, 28); + comboBoxCompany.TabIndex = 11; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(59, 164); + label2.Name = "label2"; + label2.Size = new Size(125, 20); + label2.TabIndex = 12; + label2.Text = "Сумма договора"; + // + // numericUpDownPrice + // + numericUpDownPrice.DecimalPlaces = 2; + numericUpDownPrice.Location = new Point(207, 161); + numericUpDownPrice.Margin = new Padding(3, 4, 3, 4); + numericUpDownPrice.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 }); + numericUpDownPrice.Name = "numericUpDownPrice"; + numericUpDownPrice.Size = new Size(274, 27); + numericUpDownPrice.TabIndex = 13; + // + // FormOrder + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(590, 768); + Controls.Add(numericUpDownPrice); + Controls.Add(label2); + Controls.Add(comboBoxCompany); + Controls.Add(label1); + Controls.Add(buttonCancel); + Controls.Add(buttonAdd); + Controls.Add(dataGridView); + Margin = new Padding(3, 4, 3, 4); + Name = "FormOrder"; + Text = "Заказ"; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownPrice).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label label1; + private DataGridView dataGridView; + private DataGridViewComboBoxColumn ColumnProducts; + private DataGridViewTextBoxColumn ColumnCount; + private Button buttonCancel; + private Button buttonAdd; + private ComboBox comboBoxCompany; + private Label label2; + private NumericUpDown numericUpDownPrice; + private DataGridViewComboBoxColumn ColumnService; + private DataGridViewTextBoxColumn ColumnQuantity; + private DataGridViewTextBoxColumn ColumnExecutionDate; + } +} \ No newline at end of file diff --git a/ITServiceManager/ITServiceManager/Forms/FormOrder.cs b/ITServiceManager/ITServiceManager/Forms/FormOrder.cs new file mode 100644 index 0000000..eac136c --- /dev/null +++ b/ITServiceManager/ITServiceManager/Forms/FormOrder.cs @@ -0,0 +1,53 @@ +using ITServiceManager.Entities; +using ITServiceManager.Repositories; + +namespace ITServiceManager.Forms; + +public partial class FormOrder : Form +{ + private readonly IOrderRepository _orderRepository; + public FormOrder(IOrderRepository orderRepository, IServiceRepository serviceRepository, ICompanyRepository companyRepository) + { + InitializeComponent(); + _orderRepository = orderRepository ?? throw new ArgumentNullException(nameof(orderRepository)); + + comboBoxCompany.DataSource = companyRepository.ReadCompanies(); + comboBoxCompany.DisplayMember = "Name"; + comboBoxCompany.ValueMember = "Id"; + + ColumnService.DataSource = serviceRepository.ReadServices(); + ColumnService.DisplayMember = "ServiceName"; + ColumnService.ValueMember = "Id"; + } + private void ButtonAdd_Click(object sender, EventArgs e) + { + if (dataGridView.RowCount < 1 || comboBoxCompany.SelectedIndex < 0 || numericUpDownPrice.Value <= 0) + { + throw new Exception("Имеются незаполненны поля"); + } + try + { + _orderRepository.CreateOrder(Order.CreateOperation(0, comboBoxCompany.SelectedIndex, numericUpDownPrice.Value, CreateListServiceFromDataGrid())); + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + private List CreateListServiceFromDataGrid() + { + var list = new List(); + foreach (DataGridViewRow row in dataGridView.Rows) + { + if (row.Cells["ColumService"].Value == null || row.Cells["ColumQuantity"].Value == null || row.Cells["ColumnExecutionDate"].Value == null) + { + continue; + } + list.Add(OrderService.CreateOperation(0, 0, Convert.ToInt32(row.Cells["ColumnServices"].Value), Convert.ToInt32(row.Cells["ColumnQuantity"].Value), Convert.ToDateTime(row.Cells["ColumnExecutionDate"].Value))); + } + return list; + } +} + diff --git a/ITServiceManager/ITServiceManager/Forms/FormOrder.resx b/ITServiceManager/ITServiceManager/Forms/FormOrder.resx new file mode 100644 index 0000000..3d8c384 --- /dev/null +++ b/ITServiceManager/ITServiceManager/Forms/FormOrder.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + True + + + True + + + True + + \ No newline at end of file diff --git a/ITServiceManager/ITServiceManager/Forms/FormOrders.Designer.cs b/ITServiceManager/ITServiceManager/Forms/FormOrders.Designer.cs new file mode 100644 index 0000000..4638caa --- /dev/null +++ b/ITServiceManager/ITServiceManager/Forms/FormOrders.Designer.cs @@ -0,0 +1,113 @@ +namespace ITServiceManager.Forms +{ + partial class FormOrders + { + /// + /// 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() + { + panel = new Panel(); + buttonRemove = new Button(); + buttonAdd = new Button(); + dataGridView = new DataGridView(); + panel.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // panel + // + panel.Controls.Add(buttonRemove); + panel.Controls.Add(buttonAdd); + panel.Dock = DockStyle.Right; + panel.Location = new Point(652, 0); + panel.Name = "panel"; + panel.Size = new Size(148, 450); + panel.TabIndex = 4; + // + // buttonRemove + // + buttonRemove.BackgroundImage = Properties.Resources.minus; + buttonRemove.BackgroundImageLayout = ImageLayout.Stretch; + buttonRemove.Location = new Point(39, 265); + buttonRemove.Name = "buttonRemove"; + buttonRemove.Size = new Size(75, 76); + buttonRemove.TabIndex = 1; + buttonRemove.UseVisualStyleBackColor = true; + buttonRemove.Click += ButtonRemove_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.plus; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(33, 92); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(81, 71); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // dataGridView + // + dataGridView.AllowUserToAddRows = false; + dataGridView.AllowUserToDeleteRows = false; + dataGridView.AllowUserToResizeColumns = false; + dataGridView.AllowUserToResizeRows = false; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Dock = DockStyle.Fill; + dataGridView.Location = new Point(0, 0); + dataGridView.MultiSelect = false; + dataGridView.Name = "dataGridView"; + dataGridView.ReadOnly = true; + dataGridView.RowHeadersVisible = false; + dataGridView.RowHeadersWidth = 51; + dataGridView.RowTemplate.Height = 25; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(652, 450); + dataGridView.TabIndex = 5; + // + // FormOrders + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(dataGridView); + Controls.Add(panel); + Name = "FormOrders"; + StartPosition = FormStartPosition.CenterScreen; + Text = "Заказы"; + Load += FormOrders_Load; + panel.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel; + private Button buttonRemove; + private Button buttonAdd; + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/ITServiceManager/ITServiceManager/Forms/FormOrders.cs b/ITServiceManager/ITServiceManager/Forms/FormOrders.cs new file mode 100644 index 0000000..6bb5815 --- /dev/null +++ b/ITServiceManager/ITServiceManager/Forms/FormOrders.cs @@ -0,0 +1,71 @@ +using ITServiceManager.Repositories; +using Unity; + +namespace ITServiceManager.Forms; + +public partial class FormOrders : Form +{ + private readonly IUnityContainer _container; + private readonly IOrderRepository _orderRepository; + public FormOrders(IUnityContainer container, IOrderRepository orderRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _orderRepository = orderRepository ?? throw new ArgumentNullException(nameof(orderRepository)); + } + private void FormOrders_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonRemove_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + try + { + _orderRepository.DeleteOrder(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void LoadList() => dataGridView.DataSource = _orderRepository.ReadOrders(); + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridView.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + return true; + } +} diff --git a/ITServiceManager/ITServiceManager/Forms/FormOrders.resx b/ITServiceManager/ITServiceManager/Forms/FormOrders.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ITServiceManager/ITServiceManager/Forms/FormOrders.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/ITServiceManager/ITServiceManager/Forms/FormService.Designer.cs b/ITServiceManager/ITServiceManager/Forms/FormService.Designer.cs new file mode 100644 index 0000000..3d4cb4b --- /dev/null +++ b/ITServiceManager/ITServiceManager/Forms/FormService.Designer.cs @@ -0,0 +1,145 @@ +namespace ITServiceManager.Forms +{ + partial class FormService + { + /// + /// 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() + { + buttonCancel = new Button(); + buttonAdd = new Button(); + richTextBoxDescription = new RichTextBox(); + label1 = new Label(); + label2 = new Label(); + checkedListBoxType = new CheckedListBox(); + textBoxName = new TextBox(); + labelName = new Label(); + SuspendLayout(); + // + // buttonCancel + // + buttonCancel.Location = new Point(310, 318); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(128, 37); + buttonCancel.TabIndex = 7; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // buttonAdd + // + buttonAdd.Location = new Point(84, 318); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(128, 37); + buttonAdd.TabIndex = 6; + buttonAdd.Text = "Добавить"; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // richTextBoxDescription + // + richTextBoxDescription.Location = new Point(240, 207); + richTextBoxDescription.Margin = new Padding(3, 2, 3, 2); + richTextBoxDescription.Name = "richTextBoxDescription"; + richTextBoxDescription.Size = new Size(232, 87); + richTextBoxDescription.TabIndex = 9; + richTextBoxDescription.Text = ""; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(57, 52); + label1.Name = "label1"; + label1.Size = new Size(67, 15); + label1.TabIndex = 4; + label1.Text = "Тип услуги"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(57, 239); + label2.Name = "label2"; + label2.Size = new Size(127, 20); + label2.TabIndex = 8; + label2.Text = "Описание услуги"; + // + // checkedListBoxType + // + checkedListBoxType.FormattingEnabled = true; + checkedListBoxType.Location = new Point(240, 29); + checkedListBoxType.Margin = new Padding(3, 2, 3, 2); + checkedListBoxType.Name = "checkedListBoxType"; + checkedListBoxType.Size = new Size(232, 76); + checkedListBoxType.TabIndex = 10; + // + // textBoxName + // + textBoxName.Location = new Point(240, 142); + textBoxName.Name = "textBoxName"; + textBoxName.Size = new Size(232, 23); + textBoxName.TabIndex = 11; + // + // labelName + // + labelName.AutoSize = true; + labelName.Location = new Point(57, 142); + labelName.Name = "labelName"; + labelName.Size = new Size(59, 15); + labelName.TabIndex = 12; + labelName.Text = "Название"; + // + // FormService + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(511, 362); + Controls.Add(labelName); + Controls.Add(textBoxName); + Controls.Add(checkedListBoxType); + Controls.Add(richTextBoxDescription); + Controls.Add(label2); + Controls.Add(buttonCancel); + Controls.Add(buttonAdd); + Controls.Add(label1); + Margin = new Padding(3, 2, 3, 2); + Name = "FormService"; + StartPosition = FormStartPosition.CenterScreen; + Text = "Услуга"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Button buttonCancel; + private Button buttonAdd; + private RichTextBox richTextBoxDescription; + private Label label1; + private Label label2; + private CheckedListBox checkedListBoxType; + private TextBox textBoxName; + private Label labelName; + } +} \ No newline at end of file diff --git a/ITServiceManager/ITServiceManager/Forms/FormService.cs b/ITServiceManager/ITServiceManager/Forms/FormService.cs new file mode 100644 index 0000000..7b49a63 --- /dev/null +++ b/ITServiceManager/ITServiceManager/Forms/FormService.cs @@ -0,0 +1,92 @@ +using ITServiceManager.Entities.Enums; +using ITServiceManager.Entities; +using ITServiceManager.Repositories; +using Microsoft.VisualBasic.FileIO; + +namespace ITServiceManager.Forms; + +public partial class FormService : Form +{ + private readonly IServiceRepository _serviceRepository; + private int? _serviceId; + public int Id + { + set + { + try + { + var service = + _serviceRepository.ReadServiceById(value); + if (service == null) + { + throw new + InvalidDataException(nameof(service)); + } + foreach (ServiceType elem in Enum.GetValues(typeof(ServiceType))) + { + if ((elem & service.ServiceType) != 0) + { + checkedListBoxType.SetItemChecked(checkedListBoxType.Items.IndexOf( + elem), true); + } + } + + textBoxName.Text = service.ServiceName; + richTextBoxDescription.Text = service.Description; + _serviceId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + public FormService(IServiceRepository serviceRepository) + { + InitializeComponent(); + _serviceRepository = serviceRepository ?? + throw new ArgumentNullException(nameof(serviceRepository)); + + foreach (var elem in Enum.GetValues(typeof(ServiceType))) + { + checkedListBoxType.Items.Add(elem); + } + } + private void ButtonAdd_Click(object sender, EventArgs e) + { + try + { + if (checkedListBoxType.CheckedItems.Count == 0 || + string.IsNullOrWhiteSpace(richTextBoxDescription.Text) || string.IsNullOrWhiteSpace(textBoxName.Text)) + { + throw new Exception("Имеются незаполненные поля"); + } + if (_serviceId.HasValue) + { + _serviceRepository.UpdateService(CreateService(_serviceId.Value)); + } + else + { + _serviceRepository.CreateService(CreateService(0)); + } + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + private Service CreateService(int id) + { + ServiceType serviceType = ServiceType.None; + foreach (var elem in checkedListBoxType.CheckedItems) + { + serviceType |= (ServiceType)elem; + } + + return Service.CreateEntity(id, serviceType, textBoxName.Text, richTextBoxDescription.Text); + } +} diff --git a/ITServiceManager/ITServiceManager/Forms/FormService.resx b/ITServiceManager/ITServiceManager/Forms/FormService.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ITServiceManager/ITServiceManager/Forms/FormService.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/ITServiceManager/ITServiceManager/Forms/FormServices.Designer.cs b/ITServiceManager/ITServiceManager/Forms/FormServices.Designer.cs new file mode 100644 index 0000000..6e4c2db --- /dev/null +++ b/ITServiceManager/ITServiceManager/Forms/FormServices.Designer.cs @@ -0,0 +1,133 @@ +namespace ITServiceManager.Forms +{ + partial class FormServices + { + /// + /// 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() + { + panel = new Panel(); + buttonUpdate = new Button(); + buttonRemove = new Button(); + buttonAdd = new Button(); + dataGridView = new DataGridView(); + panel.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // panel + // + panel.Controls.Add(buttonUpdate); + panel.Controls.Add(buttonRemove); + panel.Controls.Add(buttonAdd); + panel.Dock = DockStyle.Right; + panel.Location = new Point(745, 0); + panel.Margin = new Padding(3, 4, 3, 4); + panel.Name = "panel"; + panel.Size = new Size(169, 600); + panel.TabIndex = 3; + // + // buttonUpdate + // + buttonUpdate.BackgroundImage = Properties.Resources.edit; + buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpdate.Location = new Point(41, 332); + buttonUpdate.Margin = new Padding(3, 4, 3, 4); + buttonUpdate.Name = "buttonUpdate"; + buttonUpdate.Size = new Size(89, 107); + buttonUpdate.TabIndex = 2; + buttonUpdate.UseVisualStyleBackColor = true; + buttonUpdate.Click += ButtonUpd_Click; + // + // buttonRemove + // + buttonRemove.BackgroundImage = Properties.Resources.minus; + buttonRemove.BackgroundImageLayout = ImageLayout.Stretch; + buttonRemove.Location = new Point(41, 188); + buttonRemove.Margin = new Padding(3, 4, 3, 4); + buttonRemove.Name = "buttonRemove"; + buttonRemove.Size = new Size(86, 101); + buttonRemove.TabIndex = 1; + buttonRemove.UseVisualStyleBackColor = true; + buttonRemove.Click += ButtonDel_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.plus; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(38, 57); + buttonAdd.Margin = new Padding(3, 4, 3, 4); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(93, 95); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // dataGridView + // + dataGridView.AllowUserToAddRows = false; + dataGridView.AllowUserToDeleteRows = false; + dataGridView.AllowUserToResizeColumns = false; + dataGridView.AllowUserToResizeRows = false; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Dock = DockStyle.Fill; + dataGridView.Location = new Point(0, 0); + dataGridView.Margin = new Padding(3, 4, 3, 4); + dataGridView.MultiSelect = false; + dataGridView.Name = "dataGridView"; + dataGridView.ReadOnly = true; + dataGridView.RowHeadersVisible = false; + dataGridView.RowHeadersWidth = 51; + dataGridView.RowTemplate.Height = 25; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(745, 600); + dataGridView.TabIndex = 4; + // + // FormServices + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(914, 600); + Controls.Add(dataGridView); + Controls.Add(panel); + Margin = new Padding(3, 4, 3, 4); + Name = "FormServices"; + StartPosition = FormStartPosition.CenterScreen; + Text = "Услуги"; + Load += FormServices_Load; + panel.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel; + private Button buttonUpdate; + private Button buttonRemove; + private Button buttonAdd; + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/ITServiceManager/ITServiceManager/Forms/FormServices.cs b/ITServiceManager/ITServiceManager/Forms/FormServices.cs new file mode 100644 index 0000000..18e2522 --- /dev/null +++ b/ITServiceManager/ITServiceManager/Forms/FormServices.cs @@ -0,0 +1,106 @@ +using ITServiceManager.Repositories; +using Unity; + +namespace ITServiceManager.Forms; + +public partial class FormServices : Form +{ + private readonly IUnityContainer _container; + private readonly IServiceRepository _serviceRepository; + public FormServices(IUnityContainer container, IServiceRepository + serviceRepository) + { + InitializeComponent(); + _container = container ?? + throw new ArgumentNullException(nameof(container)); + _serviceRepository = serviceRepository ?? + throw new + ArgumentNullException(nameof(serviceRepository)); + } + private void FormServices_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + try + { + var form = _container.Resolve(); + form.Id = findId; + form.ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при изменении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonDel_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + if (MessageBox.Show("Удалить запись?", "Удаление", + MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + try + { + _serviceRepository.DeleteService(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void LoadList() => dataGridView.DataSource = + _serviceRepository.ReadServices(); + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridView.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + return true; + } + +} + diff --git a/ITServiceManager/ITServiceManager/Forms/FormServices.resx b/ITServiceManager/ITServiceManager/Forms/FormServices.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ITServiceManager/ITServiceManager/Forms/FormServices.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/ITServiceManager/ITServiceManager/ITServiceManager.csproj b/ITServiceManager/ITServiceManager/ITServiceManager.csproj index b57c89e..4ccf359 100644 --- a/ITServiceManager/ITServiceManager/ITServiceManager.csproj +++ b/ITServiceManager/ITServiceManager/ITServiceManager.csproj @@ -6,6 +6,36 @@ enable true enable + preview + + + + + + + + + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + + + PreserveNewest + + + \ No newline at end of file diff --git a/ITServiceManager/ITServiceManager/Program.cs b/ITServiceManager/ITServiceManager/Program.cs index 0e5c502..b76dafa 100644 --- a/ITServiceManager/ITServiceManager/Program.cs +++ b/ITServiceManager/ITServiceManager/Program.cs @@ -1,17 +1,35 @@ -namespace ITServiceManager +using ITServiceManager.Repositories.Implementations; +using ITServiceManager.Repositories; +using Unity; + +namespace ITServiceManager; + +internal static class Program { - internal static class Program + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() { - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main() - { - // To customize application configuration such as set high DPI settings or default font, - // see https://aka.ms/applicationconfiguration. - ApplicationConfiguration.Initialize(); - Application.Run(new Form1()); - } + // To customize application configuration such as set high DPI settings or default font, + // see https://aka.ms/applicationconfiguration. + ApplicationConfiguration.Initialize(); + Application.Run(CreateContainer().Resolve()); + + } + + private static IUnityContainer CreateContainer() + { + var container = new UnityContainer(); + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + + container.RegisterType(); + + return container; } } \ No newline at end of file diff --git a/ITServiceManager/ITServiceManager/Properties/Resources.Designer.cs b/ITServiceManager/ITServiceManager/Properties/Resources.Designer.cs new file mode 100644 index 0000000..37fc7f8 --- /dev/null +++ b/ITServiceManager/ITServiceManager/Properties/Resources.Designer.cs @@ -0,0 +1,113 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace ITServiceManager.Properties { + using System; + + + /// + /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д. + /// + // Этот класс создан автоматически классом StronglyTypedResourceBuilder + // с помощью такого средства, как ResGen или Visual Studio. + // Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen + // с параметром /str или перестройте свой проект VS. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.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() { + } + + /// + /// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом. + /// + [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("ITServiceManager.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Перезаписывает свойство CurrentUICulture текущего потока для всех + /// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap company { + get { + object obj = ResourceManager.GetObject("company", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap edit { + get { + object obj = ResourceManager.GetObject("edit", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap edit1 { + get { + object obj = ResourceManager.GetObject("edit1", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap minus { + get { + object obj = ResourceManager.GetObject("minus", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap plus { + get { + object obj = ResourceManager.GetObject("plus", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/ITServiceManager/ITServiceManager/Properties/Resources.resx b/ITServiceManager/ITServiceManager/Properties/Resources.resx new file mode 100644 index 0000000..edbe07a --- /dev/null +++ b/ITServiceManager/ITServiceManager/Properties/Resources.resx @@ -0,0 +1,136 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + + ..\Resources\company.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\edit.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\edit.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\plus.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\minus.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/ITServiceManager/ITServiceManager/Repositories/IAppointmentRepository.cs b/ITServiceManager/ITServiceManager/Repositories/IAppointmentRepository.cs new file mode 100644 index 0000000..71d2109 --- /dev/null +++ b/ITServiceManager/ITServiceManager/Repositories/IAppointmentRepository.cs @@ -0,0 +1,11 @@ +using ITServiceManager.Entities; + +namespace ITServiceManager.Repositories; + +public interface IAppointmentRepository +{ + IEnumerable ReadAppointments(); + Appointment ReadAppointmentById(int id); + void CreateAppointment(Appointment appointment); + void UpdateAppointment(Appointment appointment); +} diff --git a/ITServiceManager/ITServiceManager/Repositories/ICompanyRepository.cs b/ITServiceManager/ITServiceManager/Repositories/ICompanyRepository.cs new file mode 100644 index 0000000..f2f42ba --- /dev/null +++ b/ITServiceManager/ITServiceManager/Repositories/ICompanyRepository.cs @@ -0,0 +1,12 @@ +using ITServiceManager.Entities; + +namespace ITServiceManager.Repositories; + +public interface ICompanyRepository +{ + IEnumerable ReadCompanies(); + Company ReadCompanyById(int id); + void CreateCompany(Company company); + void UpdateCompany(Company company); + void DeleteCompany(int id); +} diff --git a/ITServiceManager/ITServiceManager/Repositories/IConnectionString.cs b/ITServiceManager/ITServiceManager/Repositories/IConnectionString.cs new file mode 100644 index 0000000..bb78357 --- /dev/null +++ b/ITServiceManager/ITServiceManager/Repositories/IConnectionString.cs @@ -0,0 +1,6 @@ +namespace ITServiceManager.Repositories; + +public interface IConnectionString +{ + public string ConnectionString { get; } +} diff --git a/ITServiceManager/ITServiceManager/Repositories/IEmployeeRepository.cs b/ITServiceManager/ITServiceManager/Repositories/IEmployeeRepository.cs new file mode 100644 index 0000000..cc0fbbc --- /dev/null +++ b/ITServiceManager/ITServiceManager/Repositories/IEmployeeRepository.cs @@ -0,0 +1,11 @@ +using ITServiceManager.Entities; + +namespace ITServiceManager.Repositories; +public interface IEmployeeRepository +{ + IEnumerable ReadEmployees(); + Employee ReadEmployeeById(int id); + void CreateEmployee(Employee employee); + void UpdateEmployee(Employee employee); + void DeleteEmployee(int id); +} diff --git a/ITServiceManager/ITServiceManager/Repositories/IOrderRepository.cs b/ITServiceManager/ITServiceManager/Repositories/IOrderRepository.cs new file mode 100644 index 0000000..d4632c4 --- /dev/null +++ b/ITServiceManager/ITServiceManager/Repositories/IOrderRepository.cs @@ -0,0 +1,11 @@ +using ITServiceManager.Entities; + +namespace ITServiceManager.Repositories; + +public interface IOrderRepository +{ + IEnumerable ReadOrders(DateTime? dateForm = null, DateTime? dateTo = null, int? orderId = null, int? companyId = null); + Order ReadOrderById(int orderId); + void CreateOrder(Order order); + void DeleteOrder(int id); +} diff --git a/ITServiceManager/ITServiceManager/Repositories/IServiceRepository.cs b/ITServiceManager/ITServiceManager/Repositories/IServiceRepository.cs new file mode 100644 index 0000000..39a360e --- /dev/null +++ b/ITServiceManager/ITServiceManager/Repositories/IServiceRepository.cs @@ -0,0 +1,12 @@ +using ITServiceManager.Entities; + +namespace ITServiceManager.Repositories; + +public interface IServiceRepository +{ + IEnumerable ReadServices(); + Service ReadServiceById(int id); + void CreateService(Service service); + void UpdateService(Service service); + void DeleteService(int id); +} diff --git a/ITServiceManager/ITServiceManager/Repositories/Implementations/AppointmentRepository.cs b/ITServiceManager/ITServiceManager/Repositories/Implementations/AppointmentRepository.cs new file mode 100644 index 0000000..0127623 --- /dev/null +++ b/ITServiceManager/ITServiceManager/Repositories/Implementations/AppointmentRepository.cs @@ -0,0 +1,23 @@ +using ITServiceManager.Entities; + +namespace ITServiceManager.Repositories.Implementations; + +public class AppointmentRepository : IAppointmentRepository +{ + public IEnumerable ReadAppointments() + { + return []; + } + public Appointment ReadAppointmentById(int id) + { + return null; + } + public void CreateAppointment(Appointment appointment) + { + + } + public void UpdateAppointment(Appointment appointment) + { + + } +} diff --git a/ITServiceManager/ITServiceManager/Repositories/Implementations/CompanyRepository.cs b/ITServiceManager/ITServiceManager/Repositories/Implementations/CompanyRepository.cs new file mode 100644 index 0000000..f4df14c --- /dev/null +++ b/ITServiceManager/ITServiceManager/Repositories/Implementations/CompanyRepository.cs @@ -0,0 +1,33 @@ +using ITServiceManager.Entities; + +namespace ITServiceManager.Repositories.Implementations; + +public class CompanyRepository : ICompanyRepository +{ + private readonly IConnectionString _connectionString; + + public CompanyRepository(IConnectionString connectionString) + { + _connectionString = connectionString; + } + public IEnumerable ReadCompanies() + { + return []; + } + public Company ReadCompanyById(int id) + { + return null; + } + public void CreateCompany(Company company) + { + + } + public void UpdateCompany(Company company) + { + + } + public void DeleteCompany(int id) + { + + } +} diff --git a/ITServiceManager/ITServiceManager/Repositories/Implementations/ConnectionString.cs b/ITServiceManager/ITServiceManager/Repositories/Implementations/ConnectionString.cs new file mode 100644 index 0000000..04eb28a --- /dev/null +++ b/ITServiceManager/ITServiceManager/Repositories/Implementations/ConnectionString.cs @@ -0,0 +1,6 @@ +namespace ITServiceManager.Repositories.Implementations; + +internal class ConnectionString : IConnectionString +{ + string IConnectionString.ConnectionString => ""; +} diff --git a/ITServiceManager/ITServiceManager/Repositories/Implementations/EmployeeRepository.cs b/ITServiceManager/ITServiceManager/Repositories/Implementations/EmployeeRepository.cs new file mode 100644 index 0000000..3cc552d --- /dev/null +++ b/ITServiceManager/ITServiceManager/Repositories/Implementations/EmployeeRepository.cs @@ -0,0 +1,27 @@ +using ITServiceManager.Entities; + +namespace ITServiceManager.Repositories.Implementations; + +public class EmployeeRepository : IEmployeeRepository +{ + public IEnumerable ReadEmployees() + { + return []; + } + public Employee ReadEmployeeById(int id) + { + return null; + } + public void CreateEmployee(Employee employee) + { + + } + public void UpdateEmployee(Employee employee) + { + + } + public void DeleteEmployee(int id) + { + + } +} diff --git a/ITServiceManager/ITServiceManager/Repositories/Implementations/OrderRepository.cs b/ITServiceManager/ITServiceManager/Repositories/Implementations/OrderRepository.cs new file mode 100644 index 0000000..66dd2f7 --- /dev/null +++ b/ITServiceManager/ITServiceManager/Repositories/Implementations/OrderRepository.cs @@ -0,0 +1,23 @@ +using ITServiceManager.Entities; + +namespace ITServiceManager.Repositories.Implementations; + +public class OrderRepository : IOrderRepository +{ + public IEnumerable ReadOrders(DateTime? dateForm = null, DateTime? dateTo = null, int? orderId = null, int? companyId = null) + { + return []; + } + public Order ReadOrderById(int orderId) + { + return null; + } + public void CreateOrder(Order order) + { + + } + public void DeleteOrder(int id) + { + + } +} diff --git a/ITServiceManager/ITServiceManager/Repositories/Implementations/ServiceRepository.cs b/ITServiceManager/ITServiceManager/Repositories/Implementations/ServiceRepository.cs new file mode 100644 index 0000000..296eabf --- /dev/null +++ b/ITServiceManager/ITServiceManager/Repositories/Implementations/ServiceRepository.cs @@ -0,0 +1,27 @@ +using ITServiceManager.Entities; + +namespace ITServiceManager.Repositories.Implementations; + +public class ServiceRepository : IServiceRepository +{ + public IEnumerable ReadServices() + { + return []; + } + public Service ReadServiceById(int id) + { + return null; + } + public void CreateService(Service service) + { + + } + public void UpdateService(Service service) + { + + } + public void DeleteService(int id) + { + + } +} diff --git a/ITServiceManager/ITServiceManager/Resources/company.jpg b/ITServiceManager/ITServiceManager/Resources/company.jpg new file mode 100644 index 0000000..a51256f Binary files /dev/null and b/ITServiceManager/ITServiceManager/Resources/company.jpg differ diff --git a/ITServiceManager/ITServiceManager/Resources/edit.png b/ITServiceManager/ITServiceManager/Resources/edit.png new file mode 100644 index 0000000..769aabd Binary files /dev/null and b/ITServiceManager/ITServiceManager/Resources/edit.png differ diff --git a/ITServiceManager/ITServiceManager/Resources/minus.jpg b/ITServiceManager/ITServiceManager/Resources/minus.jpg new file mode 100644 index 0000000..1a42e9c Binary files /dev/null and b/ITServiceManager/ITServiceManager/Resources/minus.jpg differ diff --git a/ITServiceManager/ITServiceManager/Resources/plus.jpg b/ITServiceManager/ITServiceManager/Resources/plus.jpg new file mode 100644 index 0000000..b766719 Binary files /dev/null and b/ITServiceManager/ITServiceManager/Resources/plus.jpg differ diff --git a/ITServiceManager/ITServiceManager/appsettings.json b/ITServiceManager/ITServiceManager/appsettings.json new file mode 100644 index 0000000..077404a --- /dev/null +++ b/ITServiceManager/ITServiceManager/appsettings.json @@ -0,0 +1,3 @@ +{ + +} \ No newline at end of file