private void button2_Click(object sender, EventArgs e) { Ilac ilac = new Ilac { ilacKodu = Convert.ToInt32(dgwIlac.CurrentRow.Cells[0].Value), ilacAdi = txtGuncelleAd.Text, ilacTuru = txtGuncelleTur.Text, ilacStt = txtGuncelleTarih.Text, ilacEtken = richGuncelleEtken.Text }; ilacdal.Update(ilac); LoadProduct(); MessageBox.Show("İLAÇ BİLGİLERİ GÜNCELLENDİ"); }
public void Add(Ilac ilac1) { database.ConnectionControl(); try { SqlCommand command = new SqlCommand("Insert into " + this.table + " values(@ad,@tur,@tarih,@etken)", database.connection); command.Parameters.AddWithValue("@ad", ilac1.ilacAdi); command.Parameters.AddWithValue("@tur", ilac1.ilacTuru); command.Parameters.AddWithValue("@tarih", ilac1.ilacStt); command.Parameters.AddWithValue("@etken", ilac1.ilacEtken); command.ExecuteNonQuery(); } catch (SqlException exception) { } }
public void Update(Ilac ilac1) { database.ConnectionControl(); try { SqlCommand command = new SqlCommand("Update " + this.table + " set ilacAdi=@ad,ilacTuru=@tur,ilacStt=@tarih,ilacEtken=@etken where ilacKodu=@kod", database.connection); command.Parameters.AddWithValue("@ad", ilac1.ilacAdi); command.Parameters.AddWithValue("@tur", ilac1.ilacTuru); command.Parameters.AddWithValue("@tarih", ilac1.ilacStt); command.Parameters.AddWithValue("@etken", ilac1.ilacEtken); command.Parameters.AddWithValue("@kod", ilac1.ilacKodu); command.ExecuteNonQuery(); } catch (SqlException exception) { } }