private void BtnSguncelle_Click(object sender, EventArgs e) { Subeler sube = new Subeler(Convert.ToInt32(dgwSubeler.CurrentRow.Cells[0].Value), tbxSubeAdi.Text, tbxSubeTelefon.Text, tbxSubeAdres.Text); islemler.SubeGuncelle(sube); MessageBox.Show("Şube Güncellendi"); islemler.LoadSubeler(dgwSubeler); }
//Sube public void SubeEkle(Subeler yeniSube) { ConnectionControl(); SqlCommand command = new SqlCommand("INSERT INTO Subeler VALUES (@ad,@telefon,@adres)", conn); command.Parameters.AddWithValue("ad", yeniSube.Ad); command.Parameters.AddWithValue("telefon", yeniSube.Telefon); command.Parameters.AddWithValue("adres", yeniSube.Adres); command.ExecuteNonQuery(); conn.Close(); }
public void SubeGuncelle(Subeler yeniSube) { ConnectionControl(); SqlCommand command = new SqlCommand("UPDATE Subeler SET Ad=@ad,Telefon=@telefon,Adres=@adres WHERE SubeID=@subeID)", conn); command.Parameters.AddWithValue("subeID", yeniSube.SubeID); command.Parameters.AddWithValue("ad", yeniSube.Ad); command.Parameters.AddWithValue("telefon", yeniSube.Telefon); command.Parameters.AddWithValue("adres", yeniSube.Adres); command.ExecuteNonQuery(); conn.Close(); }
public List <Subeler> GetSubeler() { ConnectionControl(); SqlCommand command = new SqlCommand("SELECT * FROM Subeler", conn); SqlDataReader reader = command.ExecuteReader(); List <Subeler> Sube = new List <Subeler>(); while (reader.Read()) { Subeler s = new Subeler(Convert.ToInt32(reader["SubeID"]), reader["Ad"].ToString(), reader["Telefon"].ToString(), reader["Adres"].ToString()); Sube.Add(s); } reader.Close(); conn.Close(); return(Sube); }