69 lines
1.9 KiB
C#
69 lines
1.9 KiB
C#
|
using BusinessLogics.BusinessLogics;
|
|||
|
using Contracts.BusinessLogicsContracts;
|
|||
|
using Contracts.ViewModels;
|
|||
|
using COP_V6;
|
|||
|
using DatabaseImplement.Models;
|
|||
|
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 Forms
|
|||
|
{
|
|||
|
public partial class FormMain : Form
|
|||
|
{
|
|||
|
private readonly IBookLogic _bookLogic;
|
|||
|
private readonly IAuthorLogic _authorLogic;
|
|||
|
public FormMain(IBookLogic bookLogic, IAuthorLogic authorLogic)
|
|||
|
{
|
|||
|
_bookLogic = bookLogic;
|
|||
|
_authorLogic = authorLogic;
|
|||
|
InitializeComponent();
|
|||
|
|
|||
|
List<Parameters> parameters = new List<Parameters>()
|
|||
|
{
|
|||
|
new Parameters("Идентификатор", 100, true, "Id"),
|
|||
|
new Parameters("Название", 100, true, "Name"),
|
|||
|
new Parameters("Автор", 100, true, "Surname"),
|
|||
|
new Parameters("Дата издания", 150, true, "Age")
|
|||
|
};
|
|||
|
controlDataGridView1.CreateColumns(parameters);
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
private void FormMain_Load(object sender, EventArgs e)
|
|||
|
{
|
|||
|
LoadMain();
|
|||
|
|
|||
|
}
|
|||
|
private void LoadMain()
|
|||
|
{
|
|||
|
controlDataGridView1.ClearCol();
|
|||
|
try
|
|||
|
{
|
|||
|
var books = _bookLogic.ReadList(null);
|
|||
|
if (books == null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
foreach (var book in books)
|
|||
|
{
|
|||
|
|
|||
|
controlDataGridView1.SetObject<BookViewModel>(book);
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|