示例#1
0
        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!");
            }
        }
示例#2
0
        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>");
            }
        }