private void buttonFind_Click(object sender, EventArgs e) { if (!String.IsNullOrEmpty(SearchtextBox.Text)) { if (listBoxSearchType.Enabled == true) { if (listBoxSearchType.GetSelected(0) == true) { table = bd.GetUserbyName(bd, FirstUpper(SearchtextBox.Text.ToLower())); dataGridView1.DataSource = table; } else { table = bd.GetUserbyID(bd, SearchtextBox.Text); dataGridView1.DataSource = table; } } else { table = bd.GetLoanbyID(bd, SearchtextBox.Text); dataGridView1.DataSource = table; } } else { MessageBox.Show("Строка поиска пуста!", "Пустая строка", MessageBoxButtons.OK, MessageBoxIcon.Warning); } SetTableName(dataGridView1); }
private void buttonPay_Click(object sender, EventArgs e) { BaseDataLite bd = new BaseDataLite(); DataTable loantb = bd.GetLoanbyID(bd, textBox1.Text); if (loantb != null) { BClaim claim = new BClaim(); claim = BaseDataLite.FillClaim(Convert.ToInt32(textBox1.Text), bd); NotificationWindow window = new NotificationWindow($"{claim.Id}", claim.SumLoan, claim.Days, $"{claim.SumPaid}", "Оплатить"); DialogResult result = window.ShowDialog(); if (result == DialogResult.Yes) { try { if ((Convert.ToInt32(NotificationWindow.text) + claim.PaidOut) > claim.SumPaid) { MessageBox.Show("Сумма оплаты приведет к переплате по займу.\nВведите меньшую сумму", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { BaseDataLite.SendPayment(claim.Id, Convert.ToInt32(NotificationWindow.text)); MessageBox.Show($"Ваша оплата принята в обработку\nP.s здесь должна быть оплата счета.", "", MessageBoxButtons.OK, MessageBoxIcon.Information); BaseDataLite.AutoCloseClaim(claim.Id); } } catch (Exception) { MessageBox.Show("Ой, что-то пошло не так ;(", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private void buttonFindClaim_Click(object sender, EventArgs e) { BaseDataLite bd = new BaseDataLite(); BClaim claim = new BClaim(); if (!String.IsNullOrEmpty(textBox1.Text)) { DataTable loantb = bd.GetLoanbyID(bd, textBox1.Text); if (loantb != null) { claim = BaseDataLite.FillClaim(Convert.ToInt32(textBox1.Text), bd); labelClaimSumLoan.Text = $"{claim.SumLoan} руб."; double proc = 1.0; if (claim.SumLoan > 35000) { proc = 2.0; } double sumfine = (double)claim.SumLoan * (proc / 100.0) * (double)claim.Fine; labelClaimSumPaid.Text = $"{claim.SumPaid} руб.\nвключая штраф:{sumfine}руб.({(sumfine / claim.SumLoan) * 100}%)"; labelClaimFineDays.Text = $"{claim.Fine} дня"; labelClaimPiadout.Text = $"{claim.PaidOut} руб."; labelClaimStatus.Text = $"{claim.status}"; labelClaimDays.Text = $"{claim.Days} дней до {claim.LastDate.ToString("d")}"; labelClaimFirstDate.Text = $"{claim.FirstDate.ToString("d")}"; switch (labelClaimStatus.Text.ToLower()) { case "открыто": labelClaimStatus.ForeColor = Color.FromArgb(236, 214, 22); buttonPay.Enabled = false; break; case "принято": labelClaimStatus.ForeColor = Color.FromArgb(44, 218, 65); buttonPay.Enabled = true; break; case "закрыто": labelClaimStatus.ForeColor = Color.FromArgb(140, 140, 140); buttonPay.Enabled = false; break; case "отклонено": labelClaimStatus.ForeColor = Color.FromArgb(180, 37, 23); buttonPay.Enabled = false; break; default: break; } } else { MessageBox.Show("Займ не найден!", "Займ не найден", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("Строка пуста!", "Пустая строка", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }