private void buttonEdit_Click(object sender, EventArgs e) { if (listViewRecord.SelectedItems.Count == 1) { RecordSet recordSet = listViewRecord.SelectedItems[0].Tag as RecordSet; recordSet.IdClient = Convert.ToInt32(comboBoxClient.SelectedItem.ToString().Split('.')[0]); recordSet.IdConfectioner = Convert.ToInt32(comboBoxConfectioner.SelectedItem.ToString().Split('.')[0]); recordSet.IdSweets = Convert.ToInt32(comboBoxSweets.SelectedItem.ToString().Split('.')[0]); recordSet.Prise = Convert.ToInt32(textBoxPrise.Text); Program.wftDb.SaveChanges(); ShowRecordSet(); } }
private void listViewRecord_SelectedIndexChanged(object sender, EventArgs e) { if (listViewRecord.SelectedItems.Count == 1) { RecordSet recordSet = listViewRecord.SelectedItems[0].Tag as RecordSet; comboBoxConfectioner.SelectedIndex = comboBoxConfectioner.FindString(recordSet.IdConfectioner.ToString()); comboBoxClient.SelectedIndex = comboBoxClient.FindString(recordSet.IdClient.ToString()); comboBoxSweets.SelectedIndex = comboBoxSweets.FindString(recordSet.IdSweets.ToString()); textBoxPrise.Text = recordSet.Prise.ToString(); } else { comboBoxConfectioner.SelectedItem = null; comboBoxClient.SelectedItem = null; comboBoxSweets.SelectedItem = null; textBoxPrise.Text = " "; } }
private void buttonAdd_Click(object sender, EventArgs e) { if (comboBoxConfectioner.SelectedItem != null && comboBoxClient.SelectedItem != null && comboBoxSweets.SelectedItem != null) { RecordSet recordSet = new RecordSet(); recordSet.IdConfectioner = Convert.ToInt32(comboBoxConfectioner.SelectedItem.ToString().Split('.')[0]); recordSet.IdClient = Convert.ToInt32(comboBoxClient.SelectedItem.ToString().Split('.')[0]); recordSet.IdSweets = Convert.ToInt32(comboBoxSweets.SelectedItem.ToString().Split('.')[0]); recordSet.Prise = Convert.ToInt32(textBoxPrise.Text); Program.wftDb.RecordSet.Add(recordSet); Program.wftDb.SaveChanges(); ShowRecordSet(); } else { MessageBox.Show("Данные не выбраны", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void buttonDel_Click(object sender, EventArgs e) { try { if (listViewRecord.SelectedItems.Count == 1) { RecordSet recordSet = listViewRecord.SelectedItems[0].Tag as RecordSet; Program.wftDb.RecordSet.Remove(recordSet); Program.wftDb.SaveChanges(); ShowRecordSet(); } comboBoxClient.SelectedItem = null; comboBoxConfectioner.SelectedItem = null; comboBoxSweets.SelectedItem = null; textBoxPrise.Text = ""; } catch { MessageBox.Show("Невозможно удалить, эту запись используется!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }