Labwork_4 ИСЭбд-21 Мосевнин А. #5

Closed
Aleks_andr435 wants to merge 7 commits from Labwork_4 into Labwork_3
13 changed files with 52 additions and 67 deletions
Showing only changes of commit c8c1ec5714 - Show all commits

View File

@ -9,10 +9,9 @@ namespace ProjectLibrary.Entites
{ {
public class Book_Orders public class Book_Orders
{ {
[Browsable(false)]
public int BookID { get; private set; } public int BookID { get; private set; }
[Browsable(false)]
public int OrderID { get; private set; } public int OrderID { get; private set; }
[DisplayName("Количество")] [DisplayName("Количество")]

View File

@ -4,10 +4,8 @@ namespace ProjectLibrary.Entites
{ {
public class Book_Library public class Book_Library
{ {
[Browsable(false)]
public int BookID { get; private set; } public int BookID { get; private set; }
[Browsable(false)]
public int LibraryID { get; private set; } public int LibraryID { get; private set; }
[DisplayName("Количество")] [DisplayName("Количество")]
public int Count { get; private set; } public int Count { get; private set; }

View File

@ -40,57 +40,52 @@
dataGridViewBooks.AllowUserToAddRows = false; dataGridViewBooks.AllowUserToAddRows = false;
dataGridViewBooks.AllowUserToDeleteRows = false; dataGridViewBooks.AllowUserToDeleteRows = false;
dataGridViewBooks.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dataGridViewBooks.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewBooks.Location = new Point(10, 9); dataGridViewBooks.Location = new Point(11, 12);
dataGridViewBooks.Margin = new Padding(3, 2, 3, 2);
dataGridViewBooks.Name = "dataGridViewBooks"; dataGridViewBooks.Name = "dataGridViewBooks";
dataGridViewBooks.ReadOnly = true; dataGridViewBooks.ReadOnly = true;
dataGridViewBooks.RowHeadersWidth = 51; dataGridViewBooks.RowHeadersWidth = 51;
dataGridViewBooks.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dataGridViewBooks.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewBooks.Size = new Size(602, 254); dataGridViewBooks.Size = new Size(688, 339);
dataGridViewBooks.TabIndex = 8; dataGridViewBooks.TabIndex = 8;
// //
// buttonAdd // buttonAdd
// //
buttonAdd.Location = new Point(27, 267); buttonAdd.Location = new Point(31, 356);
buttonAdd.Margin = new Padding(3, 2, 3, 2);
buttonAdd.Name = "buttonAdd"; buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(161, 37); buttonAdd.Size = new Size(184, 49);
buttonAdd.TabIndex = 9; buttonAdd.TabIndex = 9;
buttonAdd.Text = "Добавить"; buttonAdd.Text = "Добавить";
buttonAdd.Click += buttonAdd_Click; buttonAdd.Click += buttonAdd_Click;
// //
// buttonUpdate // buttonUpdate
// //
buttonUpdate.Location = new Point(247, 267); buttonUpdate.Location = new Point(282, 356);
buttonUpdate.Margin = new Padding(3, 2, 3, 2);
buttonUpdate.Name = "buttonUpdate"; buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(161, 37); buttonUpdate.Size = new Size(184, 49);
buttonUpdate.TabIndex = 10; buttonUpdate.TabIndex = 10;
buttonUpdate.Text = "Изменить"; buttonUpdate.Text = "Изменить";
buttonUpdate.Click += buttonUpdate_Click; buttonUpdate.Click += buttonUpdate_Click;
// //
// buttonRemove // buttonRemove
// //
buttonRemove.Location = new Point(452, 267); buttonRemove.Location = new Point(517, 356);
buttonRemove.Margin = new Padding(3, 2, 3, 2);
buttonRemove.Name = "buttonRemove"; buttonRemove.Name = "buttonRemove";
buttonRemove.Size = new Size(161, 37); buttonRemove.Size = new Size(184, 49);
buttonRemove.TabIndex = 11; buttonRemove.TabIndex = 11;
buttonRemove.Text = "Удалить"; buttonRemove.Text = "Удалить";
buttonRemove.Click += buttonRemove_Click; buttonRemove.Click += buttonRemove_Click;
// //
// FBooks // FBooks
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(700, 338); ClientSize = new Size(800, 451);
Controls.Add(dataGridViewBooks); Controls.Add(dataGridViewBooks);
Controls.Add(buttonAdd); Controls.Add(buttonAdd);
Controls.Add(buttonUpdate); Controls.Add(buttonUpdate);
Controls.Add(buttonRemove); Controls.Add(buttonRemove);
Margin = new Padding(3, 2, 3, 2);
Name = "FBooks"; Name = "FBooks";
Text = "FBooks"; Text = "Книги";
Load += FBooks_Load; Load += FBooks_Load;
((System.ComponentModel.ISupportInitialize)dataGridViewBooks).EndInit(); ((System.ComponentModel.ISupportInitialize)dataGridViewBooks).EndInit();
ResumeLayout(false); ResumeLayout(false);

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<root> <root>
<!-- <!--
Microsoft ResX Schema Microsoft ResX Schema
Version 2.0 Version 2.0
@ -48,7 +48,7 @@
value : The object must be serialized with value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64 mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter : System.Runtime.Serialization.Formatters.Soap.SoapFormatter

View File

@ -40,56 +40,53 @@
dataGridViewOrders.AllowUserToAddRows = false; dataGridViewOrders.AllowUserToAddRows = false;
dataGridViewOrders.AllowUserToDeleteRows = false; dataGridViewOrders.AllowUserToDeleteRows = false;
dataGridViewOrders.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dataGridViewOrders.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewOrders.Location = new Point(12, 11); dataGridViewOrders.Location = new Point(14, 15);
dataGridViewOrders.Margin = new Padding(3, 2, 3, 2);
dataGridViewOrders.Name = "dataGridViewOrders"; dataGridViewOrders.Name = "dataGridViewOrders";
dataGridViewOrders.ReadOnly = true; dataGridViewOrders.ReadOnly = true;
dataGridViewOrders.RowHeadersWidth = 51; dataGridViewOrders.RowHeadersWidth = 51;
dataGridViewOrders.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dataGridViewOrders.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewOrders.Size = new Size(525, 225); dataGridViewOrders.Size = new Size(600, 300);
dataGridViewOrders.TabIndex = 8; dataGridViewOrders.TabIndex = 8;
// //
// buttonAdd // buttonAdd
// //
buttonAdd.Location = new Point(12, 251); buttonAdd.Location = new Point(14, 335);
buttonAdd.Margin = new Padding(3, 2, 3, 2);
buttonAdd.Name = "buttonAdd"; buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(88, 22); buttonAdd.Size = new Size(101, 29);
buttonAdd.TabIndex = 9; buttonAdd.TabIndex = 9;
buttonAdd.Text = "Добавить"; buttonAdd.Text = "Добавить";
buttonAdd.Click += buttonAdd_Click; buttonAdd.Click += buttonAdd_Click;
// //
// buttonUpdate // buttonUpdate
// //
buttonUpdate.Location = new Point(227, 251); buttonUpdate.Location = new Point(259, 335);
buttonUpdate.Margin = new Padding(3, 2, 3, 2);
buttonUpdate.Name = "buttonUpdate"; buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(88, 22); buttonUpdate.Size = new Size(101, 29);
buttonUpdate.TabIndex = 10; buttonUpdate.TabIndex = 10;
buttonUpdate.Text = "Изменить"; buttonUpdate.Text = "Изменить";
buttonUpdate.Click += buttonUpdate_Click; buttonUpdate.Click += buttonUpdate_Click;
// //
// buttonRemove // buttonRemove
// //
buttonRemove.Location = new Point(450, 251); buttonRemove.Location = new Point(514, 335);
buttonRemove.Margin = new Padding(3, 2, 3, 2);
buttonRemove.Name = "buttonRemove"; buttonRemove.Name = "buttonRemove";
buttonRemove.Size = new Size(88, 22); buttonRemove.Size = new Size(101, 29);
buttonRemove.TabIndex = 11; buttonRemove.TabIndex = 11;
buttonRemove.Text = "Удалить"; buttonRemove.Text = "Удалить";
buttonRemove.Click += buttonRemove_Click; buttonRemove.Click += buttonRemove_Click;
// //
// FLibraries // FLibraries
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(562, 283); ClientSize = new Size(642, 377);
Controls.Add(dataGridViewOrders); Controls.Add(dataGridViewOrders);
Controls.Add(buttonAdd); Controls.Add(buttonAdd);
Controls.Add(buttonUpdate); Controls.Add(buttonUpdate);
Controls.Add(buttonRemove); Controls.Add(buttonRemove);
Margin = new Padding(3, 4, 3, 4);
Name = "FLibraries"; Name = "FLibraries";
Text = "FLibraries"; Text = "Библиотеки";
Load += FLibraries_Load; Load += FLibraries_Load;
((System.ComponentModel.ISupportInitialize)dataGridViewOrders).EndInit(); ((System.ComponentModel.ISupportInitialize)dataGridViewOrders).EndInit();
ResumeLayout(false); ResumeLayout(false);

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<root> <root>
<!-- <!--
Microsoft ResX Schema Microsoft ResX Schema
Version 2.0 Version 2.0
@ -48,7 +48,7 @@
value : The object must be serialized with value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64 mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter : System.Runtime.Serialization.Formatters.Soap.SoapFormatter

View File

@ -82,7 +82,7 @@
buttonCreate.UseVisualStyleBackColor = false; buttonCreate.UseVisualStyleBackColor = false;
buttonCreate.Click += ButtonCreate_Click; buttonCreate.Click += ButtonCreate_Click;
// //
// FormOrderDistributionReport // FOrderDistributionReport
// //
AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
@ -92,8 +92,8 @@
Controls.Add(label1); Controls.Add(label1);
Controls.Add(labelFileName); Controls.Add(labelFileName);
Controls.Add(buttonSelectFileName); Controls.Add(buttonSelectFileName);
Name = "FormOrderDistributionReport"; Name = "FOrderDistributionReport";
Text = "FormInvoiceDistributionReport"; Text = "Количество книг в библиотеках";
ResumeLayout(false); ResumeLayout(false);
PerformLayout(); PerformLayout();
} }

View File

@ -74,7 +74,7 @@
Controls.Add(buttonAdd); Controls.Add(buttonAdd);
Controls.Add(buttonRemove); Controls.Add(buttonRemove);
Name = "FOrders"; Name = "FOrders";
Text = "FOrders"; Text = "Заказы";
Load += FOrders_Load; Load += FOrders_Load;
((System.ComponentModel.ISupportInitialize)dataGridViewOrders).EndInit(); ((System.ComponentModel.ISupportInitialize)dataGridViewOrders).EndInit();
ResumeLayout(false); ResumeLayout(false);

View File

@ -39,45 +39,43 @@
dataGridView.AllowUserToAddRows = false; dataGridView.AllowUserToAddRows = false;
dataGridView.AllowUserToDeleteRows = false; dataGridView.AllowUserToDeleteRows = false;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Location = new Point(12, 11); dataGridView.Location = new Point(14, 15);
dataGridView.Margin = new Padding(3, 2, 3, 2);
dataGridView.Name = "dataGridView"; dataGridView.Name = "dataGridView";
dataGridView.ReadOnly = true; dataGridView.ReadOnly = true;
dataGridView.RowHeadersWidth = 51; dataGridView.RowHeadersWidth = 51;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(525, 225); dataGridView.Size = new Size(600, 300);
dataGridView.TabIndex = 8; dataGridView.TabIndex = 8;
// //
// buttonAdd // buttonAdd
// //
buttonAdd.Location = new Point(12, 251); buttonAdd.Location = new Point(14, 335);
buttonAdd.Margin = new Padding(3, 2, 3, 2);
buttonAdd.Name = "buttonAdd"; buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(88, 22); buttonAdd.Size = new Size(101, 29);
buttonAdd.TabIndex = 9; buttonAdd.TabIndex = 9;
buttonAdd.Text = "Добавить"; buttonAdd.Text = "Добавить";
buttonAdd.Click += buttonAdd_Click; buttonAdd.Click += buttonAdd_Click;
// //
// buttonUpdate // buttonUpdate
// //
buttonUpdate.Location = new Point(227, 251); buttonUpdate.Location = new Point(259, 335);
buttonUpdate.Margin = new Padding(3, 2, 3, 2);
buttonUpdate.Name = "buttonUpdate"; buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(88, 22); buttonUpdate.Size = new Size(101, 29);
buttonUpdate.TabIndex = 10; buttonUpdate.TabIndex = 10;
buttonUpdate.Text = "Изменить"; buttonUpdate.Text = "Изменить";
buttonUpdate.Click += buttonUpdate_Click; buttonUpdate.Click += buttonUpdate_Click;
// //
// FTiclet_Extensions // FTiclet_Extensions
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(569, 293); ClientSize = new Size(650, 391);
Controls.Add(dataGridView); Controls.Add(dataGridView);
Controls.Add(buttonAdd); Controls.Add(buttonAdd);
Controls.Add(buttonUpdate); Controls.Add(buttonUpdate);
Margin = new Padding(3, 4, 3, 4);
Name = "FTiclet_Extensions"; Name = "FTiclet_Extensions";
Text = "FTiclet_Extensions"; Text = "Продления билетов";
Load += FTiclet_Extensions_Load; Load += FTiclet_Extensions_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false); ResumeLayout(false);

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<root> <root>
<!-- <!--
Microsoft ResX Schema Microsoft ResX Schema
Version 2.0 Version 2.0
@ -48,7 +48,7 @@
value : The object must be serialized with value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64 mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter : System.Runtime.Serialization.Formatters.Soap.SoapFormatter

View File

@ -39,8 +39,8 @@ public class ChartReport
{ {
return _orderRepository return _orderRepository
.ReadOrders() .ReadOrders()
.GroupBy(x => x.BookOrders.First(y => y.OrderID == x.Id).BookID , (key, group) => new { ID = key, Count = group.Sum(y => y.BookOrders.First(z => z.OrderID == y.Id).Count) }) .GroupBy(x => x.BookOrders.First(y => y.OrderID == x.Id).BookName , (key, group) => new { Name = key, Count = group.Sum(y => y.BookOrders.First(z => z.OrderID == y.Id).Count) })
.Select(x => (x.ID.ToString(), (double)x.Count)) .Select(x => (x.Name, (double)x.Count))
.ToList(); .ToList();
} }
} }

View File

@ -42,9 +42,6 @@ public class TableReport
private List<string[]> GetData(DateTime? startDate = null, DateTime? endDate = null) private List<string[]> GetData(DateTime? startDate = null, DateTime? endDate = null)
{ {
var s = _orderRepository
.ReadOrders(StartDate: startDate, EndDate: endDate);
var data = _orderRepository var data = _orderRepository
.ReadOrders(StartDate: startDate, EndDate: endDate) .ReadOrders(StartDate: startDate, EndDate: endDate)
.Select(x => new .Select(x => new
@ -52,7 +49,7 @@ public class TableReport
x.Id, x.Id,
DateOrder = x.OrderDate, DateOrder = x.OrderDate,
DateReturn = x.ReturnDate, DateReturn = x.ReturnDate,
Book = x.BookOrders.FirstOrDefault(y => y.OrderID == x.Id)?.BookID,//вот эти данные не вставляются в эксель Book = x.BookOrders.FirstOrDefault(y => y.OrderID == x.Id)?.BookName,
Count = x.BookOrders.FirstOrDefault(y => y.OrderID == x.Id)?.Count Count = x.BookOrders.FirstOrDefault(y => y.OrderID == x.Id)?.Count
}) })
.OrderBy(x => x.Id); .OrderBy(x => x.Id);
@ -61,7 +58,7 @@ public class TableReport
.Union( .Union(
data data
.Select(x => new string[] { x.Id.ToString(), x.DateOrder.ToString("dd.MM.yyyy"), x.DateReturn.ToString("dd.MM.yyyy"), .Select(x => new string[] { x.Id.ToString(), x.DateOrder.ToString("dd.MM.yyyy"), x.DateReturn.ToString("dd.MM.yyyy"),
x.Book?.ToString("N0") ?? string.Empty, x.Count?.ToString("N0") ?? string.Empty})) x.Book?.ToString() ?? string.Empty, x.Count?.ToString("N0") ?? string.Empty}))
.Union([["Всего", "", "", "", data.Sum(x => x.Count ?? 0).ToString("N0")]]) .Union([["Всего", "", "", "", data.Sum(x => x.Count ?? 0).ToString("N0")]])
.ToList(); .ToList();
//return null; //return null;
Review

Закомментированного кода быть не должно

Закомментированного кода быть не должно

View File

@ -123,9 +123,9 @@ namespace ProjectLibrary.Repositories.Implementations
{ {
builder.AddCollerction("ord.ReturnDate < @EndDate"); builder.AddCollerction("ord.ReturnDate < @EndDate");
}*/ }*/
var querySelect = $@"SELECT ord.*, var querySelect = $@"SELECT ord.*, bk.Name as BookName,
bk.Name as BookName, Obo.bookid as bookid,
Obo.bookid as bookid Obo.Orderid, obo.count
FROM Orders ord FROM Orders ord
INNER JOIN Book_Orders Obo ON Obo.orderId = ord.Id INNER JOIN Book_Orders Obo ON Obo.orderId = ord.Id
Inner join book bk on bk.ID = obo.Bookid Inner join book bk on bk.ID = obo.Bookid
@ -140,6 +140,7 @@ namespace ProjectLibrary.Repositories.Implementations
Book_Orders = []; Book_Orders = [];
OrderBookDict.Add(orders.Id, Book_Orders); OrderBookDict.Add(orders.Id, Book_Orders);
} }
books_orders.BookName = orders.BookName;
Book_Orders.Add(books_orders); Book_Orders.Add(books_orders);
return orders; return orders;
}, },