private void buttonAdd_Click(object sender, EventArgs e) { AdsSet adsSet = new AdsSet(); adsSet.Num = textBoxNum.Text; adsSet.Obem = textBoxObem.Text; adsSet.IdOrg = Convert.ToInt32(comboBoxOrgId.SelectedItem.ToString().Split('.')[0]); adsSet.IdGaz = Convert.ToInt32(comboBoxGazId.SelectedItem.ToString().Split('.')[0]); Program.dailyDB.AdsSet.Add(adsSet); Program.dailyDB.SaveChanges(); ShowAds(); ShowO(); ShowG(); }
private void buttonEdit_Click(object sender, EventArgs e) { if (listViewAds.SelectedItems.Count == 1) { AdsSet adsSet = listViewAds.SelectedItems[0].Tag as AdsSet; adsSet.Num = textBoxNum.Text; adsSet.Obem = textBoxObem.Text; adsSet.IdOrg = Convert.ToInt32(comboBoxOrgId.SelectedItem.ToString().Split('.')[0]); adsSet.IdGaz = Convert.ToInt32(comboBoxGazId.SelectedItem.ToString().Split('.')[0]); Program.dailyDB.SaveChanges(); ShowAds(); ShowO(); ShowG(); } }
private void listViewGaz_SelectedIndexChanged(object sender, EventArgs e) { if (listViewAds.SelectedItems.Count == 1) { AdsSet adsSet = listViewAds.SelectedItems[0].Tag as AdsSet; textBoxNum.Text = adsSet.Num; textBoxObem.Text = adsSet.Obem; comboBoxOrgId.SelectedIndex = comboBoxOrgId.FindString(adsSet.ID.ToString()); comboBoxGazId.SelectedIndex = comboBoxGazId.FindString(adsSet.ID.ToString()); } else { textBoxNum.Text = ""; textBoxObem.Text = ""; comboBoxOrgId.SelectedItem = null; comboBoxGazId.SelectedItem = null; } }
private void buttonDel_Click(object sender, EventArgs e) { try { if (listViewAds.SelectedItems.Count == 1) { AdsSet adsSet = listViewAds.SelectedItems[0].Tag as AdsSet; Program.dailyDB.AdsSet.Remove(adsSet); Program.dailyDB.SaveChanges(); ShowAds(); ShowO(); ShowG(); } textBoxNum.Text = ""; textBoxObem.Text = ""; } catch { MessageBox.Show("Невозможно удалить, запись используется!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }