/// <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");
     }
 }
Exemplo n.º 2
0
 /// <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]);
     }
 }
Exemplo n.º 3
0
 /// <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 Delete()
 {
     if (W.tabLists.SelectedIndex == 0)
     {
         if (W.lsW.SelectedIndex != -1)
         {
             EntityDB.LowDelete(((Worker)W.lsW.SelectedItem).Id);
             Repository.db.Delete(((Worker)W.lsW.SelectedItem).Id);
         }
     }
     else if (W.tabLists.SelectedIndex == 1)
     {
         if (W.lsVIPW.SelectedIndex != -1)
         {
             EntityDB.LowDelete(((VIPworker)W.lsVIPW.SelectedItem).Id);
             Repository.db.Delete(((VIPworker)W.lsVIPW.SelectedItem).Id);
         }
     }
     else if (W.tabLists.SelectedIndex == 2)
     {
         if (W.lsOrg.SelectedIndex != -1)
         {
             EntityDB.LowDelete(((Organization)W.lsOrg.SelectedItem).Id);
             Repository.db.Delete(((Organization)W.lsOrg.SelectedItem).Id);
         }
     }
     Repository.Refresh();
 }
Exemplo n.º 5
0
 /// <summary>
 /// Добавление клиента
 /// </summary>
 public void AddClient()
 {
     if (W.accType.SelectedIndex == 0)
     {
         if (W.nameOrg.Text != "" && W.salaryOrg.Text != "" && W.typePayOrg.SelectedIndex != -1)
         {
             try
             {
                 Organization newOrg = new Organization(W.nameOrg.Text, Convert.ToInt32(W.salaryOrg.Text),
                                                        W.typePayOrg.SelectedIndex, Repository.correntMonth, Repository.db.Count);
                 Repository.db.Add(newOrg);
                 Repository.Refresh();
                 EntityDB.Add(newOrg);
                 //BaseSQL.Add(newOrg);
                 W.DialogResult = true;
             }
             catch (Exception m)
             {
                 MessageBox.Show(m.Message);
             }
         }
         else
         {
             MessageBox.Show("All string must be fulled!");
         }
     }
     else if (W.accType.SelectedIndex == 1)
     {
         if (W.firstnameW.Text != "" && W.lastnameW.Text != "" && W.ageW.Text != "" && W.salaryW.Text != "" && W.typePayW.SelectedIndex != -1)
         {
             try
             {
                 Worker newW = new Worker(W.firstnameW.Text, W.lastnameW.Text, Convert.ToInt32(W.ageW.Text),
                                          Convert.ToInt32(W.salaryW.Text), W.typePayW.SelectedIndex,
                                          Repository.correntMonth, Repository.db.Count);
                 Repository.db.Add(newW);
                 Repository.Refresh();
                 EntityDB.Add(newW);
                 //BaseSQL.Add(newW);
                 W.DialogResult = true;
             }
             catch (Exception m)
             {
                 MessageBox.Show(m.Message);
             }
         }
         else
         {
             MessageBox.Show("All string must be fulled!");
         }
     }
     else
     {
         return;
     }
 }
 /// <summary>
 /// Сделать клиента VIP клиентом
 /// </summary>
 public void SetVIPWorker()
 {
     if (W.tabLists.SelectedIndex == 0)
     {
         if (W.lsW.SelectedIndex != -1)
         {
             int       Id     = Repository.db.GetId((Worker)W.lsW.SelectedItem);
             VIPworker newvip = new VIPworker((Worker)Repository.db[Id]);
             Repository.db.ReWrite(newvip, Id);
             EntityDB.Delete(newvip.Id);
             EntityDB.Add(newvip);
             Repository.Refresh();
         }
         else
         {
             MessageBox.Show("Select client");
         }
     }
     else
     {
         MessageBox.Show("VIP can be seted only standart clients!");
     }
 }
        /// <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");
            }
        }
Exemplo n.º 8
0
 public void ConnectToDB()
 {
     entityDB = new EntityDB();
 }