diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Entities/Bus.cs b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Entities/Bus.cs new file mode 100644 index 0000000..d82eb47 --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Entities/Bus.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PIbd_24_EredavkinRA_BusBusiness.Entities; + +public class Bus +{ + public int Id { get; private set; } + public string Model { get; private set; } = string.Empty; + public string N_Z { get; private set; } = string.Empty; + public int Capacity { get; private set; } + public int Bus_mileage { get; private set; } + + public static Bus CreateEntity(int id, string model, string n_z, int capacity, int bus_mileage) + { + return new Bus + { + Id = id, + Model = model ?? string.Empty, + N_Z = n_z ?? string.Empty, + Capacity = capacity, + Bus_mileage = bus_mileage + }; + + } +} diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Entities/Enums/EmployeePost.cs b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Entities/Enums/EmployeePost.cs new file mode 100644 index 0000000..9191712 --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Entities/Enums/EmployeePost.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PIbd_24_EredavkinRA_BusBusiness.Entities.Enums; + +public enum EmployeePost +{ + None = 0, + Conductor = 1, + Driver = 2, + Mechanic = 3 +} diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Entities/Enums/ModelType.cs b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Entities/Enums/ModelType.cs new file mode 100644 index 0000000..9a636c4 --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Entities/Enums/ModelType.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PIbd_24_EredavkinRA_BusBusiness.Entities.Enums; +[Flags] +public enum ModelType +{ + None = 0, + + Maz = 1, + + Gaz = 2, + + Mercedes = 4, + + Ford = 8 +} diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Entities/Rout.cs b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Entities/Rout.cs new file mode 100644 index 0000000..ff12dd4 --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Entities/Rout.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PIbd_24_EredavkinRA_BusBusiness.Entities; + +public class Rout +{ + public int Id { get; private set; } + public string StartStop { get; private set; } = string.Empty; + public string EndStop { get; private set; } = string.Empty; + + public int NumberRout { get; private set; } + public static Rout CreateEntity(int id, string startstop, string endstop, int numberrout) + { + return new Rout + { + Id = id, + StartStop = startstop ?? string.Empty, + EndStop = endstop ?? string.Empty, + NumberRout = numberrout + + }; + } + +} diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Entities/RoutSheet.cs b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Entities/RoutSheet.cs new file mode 100644 index 0000000..5c67661 --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Entities/RoutSheet.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PIbd_24_EredavkinRA_BusBusiness.Entities; + +public class RoutSheet +{ + public int Id { get; private set; } + + public int RoutId { get; private set; } + + public IEnumerable RoutSheetBuses { get; private set; } = []; + public int DriverId { get; private set; } + public int ConductorId { get; private set; } + public DateTime BusDate { get; private set; } + public static RoutSheet CreatOpeartion(int id, int routid, int driverid, int conductorid, IEnumerable RoutSheetBuses) + { + return new RoutSheet + { + Id = id, + RoutId = routid, + RoutSheetBuses = RoutSheetBuses, + DriverId = driverid, + ConductorId = conductorid, + BusDate = DateTime.Now + }; + } +} diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Entities/RoutSheetBus.cs b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Entities/RoutSheetBus.cs new file mode 100644 index 0000000..fbb88db --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Entities/RoutSheetBus.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PIbd_24_EredavkinRA_BusBusiness.Entities; + +public class RoutSheetBus +{ + public int Id { get; private set; } + public int BusID { get; private set; } + + + + public static RoutSheetBus CreateElement(int id, int busid) + { + return new RoutSheetBus + { + Id = id, + BusID = busid, + + }; + } +} diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Entities/Staff.cs b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Entities/Staff.cs new file mode 100644 index 0000000..efbc6cd --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Entities/Staff.cs @@ -0,0 +1,27 @@ +using PIbd_24_EredavkinRA_BusBusiness.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PIbd_24_EredavkinRA_BusBusiness.Entities; + +public class Staff +{ + public int Id { get; private set; } + public string FirstName { get; private set; } = string.Empty; + public string LastName { get; private set; } = string.Empty; + + public EmployeePost EmployeePost { get; private set; } + public static Staff CreatEntity(int id, string first, string last, EmployeePost employeePost) + { + return new Staff + { + Id = id, + FirstName = first ?? string.Empty, + LastName = last ?? string.Empty, + EmployeePost = employeePost + }; + } +} diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Entities/To.cs b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Entities/To.cs new file mode 100644 index 0000000..aacd57f --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Entities/To.cs @@ -0,0 +1,34 @@ +using Microsoft.VisualBasic; +using PIbd_24_EredavkinRA_BusBusiness.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PIbd_24_EredavkinRA_BusBusiness.Entities; + +public class To +{ + public int Id { get; private set; } + public int BusID { get; private set; } + public int MechanicID { get; private set; } + public string Description { get; private set; } = string.Empty; + + public int Cost { get; private set; } + public DateTime DateTo { get; private set; } + + public static To CreatOperation(int id, string description, int cost, int busid, int mechanicid) + { + return new To() + { + Id = id, + Description = description ?? string.Empty, + Cost = cost, + DateTo = DateTime.Now, + BusID = busid, + MechanicID = mechanicid + }; + } + +} diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Form1.Designer.cs b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Form1.Designer.cs deleted file mode 100644 index 79cd427..0000000 --- a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace PIbd_24_EredavkinRA_BusBusiness -{ - 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/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Form1.cs b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Form1.cs deleted file mode 100644 index a464a45..0000000 --- a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace PIbd_24_EredavkinRA_BusBusiness -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/FormBus.Designer.cs b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/FormBus.Designer.cs new file mode 100644 index 0000000..5c66fc4 --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/FormBus.Designer.cs @@ -0,0 +1,137 @@ +namespace PIbd_24_EredavkinRA_BusBusiness +{ + partial class FormBus + { + /// + /// 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(); + RefrencesToolStripMenuItem = new ToolStripMenuItem(); + StaffToolStripMenuItem = new ToolStripMenuItem(); + BusToolStripMenuItem = new ToolStripMenuItem(); + RoutToolStripMenuItem = new ToolStripMenuItem(); + ToToolStripMenuItem = new ToolStripMenuItem(); + RoutSheetToolStripMenuItem = new ToolStripMenuItem(); + ToesToolStripMenuItem = new ToolStripMenuItem(); + отчетыToolStripMenuItem = new ToolStripMenuItem(); + menuStrip1.SuspendLayout(); + SuspendLayout(); + // + // menuStrip1 + // + menuStrip1.Items.AddRange(new ToolStripItem[] { RefrencesToolStripMenuItem, ToToolStripMenuItem, отчетыToolStripMenuItem }); + menuStrip1.Location = new Point(0, 0); + menuStrip1.Name = "menuStrip1"; + menuStrip1.Size = new Size(784, 24); + menuStrip1.TabIndex = 0; + menuStrip1.Text = "menuStrip1"; + // + // RefrencesToolStripMenuItem + // + RefrencesToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { StaffToolStripMenuItem, BusToolStripMenuItem, RoutToolStripMenuItem }); + RefrencesToolStripMenuItem.Name = "RefrencesToolStripMenuItem"; + RefrencesToolStripMenuItem.Size = new Size(94, 20); + RefrencesToolStripMenuItem.Text = "Справочники"; + // + // StaffToolStripMenuItem + // + StaffToolStripMenuItem.Name = "StaffToolStripMenuItem"; + StaffToolStripMenuItem.Size = new Size(136, 22); + StaffToolStripMenuItem.Text = "Работники"; + StaffToolStripMenuItem.Click += StaffToolStripMenuItem_Click; + // + // BusToolStripMenuItem + // + BusToolStripMenuItem.Name = "BusToolStripMenuItem"; + BusToolStripMenuItem.Size = new Size(136, 22); + BusToolStripMenuItem.Text = "Автобусы"; + BusToolStripMenuItem.Click += BusToolStripMenuItem_Click; + // + // RoutToolStripMenuItem + // + RoutToolStripMenuItem.Name = "RoutToolStripMenuItem"; + RoutToolStripMenuItem.Size = new Size(136, 22); + RoutToolStripMenuItem.Text = "Маршруты"; + RoutToolStripMenuItem.Click += RoutToolStripMenuItem_Click; + // + // ToToolStripMenuItem + // + ToToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { RoutSheetToolStripMenuItem, ToesToolStripMenuItem }); + ToToolStripMenuItem.Name = "ToToolStripMenuItem"; + ToToolStripMenuItem.Size = new Size(75, 20); + ToToolStripMenuItem.Text = "Операции"; + // + // RoutSheetToolStripMenuItem + // + RoutSheetToolStripMenuItem.Name = "RoutSheetToolStripMenuItem"; + RoutSheetToolStripMenuItem.Size = new Size(309, 22); + RoutSheetToolStripMenuItem.Text = "Получение Маршрутного листа"; + RoutSheetToolStripMenuItem.Click += RoutSheetToolStripMenuItem_Click; + // + // ToesToolStripMenuItem + // + ToesToolStripMenuItem.Name = "ToesToolStripMenuItem"; + ToesToolStripMenuItem.Size = new Size(309, 22); + ToesToolStripMenuItem.Text = "Проведение Технического Обслуживания "; + ToesToolStripMenuItem.Click += ToesToolStripMenuItem_Click_1; + // + // отчетыToolStripMenuItem + // + отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; + отчетыToolStripMenuItem.Size = new Size(60, 20); + отчетыToolStripMenuItem.Text = "Отчеты"; + // + // FormBus + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + BackgroundImage = Properties.Resources.МАТП; + BackgroundImageLayout = ImageLayout.Stretch; + ClientSize = new Size(784, 411); + Controls.Add(menuStrip1); + MainMenuStrip = menuStrip1; + Name = "FormBus"; + StartPosition = FormStartPosition.CenterScreen; + Text = "МАТП "; + menuStrip1.ResumeLayout(false); + menuStrip1.PerformLayout(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private MenuStrip menuStrip1; + private ToolStripMenuItem RefrencesToolStripMenuItem; + private ToolStripMenuItem StaffToolStripMenuItem; + private ToolStripMenuItem BusToolStripMenuItem; + private ToolStripMenuItem RoutToolStripMenuItem; + private ToolStripMenuItem RoutSheetToolStripMenuItem; + private ToolStripMenuItem отчетыToolStripMenuItem; + private ToolStripMenuItem ToesToolStripMenuItem; + private ToolStripMenuItem ToToolStripMenuItem; + } +} diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/FormBus.cs b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/FormBus.cs new file mode 100644 index 0000000..00904a9 --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/FormBus.cs @@ -0,0 +1,80 @@ +using PIbd_24_EredavkinRA_BusBusiness.Forms; +using System.ComponentModel; +using Unity; + +namespace PIbd_24_EredavkinRA_BusBusiness; + +public partial class FormBus : Form +{ + private readonly IUnityContainer _container; + public FormBus(IUnityContainer container) + { + InitializeComponent(); + _container = container ?? throw new ArgumentException(nameof(container)); + } + + private void StaffToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void BusToolStripMenuItem_Click(object sender, EventArgs e) + { + + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void RoutToolStripMenuItem_Click(object sender, EventArgs e) + { + + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + + + private void RoutSheetToolStripMenuItem_Click(object sender, EventArgs e) + { + + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ToesToolStripMenuItem_Click_1(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } +} diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/FormBus.resx b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/FormBus.resx new file mode 100644 index 0000000..a0623c8 --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/FormBus.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/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormBus.Designer.cs b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormBus.Designer.cs new file mode 100644 index 0000000..ce4c883 --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormBus.Designer.cs @@ -0,0 +1,168 @@ +namespace PIbd_24_EredavkinRA_BusBusiness.Forms +{ + partial class FormBus + { + /// + /// 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() + { + labelModel = new Label(); + labelNZ = new Label(); + labelMileage = new Label(); + labelCpacity = new Label(); + textBoxtModel = new TextBox(); + textBoxNZ = new TextBox(); + Mileage = new NumericUpDown(); + numericUpDownCapacity = new NumericUpDown(); + buttonSave = new Button(); + buttonleave = new Button(); + ((System.ComponentModel.ISupportInitialize)Mileage).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownCapacity).BeginInit(); + SuspendLayout(); + // + // labelModel + // + labelModel.AutoSize = true; + labelModel.Location = new Point(33, 24); + labelModel.Name = "labelModel"; + labelModel.Size = new Size(104, 15); + labelModel.TabIndex = 0; + labelModel.Text = "Модель Автобуса"; + // + // labelNZ + // + labelNZ.AutoSize = true; + labelNZ.Location = new Point(33, 67); + labelNZ.Name = "labelNZ"; + labelNZ.Size = new Size(143, 15); + labelNZ.TabIndex = 1; + labelNZ.Text = "Государственный номер"; + // + // labelMileage + // + labelMileage.AutoSize = true; + labelMileage.Location = new Point(33, 107); + labelMileage.Name = "labelMileage"; + labelMileage.Size = new Size(48, 15); + labelMileage.TabIndex = 2; + labelMileage.Text = "Пробег"; + // + // labelCpacity + // + labelCpacity.AutoSize = true; + labelCpacity.Location = new Point(24, 147); + labelCpacity.Name = "labelCpacity"; + labelCpacity.Size = new Size(223, 15); + labelCpacity.TabIndex = 3; + labelCpacity.Text = "Максимально Количество пассажиров"; + // + // textBoxtModel + // + textBoxtModel.Location = new Point(182, 21); + textBoxtModel.Name = "textBoxtModel"; + textBoxtModel.Size = new Size(405, 23); + textBoxtModel.TabIndex = 4; + // + // textBoxNZ + // + textBoxNZ.Location = new Point(182, 59); + textBoxNZ.Name = "textBoxNZ"; + textBoxNZ.Size = new Size(285, 23); + textBoxNZ.TabIndex = 5; + // + // Mileage + // + Mileage.Location = new Point(182, 99); + Mileage.Maximum = new decimal(new int[] { 2000000, 0, 0, 0 }); + Mileage.Name = "Mileage"; + Mileage.Size = new Size(199, 23); + Mileage.TabIndex = 6; + // + // numericUpDownCapacity + // + numericUpDownCapacity.Location = new Point(267, 145); + numericUpDownCapacity.Maximum = new decimal(new int[] { 1000, 0, 0, 0 }); + numericUpDownCapacity.Name = "numericUpDownCapacity"; + numericUpDownCapacity.Size = new Size(131, 23); + numericUpDownCapacity.TabIndex = 7; + // + // buttonSave + // + buttonSave.Location = new Point(24, 277); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(213, 23); + buttonSave.TabIndex = 8; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; + // + // buttonleave + // + buttonleave.Location = new Point(348, 277); + buttonleave.Name = "buttonleave"; + buttonleave.Size = new Size(220, 23); + buttonleave.TabIndex = 9; + buttonleave.Text = "Выйти "; + buttonleave.UseVisualStyleBackColor = true; + buttonleave.Click += buttonleave_Click; + // + // FormBus + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(601, 307); + Controls.Add(buttonleave); + Controls.Add(buttonSave); + Controls.Add(numericUpDownCapacity); + Controls.Add(Mileage); + Controls.Add(textBoxNZ); + Controls.Add(textBoxtModel); + Controls.Add(labelCpacity); + Controls.Add(labelMileage); + Controls.Add(labelNZ); + Controls.Add(labelModel); + Name = "FormBus"; + StartPosition = FormStartPosition.CenterParent; + Text = "Автобусы"; + ((System.ComponentModel.ISupportInitialize)Mileage).EndInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownCapacity).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelModel; + private Label labelNZ; + private Label labelMileage; + private Label labelCpacity; + private TextBox textBoxtModel; + private TextBox textBoxNZ; + private NumericUpDown Mileage; + private NumericUpDown numericUpDownCapacity; + private Button buttonSave; + private Button buttonleave; + } +} \ No newline at end of file diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormBus.cs b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormBus.cs new file mode 100644 index 0000000..bc9aa0a --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormBus.cs @@ -0,0 +1,87 @@ +using PIbd_24_EredavkinRA_BusBusiness.Entities; +using PIbd_24_EredavkinRA_BusBusiness.Repositories; +using PIbd_24_EredavkinRA_BusBusiness.Repositories.Implementations; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace PIbd_24_EredavkinRA_BusBusiness.Forms; + +public partial class FormBus : Form +{ + private readonly IBusRepository _busRepository; + private int? _busId; + public int Id + { + set + { + try + { + var bus = _busRepository.ReadBusByID(value); + if (bus == null) + { + throw new InvalidDataException(nameof(bus)); + } + textBoxtModel.Text = bus.Model; + textBoxNZ.Text = bus.N_Z; + Mileage.Value = bus.Bus_mileage; + numericUpDownCapacity.Value = bus.Capacity; + _busId = bus.Id; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + + } + } + + } + public FormBus(IBusRepository busRepository) + { + InitializeComponent(); + _busRepository = busRepository ?? + throw new ArgumentNullException(nameof(busRepository)); + } + + private void buttonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxtModel.Text) ||string.IsNullOrWhiteSpace(textBoxNZ.Text)) + { + throw new Exception("Имеются незаполненные поля"); + } + if (_busId.HasValue) + { + _busRepository.UpdateBus(CreateBus(_busId.Value)); + } + else + { + _busRepository.CreateBus(CreateBus(0)); + } + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonleave_Click(object sender, EventArgs e) => Close(); + + private Bus CreateBus(int id) => Bus.CreateEntity(id, + textBoxtModel.Text, + textBoxNZ.Text, + Convert.ToInt32(Mileage.Value), + Convert.ToInt32(numericUpDownCapacity.Value)); + + +} diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Form1.resx b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormBus.resx similarity index 93% rename from PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Form1.resx rename to PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormBus.resx index 1af7de1..af32865 100644 --- a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Form1.resx +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormBus.resx @@ -1,17 +1,17 @@  - diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormBuses.Designer.cs b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormBuses.Designer.cs new file mode 100644 index 0000000..c41c40f --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormBuses.Designer.cs @@ -0,0 +1,126 @@ +namespace PIbd_24_EredavkinRA_BusBusiness.Forms +{ + partial class FormBuses + { + /// + /// 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() + { + panel1 = new Panel(); + buttonDel = new Button(); + buttonUpd = new Button(); + buttonAdd = new Button(); + dataGridViewData = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(buttonDel); + panel1.Controls.Add(buttonUpd); + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(596, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(150, 428); + panel1.TabIndex = 0; + // + // buttonDel + // + buttonDel.BackgroundImage = Properties.Resources.del; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(27, 211); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(99, 85); + buttonDel.TabIndex = 2; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += buttonDel_Click; + // + // buttonUpd + // + buttonUpd.BackgroundImage = Properties.Resources.rev; + buttonUpd.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpd.Location = new Point(27, 109); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(96, 76); + buttonUpd.TabIndex = 1; + buttonUpd.UseVisualStyleBackColor = true; + buttonUpd.Click += buttonUpd_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.add; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(27, 12); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(98, 78); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += buttonAdd_Click; + // + // dataGridViewData + // + dataGridViewData.AllowUserToAddRows = false; + dataGridViewData.AllowUserToDeleteRows = false; + dataGridViewData.AllowUserToResizeColumns = false; + dataGridViewData.AllowUserToResizeRows = false; + dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewData.Dock = DockStyle.Fill; + dataGridViewData.Location = new Point(0, 0); + dataGridViewData.MultiSelect = false; + dataGridViewData.Name = "dataGridViewData"; + dataGridViewData.ReadOnly = true; + dataGridViewData.RowHeadersVisible = false; + dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewData.Size = new Size(596, 428); + dataGridViewData.TabIndex = 1; + // + // FormBuses + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(746, 428); + Controls.Add(dataGridViewData); + Controls.Add(panel1); + Name = "FormBuses"; + StartPosition = FormStartPosition.CenterParent; + Text = "Автобусы"; + Load += FormBuses_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button buttonDel; + private Button buttonUpd; + private Button buttonAdd; + private DataGridView dataGridViewData; + } +} \ No newline at end of file diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormBuses.cs b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormBuses.cs new file mode 100644 index 0000000..ffb8d95 --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormBuses.cs @@ -0,0 +1,114 @@ +using PIbd_24_EredavkinRA_BusBusiness.Repositories; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Unity; + +namespace PIbd_24_EredavkinRA_BusBusiness.Forms; + +public partial class FormBuses : Form +{ + private readonly IUnityContainer _container; + private readonly IBusRepository _busRepository; + + + + + public FormBuses(IUnityContainer container, IBusRepository busRepository) + { + InitializeComponent(); + _container = container ?? + throw new ArgumentNullException(nameof(container)); + _busRepository = busRepository ?? + throw new ArgumentNullException(nameof(busRepository)); + } + private void FormBuses_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 + { + _busRepository.DeleteBus(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + + private void LoadList() => dataGridViewData.DataSource = _busRepository.ReadBus(); + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridViewData.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ощибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value); + return true; + } +} diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormBuses.resx b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormBuses.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormBuses.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/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormRout.Designer.cs b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormRout.Designer.cs new file mode 100644 index 0000000..75efec1 --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormRout.Designer.cs @@ -0,0 +1,141 @@ +namespace PIbd_24_EredavkinRA_BusBusiness.Forms +{ + partial class FormRout + { + /// + /// 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() + { + numericUpDownNumber = new NumericUpDown(); + textBoxStarPoint = new TextBox(); + textBoxEndPoint = new TextBox(); + label1 = new Label(); + label2 = new Label(); + label3 = new Label(); + buttonSave = new Button(); + buttonLoad = new Button(); + ((System.ComponentModel.ISupportInitialize)numericUpDownNumber).BeginInit(); + SuspendLayout(); + // + // numericUpDownNumber + // + numericUpDownNumber.Location = new Point(177, 33); + numericUpDownNumber.Name = "numericUpDownNumber"; + numericUpDownNumber.Size = new Size(178, 23); + numericUpDownNumber.TabIndex = 0; + // + // textBoxStarPoint + // + textBoxStarPoint.Location = new Point(177, 79); + textBoxStarPoint.Name = "textBoxStarPoint"; + textBoxStarPoint.Size = new Size(178, 23); + textBoxStarPoint.TabIndex = 1; + // + // textBoxEndPoint + // + textBoxEndPoint.Location = new Point(177, 126); + textBoxEndPoint.Name = "textBoxEndPoint"; + textBoxEndPoint.Size = new Size(178, 23); + textBoxEndPoint.TabIndex = 2; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(41, 35); + label1.Name = "label1"; + label1.Size = new Size(105, 15); + label1.TabIndex = 3; + label1.Text = "Номер маршрута"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(41, 87); + label2.Name = "label2"; + label2.Size = new Size(126, 15); + label2.TabIndex = 4; + label2.Text = "Начальная остановка"; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(41, 134); + label3.Name = "label3"; + label3.Size = new Size(119, 15); + label3.TabIndex = 5; + label3.Text = "Конечная остановка"; + // + // buttonSave + // + buttonSave.Location = new Point(22, 243); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(106, 57); + buttonSave.TabIndex = 6; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; + // + // buttonLoad + // + buttonLoad.Location = new Point(218, 243); + buttonLoad.Name = "buttonLoad"; + buttonLoad.Size = new Size(120, 57); + buttonLoad.TabIndex = 7; + buttonLoad.Text = "Выйти"; + buttonLoad.UseVisualStyleBackColor = true; + buttonLoad.Click += buttonLoad_Click; + // + // FormRout + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(372, 314); + Controls.Add(buttonLoad); + Controls.Add(buttonSave); + Controls.Add(label3); + Controls.Add(label2); + Controls.Add(label1); + Controls.Add(textBoxEndPoint); + Controls.Add(textBoxStarPoint); + Controls.Add(numericUpDownNumber); + Name = "FormRout"; + Text = "Маршрут"; + ((System.ComponentModel.ISupportInitialize)numericUpDownNumber).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private NumericUpDown numericUpDownNumber; + private TextBox textBoxStarPoint; + private TextBox textBoxEndPoint; + private Label label1; + private Label label2; + private Label label3; + private Button buttonSave; + private Button buttonLoad; + } +} \ No newline at end of file diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormRout.cs b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormRout.cs new file mode 100644 index 0000000..1c450e4 --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormRout.cs @@ -0,0 +1,94 @@ +using PIbd_24_EredavkinRA_BusBusiness.Entities; +using PIbd_24_EredavkinRA_BusBusiness.Entities.Enums; +using PIbd_24_EredavkinRA_BusBusiness.Repositories; +using PIbd_24_EredavkinRA_BusBusiness.Repositories.Implementations; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using static System.Windows.Forms.VisualStyles.VisualStyleElement; + +namespace PIbd_24_EredavkinRA_BusBusiness.Forms; + +public partial class FormRout : Form +{ + private readonly IRoutRepositories _routRepository; + private int? _routId; + public int Id + { + set + { + try + { + var rout = _routRepository.ReadRoutByID(value); + if (rout == null) + { + throw new + InvalidDataException(nameof(rout)); + } + textBoxStarPoint.Text = rout.StartStop; + textBoxEndPoint.Text = rout.EndStop; + numericUpDownNumber.Value = rout.NumberRout; + _routId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + public FormRout(IRoutRepositories routRepositories) + { + InitializeComponent(); + _routRepository = routRepositories ?? + throw new ArgumentNullException(nameof(routRepositories)); + + } + + private void buttonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxStarPoint.Text) || string.IsNullOrWhiteSpace(textBoxEndPoint.Text)) + { + throw new Exception("Имеются незаполненные поля"); + } + if (_routId.HasValue) + { + _routRepository.UpdateRout(CreateRout(_routId.Value)); + } + else + { + _routRepository.CreateRout(CreateRout(0)); + } + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonLoad_Click(object sender, EventArgs e) => Close(); + + private Rout CreateRout(int id) => Rout.CreateEntity(id, + textBoxStarPoint.Text, + textBoxEndPoint.Text, + Convert.ToInt32(numericUpDownNumber.Value)); + + + +} + + + + + + diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormRout.resx b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormRout.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormRout.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/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormRoutSheet.Designer.cs b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormRoutSheet.Designer.cs new file mode 100644 index 0000000..1509ae7 --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormRoutSheet.Designer.cs @@ -0,0 +1,183 @@ +namespace PIbd_24_EredavkinRA_BusBusiness.Forms +{ + partial class FormRoutSheet + { + /// + /// 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() + { + buttonSave = new Button(); + buttonLeave = new Button(); + groupBox1 = new GroupBox(); + dataGridViewRoutSheet = new DataGridView(); + ColumnBus = new DataGridViewComboBoxColumn(); + label1 = new Label(); + label2 = new Label(); + label3 = new Label(); + comboBoxDriver = new ComboBox(); + comboBoxConductor = new ComboBox(); + comboBoxRout = new ComboBox(); + groupBox1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewRoutSheet).BeginInit(); + SuspendLayout(); + // + // buttonSave + // + buttonSave.Location = new Point(21, 538); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(81, 35); + buttonSave.TabIndex = 8; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; + // + // buttonLeave + // + buttonLeave.Location = new Point(179, 538); + buttonLeave.Name = "buttonLeave"; + buttonLeave.Size = new Size(92, 35); + buttonLeave.TabIndex = 9; + buttonLeave.Text = "Отмена"; + buttonLeave.UseVisualStyleBackColor = true; + buttonLeave.Click += buttonLeave_Click; + // + // groupBox1 + // + groupBox1.Controls.Add(dataGridViewRoutSheet); + groupBox1.Location = new Point(21, 145); + groupBox1.Name = "groupBox1"; + groupBox1.Size = new Size(250, 387); + groupBox1.TabIndex = 10; + groupBox1.TabStop = false; + groupBox1.Text = "Путевой Лист"; + // + // dataGridViewRoutSheet + // + dataGridViewRoutSheet.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewRoutSheet.Columns.AddRange(new DataGridViewColumn[] { ColumnBus }); + dataGridViewRoutSheet.Dock = DockStyle.Fill; + dataGridViewRoutSheet.Location = new Point(3, 19); + dataGridViewRoutSheet.Name = "dataGridViewRoutSheet"; + dataGridViewRoutSheet.Size = new Size(244, 365); + dataGridViewRoutSheet.TabIndex = 0; + // + // ColumnBus + // + ColumnBus.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + ColumnBus.HeaderText = "Автобус"; + ColumnBus.Name = "ColumnBus"; + ColumnBus.Resizable = DataGridViewTriState.True; + ColumnBus.SortMode = DataGridViewColumnSortMode.Automatic; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(12, 9); + label1.Name = "label1"; + label1.Size = new Size(58, 15); + label1.TabIndex = 11; + label1.Text = "Водитель"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(12, 46); + label2.Name = "label2"; + label2.Size = new Size(65, 15); + label2.TabIndex = 12; + label2.Text = "Кондуктор"; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(12, 88); + label3.Name = "label3"; + label3.Size = new Size(60, 15); + label3.TabIndex = 13; + label3.Text = "Маршрут"; + // + // comboBoxDriver + // + comboBoxDriver.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxDriver.FormattingEnabled = true; + comboBoxDriver.Location = new Point(83, 6); + comboBoxDriver.Name = "comboBoxDriver"; + comboBoxDriver.Size = new Size(188, 23); + comboBoxDriver.TabIndex = 15; + // + // comboBoxConductor + // + comboBoxConductor.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxConductor.FormattingEnabled = true; + comboBoxConductor.Location = new Point(83, 43); + comboBoxConductor.Name = "comboBoxConductor"; + comboBoxConductor.Size = new Size(188, 23); + comboBoxConductor.TabIndex = 16; + // + // comboBoxRout + // + comboBoxRout.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxRout.FormattingEnabled = true; + comboBoxRout.Location = new Point(83, 88); + comboBoxRout.Name = "comboBoxRout"; + comboBoxRout.Size = new Size(188, 23); + comboBoxRout.TabIndex = 17; + // + // FormRoutSheet + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(310, 582); + Controls.Add(comboBoxRout); + Controls.Add(comboBoxConductor); + Controls.Add(comboBoxDriver); + Controls.Add(label3); + Controls.Add(label2); + Controls.Add(label1); + Controls.Add(groupBox1); + Controls.Add(buttonLeave); + Controls.Add(buttonSave); + Name = "FormRoutSheet"; + Text = "Путевой Лист"; + groupBox1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewRoutSheet).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + private Button buttonSave; + private Button buttonLeave; + private GroupBox groupBox1; + private DataGridView dataGridViewRoutSheet; + private Label label1; + private Label label2; + private Label label3; + private ComboBox comboBoxDriver; + private ComboBox comboBoxConductor; + private ComboBox comboBoxRout; + private DataGridViewComboBoxColumn ColumnBus; + } +} \ No newline at end of file diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormRoutSheet.cs b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormRoutSheet.cs new file mode 100644 index 0000000..4986afe --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormRoutSheet.cs @@ -0,0 +1,71 @@ +using PIbd_24_EredavkinRA_BusBusiness.Entities; +using PIbd_24_EredavkinRA_BusBusiness.Repositories; + + +namespace PIbd_24_EredavkinRA_BusBusiness.Forms; + +public partial class FormRoutSheet : Form +{ + private readonly IRoutSheetRepository _routSheetRepository; + public FormRoutSheet(IBusRepository busRepository, IStaffRepositories staffRepositories, IRoutRepositories routRepositories, IRoutSheetRepository routSheetRepository) + { + InitializeComponent(); + _routSheetRepository = routSheetRepository ?? throw new ArgumentNullException(nameof(routSheetRepository)); + + comboBoxDriver.DataSource = staffRepositories.ReadStaff(); + comboBoxDriver.DisplayMember = "FirstName"; + comboBoxDriver.DisplayMember = "Id"; + + comboBoxConductor.DataSource = staffRepositories.ReadStaff(); + comboBoxConductor.DisplayMember = "FirstName"; + comboBoxConductor.DisplayMember = "Id"; + + comboBoxRout.DataSource = routRepositories.ReadRout(); + comboBoxRout.DisplayMember = "NumberRout"; + comboBoxRout.DisplayMember = "Id"; + + + + + } + + private void buttonSave_Click(object sender, EventArgs e) + { + try + { + if (dataGridViewRoutSheet.RowCount < 0 || comboBoxDriver.SelectedIndex < 0 || comboBoxRout.SelectedIndex < 0) + { + throw new Exception("Имеются не заполненые поля"); + } + _routSheetRepository.CreateRoutSheet(RoutSheet.CreatOpeartion(0, (int)comboBoxDriver.SelectedValue!, (int)comboBoxConductor.SelectedValue!, + (int)comboBoxRout.SelectedValue!, CreateListRoudSheetBusFromDataGrid())); + Close(); + } + catch(Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + + private void buttonLeave_Click(object sender, EventArgs e) => Close(); + + private List CreateListRoudSheetBusFromDataGrid() + { + var list = new List(); + foreach (DataGridViewRow row in dataGridViewRoutSheet.Rows) + { + if (row.Cells["ColumnBus"].Value == null) + + { + continue; + } + list.Add(RoutSheetBus.CreateElement(0, + Convert.ToInt32(row.Cells["ColumnBus"].Value))); + } + + return list; + } + + +} diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormRoutSheet.resx b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormRoutSheet.resx new file mode 100644 index 0000000..cc1fdd9 --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormRoutSheet.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 + + + True + + \ No newline at end of file diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormRoutSheetes.Designer.cs b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormRoutSheetes.Designer.cs new file mode 100644 index 0000000..f6ade19 --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormRoutSheetes.Designer.cs @@ -0,0 +1,91 @@ +namespace PIbd_24_EredavkinRA_BusBusiness.Forms +{ + partial class FormRoutSheetes + { + /// + /// 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() + { + panel1 = new Panel(); + buttonadd = new Button(); + dataGridView1 = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(buttonadd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(640, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(160, 450); + panel1.TabIndex = 0; + // + // buttonadd + // + buttonadd.BackgroundImage = Properties.Resources.add; + buttonadd.BackgroundImageLayout = ImageLayout.Stretch; + buttonadd.Location = new Point(40, 12); + buttonadd.Name = "buttonadd"; + buttonadd.Size = new Size(108, 76); + buttonadd.TabIndex = 0; + buttonadd.UseVisualStyleBackColor = true; + buttonadd.Click += buttonadd_Click; + // + // dataGridView1 + // + dataGridView1.AllowUserToAddRows = false; + dataGridView1.AllowUserToDeleteRows = false; + dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView1.Dock = DockStyle.Fill; + dataGridView1.Location = new Point(0, 0); + dataGridView1.Name = "dataGridView1"; + dataGridView1.ReadOnly = true; + dataGridView1.Size = new Size(640, 450); + dataGridView1.TabIndex = 1; + // + // FormRoutSheetes + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(dataGridView1); + Controls.Add(panel1); + Name = "FormRoutSheetes"; + Text = "Путевой лист"; + Load += FormRoutSheetes_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private DataGridView dataGridView1; + private Button buttonadd; + } +} \ No newline at end of file diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormRoutSheetes.cs b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormRoutSheetes.cs new file mode 100644 index 0000000..db3abcd --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormRoutSheetes.cs @@ -0,0 +1,53 @@ +using PIbd_24_EredavkinRA_BusBusiness.Repositories; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Unity; + +namespace PIbd_24_EredavkinRA_BusBusiness.Forms; + +public partial class FormRoutSheetes : Form +{ + private readonly IUnityContainer _container; + private readonly IRoutSheetRepository _routSheetRepository; + public FormRoutSheetes(IUnityContainer container, IRoutSheetRepository routSheetRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentException(nameof(container)); + _routSheetRepository = routSheetRepository ?? throw new ArgumentException(nameof(routSheetRepository)); + } + private void FormRoutSheetes_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 LoadList() => dataGridView1.DataSource = _routSheetRepository.ReadRoutSheet(); + + +} diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormRoutSheetes.resx b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormRoutSheetes.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormRoutSheetes.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/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormRoutes.Designer.cs b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormRoutes.Designer.cs new file mode 100644 index 0000000..5819e1f --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormRoutes.Designer.cs @@ -0,0 +1,125 @@ +namespace PIbd_24_EredavkinRA_BusBusiness.Forms +{ + partial class FormRoutes + { + /// + /// 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() + { + dataGridViewData = new DataGridView(); + panel1 = new Panel(); + buttonDel = new Button(); + buttonUpd = new Button(); + buttonAdd = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit(); + panel1.SuspendLayout(); + SuspendLayout(); + // + // dataGridViewData + // + dataGridViewData.AllowUserToAddRows = false; + dataGridViewData.AllowUserToDeleteRows = false; + dataGridViewData.AllowUserToResizeColumns = false; + dataGridViewData.AllowUserToResizeRows = false; + dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewData.Dock = DockStyle.Fill; + dataGridViewData.Location = new Point(0, 0); + dataGridViewData.MultiSelect = false; + dataGridViewData.Name = "dataGridViewData"; + dataGridViewData.ReadOnly = true; + dataGridViewData.RowHeadersVisible = false; + dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewData.Size = new Size(800, 450); + dataGridViewData.TabIndex = 2; + // + // panel1 + // + panel1.Controls.Add(buttonDel); + panel1.Controls.Add(buttonUpd); + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(650, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(150, 450); + panel1.TabIndex = 3; + // + // buttonDel + // + buttonDel.BackgroundImage = Properties.Resources.del; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(27, 211); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(99, 85); + buttonDel.TabIndex = 2; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += buttonDel_Click; + // + // buttonUpd + // + buttonUpd.BackgroundImage = Properties.Resources.rev; + buttonUpd.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpd.Location = new Point(27, 109); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(96, 76); + buttonUpd.TabIndex = 1; + buttonUpd.UseVisualStyleBackColor = true; + buttonUpd.Click += buttonUpd_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.add; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(27, 12); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(98, 78); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += buttonAdd_Click; + // + // FormRoutes + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(panel1); + Controls.Add(dataGridViewData); + Name = "FormRoutes"; + Text = "FormRoutes"; + Load += FormRoutes_Load; + ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); + panel1.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridViewData; + private Panel panel1; + private Button buttonDel; + private Button buttonUpd; + private Button buttonAdd; + } +} \ No newline at end of file diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormRoutes.cs b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormRoutes.cs new file mode 100644 index 0000000..14a05e7 --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormRoutes.cs @@ -0,0 +1,116 @@ +using PIbd_24_EredavkinRA_BusBusiness.Repositories; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Unity; + +namespace PIbd_24_EredavkinRA_BusBusiness.Forms; + +public partial class FormRoutes : Form +{ + private readonly IUnityContainer _container; + private readonly IRoutRepositories _routRepository; + + + + + public FormRoutes(IUnityContainer container, IRoutRepositories routRepository) + { + InitializeComponent(); + _container = container ?? + throw new ArgumentNullException(nameof(container)); + _routRepository = routRepository ?? + throw new ArgumentNullException(nameof(routRepository)); + } + private void FormRoutes_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 + { + _routRepository.DeleteRout(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + + private void LoadList() => dataGridViewData.DataSource = _routRepository.ReadRout(); + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridViewData.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ощибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value); + return true; + } + + +} diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormRoutes.resx b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormRoutes.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormRoutes.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/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormStaff.Designer.cs b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormStaff.Designer.cs new file mode 100644 index 0000000..2ce0af0 --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormStaff.Designer.cs @@ -0,0 +1,141 @@ +namespace PIbd_24_EredavkinRA_BusBusiness.Forms +{ + partial class FormStaff + { + /// + /// 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() + { + comboBoxPost = new ComboBox(); + textBoxLastName = new TextBox(); + textBoxFirstName = new TextBox(); + label1 = new Label(); + label2 = new Label(); + label3 = new Label(); + buttoтSave = new Button(); + buttonCancel = new Button(); + SuspendLayout(); + // + // comboBoxPost + // + comboBoxPost.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxPost.FormattingEnabled = true; + comboBoxPost.Location = new Point(132, 121); + comboBoxPost.Name = "comboBoxPost"; + comboBoxPost.Size = new Size(228, 23); + comboBoxPost.TabIndex = 0; + // + // textBoxLastName + // + textBoxLastName.Location = new Point(132, 12); + textBoxLastName.Name = "textBoxLastName"; + textBoxLastName.Size = new Size(228, 23); + textBoxLastName.TabIndex = 1; + // + // textBoxFirstName + // + textBoxFirstName.Location = new Point(132, 65); + textBoxFirstName.Name = "textBoxFirstName"; + textBoxFirstName.Size = new Size(228, 23); + textBoxFirstName.TabIndex = 2; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(21, 15); + label1.Name = "label1"; + label1.Size = new Size(34, 15); + label1.TabIndex = 3; + label1.Text = "Имя:"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(21, 65); + label2.Name = "label2"; + label2.Size = new Size(61, 15); + label2.TabIndex = 4; + label2.Text = "Фамилия:"; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(21, 124); + label3.Name = "label3"; + label3.Size = new Size(72, 15); + label3.TabIndex = 5; + label3.Text = "Должность:"; + // + // buttoтSave + // + buttoтSave.Location = new Point(52, 178); + buttoтSave.Name = "buttoтSave"; + buttoтSave.Size = new Size(75, 23); + buttoтSave.TabIndex = 6; + buttoтSave.Text = "Сохранить"; + buttoтSave.UseVisualStyleBackColor = true; + buttoтSave.Click += buttoтSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(228, 178); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(75, 23); + buttonCancel.TabIndex = 7; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += buttonCancel_Click; + // + // FormStaff + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(363, 213); + Controls.Add(buttonCancel); + Controls.Add(buttoтSave); + Controls.Add(label3); + Controls.Add(label2); + Controls.Add(label1); + Controls.Add(textBoxFirstName); + Controls.Add(textBoxLastName); + Controls.Add(comboBoxPost); + Name = "FormStaff"; + Text = "FormStaff"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private ComboBox comboBoxPost; + private TextBox textBoxLastName; + private TextBox textBoxFirstName; + private Label label1; + private Label label2; + private Label label3; + private Button buttoтSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormStaff.cs b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormStaff.cs new file mode 100644 index 0000000..091dbcf --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormStaff.cs @@ -0,0 +1,80 @@ +using PIbd_24_EredavkinRA_BusBusiness.Entities; +using PIbd_24_EredavkinRA_BusBusiness.Entities.Enums; +using PIbd_24_EredavkinRA_BusBusiness.Repositories; + + +namespace PIbd_24_EredavkinRA_BusBusiness.Forms; + +public partial class FormStaff : Form +{ + private readonly IStaffRepositories _staffRepository; + private int? _staffId; + public int Id + { + set + { + try + { + var staff = _staffRepository.ReadStaffByID(value); + if (staff == null) + { + throw new + InvalidDataException(nameof(staff)); + } + textBoxFirstName.Text = staff.FirstName; + textBoxLastName.Text = staff.LastName; + comboBoxPost.SelectedItem = staff.EmployeePost; + _staffId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + + + public FormStaff(IStaffRepositories staffRepositories) + { + InitializeComponent(); + _staffRepository = staffRepositories ?? + throw new ArgumentNullException(nameof(staffRepositories)); + comboBoxPost.DataSource = Enum.GetValues(typeof(EmployeePost)); + } + + private void buttoтSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxFirstName.Text) ||string.IsNullOrWhiteSpace(textBoxLastName.Text) || comboBoxPost.SelectedIndex < 1) + { + throw new Exception("Имеются незаполненныеполя"); + } + if (_staffId.HasValue) + { + _staffRepository.UpdateStaff(CreateStaff(_staffId.Value)); + } + else + { + _staffRepository.CreateStaff(CreateStaff(0)); + } + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonCancel_Click(object sender, EventArgs e) => Close(); + private Staff CreateStaff(int id) => Staff.CreatEntity(id, + textBoxFirstName.Text, + textBoxLastName.Text, + (EmployeePost)comboBoxPost.SelectedItem!); + + + + +} diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormStaff.resx b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormStaff.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormStaff.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/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormStaffes.Designer.cs b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormStaffes.Designer.cs new file mode 100644 index 0000000..ee38040 --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormStaffes.Designer.cs @@ -0,0 +1,125 @@ +namespace PIbd_24_EredavkinRA_BusBusiness.Forms +{ + partial class FormStaffes + { + /// + /// 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() + { + panel1 = new Panel(); + buttonDel = new Button(); + buttonUpd = new Button(); + buttonAdd = new Button(); + dataGridViewData = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(buttonDel); + panel1.Controls.Add(buttonUpd); + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(698, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(200, 586); + panel1.TabIndex = 0; + // + // buttonDel + // + buttonDel.BackgroundImage = Properties.Resources.del; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(54, 231); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(99, 85); + buttonDel.TabIndex = 3; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += buttonDel_Click; + // + // buttonUpd + // + buttonUpd.BackgroundImage = Properties.Resources.rev; + buttonUpd.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpd.Location = new Point(54, 119); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(96, 76); + buttonUpd.TabIndex = 2; + buttonUpd.UseVisualStyleBackColor = true; + buttonUpd.Click += buttonUpd_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.add; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(54, 23); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(98, 78); + buttonAdd.TabIndex = 1; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += buttonAdd_Click; + // + // dataGridViewData + // + dataGridViewData.AllowUserToAddRows = false; + dataGridViewData.AllowUserToDeleteRows = false; + dataGridViewData.AllowUserToResizeColumns = false; + dataGridViewData.AllowUserToResizeRows = false; + dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewData.Dock = DockStyle.Fill; + dataGridViewData.Location = new Point(0, 0); + dataGridViewData.MultiSelect = false; + dataGridViewData.Name = "dataGridViewData"; + dataGridViewData.ReadOnly = true; + dataGridViewData.RowHeadersVisible = false; + dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewData.Size = new Size(698, 586); + dataGridViewData.TabIndex = 2; + // + // FormStaffes + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(898, 586); + Controls.Add(dataGridViewData); + Controls.Add(panel1); + Name = "FormStaffes"; + Text = "Сотрудники"; + Load += FormStaffes_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private DataGridView dataGridViewData; + private Button buttonAdd; + private Button buttonUpd; + private Button buttonDel; + } +} \ No newline at end of file diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormStaffes.cs b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormStaffes.cs new file mode 100644 index 0000000..8537c53 --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormStaffes.cs @@ -0,0 +1,118 @@ +using PIbd_24_EredavkinRA_BusBusiness.Repositories; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Unity; + +namespace PIbd_24_EredavkinRA_BusBusiness.Forms +{ + public partial class FormStaffes : Form + { + private readonly IUnityContainer _container; + private readonly IStaffRepositories _staffRepository; + + + + + public FormStaffes(IUnityContainer container, IStaffRepositories staffRepository) + { + InitializeComponent(); + _container = container ?? + throw new ArgumentNullException(nameof(container)); + _staffRepository = staffRepository ?? + throw new ArgumentNullException(nameof(staffRepository)); + } + + 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 + { + _staffRepository.DeleteStaff(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + + private void LoadList() => dataGridViewData.DataSource = _staffRepository.ReadStaff(); + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridViewData.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ощибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value); + return true; + } + + private void FormStaffes_Load(object sender, EventArgs e) + { + + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } +} diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormStaffes.resx b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormStaffes.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormStaffes.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/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormTO.Designer.cs b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormTO.Designer.cs new file mode 100644 index 0000000..8ebf913 --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormTO.Designer.cs @@ -0,0 +1,189 @@ +namespace PIbd_24_EredavkinRA_BusBusiness.Forms +{ + partial class FormTO + { + /// + /// 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() + { + buttonSave = new Button(); + buttonLeave = new Button(); + comboBoxStaff = new ComboBox(); + label3 = new Label(); + label1 = new Label(); + dateTimePicker1 = new DateTimePicker(); + label2 = new Label(); + textBoxDescription = new TextBox(); + numericUpDownCost = new NumericUpDown(); + label4 = new Label(); + label5 = new Label(); + comboBoxBus = new ComboBox(); + ((System.ComponentModel.ISupportInitialize)numericUpDownCost).BeginInit(); + SuspendLayout(); + // + // buttonSave + // + buttonSave.Location = new Point(15, 391); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(94, 44); + buttonSave.TabIndex = 4; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; + // + // buttonLeave + // + buttonLeave.Location = new Point(248, 391); + buttonLeave.Name = "buttonLeave"; + buttonLeave.Size = new Size(106, 44); + buttonLeave.TabIndex = 5; + buttonLeave.Text = "Отмена"; + buttonLeave.UseVisualStyleBackColor = true; + buttonLeave.Click += buttonLeave_Click; + // + // comboBoxStaff + // + comboBoxStaff.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxStaff.FormattingEnabled = true; + comboBoxStaff.Location = new Point(98, 20); + comboBoxStaff.Name = "comboBoxStaff"; + comboBoxStaff.Size = new Size(245, 23); + comboBoxStaff.TabIndex = 7; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(10, 23); + label3.Name = "label3"; + label3.Size = new Size(59, 15); + label3.TabIndex = 9; + label3.Text = "Работник"; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(10, 119); + label1.Name = "label1"; + label1.Size = new Size(50, 15); + label1.TabIndex = 12; + label1.Text = "Дата ТО"; + // + // dateTimePicker1 + // + dateTimePicker1.Location = new Point(98, 111); + dateTimePicker1.Name = "dateTimePicker1"; + dateTimePicker1.Size = new Size(245, 23); + dateTimePicker1.TabIndex = 13; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(3, 159); + label2.Name = "label2"; + label2.Size = new Size(62, 15); + label2.TabIndex = 14; + label2.Text = "Описание"; + // + // textBoxDescription + // + textBoxDescription.Location = new Point(98, 159); + textBoxDescription.Multiline = true; + textBoxDescription.Name = "textBoxDescription"; + textBoxDescription.Size = new Size(238, 145); + textBoxDescription.TabIndex = 15; + // + // numericUpDownCost + // + numericUpDownCost.Location = new Point(105, 334); + numericUpDownCost.Name = "numericUpDownCost"; + numericUpDownCost.Size = new Size(238, 23); + numericUpDownCost.TabIndex = 16; + // + // label4 + // + label4.AutoSize = true; + label4.Location = new Point(15, 334); + label4.Name = "label4"; + label4.Size = new Size(67, 15); + label4.TabIndex = 17; + label4.Text = "Стоимость"; + // + // label5 + // + label5.AutoSize = true; + label5.Location = new Point(15, 77); + label5.Name = "label5"; + label5.Size = new Size(52, 15); + label5.TabIndex = 18; + label5.Text = "Автобус"; + // + // comboBoxBus + // + comboBoxBus.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxBus.FormattingEnabled = true; + comboBoxBus.Location = new Point(98, 69); + comboBoxBus.Name = "comboBoxBus"; + comboBoxBus.Size = new Size(245, 23); + comboBoxBus.TabIndex = 19; + // + // FormTO + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(380, 441); + Controls.Add(comboBoxBus); + Controls.Add(label5); + Controls.Add(label4); + Controls.Add(numericUpDownCost); + Controls.Add(textBoxDescription); + Controls.Add(label2); + Controls.Add(dateTimePicker1); + Controls.Add(label1); + Controls.Add(label3); + Controls.Add(comboBoxStaff); + Controls.Add(buttonLeave); + Controls.Add(buttonSave); + Name = "FormTO"; + Text = "Техническое обслуживание"; + ((System.ComponentModel.ISupportInitialize)numericUpDownCost).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + private Button buttonSave; + private Button buttonLeave; + private ComboBox comboBoxStaff; + private Label label3; + private Label label1; + private DateTimePicker dateTimePicker1; + private Label label2; + private TextBox textBoxDescription; + private NumericUpDown numericUpDownCost; + private Label label4; + private Label label5; + private ComboBox comboBoxBus; + } +} \ No newline at end of file diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormTO.cs b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormTO.cs new file mode 100644 index 0000000..0c66a83 --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormTO.cs @@ -0,0 +1,53 @@ +using PIbd_24_EredavkinRA_BusBusiness.Entities; +using PIbd_24_EredavkinRA_BusBusiness.Repositories; + + +namespace PIbd_24_EredavkinRA_BusBusiness.Forms; + +public partial class FormTO : Form +{ + private readonly IToRepository _toRepository; + + + public FormTO(IToRepository toRepository, IStaffRepositories staffRepositories, IBusRepository busRepository) + { + InitializeComponent(); + _toRepository = toRepository ?? throw new ArgumentNullException(nameof(toRepository)); + + comboBoxStaff.DataSource = staffRepositories.ReadStaff(); + comboBoxStaff.DisplayMember = "FirstName"; + comboBoxStaff.ValueMember = "Id"; + + comboBoxBus.DataSource = busRepository.ReadBus(); + comboBoxBus.DisplayMember = "N_Z"; + comboBoxBus.ValueMember = "Id"; + } + + private void buttonSave_Click(object sender, EventArgs e) + { + try + { + if (comboBoxStaff.SelectedIndex < 0 || comboBoxBus.SelectedIndex < 0 || string.IsNullOrWhiteSpace(textBoxDescription.Text)) + { + throw new Exception("Имеются не заполненые поля"); + } + _toRepository.CreateTo(To.CreatOperation(0, textBoxDescription.Text, Convert.ToInt32(numericUpDownCost.Value), (int)comboBoxBus.SelectedValue!, + (int)comboBoxStaff.SelectedValue!)); + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + + } + + + + private void buttonLeave_Click(object sender, EventArgs e) => Close(); + + + + +} diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormTO.resx b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormTO.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormTO.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/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormTOes.Designer.cs b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormTOes.Designer.cs new file mode 100644 index 0000000..73270af --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormTOes.Designer.cs @@ -0,0 +1,111 @@ +namespace PIbd_24_EredavkinRA_BusBusiness.Forms +{ + partial class FormTOes + { + /// + /// 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() + { + dataGridViewData = new DataGridView(); + panel1 = new Panel(); + buttonDel = new Button(); + buttonAdd = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit(); + panel1.SuspendLayout(); + SuspendLayout(); + // + // dataGridViewData + // + dataGridViewData.AllowUserToAddRows = false; + dataGridViewData.AllowUserToDeleteRows = false; + dataGridViewData.AllowUserToResizeColumns = false; + dataGridViewData.AllowUserToResizeRows = false; + dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewData.Dock = DockStyle.Fill; + dataGridViewData.Location = new Point(0, 0); + dataGridViewData.MultiSelect = false; + dataGridViewData.Name = "dataGridViewData"; + dataGridViewData.ReadOnly = true; + dataGridViewData.RowHeadersVisible = false; + dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewData.Size = new Size(800, 450); + dataGridViewData.TabIndex = 2; + // + // panel1 + // + panel1.Controls.Add(buttonDel); + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(650, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(150, 450); + panel1.TabIndex = 3; + // + // buttonDel + // + buttonDel.BackgroundImage = Properties.Resources.del; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(27, 211); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(99, 85); + buttonDel.TabIndex = 2; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += buttonDel_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.add; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(27, 12); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(98, 78); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += buttonAdd_Click; + // + // FormTOes + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(panel1); + Controls.Add(dataGridViewData); + Name = "FormTOes"; + Text = "FormTOes"; + Load += FormTOes_Load; + ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); + panel1.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridViewData; + private Panel panel1; + private Button buttonDel; + private Button buttonAdd; + } +} \ No newline at end of file diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormTOes.cs b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormTOes.cs new file mode 100644 index 0000000..b3dd1d6 --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormTOes.cs @@ -0,0 +1,98 @@ +using PIbd_24_EredavkinRA_BusBusiness.Repositories; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Unity; + +namespace PIbd_24_EredavkinRA_BusBusiness.Forms; + +public partial class FormTOes : Form +{ + private readonly IUnityContainer _container; + private readonly IToRepository _toRepository; + + + + + public FormTOes(IUnityContainer container, IToRepository toRepository) + { + InitializeComponent(); + _container = container ?? + throw new ArgumentNullException(nameof(container)); + _toRepository = toRepository ?? + throw new ArgumentNullException(nameof(toRepository)); + } + private void FormTOes_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 buttonDel_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + if (MessageBox.Show("Удалить запись?", "Удаление", + MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + try + { + _toRepository.DeleteTo(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + + private void LoadList() => dataGridViewData.DataSource = _toRepository.ReadTo(); + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridViewData.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ощибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value); + return true; + } + + +} diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormTOes.resx b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormTOes.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormTOes.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/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness.csproj b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness.csproj index 9e0bd83..e83911a 100644 --- a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness.csproj +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness.csproj @@ -9,4 +9,23 @@ enable + + + + + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + \ No newline at end of file diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Program.cs b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Program.cs index d5dee0a..0657312 100644 --- a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Program.cs +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Program.cs @@ -1,3 +1,7 @@ +using PIbd_24_EredavkinRA_BusBusiness.Repositories; +using PIbd_24_EredavkinRA_BusBusiness.Repositories.Implementations; +using Unity; + namespace PIbd_24_EredavkinRA_BusBusiness { internal static class Program @@ -11,7 +15,18 @@ namespace PIbd_24_EredavkinRA_BusBusiness // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new Form1()); + Application.Run(CreateContainer().Resolve()); + } + + private static IUnityContainer CreateContainer() + { + var container = new UnityContainer(); + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + return container; } } } \ No newline at end of file diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Properties/Resources.Designer.cs b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Properties/Resources.Designer.cs new file mode 100644 index 0000000..dde3891 --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Properties/Resources.Designer.cs @@ -0,0 +1,103 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace PIbd_24_EredavkinRA_BusBusiness.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("PIbd_24_EredavkinRA_BusBusiness.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 add { + get { + object obj = ResourceManager.GetObject("add", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap del { + get { + object obj = ResourceManager.GetObject("del", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap rev { + get { + object obj = ResourceManager.GetObject("rev", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap МАТП { + get { + object obj = ResourceManager.GetObject("МАТП", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Properties/Resources.resx b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Properties/Resources.resx new file mode 100644 index 0000000..1da836e --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Properties/Resources.resx @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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\МАТП.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\rev.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\add.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\del.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Repositories/IBusRepository.cs b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Repositories/IBusRepository.cs new file mode 100644 index 0000000..04e348a --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Repositories/IBusRepository.cs @@ -0,0 +1,20 @@ +using PIbd_24_EredavkinRA_BusBusiness.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PIbd_24_EredavkinRA_BusBusiness.Repositories; + +public interface IBusRepository +{ + IEnumerable ReadBus(); + Bus ReadBusByID(int id); + + void CreateBus(Bus bus); + + void UpdateBus(Bus bus); + + void DeleteBus(int id); +} diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Repositories/IRoutRepositories.cs b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Repositories/IRoutRepositories.cs new file mode 100644 index 0000000..13d3bbf --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Repositories/IRoutRepositories.cs @@ -0,0 +1,20 @@ +using PIbd_24_EredavkinRA_BusBusiness.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PIbd_24_EredavkinRA_BusBusiness.Repositories; + +public interface IRoutRepositories +{ + IEnumerable ReadRout(); + Rout ReadRoutByID(int id); + + void CreateRout(Rout rout); + + void UpdateRout(Rout rout); + + void DeleteRout(int id); +} diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Repositories/IRoutSheetRepository.cs b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Repositories/IRoutSheetRepository.cs new file mode 100644 index 0000000..52d6e5e --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Repositories/IRoutSheetRepository.cs @@ -0,0 +1,15 @@ +using PIbd_24_EredavkinRA_BusBusiness.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PIbd_24_EredavkinRA_BusBusiness.Repositories; + +public interface IRoutSheetRepository +{ + IEnumerable ReadRoutSheet(DateTime? dateForm = null, DateTime? dateTo = null, int? routId = null, int? busid = null, int? driverid = null, int? conductorid = null); + void CreateRoutSheet(RoutSheet routsheet); + void DeleteRoutSheet(int id); +} diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Repositories/IStaffRepositories.cs b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Repositories/IStaffRepositories.cs new file mode 100644 index 0000000..c32970b --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Repositories/IStaffRepositories.cs @@ -0,0 +1,20 @@ +using PIbd_24_EredavkinRA_BusBusiness.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PIbd_24_EredavkinRA_BusBusiness.Repositories; + +public interface IStaffRepositories +{ + IEnumerable ReadStaff(); + Staff ReadStaffByID(int id); + + void CreateStaff(Staff staff); + + void UpdateStaff(Staff staff); + + void DeleteStaff(int id); +} diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Repositories/IToRepository.cs b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Repositories/IToRepository.cs new file mode 100644 index 0000000..7d8ebda --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Repositories/IToRepository.cs @@ -0,0 +1,17 @@ +using PIbd_24_EredavkinRA_BusBusiness.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PIbd_24_EredavkinRA_BusBusiness.Repositories; + +public interface IToRepository +{ + IEnumerable ReadTo(DateTime? dateForm = null, DateTime? dateTo = null, int? mechanicid = null, int? busid = null); + + void CreateTo(To to); + + void DeleteTo(int id); +} diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Repositories/Implementations/BusRepository.cs b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Repositories/Implementations/BusRepository.cs new file mode 100644 index 0000000..0b9fbfc --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Repositories/Implementations/BusRepository.cs @@ -0,0 +1,37 @@ +using PIbd_24_EredavkinRA_BusBusiness.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PIbd_24_EredavkinRA_BusBusiness.Repositories.Implementations; + + +public class BusRepository : IBusRepository +{ + public void CreateBus(Bus bus) + { + + } + + public void DeleteBus(int id) + { + + } + + public IEnumerable ReadBus() + { + return []; + } + + public Bus ReadBusByID(int id) + { + return Bus.CreateEntity(0, string.Empty, string.Empty, 0, 0); + } + + public void UpdateBus(Bus bus) + { + + } +} diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Repositories/Implementations/RoutRepositories.cs b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Repositories/Implementations/RoutRepositories.cs new file mode 100644 index 0000000..641dd1e --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Repositories/Implementations/RoutRepositories.cs @@ -0,0 +1,36 @@ +using PIbd_24_EredavkinRA_BusBusiness.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PIbd_24_EredavkinRA_BusBusiness.Repositories.Implementations; + +public class RoutRepositories : IRoutRepositories +{ + public void CreateRout(Rout rout) + { + + } + + public void DeleteRout(int id) + { + + } + + public IEnumerable ReadRout() + { + return []; + } + + public Rout ReadRoutByID(int id) + { + return Rout.CreateEntity(0, string.Empty, string.Empty, 0); + } + + public void UpdateRout(Rout rout) + { + + } +} diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Repositories/Implementations/RoutSheetRepository.cs b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Repositories/Implementations/RoutSheetRepository.cs new file mode 100644 index 0000000..559f3ed --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Repositories/Implementations/RoutSheetRepository.cs @@ -0,0 +1,26 @@ +using PIbd_24_EredavkinRA_BusBusiness.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PIbd_24_EredavkinRA_BusBusiness.Repositories.Implementations; + +public class RoutSheetRepository : IRoutSheetRepository +{ + public void CreateRoutSheet(RoutSheet routsheet) + { + + } + + public void DeleteRoutSheet(int id) + { + + } + + public IEnumerable ReadRoutSheet(DateTime? dateForm = null, DateTime? dateTo = null, int? routId = null, int? busid = null, int? driverid = null, int? conductorid = null) + { + return []; + } +} diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Repositories/Implementations/StaffRepository.cs b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Repositories/Implementations/StaffRepository.cs new file mode 100644 index 0000000..73e5e52 --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Repositories/Implementations/StaffRepository.cs @@ -0,0 +1,37 @@ +using PIbd_24_EredavkinRA_BusBusiness.Entities; +using PIbd_24_EredavkinRA_BusBusiness.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PIbd_24_EredavkinRA_BusBusiness.Repositories.Implementations; + +internal class StaffRepository : IStaffRepositories +{ + public void CreateStaff(Staff staff) + { + + } + + public void DeleteStaff(int id) + { + + } + + public IEnumerable ReadStaff() + { + return []; + } + + public Staff ReadStaffByID(int id) + { + return Staff.CreatEntity(0, string.Empty, string.Empty, EmployeePost.None); + } + + public void UpdateStaff(Staff staff) + { + + } +} diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Repositories/Implementations/ToRepository.cs b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Repositories/Implementations/ToRepository.cs new file mode 100644 index 0000000..74a60c9 --- /dev/null +++ b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Repositories/Implementations/ToRepository.cs @@ -0,0 +1,27 @@ +using PIbd_24_EredavkinRA_BusBusiness.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PIbd_24_EredavkinRA_BusBusiness.Repositories.Implementations; + +public class ToRepository : IToRepository +{ + public void CreateTo(To to) + { + + } + + public void DeleteTo(int id) + { + + } + + public IEnumerable ReadTo(DateTime? dateForm = null, DateTime? dateTo = null, int? mechanicid = null, int? busid = null) + { + return []; + } + +} diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Resources/add.png b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Resources/add.png new file mode 100644 index 0000000..e4d9850 Binary files /dev/null and b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Resources/add.png differ diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Resources/del.png b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Resources/del.png new file mode 100644 index 0000000..1045e27 Binary files /dev/null and b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Resources/del.png differ diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Resources/rev.jpg b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Resources/rev.jpg new file mode 100644 index 0000000..4b4bb0c Binary files /dev/null and b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Resources/rev.jpg differ diff --git a/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Resources/МАТП.jpg b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Resources/МАТП.jpg new file mode 100644 index 0000000..5f3e39d Binary files /dev/null and b/PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Resources/МАТП.jpg differ