private void ButtonEdit_Click(object sender, EventArgs e) { if (listViewCustom.SelectedItems.Count == 1) { CustomSet customSet = listViewCustom.SelectedItems[0].Tag as CustomSet; customSet.IdClient = Convert.ToInt32(comboBoxClient.SelectedItem.ToString().Split('.')[0]); customSet.IdWorker = Convert.ToInt32(comboBoxWorker.SelectedItem.ToString().Split('.')[0]); customSet.IdProduct = Convert.ToInt32(comboBoxProduct.SelectedItem.ToString().Split('.')[0]); if (textBoxNumber.Text != "") { customSet.Number = Convert.ToInt32(textBoxNumber.Text); } customSet.Data = maskedTextBoxData.Text; Program.psDb.SaveChanges(); ShowCustom(); } }
private void ListViewCustom_SelectedIndexChanged(object sender, EventArgs e) { if (listViewCustom.SelectedItems.Count == 1) { CustomSet customSet = listViewCustom.SelectedItems[0].Tag as CustomSet; comboBoxClient.Text = customSet.IdClient.ToString() + "." + customSet.ClientSet.LastName + " " + customSet.ClientSet.FirstName + " " + customSet.ClientSet.MiddleName; comboBoxWorker.Text = customSet.IdWorker.ToString() + "." + customSet.WorkerSet.LastName + " " + customSet.WorkerSet.FirstName + " " + customSet.WorkerSet.MiddleName; comboBoxProduct.Text = customSet.IdProduct.ToString() + "." + customSet.ProductSet.Product; textBoxNumber.Text = customSet.Number.ToString(); maskedTextBoxData.Text = customSet.Data.ToString(); } else { comboBoxClient.Text = ""; comboBoxWorker.Text = ""; comboBoxProduct.Text = ""; textBoxNumber.Text = ""; maskedTextBoxData.Text = ""; } }
private void ButtonDel_Click(object sender, EventArgs e) { try { if (listViewCustom.SelectedItems.Count == 1) { CustomSet customSet = listViewCustom.SelectedItems[0].Tag as CustomSet; Program.psDb.CustomSet.Remove(customSet); Program.psDb.SaveChanges(); ShowProduct(); } comboBoxClient.Text = ""; comboBoxWorker.Text = ""; comboBoxProduct.Text = ""; textBoxNumber.Text = ""; maskedTextBoxData.Text = ""; ShowCustom(); } catch { MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void ButtonAdd_Click(object sender, EventArgs e) { if (comboBoxClient.SelectedItem != null && comboBoxWorker.SelectedItem != null && comboBoxProduct.SelectedItem != null) { CustomSet customSet = new CustomSet(); customSet.IdClient = Convert.ToInt32(comboBoxClient.SelectedItem.ToString().Split('.')[0]); customSet.IdWorker = Convert.ToInt32(comboBoxWorker.SelectedItem.ToString().Split('.')[0]); customSet.IdProduct = Convert.ToInt32(comboBoxProduct.SelectedItem.ToString().Split('.')[0]); if (textBoxNumber.Text != "") { customSet.Number = Convert.ToInt32(textBoxNumber.Text); } customSet.Data = maskedTextBoxData.Text; Program.psDb.CustomSet.Add(customSet); Program.psDb.SaveChanges(); ShowCustom(); } else { MessageBox.Show("Данные не выбраны", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information); } }