コード例 #1
0
        private void btnKitapEkle_Click(object sender, EventArgs e)
        {
            try
            {
                KitapDTO kitap = new KitapDTO()
                {
                    KitapAd    = txtKitapAdi.Text,
                    KitapKonu  = txtKitapKonusu.Text,
                    YayinEv    = txtYayinEvi.Text,
                    YayinTarih = dtpYayinTarihi.Value,
                    YazarID    = Convert.ToInt32(txtYazarId.Text)
                };

                KitapRepository.KitapEkle(kitap);

                DialogResult dr = MessageBox.Show("Kitap Başarıyla Eklenmiştir. Yeni Kitap Eklemek ister Misiniz ?", "Ekleme bildirimi!", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dr == DialogResult.Yes)
                {
                    Temizle();
                }
                else
                {
                    frmMain frm = new frmMain();
                    this.Close();
                    frm.Show();
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #2
0
        public bool Ekle(Kitap entity)
        {
            /*try
             * {
             *  Context.Set<Kitap>().Add(entity);
             *  Context.SaveChanges();
             *  return true;
             * }
             * catch (Exception ex)
             * {
             *  throw new Exception("Business:KitapBusiness::KitapEkle::Error occured.", ex);
             * }*/

            try
            {
                bool isSuccess;
                using (var repo = new KitapRepository())
                {
                    isSuccess = repo.Ekle(entity);
                }
                return(isSuccess);
            }
            catch (Exception ex)
            {
                throw new Exception("BusinessLogic:KitapBusiness::InsertCustomer::Error occured.", ex);
            }
        }
コード例 #3
0
        private void cbKitaplar_SelectionChangeCommitted(object sender, EventArgs e)
        {
            int kitapId = (int)cbKitaplar.SelectedValue;

            txtKitapId.Text = kitapId.ToString();

            txtKitapAdi.Text    = KitapRepository.IDyeGoreKitapGetir(kitapId).KitapAd;
            txtKitapKonusu.Text = KitapRepository.IDyeGoreKitapGetir(kitapId).KitapKonu;
            txtYayinEvi.Text    = KitapRepository.IDyeGoreKitapGetir(kitapId).YayinEv;
            dtpYayinTarihi.Text = (KitapRepository.IDyeGoreKitapGetir(kitapId).YayinTarih).ToString();
        }
コード例 #4
0
 public bool Sil(int id)
 {
     try
     {
         bool isSuccess;
         using (var repo = new KitapRepository())
         {
             isSuccess = repo.DeleteById(id);
         }
         return(isSuccess);
     }
     catch (Exception ex)
     {
         throw new Exception("BusinessLogic:CustomerBusiness::DeleteCustomer::Error occured.", ex);
     }
 }
コード例 #5
0
 public bool Guncelle(Kitap entity)
 {
     try
     {
         bool isSuccess;
         using (var repo = new KitapRepository())
         {
             isSuccess = repo.Guncelle(entity);
         }
         return(isSuccess);
     }
     catch (Exception ex)
     {
         throw new Exception("BusinessLogic:KitapBusiness::GuncelleKitap::Error occured.", ex);
     }
 }
コード例 #6
0
        private void Listele()
        {
            lstwKitapSil.Items.Clear();

            List <KitapDTO> kitapListele = KitapRepository.TumKitaplar();

            foreach (KitapDTO ki in kitapListele)
            {
                ListViewItem li = new ListViewItem();

                li.Tag  = ki;
                li.Text = ki.KitapID.ToString();
                li.SubItems.Add(ki.KitapAd);
                li.SubItems.Add(ki.YazarID.ToString());


                lstwKitapSil.Items.Add(li);
            }
        }
コード例 #7
0
 public Kitap GetById(int id)
 {
     try
     {
         Kitap responseEntitiy;
         using (var repo = new KitapRepository())
         {
             responseEntitiy = repo.GetById(id);
             if (responseEntitiy == null)
             {
                 throw new NullReferenceException("Boyle bir kitap yok!");
             }
         }
         return(responseEntitiy);
     }
     catch (Exception ex)
     {
         throw new Exception("BusinessLogic:CustomerBusiness::SelectCustomerById::Error occured.", ex);
     }
 }
コード例 #8
0
        public List <Kitap> Listele()
        {
            var responseEntities = new List <Kitap>();

            try
            {
                using (var repo = new KitapRepository())
                {
                    foreach (var entity in repo.Listele())
                    {
                        responseEntities.Add(entity);
                    }
                }
                return(responseEntities);
            }
            catch (Exception ex)
            {
                throw new Exception("BusinessLogic:CustomerBusiness::SelectAllCustomers::Error occured.", ex);
            }
        }
コード例 #9
0
        private void btnKitapGuncelle_Click(object sender, EventArgs e)
        {
            KitapDTO guncelKitap = new KitapDTO
            {
                KitapAd    = txtKitapAdi.Text,
                KitapKonu  = txtKitapKonusu.Text,
                YayinEv    = txtYayinEvi.Text,
                YayinTarih = dtpYayinTarihi.Value,
                KitapID    = Convert.ToInt32(txtKitapId.Text),
                YazarID    = Convert.ToInt32(txtYazarId.Text)
            };

            KitapRepository.KitapGuncelle(guncelKitap);

            MessageBox.Show("Kitap başarıyla güncellenmiştir.");

            frmMain frm = new frmMain();

            this.Close();
            frm.Show();
        }
コード例 #10
0
        private void btnKitapSil_Click(object sender, EventArgs e)
        {
            try
            {
                if (lstwKitapSil.SelectedItems.Count > 0)
                {
                    KitapRepository.KitapSil((KitapDTO)lstwKitapSil.SelectedItems[0].Tag);

                    MessageBox.Show("Kitap başarıyla silinmiştir.");

                    Listele();
                }
                else
                {
                    MessageBox.Show("Lütfen silmek istediğiniz yazarı seçiniz!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Bağlı tablolardan veya başka bir sebepten silme gerçekleştirelemedi.");
            }
        }