//Update private void button3_Click(object sender, EventArgs e) { try { if (selectCombobox.SelectedIndex == 0) { BLL bll = new BLL(); Sehir newSehir = new Sehir(Convert.ToInt16(sehirControl.id.Text), sehirControl.ad.Text); bll.Update <Sehir>(newSehir); dataGridView.DataSource = bll.Get("Sehir"); } else if (selectCombobox.SelectedItem.ToString() == "Kisi") { BLL bll = new BLL(); Kisi newKisi = new Kisi(Convert.ToInt16(kisiControl.id.Text), kisiControl.ad.Text, kisiControl.soyad.Text, Convert.ToInt16(kisiControl.yas.Text), kisiControl.adres.Text, kisiControl.sehir.Text, kisiControl.ilce.Text); bll.Update <Kisi>(newKisi); dataGridView.DataSource = bll.Get("Kisi"); } else if (selectCombobox.SelectedItem.ToString() == "Ilce") { BLL bll = new BLL(); Ilce newIlce = new Ilce(Convert.ToInt16(ilceControl.id.Text), ilceControl.ad.Text, Convert.ToInt16(ilceControl.sehirId.Text)); bll.Update <Ilce>(newIlce); dataGridView.DataSource = bll.Get("Ilce"); } } catch { MessageBox.Show("Error occured during update."); } }
//Insert private void button2_Click(object sender, EventArgs e) { try { BLL BLL = new BLL(); //BLL Business Logic Layer if (selectCombobox.SelectedItem.ToString() == "Sehir") { Sehir newSehir = new Sehir(Convert.ToInt16(sehirControl.id.Text), sehirControl.ad.Text); BLL.Insert <Sehir>(newSehir); dataGridView.DataSource = BLL.Get("Sehir"); } else if (selectCombobox.SelectedItem.ToString() == "Kisi") { Kisi newKisi = new Kisi(Convert.ToInt16(kisiControl.id.Text), kisiControl.ad.Text, kisiControl.soyad.Text, Convert.ToInt16(kisiControl.yas.Text), kisiControl.adres.Text, kisiControl.sehir.Text, kisiControl.ilce.Text); BLL.Insert <Kisi>(newKisi); dataGridView.DataSource = BLL.Get("Kisi"); } else if (selectCombobox.SelectedItem.ToString() == "Ilce") { Ilce newIlce = new Ilce(Convert.ToInt16(ilceControl.id.Text), ilceControl.ad.Text, Convert.ToInt16(ilceControl.sehirId.Text)); BLL.Insert <Ilce>(newIlce); dataGridView.DataSource = BLL.Get("Ilce"); } } catch { MessageBox.Show("An error occured during insert"); } }
//Combobox selection and filling the Grid private void comboBox1_SelectedValueChanged(object sender, EventArgs e) { //Show the selected UserControl and hide the others. foreach (Control u in this.Controls) { if (u.Name == selectCombobox.SelectedItem + "Control") { u.Visible = true; u.Location = new Point(400, 0); u.BringToFront(); } else if (u is UserControl) { u.Visible = false; } } //Fill the grid with selected item try { BLL bll = new BLL(); dataGridView.DataSource = bll.Get(selectCombobox.SelectedItem.ToString()); } catch { MessageBox.Show("An error occured."); } //Determine active sheet if (selectCombobox.SelectedItem.ToString() == "Kisi") { activeSheet = ActiveSheet.Kisi; } else if (selectCombobox.SelectedItem.ToString() == "Sehir") { activeSheet = ActiveSheet.Sehir; } else if (selectCombobox.SelectedItem.ToString() == "Ilce") { activeSheet = ActiveSheet.Ilce; } }
//Select private void button1_Click(object sender, EventArgs e) { BLL bll = new BLL(); dataGridView.DataSource = bll.Get(selectCombobox.SelectedItem.ToString()); }