private void buttonDodajOpiekun_Click(object sender, EventArgs e) { bool IsOpen = false; foreach (Form f in Application.OpenForms) { if (f.Text == "Dodawanie opiekuna") { IsOpen = true; f.Focus(); break; } } if (IsOpen == false) { if (idopiekun == null) { this.Opacity = 0.5; DodajOpiekun f2 = new DodajOpiekun(); f2.ShowDialog(); this.idopiekun = f2.idopiekunSend; this.Opacity = 1; if (idopiekun != null) { buttonDodajOpiekun.Text = "Dodaj drugiego opiekuna"; } } else { this.Opacity = 0.5; DodajOpiekun f2 = new DodajOpiekun(); f2.ShowDialog(); this.idopiekunDrugi = f2.idopiekunSend; this.Opacity = 1; if (idopiekunDrugi != null) { buttonDodajOpiekun.Text = "Niedostępne"; buttonDodajOpiekun.Enabled = false; } } } }
private void buttonDodaj_Click(object sender, EventArgs e) { bool IsOpen = false; foreach (Form f in Application.OpenForms) { if (f.Text == "Dodawanie opiekuna") { IsOpen = true; f.Focus(); break; } } if (IsOpen == false) { if (comboBoxOpiekun.Items.Count <= 1) { this.Opacity = 0.5; DodajOpiekun f2 = new DodajOpiekun(); f2.ShowDialog(); this.idopiekun = f2.idopiekunSend; this.Opacity = 1; if (idopiekun != null) { try { Database database = new Database(); database.Insert("insert into pacjentopiekun (idpacjent, idopiekun) values ('" + this.idpacjent + "', '" + this.idopiekun + "')", database.Conect()); } catch (Exception ex) { MessageBox.Show(ex.Message); } All_clear(); Update_opiekun(); Update_buttonDodaj(); } } } }