/// <summary> /// Внесение денег на счет клиента /// </summary> public void DepositMoney() { try { if (Convert.ToDouble(W.sum.Text) < 0) { throw new MoneyException("Sum can be only positive number"); } Repository.db[Convert.ToInt32(W.ID.Text)].deposit += Convert.ToDouble(W.sum.Text); EntityDB.Change(Repository.db[Convert.ToInt32(W.ID.Text)]); //BaseSQL.Change(SystemPayments.db[Convert.ToInt32(ID.Text)]); string log = $"-->Счёт клиента с ID: {W.ID.Text} был пополнен на сумму {W.sum.Text}"; using (StreamWriter st = new StreamWriter(@"logs.txt", true)) { st.WriteLine(log); } W.DialogResult = true; } catch (MoneyException ex) { MessageBox.Show(ex.Message); } catch (FormatException) { MessageBox.Show("Wrong sum"); } }
/// <summary> /// Метод для выплаты каждый месяц /// </summary> public void MethodPaymentsCapitalizated(int Id) { if (Repository.db[Id].GetType() == Type.GetType("Rushtell_Bunk.Clients.Worker")) { DepositChanged?.Invoke(Repository.db[Id], Math.Round(Repository.db[Id].deposit * 1.02 - Repository.db[Id].deposit, 2)); Repository.db[Id].deposit = Repository.db[Id].deposit * 1.02; Repository.db[Id].deposit = Math.Round(Repository.db[Id].deposit, 2); EntityDB.Change(Repository.db[Id]); //BaseSQL.Change(db[Id]); } else if (Repository.db[Id].GetType() == Type.GetType("Rushtell_Bunk.Clients.VIPworker")) { DepositChanged?.Invoke(Repository.db[Id], Math.Round(Repository.db[Id].deposit * 1.03 - Repository.db[Id].deposit, 2)); Repository.db[Id].deposit = Repository.db[Id].deposit * 1.03; Repository.db[Id].deposit = Math.Round(Repository.db[Id].deposit, 2); EntityDB.Change(Repository.db[Id]); //BaseSQL.Change(db[Id]); } else if (Repository.db[Id].GetType() == Type.GetType("Rushtell_Bunk.Clients.Organization")) { DepositChanged?.Invoke(Repository.db[Id], Math.Round(Repository.db[Id].deposit * 1.01 - Repository.db[Id].deposit, 2)); Repository.db[Id].deposit = Repository.db[Id].deposit * 1.01; Repository.db[Id].deposit = Math.Round(Repository.db[Id].deposit, 2); EntityDB.Change(Repository.db[Id]); //BaseSQL.Change(db[Id]); } }
/// <summary> /// Метод для стандартной выплаты /// </summary> public void MethodPaymentsStandart(int Id) { if (Repository.db[Id].GetType() == Type.GetType("Rushtell_Bunk.Clients.Worker")) { DepositChanged?.Invoke(Repository.db[Id], Math.Round(Repository.db[Id].deposit * 1.24 - Repository.db[Id].deposit, 2)); Repository.db[Id].deposit = Repository.db[Id].deposit * 1.24; Repository.db[Id].deposit = Math.Round(Repository.db[Id].deposit, 2); EntityDB.Change(Repository.db[Id]); //BaseSQL.Change(db[Id]); } else if (Repository.db[Id].GetType() == Type.GetType("Rushtell_Bunk.Clients.VIPworker")) { DepositChanged?.Invoke(Repository.db[Id], Math.Round(Repository.db[Id].deposit * 1.36 - Repository.db[Id].deposit, 2)); Repository.db[Id].deposit = Repository.db[Id].deposit * 1.36; Repository.db[Id].deposit = Math.Round(Repository.db[Id].deposit, 2); EntityDB.Change(Repository.db[Id]); //BaseSQL.Change(db[Id]); } else if (Repository.db[Id].GetType() == Type.GetType("Rushtell_Bunk.Clients.Organization")) { DepositChanged?.Invoke(Repository.db[Id], Math.Round(Repository.db[Id].deposit * 1.12 - Repository.db[Id].deposit, 2)); Repository.db[Id].deposit = Repository.db[Id].deposit * 1.12; Repository.db[Id].deposit = Math.Round(Repository.db[Id].deposit, 2); EntityDB.Change(Repository.db[Id]); //BaseSQL.Change(db[Id]); } }
/// <summary> /// Перевод денег со счета на счет клинтов /// </summary> public void TransferMoney() { try { if (Convert.ToDouble(W.sum.Text) < 0) { throw new MoneyException("Sum can be only positive number"); } if (Convert.ToDouble(W.sum.Text) > Convert.ToDouble(W.Deposit.Text)) { throw new MoneyException("You havent so much money"); } if (Repository.db[Convert.ToInt32(W.idAddressee.Text)] == null) { throw new IDException("Wrong ID addressee"); } if (Repository.db[Convert.ToInt32(W.ID.Text)].GetType() == Type.GetType("Rushtell_Bunk.Clients.Organization") && Repository.db[Convert.ToInt32(W.idAddressee.Text)].GetType() == Type.GetType("Rushtell_Bunk.Clients.Worker")) { throw new ClassTypeException("Juristical clints can transfer money only juristical client"); } if (Repository.db[Convert.ToInt32(W.ID.Text)].GetType() == Type.GetType("Rushtell_Bunk.Clients.Organization") && Repository.db[Convert.ToInt32(W.idAddressee.Text)].GetType() == Type.GetType("Rushtell_Bunk.Clients.VIPworker")) { throw new ClassTypeException("Juristical clints can transfer money only juristical client"); } Repository.db[Convert.ToInt32(W.ID.Text)].deposit -= Convert.ToDouble(W.sum.Text); Repository.db[Convert.ToInt32(W.idAddressee.Text)].deposit += Convert.ToDouble(W.sum.Text); EntityDB.Change(Repository.db[Convert.ToInt32(W.ID.Text)]); EntityDB.Change(Repository.db[Convert.ToInt32(W.idAddressee.Text)]); //BaseSQL.Change(SystemPayments.db[Convert.ToInt32(ID.Text)]); //BaseSQL.Change(SystemPayments.db[Convert.ToInt32(idAddressee.Text)]); string log = $"-->Со счёта клиента с ID: {W.ID.Text} была переведена сумма {W.sum.Text}, клиенту {W.idAddressee.Text}"; using (StreamWriter st = new StreamWriter(@"logs.txt", true)) { st.WriteLine(log); } W.DialogResult = true; } catch (IDException ex) { MessageBox.Show(ex.Message); } catch (MoneyException ex) { MessageBox.Show(ex.Message); } catch (ClassTypeException ex) { MessageBox.Show(ex.Message); } catch (Exception) { MessageBox.Show("Wrong sum or ID addressee"); } }