//Emanet Ara Butonu private void btnAra_Click(object sender, EventArgs e) { try { Emanet emanet = new Emanet(); EmanetBLL bll = new EmanetBLL(); emanet.UYE_TCKNO = txtAraTckno.Text; //BLL katmanı nesnesiyle dataGridView objesine veri kaynağı gösterilir dataGridViewAra.DataSource = bll.EmanetAra(emanet); TabloDuzenleEmanet(dataGridViewAra); //Uygun emanet bulunamazsa uyarı verir if (dataGridViewAra.RowCount == 0) { MessageBox.Show("Aradığınız emanet kaydı bulunamadı!", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); //Kayıt bulunamazsa emanet et butonu inaktif olacaktır btnTeslimEt.Enabled = false; btnTeslimEt.BackColor = Color.Gray; btnTeslimEt.ForeColor = Color.DarkGray; btnTeslimEt.FlatAppearance.BorderColor = Color.DarkGray; } else { //Kayıt bulunursa emanet et butonu aktif olacaktır btnTeslimEt.Enabled = true; btnTeslimEt.BackColor = Color.Honeydew; btnTeslimEt.ForeColor = Color.DarkGreen; btnTeslimEt.FlatAppearance.BorderColor = Color.DarkGreen; //Emanetlerin teslim durumlarına göre satır rengi değiştirilir for (int i = 0; i < dataGridViewAra.Rows.Count; i++) { TimeSpan zamanFarki = DateTime.Now - Convert.ToDateTime(dataGridViewAra.Rows[i].Cells["SON_TESLIM_TARIHI"].Value.ToString()); double gun = zamanFarki.TotalDays; //Teslim tarihine 2 gün kalanlar sarı if ((gun <= 0) && (gun >= -2)) { dataGridViewAra.Rows[i].DefaultCellStyle.BackColor = Color.Yellow; } //Teslim edilenler yeşil if (dataGridViewAra.Rows[i].Cells["TESLIM_DURUMU"].Value.ToString() == "TESLİM EDİLDİ") { dataGridViewAra.Rows[i].DefaultCellStyle.BackColor = Color.Green; } //Teslim edilmeyenler kırmızı if (dataGridViewAra.Rows[i].Cells["TESLIM_DURUMU"].Value.ToString() == "TESLİM EDİLMEDİ") { dataGridViewAra.Rows[i].DefaultCellStyle.BackColor = Color.Red; } } } } catch (Exception ex) { MessageBox.Show("Lütfen bilgileri kontrol ediniz!", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
//Teslim Et Butonu private void btnTeslimEt_Click(object sender, EventArgs e) { try { //Seçilen emanet kaydı teslim edildiyse uyarı vericektir if (tmpTeslimDurumu == "TESLİM EDİLDİ") { MessageBox.Show("Bu emanet teslim edilmiş, lütfen başka bir emanet kaydı seçiniz!", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { Emanet emanet = new Emanet(); emanet.EMANET_NO = tmpEmanetNo; emanet.KITAP_NO = tmpKitapNo; emanet.TESLIM_DURUMU = "TESLİM EDİLDİ"; emanet.KITAP_DURUMU = "HAZIR"; emanet.TESLIM_TARIHI = DateTime.Today.Date.ToString(); //Teslim Tarihi = Sistem Tarihi EmanetBLL bll = new EmanetBLL(); //BLL katmanı nesnesiyle önce teslim işlemi yapılır daha sonra da teslim edilen kitabın durumu güncellenir bll.EmanetTeslim(emanet); bll.EmanetKitapGuncelleme(emanet); MessageBox.Show("Kitap teslim edildi!", "Başarılı", MessageBoxButtons.OK); } } catch (Exception ex) { MessageBox.Show("Lütfen bilgileri kontrol ediniz!", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
//Emanet Kayıt Butonu private void btnEkle_Click(object sender, EventArgs e) { try { Uye uye = new Uye(); uye.UYE_TCKNO = txtTCKNO.Text; //Nesne eşleştirmesi için tmpUye nesnesi oluşturulur Uye tmpUye = new Uye(); UyeBLL uyeBLL = new UyeBLL(); tmpUye = uyeBLL.UyeAra2(uye); //return edilen nesne eşleştirildi //Üye Adı alanı boş ise bulunamadı uyarısı verir if (tmpUye.UYE_AD == null) { MessageBox.Show("Kayıtlı üye bulunamadı, TCKNO'yu kontrol ediniz!", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { Emanet emanet = new Emanet(); emanet.UYE_TCKNO = txtTCKNO.Text; emanet.KITAP_NO = Convert.ToInt32(kitapNoLabel.Text); emanet.KITAP_DURUMU = "EMANETTE";//Emanet kaydı sırasında Kitap Durumu'da değiştirilir EmanetBLL bll = new EmanetBLL(); //BLL katmanı nesnesiyle ekle ve kitap guncelle metodu çağırılır bll.EmanetEkle(emanet); bll.EmanetKitapGuncelleme(emanet); MessageBox.Show("Kayıt oluşturuldu!", "Başarılı!", MessageBoxButtons.OK); } } catch (Exception ex) { MessageBox.Show("Lütfen bilgileri kontrol ediniz!", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
//Load private void Form1_Load(object sender, EventArgs e) { EmanetBLL bll = new EmanetBLL(); //Panel Seçim Formu her açıldığında günlük borç güncelleme metodu çağırılır bll.EmanetGunlukGuncelleme(); buttonOp(button1); buttonOp(button2); buttonOp(button3); buttonOp(button4); }
//Tüm Emanetlerin Listesi Butonu private void btnTumEmanetler_Click(object sender, EventArgs e) { //Tüm Emanetler Listesi Formu açılır TumEmanetlerListesi yeniForm = new TumEmanetlerListesi(); yeniForm.Show(); EmanetBLL bll = new EmanetBLL(); try { //BLL katmanı nesnesiyle dataGridView objesine veri kaynağı gösterilir yeniForm.dataGridViewTumEmanetler.DataSource = bll.TumEmanetleriListele(); TabloDuzenleEmanet(yeniForm.dataGridViewTumEmanetler); //Hücre boyut ayarları yeniForm.dataGridViewTumEmanetler.Columns[0].Width = 40; yeniForm.dataGridViewTumEmanetler.Columns[1].Width = 120; yeniForm.dataGridViewTumEmanetler.Columns[2].Width = 80; yeniForm.dataGridViewTumEmanetler.Columns[3].Width = 80; yeniForm.dataGridViewTumEmanetler.Columns[4].Width = 40; yeniForm.dataGridViewTumEmanetler.Columns[5].Width = 150; yeniForm.dataGridViewTumEmanetler.Columns[6].Width = 120; //Emanetlerin teslim durumlarına göre satır rengi değiştirilir for (int i = 0; i < yeniForm.dataGridViewTumEmanetler.Rows.Count; i++) { TimeSpan zamanFarki = DateTime.Now - Convert.ToDateTime(yeniForm.dataGridViewTumEmanetler.Rows[i].Cells["SON_TESLIM_TARIHI"].Value.ToString()); double gun = zamanFarki.TotalDays; //Teslim tarihine 2 gün kalanlar sarı if ((gun <= 0) && (gun >= -2)) { yeniForm.dataGridViewTumEmanetler.Rows[i].DefaultCellStyle.BackColor = Color.Yellow; } //Teslim edilenler yeşil if (yeniForm.dataGridViewTumEmanetler.Rows[i].Cells["TESLIM_DURUMU"].Value.ToString() == "TESLİM EDİLDİ") { yeniForm.dataGridViewTumEmanetler.Rows[i].DefaultCellStyle.BackColor = Color.Green; } //Teslim edilmeyenler kırmızı if (yeniForm.dataGridViewTumEmanetler.Rows[i].Cells["TESLIM_DURUMU"].Value.ToString() == "TESLİM EDİLMEDİ") { yeniForm.dataGridViewTumEmanetler.Rows[i].DefaultCellStyle.BackColor = Color.Red; } } } catch (Exception ex) { MessageBox.Show("Lütfen bilgileri kontrol ediniz!", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }