private void CuzdanDoldur() { userCuzdanList.Clear(); var borsaList = HelperBorsa.getAllRecords(false); foreach (var b in borsaList) { double toplam = 0; var cuzdanList = HelperBorsaKullaniciIslem.getRecordsbyBorsaID(userID, b.BorsaID); foreach (var c in cuzdanList) { if (c.CuzdanEkle) { toplam += c.Miktar; } else { toplam -= c.Miktar; } } if (toplam > 0) { string[] cuzdanDeger = { b.BorsaID.ToString(), b.Adi, toplam.ToString() }; userCuzdanList.Add(cuzdanDeger); } } }
private void BtnOzetAl_Click(object sender, EventArgs e) { dataHesapOzet.Rows.Clear(); var hesapList = HelperBorsaKullaniciIslem.getAllRecordsbyID(userID); foreach (var h in hesapList) { if (h.Tarih >= dtpOzetBas.Value && h.Tarih <= dtpOzetBit.Value) { int satir = dataHesapOzet.Rows.Add(); dataHesapOzet.Rows[satir].Cells[0].Value = (BorsaTur)h.Borsa.Tur; dataHesapOzet.Rows[satir].Cells[1].Value = h.Borsa.Adi; dataHesapOzet.Rows[satir].Cells[2].Value = h.Miktar; dataHesapOzet.Rows[satir].Cells[3].Value = CuzdanDurumu(h.CuzdanEkle, h.BorsaID); dataHesapOzet.Rows[satir].Cells[4].Value = h.Tarih; if (h.CuzdanEkle) { dataHesapOzet.Rows[satir].DefaultCellStyle.BackColor = Color.LightGreen; } else { dataHesapOzet.Rows[satir].DefaultCellStyle.BackColor = Color.PaleVioletRed; } } } }
private void BtnYukle_Click(object sender, EventArgs e) { if (txtOnay.Text.Equals(lblOnay.Text)) { if (string.IsNullOrEmpty(txtBakiye.Text)) { MessageBox.Show("Bakiye Bilgisi Girmediniz!!", "Bakiye Hata", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { var durumBakiye = HelperBorsaKullaniciIslem.BakiyeEkle(userID, double.Parse(txtBakiye.Text), true); if (durumBakiye) { MessageBox.Show("Bakiye Başarıyla Eklenmiştir.", "", MessageBoxButtons.OK, MessageBoxIcon.Information); CuzdanDoldur(); BakiyeHesapla(); lblBakiye.Text = userBakiye.ToString("#,##0"); } else { MessageBox.Show("Bakiye yükleme sırasında bir hata oluştu!!"); } } } else { MessageBox.Show("Girdiğiniz onay kodu yanlış, tekrar deneyiniz.", "Onay Hata", MessageBoxButtons.OK, MessageBoxIcon.Error); OnayKoduAl(); } }
private void BtnAlim_Click(object sender, EventArgs e) { var alimID = Convert.ToInt32(cmbMenkul.SelectedValue); var islem = HelperBorsaIslem.getLastRecord(alimID); if (string.IsNullOrEmpty(txtMenkulTutar.Text)) { MessageBox.Show("Tutar bilgisi girmediniz!!", "Tutar Hata", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { var tutar = islem.Satis * int.Parse(txtMenkulTutar.Text); DialogResult result = MessageBox.Show($"{islem.Satis.ToString("0.0000")} birim fiyatından {cmbMenkul.Text} alımı yapıyorsunuz.\n" + $"İşlem Tutarı: {tutar.ToString("0.0000")} Devam ediyor musunuz?", "İşlem Onay", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { if (userBakiye >= tutar) { BorsaKullaniciIslem bki = new BorsaKullaniciIslem() { KullaniciID = userID, BorsaID = islem.BorsaID, Miktar = int.Parse(txtMenkulTutar.Text), Tarih = DateTime.Now, CuzdanEkle = true }; var durumIslem = HelperBorsaKullaniciIslem.CUD(bki, EntityState.Added); if (durumIslem.Item1) { HelperBorsaKullaniciIslem.BakiyeEkle(userID, tutar, false); MessageBox.Show("işlem tamamlanmıştır"); CuzdanGuncelle(); } else { MessageBox.Show("işlem sırasında bir hata meydana geldi"); } } else { MessageBox.Show("Bakiyeniz bu işlem için yetersiz!!\n" + "İsterseniz bakiye yükleyerek işleme devam edebilir veya işlem tutarını değiştirebilirsiniz.", "Bakiye Hata", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private void BtnSat_Click(object sender, EventArgs e) { if (dataCuzdan.CurrentRow == null) { MessageBox.Show("Herhangi bir menkul seçmediniz", "Seçim Hatası", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { var index = dataCuzdan.CurrentRow.Index; var cuzdanID = Convert.ToInt32(dataCuzdan.Rows[index].Cells[2].Value); var islem = HelperBorsaIslem.getLastRecord(cuzdanID); if (string.IsNullOrEmpty(txtMenkulSat.Text)) { MessageBox.Show("Tutar bilgisi girmediniz!!", "Tutar Hata", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { var toplam = islem.Alis * int.Parse(txtMenkulSat.Text); DialogResult result = MessageBox.Show($"{islem.Alis.ToString("0.0000")} birim fiyatından {dataCuzdan.Rows[index].Cells[0].Value} satışı yapıyorsunuz.\n" + $"İşlem Tutarı: {toplam.ToString("0.0000")} Devam ediyor musunuz?", "İşlem Onay", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { BorsaKullaniciIslem bki = new BorsaKullaniciIslem() { KullaniciID = userID, BorsaID = islem.BorsaID, Miktar = int.Parse(txtMenkulSat.Text), Tarih = DateTime.Now, CuzdanEkle = false }; var durumIslem = HelperBorsaKullaniciIslem.CUD(bki, EntityState.Added); if (durumIslem.Item1) { HelperBorsaKullaniciIslem.BakiyeEkle(userID, toplam, true); MessageBox.Show("işlem tamamlanmıştır"); CuzdanGuncelle(); } else { MessageBox.Show("işlem sırasında bir hata meydana geldi"); } } } } }
private void BakiyeHesapla() { double toplam = 0; var bakiyeList = HelperBorsaKullaniciIslem.getRecordsbyBorsaID(userID, 1); foreach (var b in bakiyeList) { if (b.CuzdanEkle) { toplam += b.Miktar; } else { toplam -= b.Miktar; } userBakiye = toplam; } }
private void KullaniciIslemYukle(bool deleted) { dataKullaniciIslem.Rows.Clear(); var islemList = HelperBorsaKullaniciIslem.getAllRecords(); foreach (var i in islemList) { if (i.isDeleted == deleted) { int satir = dataKullaniciIslem.Rows.Add(); dataKullaniciIslem.Rows[satir].Cells[0].Value = i.KullaniciIslemID; dataKullaniciIslem.Rows[satir].Cells[1].Value = i.KullaniciID; dataKullaniciIslem.Rows[satir].Cells[2].Value = i.Borsa.Adi; dataKullaniciIslem.Rows[satir].Cells[3].Value = i.Miktar; dataKullaniciIslem.Rows[satir].Cells[4].Value = i.Tarih; } } }
private void TarihliIslemler(DateTime bas, DateTime son) { dataKullaniciIslem.Rows.Clear(); var islemList = HelperBorsaKullaniciIslem.getAllRecords(); foreach (var i in islemList) { if (i.isDeleted == false) { if (i.Tarih >= bas && i.Tarih <= son) { int satir = dataKullaniciIslem.Rows.Add(); dataKullaniciIslem.Rows[satir].Cells[0].Value = i.KullaniciIslemID; dataKullaniciIslem.Rows[satir].Cells[1].Value = i.KullaniciID; dataKullaniciIslem.Rows[satir].Cells[2].Value = i.Borsa.Adi; dataKullaniciIslem.Rows[satir].Cells[3].Value = i.Miktar; dataKullaniciIslem.Rows[satir].Cells[4].Value = i.Tarih; } } } }
private void btnKisiSil_Click(object sender, EventArgs e) { int selectedID = getSelectedID(dataKullanıcılar); if (selectedID != -1) { int index = dataKullanıcılar.CurrentRow.Index; dataKullanıcılar.Rows.RemoveAt(index); var durum = HelperBorsaKullanici.UserDeleted(selectedID, true); HelperBorsaKullaniciIslem.IslemDeleted(selectedID, true); if (durum) { MessageBox.Show("Kullanıcı başarıyla silindi.."); } else { MessageBox.Show("Silme sırasında bir hata oluştu!!"); } } else { MessageBox.Show("Seçim Yapmadınız.."); } }