diff --git a/FuelAndLubricants/FuelAndLubricants/Form1.Designer.cs b/FuelAndLubricants/FuelAndLubricants/Form1.Designer.cs deleted file mode 100644 index 2978835..0000000 --- a/FuelAndLubricants/FuelAndLubricants/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace FuelAndLubricants -{ - 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/FuelAndLubricants/FuelAndLubricants/FormFuelAndLubricants.Designer.cs b/FuelAndLubricants/FuelAndLubricants/FormFuelAndLubricants.Designer.cs new file mode 100644 index 0000000..95ed9e6 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/FormFuelAndLubricants.Designer.cs @@ -0,0 +1,140 @@ +namespace FuelAndLubricants +{ + partial class FormFuelAndLubricants + { + /// + /// 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() + { + menuStrip = new MenuStrip(); + справочникиToolStripMenuItem = new ToolStripMenuItem(); + операцииToolStripMenuItem = new ToolStripMenuItem(); + отчетыToolStripMenuItem = new ToolStripMenuItem(); + машиныToolStripMenuItem = new ToolStripMenuItem(); + водителиToolStripMenuItem = new ToolStripMenuItem(); + топливоToolStripMenuItem = new ToolStripMenuItem(); + маршрутыToolStripMenuItem = new ToolStripMenuItem(); + заправкаToolStripMenuItem = new ToolStripMenuItem(); + поездкаToolStripMenuItem = new ToolStripMenuItem(); + menuStrip.SuspendLayout(); + SuspendLayout(); + // + // menuStrip + // + menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, операцииToolStripMenuItem, отчетыToolStripMenuItem }); + menuStrip.Location = new Point(0, 0); + menuStrip.Name = "menuStrip"; + menuStrip.Size = new Size(784, 24); + menuStrip.TabIndex = 0; + menuStrip.Text = "menuStrip1"; + // + // справочникиToolStripMenuItem + // + справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { машиныToolStripMenuItem, водителиToolStripMenuItem, топливоToolStripMenuItem, маршрутыToolStripMenuItem }); + справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; + справочникиToolStripMenuItem.Size = new Size(94, 20); + справочникиToolStripMenuItem.Text = "Справочники"; + // + // операцииToolStripMenuItem + // + операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { заправкаToolStripMenuItem, поездкаToolStripMenuItem }); + операцииToolStripMenuItem.Name = "операцииToolStripMenuItem"; + операцииToolStripMenuItem.Size = new Size(75, 20); + операцииToolStripMenuItem.Text = "Операции"; + // + // отчетыToolStripMenuItem + // + отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; + отчетыToolStripMenuItem.Size = new Size(60, 20); + отчетыToolStripMenuItem.Text = "Отчеты"; + // + // машиныToolStripMenuItem + // + машиныToolStripMenuItem.Name = "машиныToolStripMenuItem"; + машиныToolStripMenuItem.Size = new Size(180, 22); + машиныToolStripMenuItem.Text = "Машины"; + // + // водителиToolStripMenuItem + // + водителиToolStripMenuItem.Name = "водителиToolStripMenuItem"; + водителиToolStripMenuItem.Size = new Size(180, 22); + водителиToolStripMenuItem.Text = "Водители"; + // + // топливоToolStripMenuItem + // + топливоToolStripMenuItem.Name = "топливоToolStripMenuItem"; + топливоToolStripMenuItem.Size = new Size(180, 22); + топливоToolStripMenuItem.Text = "Топливо"; + // + // маршрутыToolStripMenuItem + // + маршрутыToolStripMenuItem.Name = "маршрутыToolStripMenuItem"; + маршрутыToolStripMenuItem.Size = new Size(180, 22); + маршрутыToolStripMenuItem.Text = "Маршруты"; + // + // заправкаToolStripMenuItem + // + заправкаToolStripMenuItem.Name = "заправкаToolStripMenuItem"; + заправкаToolStripMenuItem.Size = new Size(180, 22); + заправкаToolStripMenuItem.Text = "Заправка"; + // + // поездкаToolStripMenuItem + // + поездкаToolStripMenuItem.Name = "поездкаToolStripMenuItem"; + поездкаToolStripMenuItem.Size = new Size(180, 22); + поездкаToolStripMenuItem.Text = "Поездка"; + // + // FormFuelAndLubricants + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + BackgroundImage = Properties.Resources.ГСМ; + BackgroundImageLayout = ImageLayout.Stretch; + ClientSize = new Size(784, 411); + Controls.Add(menuStrip); + MainMenuStrip = menuStrip; + Name = "FormFuelAndLubricants"; + StartPosition = FormStartPosition.CenterScreen; + Text = "ГСМ"; + menuStrip.ResumeLayout(false); + menuStrip.PerformLayout(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private MenuStrip menuStrip; + private ToolStripMenuItem справочникиToolStripMenuItem; + private ToolStripMenuItem машиныToolStripMenuItem; + private ToolStripMenuItem водителиToolStripMenuItem; + private ToolStripMenuItem топливоToolStripMenuItem; + private ToolStripMenuItem маршрутыToolStripMenuItem; + private ToolStripMenuItem операцииToolStripMenuItem; + private ToolStripMenuItem заправкаToolStripMenuItem; + private ToolStripMenuItem поездкаToolStripMenuItem; + private ToolStripMenuItem отчетыToolStripMenuItem; + } +} diff --git a/FuelAndLubricants/FuelAndLubricants/Form1.cs b/FuelAndLubricants/FuelAndLubricants/FormFuelAndLubricants.cs similarity index 51% rename from FuelAndLubricants/FuelAndLubricants/Form1.cs rename to FuelAndLubricants/FuelAndLubricants/FormFuelAndLubricants.cs index 9d5b795..584f691 100644 --- a/FuelAndLubricants/FuelAndLubricants/Form1.cs +++ b/FuelAndLubricants/FuelAndLubricants/FormFuelAndLubricants.cs @@ -1,8 +1,8 @@ namespace FuelAndLubricants { - public partial class Form1 : Form + public partial class FormFuelAndLubricants : Form { - public Form1() + public FormFuelAndLubricants() { InitializeComponent(); } diff --git a/FuelAndLubricants/FuelAndLubricants/FormFuelAndLubricants.resx b/FuelAndLubricants/FuelAndLubricants/FormFuelAndLubricants.resx new file mode 100644 index 0000000..31084d5 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/FormFuelAndLubricants.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/FuelAndLubricants/FuelAndLubricants/Forms/FormDriver.Designer.cs b/FuelAndLubricants/FuelAndLubricants/Forms/FormDriver.Designer.cs new file mode 100644 index 0000000..d69f2c4 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Forms/FormDriver.Designer.cs @@ -0,0 +1,141 @@ +namespace FuelAndLubricants.Forms +{ + partial class FormDriver + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + label1 = new Label(); + textBoxDriverFirstname = new TextBox(); + textBoxDriverSecondname = new TextBox(); + label2 = new Label(); + label3 = new Label(); + buttonDriverSave = new Button(); + buttonDriverCancel = new Button(); + checkedListBoxDriverLicense = new CheckedListBox(); + SuspendLayout(); + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(13, 18); + label1.Name = "label1"; + label1.Size = new Size(31, 15); + label1.TabIndex = 0; + label1.Text = "Имя"; + // + // textBoxDriverFirstname + // + textBoxDriverFirstname.Location = new Point(111, 15); + textBoxDriverFirstname.Name = "textBoxDriverFirstname"; + textBoxDriverFirstname.Size = new Size(140, 23); + textBoxDriverFirstname.TabIndex = 1; + // + // textBoxDriverSecondname + // + textBoxDriverSecondname.Location = new Point(111, 44); + textBoxDriverSecondname.Name = "textBoxDriverSecondname"; + textBoxDriverSecondname.Size = new Size(140, 23); + textBoxDriverSecondname.TabIndex = 3; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(13, 47); + label2.Name = "label2"; + label2.Size = new Size(58, 15); + label2.TabIndex = 2; + label2.Text = "Фамилия"; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(13, 76); + label3.Name = "label3"; + label3.Size = new Size(92, 15); + label3.TabIndex = 4; + label3.Text = "Категория прав"; + // + // buttonDriverSave + // + buttonDriverSave.Location = new Point(13, 176); + buttonDriverSave.Name = "buttonDriverSave"; + buttonDriverSave.Size = new Size(75, 23); + buttonDriverSave.TabIndex = 6; + buttonDriverSave.Text = "Сохранить"; + buttonDriverSave.UseVisualStyleBackColor = true; + buttonDriverSave.Click += ButtonDriverSave_Click; + // + // buttonDriverCancel + // + buttonDriverCancel.Location = new Point(176, 176); + buttonDriverCancel.Name = "buttonDriverCancel"; + buttonDriverCancel.Size = new Size(75, 23); + buttonDriverCancel.TabIndex = 7; + buttonDriverCancel.Text = "Отмена"; + buttonDriverCancel.UseVisualStyleBackColor = true; + buttonDriverCancel.Click += ButtonDriverCancel_Click; + // + // checkedListBoxDriverLicense + // + checkedListBoxDriverLicense.FormattingEnabled = true; + checkedListBoxDriverLicense.Location = new Point(111, 76); + checkedListBoxDriverLicense.Name = "checkedListBoxDriverLicense"; + checkedListBoxDriverLicense.Size = new Size(140, 94); + checkedListBoxDriverLicense.TabIndex = 9; + // + // FormDriver + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(264, 211); + Controls.Add(checkedListBoxDriverLicense); + Controls.Add(buttonDriverCancel); + Controls.Add(buttonDriverSave); + Controls.Add(label3); + Controls.Add(textBoxDriverSecondname); + Controls.Add(label2); + Controls.Add(textBoxDriverFirstname); + Controls.Add(label1); + Name = "FormDriver"; + StartPosition = FormStartPosition.CenterParent; + Text = "Водитель"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label label1; + private TextBox textBoxDriverFirstname; + private TextBox textBoxDriverSecondname; + private Label label2; + private Label label3; + private Button buttonDriverSave; + private Button buttonDriverCancel; + private CheckedListBox checkedListBoxDriverLicense; + } +} \ No newline at end of file diff --git a/FuelAndLubricants/FuelAndLubricants/Forms/FormDriver.cs b/FuelAndLubricants/FuelAndLubricants/Forms/FormDriver.cs new file mode 100644 index 0000000..b67eb43 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Forms/FormDriver.cs @@ -0,0 +1,87 @@ +using FuelAndLubricants.Entities; +using FuelAndLubricants.Entities.Enums; +using FuelAndLubricants.Repositories; + +namespace FuelAndLubricants.Forms +{ + public partial class FormDriver : Form + { + private readonly IDriverRepository _driverRepository; + + private int? _driverId; + + public int Id + { + set + { + try + { + var driver = _driverRepository.ReadDriverByID(value); + if (driver == null) + throw new InvalidOperationException(nameof(driver)); + + foreach (Driver_License elem in Enum.GetValues(typeof(Driver_License))) + { + if ((elem & driver.Driver_License) != 0) + { + checkedListBoxDriverLicense.SetItemChecked(checkedListBoxDriverLicense.Items.IndexOf(elem), true); + } + } + + + textBoxDriverFirstname.Text = driver.Firstname; + textBoxDriverSecondname.Text = driver.Secondname; + _driverId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + + public FormDriver(IDriverRepository driverRepository) + { + InitializeComponent(); + _driverRepository = driverRepository ?? + throw new ArgumentNullException(nameof(driverRepository)); + + foreach (var elem in Enum.GetValues(typeof(Driver_License))) + checkedListBoxDriverLicense.Items.Add(elem); + } + + private void ButtonDriverSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxDriverFirstname.Text) || string.IsNullOrWhiteSpace(textBoxDriverSecondname.Text) || checkedListBoxDriverLicense.CheckedItems.Count == 0) + throw new Exception("Имеются незаполненные поля"); + + if (_driverId.HasValue) + _driverRepository.UpdateDriver(CreateDriver(_driverId.Value)); + else + _driverRepository.CreateDriver(CreateDriver(0)); + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonDriverCancel_Click(object sender, EventArgs e) => Close(); + + private Driver CreateDriver(int id) + { + Driver_License driver_License = Driver_License.None; + foreach (var elem in checkedListBoxDriverLicense.CheckedItems) + { + driver_License |= (Driver_License)elem; + } + + return Driver.CreateEntity(id, textBoxDriverFirstname.Text, textBoxDriverSecondname.Text, driver_License); + } + } +} diff --git a/FuelAndLubricants/FuelAndLubricants/Forms/FormDriver.resx b/FuelAndLubricants/FuelAndLubricants/Forms/FormDriver.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Forms/FormDriver.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/FuelAndLubricants/FuelAndLubricants/FuelAndLubricants.csproj b/FuelAndLubricants/FuelAndLubricants/FuelAndLubricants.csproj index 894afcd..accbdf0 100644 --- a/FuelAndLubricants/FuelAndLubricants/FuelAndLubricants.csproj +++ b/FuelAndLubricants/FuelAndLubricants/FuelAndLubricants.csproj @@ -12,4 +12,19 @@ + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + \ No newline at end of file diff --git a/FuelAndLubricants/FuelAndLubricants/Program.cs b/FuelAndLubricants/FuelAndLubricants/Program.cs index dd083d0..5ab9ffd 100644 --- a/FuelAndLubricants/FuelAndLubricants/Program.cs +++ b/FuelAndLubricants/FuelAndLubricants/Program.cs @@ -15,7 +15,7 @@ namespace FuelAndLubricants // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(CreateContainer().Resolve()); + Application.Run(CreateContainer().Resolve()); } private static UnityContainer CreateContainer() diff --git a/FuelAndLubricants/FuelAndLubricants/Properties/Resources.Designer.cs b/FuelAndLubricants/FuelAndLubricants/Properties/Resources.Designer.cs new file mode 100644 index 0000000..6091d21 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Properties/Resources.Designer.cs @@ -0,0 +1,73 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace FuelAndLubricants.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("FuelAndLubricants.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 ГСМ { + get { + object obj = ResourceManager.GetObject("ГСМ", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/FuelAndLubricants/FuelAndLubricants/Form1.resx b/FuelAndLubricants/FuelAndLubricants/Properties/Resources.resx similarity index 93% rename from FuelAndLubricants/FuelAndLubricants/Form1.resx rename to FuelAndLubricants/FuelAndLubricants/Properties/Resources.resx index 1af7de1..589857c 100644 --- a/FuelAndLubricants/FuelAndLubricants/Form1.resx +++ b/FuelAndLubricants/FuelAndLubricants/Properties/Resources.resx @@ -117,4 +117,8 @@ 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 + \ No newline at end of file diff --git a/FuelAndLubricants/FuelAndLubricants/Resources/ГСМ.jpg b/FuelAndLubricants/FuelAndLubricants/Resources/ГСМ.jpg new file mode 100644 index 0000000..5fcd8ee Binary files /dev/null and b/FuelAndLubricants/FuelAndLubricants/Resources/ГСМ.jpg differ