using CarRentContracts.BusinessLogicContracts; 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 CarRent { public partial class FormRentals : Form { private readonly IRentalLogic _rentalLogic; private readonly IClientLogic _clientLogic; public FormRentals(IRentalLogic rentalLogic, IClientLogic clientLogic) { InitializeComponent(); _rentalLogic = rentalLogic; _clientLogic = clientLogic; } private void LoadData() { try { var list = _rentalLogic.ReadList(null); var listClients = _clientLogic.ReadList(null); if (list != null) { dataGridView.DataSource = list; dataGridView.Columns["ClientId"].Visible = false; dataGridView.Columns["CarId"].Visible = false; dataGridView.Columns["Id"].Visible = false; } if (listClients != null) { comboBoxClientsEmail.DisplayMember = "Email"; comboBoxClientsEmail.ValueMember = "Id"; comboBoxClientsEmail.DataSource = listClients; comboBoxClientsEmail.SelectedItem = null; } } catch (Exception ex) {} } private void филиалыToolStripMenuItem_Click(object sender, EventArgs e) { var service = Program.ServiceProvider?.GetService(typeof(FormBranches)); if (service is FormBranches form) { form.ShowDialog(); LoadData(); } } private void автомобилиToolStripMenuItem_Click(object sender, EventArgs e) { var service = Program.ServiceProvider?.GetService(typeof(FormCars)); if (service is FormCars form) { form.ShowDialog(); LoadData(); } } private void клиентыToolStripMenuItem_Click(object sender, EventArgs e) { var service = Program.ServiceProvider?.GetService(typeof(FormClients)); if (service is FormClients form) { form.ShowDialog(); LoadData(); } } private void buttonAdd_Click(object sender, EventArgs e) { var service = Program.ServiceProvider?.GetService(typeof(FormCreateRental)); if (service is FormCreateRental form) { form.ShowDialog(); LoadData(); } } private void buttonUpdate_Click(object sender, EventArgs e) { LoadData(); } private void FormRentals_Load(object sender, EventArgs e) { LoadData(); } private void buttonAddReview_Click(object sender, EventArgs e) { if (dataGridView.SelectedRows.Count == 1) { var service = Program.ServiceProvider?.GetService(typeof(FormAddReview)); if (service is FormAddReview form) { form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); form.ShowDialog(); LoadData(); } } } private void testsToolStripMenuItem_Click(object sender, EventArgs e) { var service = Program.ServiceProvider?.GetService(typeof(FormTests)); if (service is FormTests form) { form.ShowDialog(); LoadData(); } } } }