private void FormReports_Load(object sender, EventArgs e) { List <ModelContractAgent> listCA = serviceCA.GetList(); if (listCA != null) { comboBoxAgent.DisplayMember = "Id"; comboBoxAgent.ValueMember = "AgentId"; comboBoxAgent.DataSource = listCA; comboBoxAgent.SelectedItem = 0; } dateTimePicker1.CustomFormat = "dd.MM.yyyy"; dateTimePicker1.Format = DateTimePickerFormat.Custom; dateTimePicker2.CustomFormat = "dd.MM.yyyy"; dateTimePicker2.Format = DateTimePickerFormat.Custom; }
private void LoadData() { try { List <ModelContractAgent> listCA = serviceCA.GetList(); if (listCA != null) { comboBoxAgent.DisplayMember = "Id"; comboBoxAgent.ValueMember = "Id"; comboBoxAgent.DataSource = listCA; comboBoxAgent.SelectedItem = null; } List <ModelClient> listC = serviceC.GetList(new DateTime().AddYears(2000), DateTime.Now.AddYears(10)); if (listC != null) { comboBoxClient.DisplayMember = "FIO"; comboBoxClient.ValueMember = "Id"; comboBoxClient.DataSource = listC; comboBoxClient.SelectedItem = null; } List <ModelServices> listS = serviceS.GetList(); if (listS != null) { toolStripComboBoxService.ComboBox.DisplayMember = "NameService"; toolStripComboBoxService.ComboBox.ValueMember = "Id"; toolStripComboBoxService.ComboBox.DataSource = listS; toolStripComboBoxService.ComboBox.SelectedItem = 0; } textBoxSum.Text = "0"; if (ID != null) { List <ModelDirectory> list = serviceCC.GetListDirection(ID); if (list != null) { dataGridView1.DataSource = list; dataGridView1.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dataGridView1.Columns[4].Visible = false; dataGridView1.Columns[5].Visible = false; } ModelContractClient elem = serviceCC.GetElement(Convert.ToInt32(ID)); if (elem != null) { ModelClient client = serviceC.GetElement(elem.ClientId); comboBoxAgent.Text = elem.AgentId + ""; comboBoxClient.Text = client.FIO; dateTimePicker1.Value = elem.DateStart; dateTimePicker2.Value = elem.DateEnd; } textBoxSum.Text = serviceCC.GetSum(Convert.ToInt32(ID)); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }