private void btnSil_Click(object sender, EventArgs e) { if (lvYazar.SelectedItems.Count > 0) { int selectedAuthorID = (int)lvYazar.SelectedItems[0].Tag; DialogResult result = MessageBox.Show("Silmek istediğinize emin misiniz ?", "Uyarı", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { EAuthors silinecekYazar = new EAuthors(); silinecekYazar.ID = selectedAuthorID; EAuthors author = new EAuthors(); author.ID = silinecekYazar.ID; if (BLLAuthors.Delete(author)) { MessageBox.Show("Silme işleminiz başarıyla tamamlanmıştır."); lvYazar.Items.Clear(); txtYazarAdi.Clear(); txtYazarSoyadi.Clear(); } else { MessageBox.Show("Bir hata oluştu!"); } Listele(); } } else { MessageBox.Show("Silmek istediğiniz yazarı seçiniz."); } }
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 Page_Load(object sender, EventArgs e) { if (IsPostBack) { return; } if (Request.QueryString["ID"] != null) { EAuthors author = new EAuthors(); author.ID = int.Parse(Request.QueryString["ID"]); bool sonuc = BLLAuthors.Delete(author); if (sonuc) { Response.Write("<script>alert('Harika! Silindi!')</script>"); } else { Response.Write("<script>alert('Hay Aksi! Silinemedi!')</script>"); } } rptYazarlar.DataSource = BLLAuthors.GetAll(); rptYazarlar.DataBind(); if (Request.QueryString["scs"] != null) { int scsID = Convert.ToInt32(Request.QueryString["scs"].ToString()); if (scsID == 1) { Response.Write("<script>alert('Harika! Güncellendi!');</script>"); } } }
public static void Delete(EAuthors author) { SqlCommand cmd = new SqlCommand("spAuthor_Delete", Baglanti.conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("authorID", author.ID); Baglanti.conn.Open(); cmd.ExecuteNonQuery(); Baglanti.conn.Close(); }
private void lvYazar_DoubleClick(object sender, EventArgs e) { int selectedAuthorID = (int)lvYazar.SelectedItems[0].Tag; EAuthors selectedAuthor = new EAuthors(); selectedAuthor = BLLAuthors.GetIdOnly(selectedAuthorID); txtYazarAdi.Text = selectedAuthor.FirstName; txtYazarSoyadi.Text = selectedAuthor.LastName; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int authorID = Convert.ToInt32(Request.QueryString["yazarID"].ToString()); EAuthors author = new EAuthors(); author = BLLAuthors.GetIdOnly(authorID); txtYazarAdi.Text = author.FirstName; txtYazarSoyadi.Text = author.LastName; } }
public static bool InsertNewAuthor(EAuthors author) { if (author.FirstName == "" || author.LastName == "") { return(false); } else { DALAuthors.InsertNewAuthor(author); return(true); } }
public static void InsertNewAuthor(EAuthors author) { SqlCommand cmd = new SqlCommand("spAuthor_Insert", Baglanti.conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@FirstName", author.FirstName); cmd.Parameters.AddWithValue("@LastName", author.LastName); Baglanti.conn.Open(); cmd.ExecuteNonQuery(); Baglanti.conn.Close(); }
private void btnKaydet_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtYazarAdi.Text) & !string.IsNullOrEmpty(txtYazarSoyadi.Text)) { 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 author = new EAuthors(); author.FirstName = txtYazarAdi.Text; author.LastName = txtYazarSoyadi.Text; bool sonuc = BLLAuthors.InsertNewAuthor(author); if (sonuc) { MessageBox.Show("Yazar kayıt işlemi başarıyla gerçekleşmiştir!"); txtYazarAdi.Clear(); txtYazarSoyadi.Clear(); txtYazarAdi.Focus(); lvYazar.Items.Clear(); Listele(); } else { MessageBox.Show("Bir hata oluştu"); } } else { MessageBox.Show("Yazar zaten kayıtlı!"); } } else { MessageBox.Show("Eksik bilgi girdiniz.Lütfen kontrol ediniz!"); } }
public static List <EAuthors> GetAuthorNames() { SqlCommand cmd = new SqlCommand("spAuthors_GetNames", Baglanti.conn); cmd.CommandType = CommandType.StoredProcedure; Baglanti.conn.Open(); SqlDataReader dr = cmd.ExecuteReader(); List <EAuthors> aliste = new List <EAuthors>(); while (dr.Read()) { EAuthors a = new EAuthors(); a.ID = Convert.ToInt32(dr["ID"]); a.FullName = dr["FullName"].ToString(); aliste.Add(a); } dr.Close(); Baglanti.conn.Close(); return(aliste); }
public static EAuthors GetIdOnly(int authorId) { SqlCommand cmd = new SqlCommand("spAuthors_GetIdOnly", Baglanti.conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@AuthorID", authorId); Baglanti.conn.Open(); SqlDataReader dr = cmd.ExecuteReader(); EAuthors author = new EAuthors(); while (dr.Read()) { author.ID = Convert.ToInt32(dr["ID"]); author.FirstName = dr["FirstName"].ToString(); author.LastName = dr["LastName"].ToString(); } dr.Close(); Baglanti.conn.Close(); return(author); }
protected void btnKaydet_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtYazarAdi.Text) & !string.IsNullOrEmpty(txtYazarSoyadi.Text)) { 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 author = new EAuthors(); author.FirstName = txtYazarAdi.Text; author.LastName = txtYazarSoyadi.Text; if (BLLAuthors.InsertNewAuthor(author)) { Response.Write("<script>alert('Yazar kayıt işleminiz başarıyla gerçekleşmiştir.')</script>"); } else { Response.Write("<script>alert('Hata Oluştu!')</script>"); } } else { Response.Write("<script>alert('Kaydetmek istediğiniz yazar zaten kayıtlıdır!')</script>"); } txtYazarAdi.Text = String.Empty; txtYazarSoyadi.Text = String.Empty; txtYazarAdi.Focus(); } else { Response.Write("<script>alert('Eksik bilgi girdiniz. Lütfen kontrol ediniz!')</script>"); } }
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>"); } }
public static bool Delete(EAuthors author) { DALAuthors.Delete(author); return(true); }
public static bool Update(EAuthors author) { DALAuthors.Update(author); return(true); }