private void button2_Click(object sender, EventArgs e) { int y = listBox1.Items.Count; String[] split; for (int i = 0; i < y; i++) { listBox1.SetSelected(i, true); split = listBox1.SelectedItem.ToString().Split(' '); int id = Int32.Parse(split[0]); Plan_Pracy u = new Plan_Pracy(1, id); db.Plan_Pracy.Add(u); var s = db.Zamówienie.Where(j => j.id == id).FirstOrDefault(); if (s != null) { s.Status = "Oczekujacy"; } db.SaveChanges(); listBox1.Items.RemoveAt(listBox1.SelectedIndex); } }
private void stworzButt_Click(object sender, EventArgs e) { String[] split; int x = listBox.Items.Count; if (radioButton1.Checked) { for (int i = 0; i < x; i++) { listBox.SetSelected(i, true); split = listBox.SelectedItem.ToString().Split(' '); int id = Int32.Parse(split[0]); Plan_Pracy u = new Plan_Pracy(1, id); db.Plan_Pracy.Add(u); var s = db.Zamówienie.Where(j => j.id == id).FirstOrDefault(); if (s != null) { s.Status = "W Planie"; } db.SaveChanges(); listBox.Items.RemoveAt(listBox.SelectedIndex); } } else if (radioButton2.Checked) { for (int i = 0; i < x; i++) { listBox.SetSelected(i, true); split = listBox.SelectedItem.ToString().Split(' '); int id = Int32.Parse(split[0]); Plan_Pracy u = new Plan_Pracy(2, id); db.Plan_Pracy.Add(u); var s = db.Zamówienie.Where(j => j.id == id).FirstOrDefault(); if (s != null) { s.Status = "W Planie"; } db.SaveChanges(); listBox.Items.RemoveAt(listBox.SelectedIndex); } } }