From c429a9c591185e1edace13a19ea9a7cba795928b Mon Sep 17 00:00:00 2001 From: F1rsTTeaM Date: Sun, 17 Nov 2024 17:12:27 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D1=84=D0=BE=D1=80=D0=BC=D1=8B=20=D0=B7=D0=B0=D0=BF?= =?UTF-8?q?=D1=80=D0=B0=D0=B2=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Forms/FormRefill.Designer.cs | 174 ++++++++++++++++++ .../FuelAndLubricants/Forms/FormRefill.cs | 43 +++++ .../FuelAndLubricants/Forms/FormRefill.resx | 120 ++++++++++++ 3 files changed, 337 insertions(+) create mode 100644 FuelAndLubricants/FuelAndLubricants/Forms/FormRefill.Designer.cs create mode 100644 FuelAndLubricants/FuelAndLubricants/Forms/FormRefill.cs create mode 100644 FuelAndLubricants/FuelAndLubricants/Forms/FormRefill.resx diff --git a/FuelAndLubricants/FuelAndLubricants/Forms/FormRefill.Designer.cs b/FuelAndLubricants/FuelAndLubricants/Forms/FormRefill.Designer.cs new file mode 100644 index 0000000..6fd5a9f --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Forms/FormRefill.Designer.cs @@ -0,0 +1,174 @@ +namespace FuelAndLubricants.Forms +{ + partial class FormRefill + { + /// + /// 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() + { + label4 = new Label(); + buttonCancel = new Button(); + buttonRefillSave = new Button(); + label2 = new Label(); + dateTimePickerRefillDate = new DateTimePicker(); + label1 = new Label(); + numericUpDownRefillAmount = new NumericUpDown(); + label3 = new Label(); + comboBoxCarID = new ComboBox(); + comboBoxFuelID = new ComboBox(); + ((System.ComponentModel.ISupportInitialize)numericUpDownRefillAmount).BeginInit(); + SuspendLayout(); + // + // label4 + // + label4.AutoSize = true; + label4.Location = new Point(11, 70); + label4.Name = "label4"; + label4.Size = new Size(54, 15); + label4.TabIndex = 31; + label4.Text = "Топливо"; + // + // buttonCancel + // + buttonCancel.Location = new Point(174, 135); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(75, 23); + buttonCancel.TabIndex = 28; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // buttonRefillSave + // + buttonRefillSave.Location = new Point(11, 135); + buttonRefillSave.Name = "buttonRefillSave"; + buttonRefillSave.Size = new Size(75, 23); + buttonRefillSave.TabIndex = 27; + buttonRefillSave.Text = "Сохранить"; + buttonRefillSave.UseVisualStyleBackColor = true; + buttonRefillSave.Click += ButtonSave_Click; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(11, 41); + label2.Name = "label2"; + label2.Size = new Size(72, 15); + label2.TabIndex = 24; + label2.Text = "Количество"; + // + // dateTimePickerRefillDate + // + dateTimePickerRefillDate.Location = new Point(109, 9); + dateTimePickerRefillDate.Name = "dateTimePickerRefillDate"; + dateTimePickerRefillDate.Size = new Size(140, 23); + dateTimePickerRefillDate.TabIndex = 34; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(11, 15); + label1.Name = "label1"; + label1.Size = new Size(85, 15); + label1.TabIndex = 35; + label1.Text = "Дата заправки"; + // + // numericUpDownRefillAmount + // + numericUpDownRefillAmount.DecimalPlaces = 2; + numericUpDownRefillAmount.Location = new Point(109, 39); + numericUpDownRefillAmount.Minimum = new decimal(new int[] { 1, 0, 0, 131072 }); + numericUpDownRefillAmount.Name = "numericUpDownRefillAmount"; + numericUpDownRefillAmount.Size = new Size(140, 23); + numericUpDownRefillAmount.TabIndex = 36; + numericUpDownRefillAmount.Value = new decimal(new int[] { 1, 0, 0, 131072 }); + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(11, 99); + label3.Name = "label3"; + label3.Size = new Size(55, 15); + label3.TabIndex = 38; + label3.Text = "Машина"; + // + // comboBoxCarID + // + comboBoxCarID.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxCarID.FormattingEnabled = true; + comboBoxCarID.Location = new Point(109, 96); + comboBoxCarID.Name = "comboBoxCarID"; + comboBoxCarID.Size = new Size(140, 23); + comboBoxCarID.TabIndex = 37; + // + // comboBoxFuelID + // + comboBoxFuelID.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxFuelID.FormattingEnabled = true; + comboBoxFuelID.Location = new Point(109, 67); + comboBoxFuelID.Name = "comboBoxFuelID"; + comboBoxFuelID.Size = new Size(140, 23); + comboBoxFuelID.TabIndex = 39; + // + // FormRefill + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(257, 165); + Controls.Add(comboBoxFuelID); + Controls.Add(label3); + Controls.Add(comboBoxCarID); + Controls.Add(numericUpDownRefillAmount); + Controls.Add(label1); + Controls.Add(dateTimePickerRefillDate); + Controls.Add(label4); + Controls.Add(buttonCancel); + Controls.Add(buttonRefillSave); + Controls.Add(label2); + Name = "FormRefill"; + Text = "FormRefill"; + ((System.ComponentModel.ISupportInitialize)numericUpDownRefillAmount).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label label5; + private NumericUpDown numericUpDownConsumptionRate; + private Label label4; + private ComboBox comboBoxCarType; + private CheckedListBox checkedListBoxDriverLicense; + private Button buttonCancel; + private Button buttonRefillSave; + private Label label2; + private DateTimePicker dateTimePickerRefillDate; + private Label label1; + private NumericUpDown numericUpDownRefillAmount; + private Label label3; + private ComboBox comboBoxCarID; + private ComboBox comboBoxFuelID; + } +} \ No newline at end of file diff --git a/FuelAndLubricants/FuelAndLubricants/Forms/FormRefill.cs b/FuelAndLubricants/FuelAndLubricants/Forms/FormRefill.cs new file mode 100644 index 0000000..61140f4 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Forms/FormRefill.cs @@ -0,0 +1,43 @@ +using FuelAndLubricants.Entities; +using FuelAndLubricants.Repositories; + +namespace FuelAndLubricants.Forms +{ + public partial class FormRefill : Form + { + private readonly IRefillRepository _refillRepository; + + public FormRefill(IRefillRepository refillRepository, IFuelRepository fuelRepository, ICarRepository carRepository) + { + InitializeComponent(); + + _refillRepository = refillRepository ?? + throw new ArgumentNullException(nameof(refillRepository)); + + comboBoxFuelID.DataSource = fuelRepository.ReadFuels(); + comboBoxFuelID.DisplayMember = "Fuel_Type"; + comboBoxFuelID.ValueMember = "Fuel_ID"; + + comboBoxCarID.DataSource = carRepository.ReadCars(); + comboBoxCarID.DisplayMember = "Car_Mark"; + comboBoxCarID.ValueMember = "Car_ID"; + } + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (comboBoxFuelID.SelectedIndex < 0 || comboBoxCarID.SelectedIndex < 0) + throw new Exception("Имеются незаполненные поля"); + + _refillRepository.CreateRefill(Refill.CreateOperation(0, dateTimePickerRefillDate.Value, (float)numericUpDownRefillAmount.Value, (int)comboBoxFuelID.SelectedValue!, (int)comboBoxCarID.SelectedValue!)); + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + } +} diff --git a/FuelAndLubricants/FuelAndLubricants/Forms/FormRefill.resx b/FuelAndLubricants/FuelAndLubricants/Forms/FormRefill.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/FuelAndLubricants/FuelAndLubricants/Forms/FormRefill.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