Exemple #1
0
        private void btnDuze_Click(object sender, EventArgs e)
        {
            try
            {
                Ogrenci o1 = new Ogrenci();
                o1.Ad         = txtAdOgrenci.Text.Trim().ToUpper();
                o1.Soyad      = txtSoyadOgrenci.Text.Trim().ToUpper();
                o1.TCKimlikNo = txtTCogrenci.Text.Trim();
                o1.OkulNo     = txtOkulNo.Text.Trim();
                o1.SinifId    = (int)cmbSinif.SelectedValue;
                o1.Resim      = txtResim.Text.Trim();
                o1.VeliAd     = txtVeliAd.Text.Trim().ToUpper();
                o1.VeliSoyad  = txtVeliSoyad.Text.Trim().ToUpper();
                o1.Tel        = txtTelVeli.Text.Trim().ToUpper();
                o1.Adres      = txtAdresVeli.Text.Trim().ToUpper();
                o1.OgrenciId  = Convert.ToInt32(txtogrenciIdGelen.Text);
                bool sonuc = OgrenciBL.OgrenciDuzenleme(o1);
                if (sonuc)
                {
                    MessageBox.Show("Düzeltme İşlemi başarılı");
                    OgrenciListele();
                    Utility.CleanTextBoxes(grpOgrenciBilgileri.Controls);
                    Utility.CleanTextBoxes(grpVeliBilgileri.Controls);
                    pcbOgrenci.Image = Properties.Resources.indir;
                }
                else
                {
                    MessageBox.Show("Düzeltme Başarısız");
                }
            }
            catch (SqlException ex)
            {
                switch (ex.Number)
                {
                case 2627:
                    if (ex.Message.Contains("TCKimlikNo"))
                    {
                        MessageBox.Show("Bu TC Kimlik numarası zaten kayıtlı!!" + ex.Number);
                    }
                    else
                    {
                        MessageBox.Show("Bu Öğrenci numarası zaten kayıtlı!!" + ex.Number);
                    }
                    break;

                default:
                    MessageBox.Show("Veritabanı Hatası!!" + ex.Number);
                    break;
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Bilinmeyen Hata!!");
            }
        }