private void BtnKuryeGuncel_Click(object sender, EventArgs e) { Kuryeler kurye = new Kuryeler(Convert.ToInt32(dgwKuryeler.CurrentRow.Cells[1]), tbxKuryeAd.Text, tbxKuryeSoyad.Text); islemler.KuryeGuncelle(kurye); MessageBox.Show("Güncellendi!"); }
//Kurye public void KuryeEkle(Kuryeler yeniKurye) { ConnectionControl(); SqlCommand command = new SqlCommand("INSERT INTO Kuryeler VALUES (@subeID,@ad,@soyad)", conn); command.Parameters.AddWithValue("subeID", yeniKurye.SubeID); command.Parameters.AddWithValue("ad", yeniKurye.Ad); command.Parameters.AddWithValue("soyad", yeniKurye.Soyad); command.ExecuteNonQuery(); conn.Close(); }
public void KuryeGuncelle(Kuryeler yeniKurye) { ConnectionControl(); SqlCommand command = new SqlCommand("UPDATE Kuryeler SET SubeID=@subeID,Ad=@ad,Soyad=@soyad WHERE KuryeID=@kuryeID)", conn); command.Parameters.AddWithValue("kuryeID", yeniKurye.KuryeID); command.Parameters.AddWithValue("subeID", yeniKurye.SubeID); command.Parameters.AddWithValue("ad", yeniKurye.Ad); command.Parameters.AddWithValue("soyad", yeniKurye.Soyad); command.ExecuteNonQuery(); conn.Close(); }
public List <Kuryeler> GetKuryeler() { ConnectionControl(); SqlCommand command = new SqlCommand("SELECT * FROM Kuryeler", conn); SqlDataReader reader = command.ExecuteReader(); List <Kuryeler> Kurye = new List <Kuryeler>(); while (reader.Read()) { Kuryeler k = new Kuryeler(Convert.ToInt32(reader["KuryeID"]), Convert.ToInt32(reader["SubeID"]), reader["Ad"].ToString(), reader["Soyad"].ToString()); Kurye.Add(k); } reader.Close(); conn.Close(); return(Kurye); }