private void addNamesToList <T>(ComboBox box) { if (typeof(T) == typeof(LClient)) { foreach (var client in ClientController.GetAllLClients()) { box.Items.Add(client.Name); } } else if (typeof(T) == typeof(ServiceType)) { foreach (var type in ServiceTypeController.GetAllTypes()) { box.Items.Add(type.Name); } } else if (typeof(T) == typeof(PClient)) { foreach (var client in ClientController.GetAllPClients()) { box.Items.Add(client.GetShortName()); } } else if (typeof(T) == typeof(Employee)) { foreach (var employee in EmployeeController.GetAllEmployees()) { box.Items.Add(employee.GetShortName()); } } }
private long getSumForSelectedServices(out List <ServiceType> selectedServices, out List <int> selectedCount) { selectedServices = new List <ServiceType>(); selectedCount = new List <int>(); long sum = 0; var types = ServiceTypeController.GetAllTypes(); if (types.Count == 0) { return(0); } foreach (var row in servicePanel.Controls.Cast <Panel>()) { var selectedService = types.First(t => t.Name == (row.Controls[1] as ComboBox)?.SelectedItem.ToString()); var count = Convert.ToInt32((row.Controls[3] as NumericUpDown)?.Value); sum += (selectedService.Price * count); selectedServices.Add(selectedService); selectedCount.Add(count); } return(sum); }
private void button1_Click(object sender, EventArgs e) { int type = radioButton1.Checked ? 0 : (radioButton2.Checked ? 1 : 2); switch (type) { case 0: var executedPurchases = ReportExecutor.GetAllExecutedPurchases(dateTimeFirst.Value, dateTimeSecond.Value); new ReportViewer(executedPurchases, type, dateTimeFirst.Value, dateTimeSecond.Value).ShowDialog(); break; case 1: var priceReportData = ReportExecutor.GetDataForPriceReport(dateTimeFirst.Value, dateTimeSecond.Value); new ReportViewer(priceReportData, type, dateTimeFirst.Value, dateTimeSecond.Value).ShowDialog(); break; case 2: new ReportViewer(ServiceTypeController.GetAllTypes(), type).ShowDialog(); break; default: break; } }