LabWork01_Hard: Лабраторная сдана, фиксы даты основания магазина

This commit is contained in:
Safgerd 2023-03-25 21:40:02 +04:00
parent e40428438f
commit bb968d63f9
8 changed files with 52 additions and 92 deletions

View File

@ -38,40 +38,40 @@
this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.buttonCancel = new System.Windows.Forms.Button(); this.buttonCancel = new System.Windows.Forms.Button();
this.buttonSave = new System.Windows.Forms.Button(); this.buttonSave = new System.Windows.Forms.Button();
this.foundingDateLabel = new System.Windows.Forms.Label();
this.foundingDateTimePicker = new System.Windows.Forms.DateTimePicker();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
// textBoxAddress // textBoxAddress
// //
this.textBoxAddress.Location = new System.Drawing.Point(88, 34); this.textBoxAddress.Location = new System.Drawing.Point(101, 45);
this.textBoxAddress.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.textBoxAddress.Name = "textBoxAddress"; this.textBoxAddress.Name = "textBoxAddress";
this.textBoxAddress.Size = new System.Drawing.Size(276, 23); this.textBoxAddress.Size = new System.Drawing.Size(315, 27);
this.textBoxAddress.TabIndex = 7; this.textBoxAddress.TabIndex = 7;
// //
// textBoxName // textBoxName
// //
this.textBoxName.Location = new System.Drawing.Point(88, 9); this.textBoxName.Location = new System.Drawing.Point(101, 12);
this.textBoxName.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.textBoxName.Name = "textBoxName"; this.textBoxName.Name = "textBoxName";
this.textBoxName.Size = new System.Drawing.Size(276, 23); this.textBoxName.Size = new System.Drawing.Size(315, 27);
this.textBoxName.TabIndex = 6; this.textBoxName.TabIndex = 6;
// //
// labelAddress // labelAddress
// //
this.labelAddress.AutoSize = true; this.labelAddress.AutoSize = true;
this.labelAddress.Location = new System.Drawing.Point(12, 38); this.labelAddress.Location = new System.Drawing.Point(14, 51);
this.labelAddress.Name = "labelAddress"; this.labelAddress.Name = "labelAddress";
this.labelAddress.Size = new System.Drawing.Size(43, 15); this.labelAddress.Size = new System.Drawing.Size(54, 20);
this.labelAddress.TabIndex = 5; this.labelAddress.TabIndex = 5;
this.labelAddress.Text = "Адрес:"; this.labelAddress.Text = "Адрес:";
// //
// labelName // labelName
// //
this.labelName.AutoSize = true; this.labelName.AutoSize = true;
this.labelName.Location = new System.Drawing.Point(12, 11); this.labelName.Location = new System.Drawing.Point(14, 15);
this.labelName.Name = "labelName"; this.labelName.Name = "labelName";
this.labelName.Size = new System.Drawing.Size(62, 15); this.labelName.Size = new System.Drawing.Size(80, 20);
this.labelName.TabIndex = 4; this.labelName.TabIndex = 4;
this.labelName.Text = "Название:"; this.labelName.Text = "Название:";
// //
@ -82,12 +82,11 @@
this.ColumnId, this.ColumnId,
this.ColumnCarName, this.ColumnCarName,
this.ColumnCount}); this.ColumnCount});
this.dataGridView.Location = new System.Drawing.Point(12, 61); this.dataGridView.Location = new System.Drawing.Point(14, 127);
this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.dataGridView.Name = "dataGridView"; this.dataGridView.Name = "dataGridView";
this.dataGridView.RowHeadersWidth = 51; this.dataGridView.RowHeadersWidth = 51;
this.dataGridView.RowTemplate.Height = 29; this.dataGridView.RowTemplate.Height = 29;
this.dataGridView.Size = new System.Drawing.Size(351, 251); this.dataGridView.Size = new System.Drawing.Size(401, 289);
this.dataGridView.TabIndex = 10; this.dataGridView.TabIndex = 10;
// //
// ColumnId // ColumnId
@ -114,10 +113,9 @@
// //
// buttonCancel // buttonCancel
// //
this.buttonCancel.Location = new System.Drawing.Point(200, 327); this.buttonCancel.Location = new System.Drawing.Point(229, 436);
this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonCancel.Name = "buttonCancel"; this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(136, 31); this.buttonCancel.Size = new System.Drawing.Size(155, 41);
this.buttonCancel.TabIndex = 12; this.buttonCancel.TabIndex = 12;
this.buttonCancel.Text = "Отмена"; this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true; this.buttonCancel.UseVisualStyleBackColor = true;
@ -125,20 +123,37 @@
// //
// buttonSave // buttonSave
// //
this.buttonSave.Location = new System.Drawing.Point(42, 327); this.buttonSave.Location = new System.Drawing.Point(48, 436);
this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonSave.Name = "buttonSave"; this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(136, 31); this.buttonSave.Size = new System.Drawing.Size(155, 41);
this.buttonSave.TabIndex = 11; this.buttonSave.TabIndex = 11;
this.buttonSave.Text = "Сохранить"; this.buttonSave.Text = "Сохранить";
this.buttonSave.UseVisualStyleBackColor = true; this.buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click); this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
// //
// foundingDateLabel
//
this.foundingDateLabel.AutoSize = true;
this.foundingDateLabel.Location = new System.Drawing.Point(14, 83);
this.foundingDateLabel.Name = "foundingDateLabel";
this.foundingDateLabel.Size = new System.Drawing.Size(121, 20);
this.foundingDateLabel.TabIndex = 13;
this.foundingDateLabel.Text = "Дата основания";
//
// foundingDateTimePicker
//
this.foundingDateTimePicker.Location = new System.Drawing.Point(141, 78);
this.foundingDateTimePicker.Name = "foundingDateTimePicker";
this.foundingDateTimePicker.Size = new System.Drawing.Size(274, 27);
this.foundingDateTimePicker.TabIndex = 14;
//
// FormShop // FormShop
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(389, 367); this.ClientSize = new System.Drawing.Size(445, 489);
this.Controls.Add(this.foundingDateTimePicker);
this.Controls.Add(this.foundingDateLabel);
this.Controls.Add(this.buttonCancel); this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonSave); this.Controls.Add(this.buttonSave);
this.Controls.Add(this.dataGridView); this.Controls.Add(this.dataGridView);
@ -146,13 +161,13 @@
this.Controls.Add(this.textBoxName); this.Controls.Add(this.textBoxName);
this.Controls.Add(this.labelAddress); this.Controls.Add(this.labelAddress);
this.Controls.Add(this.labelName); this.Controls.Add(this.labelName);
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.Name = "FormShop"; this.Name = "FormShop";
this.Text = "Магазин"; this.Text = "Магазин";
this.Load += new System.EventHandler(this.FormShop_Load); this.Load += new System.EventHandler(this.FormShop_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
} }
#endregion #endregion
@ -167,5 +182,7 @@
private DataGridViewTextBoxColumn ColumnId; private DataGridViewTextBoxColumn ColumnId;
private DataGridViewTextBoxColumn ColumnCarName; private DataGridViewTextBoxColumn ColumnCarName;
private DataGridViewTextBoxColumn ColumnCount; private DataGridViewTextBoxColumn ColumnCount;
private Label foundingDateLabel;
private DateTimePicker foundingDateTimePicker;
} }
} }

View File

@ -45,6 +45,7 @@ namespace AutomobilePlant
{ {
textBoxName.Text = view.Name; textBoxName.Text = view.Name;
textBoxAddress.Text = view.Address; textBoxAddress.Text = view.Address;
foundingDateTimePicker.Value = view.FoundingDate;
_shopCars = view.ShopCars ?? new Dictionary<int, (ICarModel, int)>(); _shopCars = view.ShopCars ?? new Dictionary<int, (ICarModel, int)>();
LoadData(); LoadData();
} }
@ -102,7 +103,8 @@ namespace AutomobilePlant
Id = _id ?? 0, Id = _id ?? 0,
Name = textBoxName.Text, Name = textBoxName.Text,
Address = textBoxAddress.Text, Address = textBoxAddress.Text,
OpeningDate = DateTime.Now FoundingDate = foundingDateTimePicker.Value.Date,
ShopCars= _shopCars
}; };
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);

View File

@ -1,64 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <root>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true"> <xsd:element name="root" msdata:IsDataSet="true">

View File

@ -104,7 +104,6 @@ namespace AutomobilePlantBusinessLogic.BusinessLogics
Id = shopElement.Id, Id = shopElement.Id,
Name = shopElement.Name, Name = shopElement.Name,
Address = shopElement.Address, Address = shopElement.Address,
OpeningDate = shopElement.OpeningDate,
ShopCars = shopElement.ShopCars ShopCars = shopElement.ShopCars
}); });

View File

@ -15,7 +15,7 @@ namespace AutomobilePlantContracts.BindingModels
public string Address { get; set; } = string.Empty; public string Address { get; set; } = string.Empty;
public DateTime OpeningDate { get; set; } public DateTime FoundingDate { get; set; }
public Dictionary<int, (ICarModel, int)> ShopCars { get; set; } public Dictionary<int, (ICarModel, int)> ShopCars { get; set; }
} }

View File

@ -18,8 +18,8 @@ namespace AutomobilePlantContracts.ViewModels
[DisplayName("Адрес")] [DisplayName("Адрес")]
public string Address { get; set; } = string.Empty; public string Address { get; set; } = string.Empty;
[DisplayName("Дата открытия")] [DisplayName("Дата основания")]
public DateTime OpeningDate { get; set; } public DateTime FoundingDate { get; set; }
public Dictionary<int, (ICarModel, int)> ShopCars { get; set; } = new(); public Dictionary<int, (ICarModel, int)> ShopCars { get; set; } = new();
} }

View File

@ -10,7 +10,7 @@ namespace AutomobilePlantDataModels.Models
{ {
string Name { get; } string Name { get; }
string Address { get; } string Address { get; }
DateTime OpeningDate { get; } DateTime FoundingDate { get; }
Dictionary<int, (ICarModel, int)> ShopCars { get; } Dictionary<int, (ICarModel, int)> ShopCars { get; }
} }
} }

View File

@ -19,6 +19,8 @@ namespace AutomobilePlantListImplements.Models
public DateTime OpeningDate { get; private set; } public DateTime OpeningDate { get; private set; }
public DateTime FoundingDate { get; private set; }
public Dictionary<int, (ICarModel, int)> ShopCars { get; private set; } = new(); public Dictionary<int, (ICarModel, int)> ShopCars { get; private set; } = new();
public static Shop? Create(ShopBindingModel model) public static Shop? Create(ShopBindingModel model)
@ -33,7 +35,7 @@ namespace AutomobilePlantListImplements.Models
Id = model.Id, Id = model.Id,
Name = model.Name, Name = model.Name,
Address = model.Address, Address = model.Address,
OpeningDate = model.OpeningDate, FoundingDate = model.FoundingDate,
ShopCars = new() ShopCars = new()
}; };
} }
@ -55,7 +57,7 @@ namespace AutomobilePlantListImplements.Models
Id = Id, Id = Id,
Name = Name, Name = Name,
Address = Address, Address = Address,
OpeningDate = OpeningDate, FoundingDate = FoundingDate,
ShopCars = ShopCars ShopCars = ShopCars
}; };
} }