private void buttonAdd_Click(object sender, EventArgs e) { if (comboBoxAgent.SelectedItem != null && comboBoxClient.SelectedItem != null) { sdelkaSet sdelka = new sdelkaSet(); sdelka.Id__agent = Convert.ToInt32(comboBoxAgent.SelectedItem.ToString().Split()[0]); sdelka.Id_client = Convert.ToInt32(comboBoxClient.SelectedItem.ToString().Split()[0]); Program.BD.sdelkaSet.Add(sdelka); Program.BD.SaveChanges(); ShowVis(); } else { MessageBox.Show("данные не выбраны", "ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void listViewSdelka_SelectedIndexChanged(object sender, EventArgs e) { if (listViewSdelka.SelectedItems.Count == 1) { sdelkaSet sdelka = listViewSdelka.SelectedItems[0].Tag as sdelkaSet; comboBoxAgent.Text = Convert.ToString(sdelka.AgentSet.Id_agent); comboBoxAgent.Text = sdelka.AgentSet.Name; comboBoxAgent.Text = sdelka.AgentSet.Napravlenie; comboBoxClient.Text = Convert.ToString(sdelka.ClientSet.Last_Name); comboBoxClient.Text = Convert.ToString(sdelka.ClientSet.Phone); } else { comboBoxAgent.Text = ""; comboBoxAgent.Text = ""; comboBoxAgent.Text = ""; comboBoxClient.Text = ""; comboBoxClient.Text = ""; } }