private void buttonSendDecision_Click(object sender, EventArgs e) { DecideForm f = new DecideForm(); DialogResult result = f.ShowDialog(); try { if (result == DialogResult.Yes) { BaseDataLite.SetNewStatus(Convert.ToInt32(labelLoanID.Text.Substring(1)), "принято"); buttonSendDecision.Enabled = false; MessageBox.Show("Заявка принята", "", MessageBoxButtons.OK, MessageBoxIcon.Information); labelStatus.ForeColor = Color.FromArgb(44, 218, 65); labelStatus.Text = "принято"; DataBase.GeneralMessages.SendEmailNewStatus(labelEmail.Text, "принято", labelName.Text, BaseDataLite.FillClaim(Convert.ToInt32(labelLoanID.Text.Substring(1)), bd)); } else if (result == DialogResult.No) { BaseDataLite.SetNewStatus(Convert.ToInt32(labelLoanID.Text.Substring(1)), "отклонено"); buttonSendDecision.Enabled = false; MessageBox.Show("Заявка отклонена", "", MessageBoxButtons.OK, MessageBoxIcon.Information); labelStatus.ForeColor = Color.FromArgb(180, 37, 23); labelStatus.Text = "отклонено"; DataBase.GeneralMessages.SendEmailNewStatus(labelEmail.Text, "отклонено", labelName.Text, BaseDataLite.FillClaim(Convert.ToInt32(labelLoanID.Text.Substring(1)), bd)); } } catch (Exception) { MessageBox.Show("Ой, что-то пошло не так ;(", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
} // Отрисовка заявки private void buttonSendUpdate_Click(object sender, EventArgs e) { DialogResult dialogResult = MessageBox.Show("Вы хотите сохранить изменения ?", "Сохранить ?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dialogResult == DialogResult.Yes) { try { string tablename; if (listBoxTypeVision.GetSelected(0)) { tablename = "Loan"; } else { tablename = "Users"; } table = (DataTable)dataGridView1.DataSource; BaseDataLite.UpdateBaseDate(table, tablename); MessageBox.Show("Таблица успешно сохранена.", "Успех!", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception) { MessageBox.Show("Ой, что-то пошло не так ;(\nВозможно вы оставлили пустую строку.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
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); } }
private void buttonAddFine_Click(object sender, EventArgs e) { try { BaseDataLite.SetFine(Convert.ToInt32(textBoxFineDays.Text), Convert.ToInt32(labelLoanID.Text.Substring(1)), claim); MessageBox.Show("Штрафные дни увеличены", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception) { MessageBox.Show("Ой, что-то пошло не так ;(", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void buttonCloseClaim_Click(object sender, EventArgs e) { if (labelStatus.Text == "принято") { buttonCloseClaim.Enabled = true; DialogResult dialogResult = MessageBox.Show("Вы уверены что хотитие закрыть заявку ?", "", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); if (dialogResult == DialogResult.OK) { BaseDataLite.SetNewStatus(Convert.ToInt32(labelLoanID.Text.Substring(1)), "закрыто"); MessageBox.Show("Заявка закрыта", "", MessageBoxButtons.OK, MessageBoxIcon.Information); labelStatus.ForeColor = Color.FromArgb(140, 140, 140); labelStatus.Text = "закрыто"; DataBase.GeneralMessages.SendEmailNewStatus(labelEmail.Text, "закрыто", labelName.Text, BaseDataLite.FillClaim(Convert.ToInt32(labelLoanID.Text.Substring(1)), bd)); } } }
private void buttonDeleateOLD_Click(object sender, EventArgs e) // Удалить все отклоненые заявки. { try { DialogResult dialogResult = MessageBox.Show(" Вы уверены что хотите удалить отклоненые заявки ?\n Это приведет к тому, что пользователи утратят доступ к увдомлению об отклонении.\n Уведомление отправленные на почту не удалятся.", "Удалить ?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dialogResult == DialogResult.Yes) { BaseDataLite.DeleateOld(); MessageBox.Show("Успешно удаленно", "Успех!", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception) { MessageBox.Show("Ой, что-то пошло не так ;(", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void button2_Click(object sender, EventArgs e) { try { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "PDF files(.pdf)|*.pdf"; saveFileDialog.FileName = $"Паспорт клиента {labelClientId.Text}"; if (saveFileDialog.ShowDialog() == DialogResult.Cancel) { return; } LoadingScreen(true); File.WriteAllBytes(saveFileDialog.FileName, BaseDataLite.GetFile(Convert.ToInt32(labelLoanID.Text.Substring(1)))); LoadingScreen(false); MessageBox.Show("Ваш файл был успешно загружен и сохранен", "Сохранено", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception) { MessageBox.Show("Ой, что-то пошло не так ;(", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); LoadingScreen(false); } }
private void buttonOpenClaim_Click(object sender, EventArgs e) { if (!String.IsNullOrEmpty(textBoxIDClaim.Text)) { DataTable loantb = bd.GetLoanbyID(bd, $"{textBoxIDClaim.Text}"); if (loantb != null) { try { DataTable usertb = bd.GetUserbyID(bd, $"{Convert.ToInt32(loantb.Rows[0][5])}"); groupBox1.Enabled = true; #region claimdata //GetDataFromBD claim = BaseDataLite.FillClaim(Convert.ToInt32(textBoxIDClaim.Text), bd); //Write data to claim interface labelLoanID.Text = $"№{claim.Id}"; lableLoanSum.Text = $"{claim.SumLoan}"; labelDays.Text = $"{claim.Days}"; lableFineDays.Text = $"{claim.Fine}"; labelCardNumber.Text = $"{claim.CardNumber}"; labelType.Text = claim.type.ToLower();; labelStatus.Text = claim.status.ToLower(); double proc = 1.0; if (claim.SumLoan > 35000) { proc = 2.0; } double sumfine = (double)claim.SumLoan * (proc / 100.0) * (double)claim.Fine; labelPaidOUT.Text = $"{claim.PaidOut}/{claim.SumPaid} \nвключая штраф:{sumfine}руб.({(sumfine/claim.SumLoan)*100}%)"; #endregion #region userdata //GetDataFromBD user.Id = Convert.ToInt32(loantb.Rows[0][5]); user.Name = Convert.ToString(usertb.Rows[0][1]); user.SecoundName = Convert.ToString(usertb.Rows[0][2]); user.MiddleName = Convert.ToString(usertb.Rows[0][3]); user.Passport = Convert.ToString(usertb.Rows[0][7]); user.BirthDay = Convert.ToDateTime(usertb.Rows[0][4]); user.Phone = Convert.ToString(usertb.Rows[0][5]); user.Email = Convert.ToString(usertb.Rows[0][6]); //Write data to claim interface labelClientId.Text = $"{user.Id}"; labelName.Text = $"{user.SecoundName} {user.Name} {user.MiddleName}"; labelPass.Text = user.Passport; labelBirthday.Text = user.BirthDay.ToString("d"); labelPhone.Text = user.Phone.ToString(); labelEmail.Text = user.Email; #endregion } catch (Exception) { groupBox1.Enabled = false; MessageBox.Show("Ой, что-то пошло не так ;(", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (Convert.ToInt32(lableFineDays.Text) > 0) { lableFineDays.ForeColor = Color.FromArgb(180, 37, 23); label12.ForeColor = Color.FromArgb(180, 37, 23); } switch (labelStatus.Text.ToLower()) { case "открыто": labelStatus.ForeColor = Color.FromArgb(236, 214, 22); buttonSendDecision.Enabled = true; buttonAddFine.Enabled = false; buttonCloseClaim.Enabled = false; break; case "принято": labelStatus.ForeColor = Color.FromArgb(44, 218, 65); buttonSendDecision.Enabled = false; buttonAddFine.Enabled = true; buttonCloseClaim.Enabled = true; break; case "закрыто": labelStatus.ForeColor = Color.FromArgb(140, 140, 140); buttonSendDecision.Enabled = false; buttonAddFine.Enabled = false; buttonCloseClaim.Enabled = false; break; case "отклонено": labelStatus.ForeColor = Color.FromArgb(180, 37, 23); buttonSendDecision.Enabled = false; buttonAddFine.Enabled = true; buttonCloseClaim.Enabled = false; break; default: break; } } else { MessageBox.Show("Займ не найден!", "Займ не найден", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("Строка пуста!", "Пустая строка", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } // Отрисовка заявки
private void CreateClaim() // Создание заявки и отправка { BClaim claim = new BClaim(); User user = new User(); #region Claim while (true) { claim.Id = BClaim.GenerateID(6); if (!BaseDataLite.CheckLoanID(claim.Id)) { break; } } claim.SumLoan = Convert.ToInt32(textBoxSumLoan.Text); claim.Days = Convert.ToInt32(textBoxDays.Text); claim.FirstDate = DateTime.Parse(maskedTextBoxFirstDay.Text); if (radioButtonCard.Checked) { claim.CardNumber = maskedCardNumber.Text; } else { claim.CardNumber = "-"; } claim.SumPaid = Convert.ToInt32(labelPaidSum.Text); claim.LastDate = claim.FirstDate.AddDays(claim.Days); claim.Fine = 0; claim.PaidOut = 0; if (radioButtonCard.Checked) { claim.type = "карта"; } else { claim.type = "наличка"; } claim.status = "открыто"; #endregion #region User if (!BaseDataLite.CheckUserExist(textBoxUserPassport.Text)) { while (true) { user.Id = BClaim.GenerateID(4); if (!BaseDataLite.CheckUsersID(user.Id)) { break; } } user.Name = textBoxUserName.Text; user.SecoundName = textBoxUserSecName.Text; user.MiddleName = textBoxUserMidName.Text; user.BirthDay = DateTime.Parse(maskedUserBirthDay.Text); user.Phone = maskedUserPhone.Text; user.Email = maskedEmail.Text; user.Passport = textBoxUserPassport.Text; LoadingScreen(true); BaseDataLite.CreateNewUser(user.Id, user.Name, user.SecoundName, user.MiddleName, user.BirthDay, user.Phone, user.Email, user.Passport); LoadingScreen(false); } else { user.Id = BaseDataLite.GetUserID(textBoxUserPassport.Text); BaseDataLite.SendUserDataUpdate(user.Id, maskedEmail.Text, maskedUserPhone.Text); } #endregion #region Docs int docid; while (true) { docid = BClaim.GenerateID(5); if (!BaseDataLite.CheckDocID(claim.Id)) { break; } } #endregion if (!BaseDataLite.CheckSeveralLoan(user.Id)) { try { LoadingScreen(true); BaseDataLite.SendClaim(claim.Id, claim.SumPaid / claim.Days, claim.SumLoan, claim.Days, claim.FirstDate, user.Id, docid, claim.CardNumber, claim.SumPaid, claim.Fine, claim.PaidOut, claim.type, claim.status); BaseDataLite.SendFile(FileAddres, docid); GeneralMessages.SendEmailNewLoan(user.Email, $"{user.Name} {user.SecoundName} {user.MiddleName} ", claim); LoadingScreen(false); NotificationWindow f = new NotificationWindow($"{claim.Id}", claim.SumLoan, claim.Days, $"{claim.SumPaid}"); DialogResult result = f.ShowDialog(); if (result == DialogResult.OK) { if (panelCreateClaim.Visible == true) { panelMain.Visible = false; panelCheckClaim.Visible = true; panelCreateClaim.Visible = false; panelAbout.Visible = false; } else { panelMain.Visible = false; panelCheckClaim.Visible = true; panelAbout.Visible = false; } } } catch (Exception) { LoadingScreen(false); MessageBox.Show("Ой, что-то пошло не так ;(", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show($"Похоже что у вас уже есть принятые или новые заявки.\nЗавершите предыдущий займ, для того чтобы взять новый.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }