private void btnGuncelle_Click(object sender, EventArgs e) { if (lvYazar.SelectedItems.Count > 0) { if (!string.IsNullOrEmpty(txtYazarAdi.Text) & !string.IsNullOrEmpty(txtYazarSoyadi.Text)) { EAuthors author = new EAuthors(); author.ID = Convert.ToInt32((int)lvYazar.SelectedItems[0].Tag); author.FirstName = txtYazarAdi.Text; author.LastName = txtYazarSoyadi.Text; if (BLLAuthors.Update(author)) { MessageBox.Show("Güncelleme başarılı!"); txtYazarAdi.Clear(); txtYazarSoyadi.Clear(); lvYazar.Items.Clear(); Listele(); } else { MessageBox.Show("Güncelleme başarısız oldu!"); } } else { MessageBox.Show("Eksik bilgi girdiniz. Lütfen kontrol ediniz!"); } } else { MessageBox.Show("Güncelleme işlemi yapmak istediğiniz yazarı listeden çift tıklayarak seçiniz."); } }
protected void btnGuncelle_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtYazarAdi.Text) & !string.IsNullOrEmpty(txtYazarSoyadi.Text)) { List <EAuthors> authorList = new List <EAuthors>(); authorList = BLLAuthors.GetAll(); authorList = (from l in authorList where l.FirstName.Trim().ToLower().Equals(txtYazarAdi.Text.Trim().ToLower()) && l.LastName.Trim().ToLower().Equals(txtYazarSoyadi.Text.Trim().ToLower()) select l).ToList(); if (authorList.Count == 0) { EAuthors guncellenecek = new EAuthors(); guncellenecek.ID = int.Parse(Request.QueryString["yazarID"]); guncellenecek.FirstName = txtYazarAdi.Text; guncellenecek.LastName = txtYazarSoyadi.Text; bool sonuc = BLLAuthors.Update(guncellenecek); if (sonuc) { Response.Write("<script>alert('Harika! Güncellendi!');</script>"); Response.Redirect("Yazarlar.aspx?scs=1"); } else { Response.Write("<script>alert('Hay Aksi! Hata Oluştu!')</script>"); } } else { Response.Write("<script>alert('Aynı isimde kayıtlı yazar mevcuttur!')</script>"); Response.Redirect("Yazarlar.aspx?scs=1"); } } else { Response.Write("<script>alert('Eksik bilgi girdiniz. Lütfen kontrol ediniz!')</script>"); } }