private void buttonEdit_Click(object sender, EventArgs e) { if (listViewOrders.SelectedItems.Count == 1) { OrdersSet orders = listViewOrders.SelectedItems[0].Tag as OrdersSet; orders.idNameMaterial = Convert.ToInt32(comboBoxMaterials.SelectedItem.ToString().Split('.')[0]); orders.idClient = Convert.ToInt32(comboBoxClients.SelectedItem.ToString().Split('.')[0]); orders.idStaff = Convert.ToInt32(comboBoxStaff.SelectedItem.ToString().Split('.')[0]); orders.Date = textBoxDate.Text; Program.wftDb.SaveChanges(); ShowOrders(); } }
private void buttonAdd_Click(object sender, EventArgs e) { if (comboBoxMaterials.SelectedItem != null && comboBoxStaff.SelectedItem != null && comboBoxClients.SelectedItem != null && textBoxDate.Text != "") { OrdersSet orders = new OrdersSet(); orders.idNameMaterial = Convert.ToInt32(comboBoxMaterials.SelectedItem.ToString().Split('.')[0]); orders.idClient = Convert.ToInt32(comboBoxClients.SelectedItem.ToString().Split('.')[0]); orders.idStaff = Convert.ToInt32(comboBoxStaff.SelectedItem.ToString().Split('.')[0]); orders.Date = textBoxDate.Text; Program.wftDb.OrdersSet.Add(orders); Program.wftDb.SaveChanges(); ShowOrders(); } else { MessageBox.Show("Данные не выбраны", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void listViewOrders_SelectedIndexChanged(object sender, EventArgs e) { if (listViewOrders.SelectedItems.Count == 1) { OrdersSet orders = listViewOrders.SelectedItems[0].Tag as OrdersSet; comboBoxMaterials.SelectedIndex = comboBoxMaterials.FindString(orders.idNameMaterial.ToString()); comboBoxClients.SelectedIndex = comboBoxClients.FindString(orders.idClient.ToString()); comboBoxStaff.SelectedIndex = comboBoxStaff.FindString(orders.idStaff.ToString()); textBoxDate.Text = orders.Date; } else { comboBoxMaterials.SelectedItem = null; comboBoxClients.SelectedItem = null; comboBoxStaff.SelectedItem = null; textBoxDate.Text = ""; } }
private void buttonDel_Click(object sender, EventArgs e) { try { if (listViewOrders.SelectedItems.Count == 1) { OrdersSet orders = listViewOrders.SelectedItems[0].Tag as OrdersSet; Program.wftDb.OrdersSet.Remove(orders); Program.wftDb.SaveChanges(); ShowOrders(); } comboBoxMaterials.SelectedItem = null; comboBoxClients.SelectedItem = null; comboBoxStaff.SelectedItem = null; textBoxDate.Text = ""; } catch { MessageBox.Show("Невозможно удалить, эта запись используется", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }