public static bool OgrenciEkle(Model.Values.Ogrenci Ogrc) { using (DbManager dbManager = new DbManager(Sessions.ConnectionStringSql)) { string sql = @"insert into tblOgrenci(KullaniciAdi,KullaniciSoyadi,Sifre)values(@KullaniciAdi,@KullaniciSoyadi,@Sifre)"; dbManager.DataCommand.Parameters.Add("@KullaniciAdi", SqlDbType.VarChar).Value = Ogrc.OgrenciAdi; dbManager.DataCommand.Parameters.Add("@KullaniciSoyadi", SqlDbType.VarChar).Value = Ogrc.OgrenciSoyadi; dbManager.DataCommand.Parameters.Add("@Sifre", SqlDbType.VarChar).Value = Ogrc.Sifre; dbManager.RunCommand(sql); return(dbManager.CommitTransaction()); } }
private void btn_Kaydet_Click(object sender, EventArgs e) { if (txtOgrenciKullanici.Text == "" || txtOgrenciSifre.Text == "") { MessageBox.Show("Boş bıraktığınız alanları doldurunuz"); } else { Model.Values.Ogrenci ogrc = new Model.Values.Ogrenci() { OgrenciAdi = txtOgrenciKullanici.Text, OgrenciSoyadi = txtSoyadi.Text, Sifre = txtOgrenciSifre.Text, }; DataSqlQuestion.OgrenciEkle(ogrc); MessageBox.Show("Kayıt Başarılı"); txtOgrenciKullanici.Text = ""; txtSoyadi.Text = ""; txtOgrenciSifre.Text = ""; } }