private void button2_Click(object sender, EventArgs e)
        {
            Dictionary <uint, Client> clientsDictionary = Serealizator.desearealizable();

            if (tb1.Text == "")
            {
                MessageBox.Show("Заповніть поле з паролем!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (tb1.Text == "0000")
            {
                Admin admin = new Admin();
                admin.Show();
                this.Hide();
                return;
            }
            Client client = null;

            try
            {
                client = clientsDictionary[Convert.ToUInt32(tb1.Text)];
            }
            catch
            {
                MessageBox.Show("Такого пін коду не знайдено!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                tb1.Text = "";
                return;
            }
            User user = new User(clientsDictionary, client, Convert.ToUInt32(tb1.Text));

            user.Show();
            this.Hide();
        }
示例#2
0
        private void Button2_Click(object sender, EventArgs e)
        {
            string suma = Interaction.InputBox("Введіть cуму", "", "");

            if (!tryToUint(suma))
            {
                return;
            }

            if (Convert.ToDouble(suma) == 0)
            {
                showMes("Не може бути 0");
                return;
            }
            if (client.account.balance.Equals(0) || ToUInt(suma) > client.account.balance)
            {
                showMes("Недостатньо коштів на рахунку");
                return;
            }
            else
            {
                client.account.minusMoney(Convert.ToDouble(suma));
                client.account.lastOperations.Add(new Operation(DateTime.Now, ("-" + suma + " UAH")));
                clientsDictionary[key] = client;
                Serealizator.serealizable(clientsDictionary);
                label7.Text = "Баланс " + client.account.balance.ToString();
                refreshDatagrid(client.account.lastOperations);
                tSS2.Text = "Знято" + suma + " UAH";
            }
        }
示例#3
0
        private void BtEditClientPlusMoneyDeposit_Click(object sender, EventArgs e)
        {
            if (cbEditClient.SelectedItem == null)
            {
                showMes("Оберіть клієнта");
                return;
            }
            if (cbEditClient.Items.Count == 0)
            {
                showMes("Список клієнтів пустий");
                return;
            }
            Client client = clientsDictionary.Values.ToList().Find(a => a.pasport == ToUInt(cbEditClient.SelectedItem.ToString()));
            uint   key    = clientsDictionary.FirstOrDefault(x => x.Value == client).Key;
            string suma   = Interaction.InputBox("Введіть cуму : ", "", "");

            if (!tryToUint(suma))
            {
                return;
            }

            if (Convert.ToDouble(suma) == 0)
            {
                showMes("Не може бути 0");
                return;
            }
            client.account.deposit.plusMoney(Convert.ToDouble(suma));
            client.account.lastOperations.Add(new Operation(DateTime.Now, ("(Депозит) +" + suma + " UAH")));
            clientsDictionary[key] = client;
            Serealizator.serealizable(clientsDictionary);
            label13.Text = "Баланс " + client.account.deposit.balance.ToString();
            refreshDatagrid(client.account.lastOperations);
            tSS.Text = "Внесено на депозит " + suma + " UAH";
        }
示例#4
0
        private void BtEditClientDeposit_Click(object sender, EventArgs e)
        {
            if (cbEditClient.SelectedItem == null)
            {
                showMes("Оберіть клієнта");
                return;
            }
            if (cbEditClient.Items.Count == 0)
            {
                showMes("Список клієнтів пустий");
                return;
            }
            Client client = clientsDictionary.Values.ToList().Find(a => a.pasport == ToUInt(cbEditClient.SelectedItem.ToString()));
            uint   key    = clientsDictionary.FirstOrDefault(x => x.Value == client).Key;

            if (cbEditDeposit.Text == "")
            {
                showMes("Оберіть тип депозиту!");
                return;
            }
            client.account.deposit.type = cbEditDeposit.Text;
            client.account.deposit.initStavka(cbEditDeposit.Text);
            client.account.deposit.dateOfDeposit = DateTime.Now;

            string interval = Interaction.InputBox("Введіть кількість місяців: на скільки ви хочете покласти: ", "", "");

            if (!tryToUint(interval))
            {
                return;
            }
            if (Convert.ToDouble(interval) == 0)
            {
                showMes("Не може бути 0");
                return;
            }
            TimeSpan interv = new TimeSpan((int)(ToUInt(interval) * 31), 0, 0, 0);

            client.account.deposit.interval = interv;
            string suma = Interaction.InputBox("Введіть cуму яку ви хочете покласти: ", "", "");

            if (!tryToUint(suma))
            {
                return;
            }
            if (Convert.ToDouble(suma) == 0)
            {
                showMes("Не може бути 0");
                return;
            }
            client.account.deposit.balance = Convert.ToDouble(suma);
            client.account.lastOperations.Add(new Operation(DateTime.Now, ("(Депозит) +" + suma + " UAH")));
            clientsDictionary[key] = client;
            Serealizator.serealizable(clientsDictionary);
            label13.Text = "Баланс " + client.account.deposit.balance.ToString();
            refreshDatagrid(client.account.lastOperations);
            tSS.Text     = "Внесено на депозит" + suma + " UAH";
            label15.Text = client.account.deposit.dateOfDeposit.ToString();
            btEditClientDeposit.Visible = false;
            cbEditDeposit.Enabled       = false;
        }
示例#5
0
 private void Admin_Load(object sender, EventArgs e)
 {
     this.Width        = 866;
     this.Height       = 426;
     clientsDictionary = Serealizator.desearealizable();
     if (clientsDictionary == null)
     {
         clientsDictionary = new Dictionary <uint, Client>();
     }
     tSS2.Text = "Прочитано клієнтів з файлу";
 }
示例#6
0
        private void BtEditClient_Click(object sender, EventArgs e)
        {
            Client client = clientsDictionary.Values.ToList().Find(a => a.pasport == ToUInt(cbEditClient.SelectedItem.ToString()));

            if (client.prizv != null)
            {
                if (tbEditName.Text == "" || tbEditPrizv.Text == "" || tbEditSurname.Text == "" || tbEditPasport.Text == "" || tbEditPinKod.Text == "")
                {
                    showMes("Не всі рядки заповнено!");
                    return;
                }
                client.name    = tbEditName.Text;
                client.prizv   = tbEditPrizv.Text;
                client.surname = tbEditSurname.Text;
                client.pasport = ToUInt(tbEditPasport.Text);
            }
            else
            {
                if (tbEditName.Text == "" || tbEditPasport.Text == "" || tbEditPinKod.Text == "")
                {
                    showMes("Не всі рядки заповнено!");
                    return;
                }
                client.name    = tbEditName.Text;
                client.prizv   = null;
                client.surname = null;
                client.pasport = ToUInt(tbEditPasport.Text);
            }
            if (!tryToUint(tbEditPasport.Text) || !tryToUint(tbEditPinKod.Text))
            {
                return;
            }

            if (cbEditClient.SelectedItem == null)
            {
                return;
            }
            if (cbEditClient.Items.Count == 0)
            {
                showMes("Список клієнтів пустий");
                return;
            }

            uint key = clientsDictionary.FirstOrDefault(x => x.Value == client).Key;

            clientsDictionary.Remove(key);
            clientsDictionary.Add(ToUInt(tbEditPinKod.Text), client);
            Serealizator.serealizable(clientsDictionary);
            clearAllFields();
            refreshCbEditClient();
            tSS.Text = "Віредаговано";
        }
示例#7
0
        private void BtEditClientMinusMoney_Click(object sender, EventArgs e)
        {
            if (cbEditClient.SelectedItem == null)
            {
                showMes("Оберіть клієнта");
                return;
            }
            if (cbEditClient.Items.Count == 0)
            {
                showMes("Список клієнтів пустий");
                return;
            }
            Client client = clientsDictionary.Values.ToList().Find(a => a.pasport == ToUInt(cbEditClient.SelectedItem.ToString()));
            uint   key    = clientsDictionary.FirstOrDefault(x => x.Value == client).Key;
            string suma   = Interaction.InputBox("Введіть cуму", "", "");

            if (!tryToUint(suma))
            {
                return;
            }

            if (Convert.ToDouble(suma) == 0)
            {
                showMes("Не може бути 0");
                return;
            }
            if (client.account.balance.Equals(0) || ToUInt(suma) > client.account.balance)
            {
                showMes("Недостатньо коштів на рахунку");
                return;
            }
            else
            {
                client.account.minusMoney(Convert.ToDouble(suma));
                client.account.lastOperations.Add(new Operation(DateTime.Now, ("-" + suma + " UAH")));
                clientsDictionary[key] = client;
                Serealizator.serealizable(clientsDictionary);
                label7.Text = "Баланс " + client.account.balance.ToString();
                refreshDatagrid(client.account.lastOperations);
                tSS.Text = "Знято" + suma + " UAH";
            }
        }
示例#8
0
        private void Button1_Click(object sender, EventArgs e)
        {
            if (cbEditClient.SelectedItem == null)
            {
                showMes("Оберіть клієнта");
                return;
            }
            if (cbEditClient.Items.Count == 0)
            {
                showMes("Список клієнтів пустий");
                return;
            }
            Client client = clientsDictionary.Values.ToList().Find(a => a.pasport == ToUInt(cbEditClient.SelectedItem.ToString()));
            uint   key    = clientsDictionary.FirstOrDefault(x => x.Value == client).Key;

            clientsDictionary.Remove(key);
            Serealizator.serealizable(clientsDictionary);
            clearAllFields();
            refreshCbEditClient();
            tSS.Text = "Видалено";
        }
示例#9
0
        private void Button3_Click(object sender, EventArgs e)
        {
            string suma = Interaction.InputBox("Введіть cуму", "", "");

            if (!tryToUint(suma))
            {
                return;
            }
            if (Convert.ToDouble(suma) == 0)
            {
                showMes("Не може бути 0");
                return;
            }
            client.account.plusMoney(Convert.ToDouble(suma));
            client.account.lastOperations.Add(new Operation(DateTime.Now, ("+" + suma + " UAH")));
            clientsDictionary[key] = client;
            Serealizator.serealizable(clientsDictionary);
            label7.Text = "Баланс " + client.account.balance.ToString();
            refreshDatagrid(client.account.lastOperations);
            tSS2.Text = "Внесено на баланс" + suma + " UAH";
        }
示例#10
0
        private void Button5_Click(object sender, EventArgs e)
        {
            if (comboBox1.SelectedItem == null)
            {
                showMes("Оберіть тип клієнта!");
                return;
            }
            if (comboBox1.SelectedItem.ToString() == "Фізична особа" && (tbAddName.Text == "" || tbAddPrizv.Text == "" || tbAddSurname.Text == "" || tbAddPasport.Text == "" || tbAddPinKod.Text == ""))
            {
                showMes("Не всі рядки заповнено!");
                return;
            }
            if (comboBox1.SelectedItem.ToString() == "Юридична особа" && (tbAddName.Text == "" || tbAddPrizv.Text == "" || tbAddPinKod.Text == ""))
            {
                showMes("Не всі рядки заповнено!");
                return;
            }
            if (comboBox1.SelectedItem.ToString() == "Фізична особа" && (!tryToUint(tbAddPasport.Text) || !tryToUint(tbAddPinKod.Text)))
            {
                showMes("Некоректно введенні данні!");
                return;
            }

            if (comboBox1.SelectedItem.ToString() == "Юридична особа" && (!tryToUint(tbAddPrizv.Text) || !tryToUint(tbAddPinKod.Text)))
            {
                showMes("Некоректно введенні данні!");
                return;
            }
            Client client = null;

            if (comboBox1.SelectedItem.ToString() == "Фізична особа")
            {
                if (clientsDictionary != null)
                {
                    if (!clientsDictionary.Values.All(a => a.pasport != ToUInt(tbAddPasport.Text)))
                    {
                        showMes("Такий клієнт вже існує");
                        return;
                    }

                    if (!clientsDictionary.Keys.All(a => a != ToUInt(tbAddPinKod.Text)) || tbAddPinKod.Text == "0000")
                    {
                        showMes("Такий пін Код вже існує");
                        return;
                    }
                }
                client = new Client(tbAddName.Text, tbAddPrizv.Text, tbAddSurname.Text, ToUInt(tbAddPasport.Text), new Account(0, new Deposit("", 0, 0, default(DateTime), default(TimeSpan)), new List <Operation>()));
            }
            else
            {
                if (clientsDictionary != null)
                {
                    if (!clientsDictionary.Values.All(a => a.pasport != ToUInt(tbAddPrizv.Text)))
                    {
                        showMes("Такий клієнт вже існує");
                        return;
                    }

                    if (!clientsDictionary.Keys.All(a => a != ToUInt(tbAddPinKod.Text)))
                    {
                        showMes("Такий пін Код вже існує");
                        return;
                    }
                }
                client = new Client(tbAddName.Text, null, null, ToUInt(tbAddPrizv.Text), new Account(0, new Deposit("", 0, 0, default(DateTime), default(TimeSpan)), new List <Operation>()));
            }
            clientsDictionary.Add(ToUInt(tbAddPinKod.Text), client);
            Serealizator.serealizable(clientsDictionary);
            clearTb(tbAddName); clearTb(tbAddPrizv); clearTb(tbAddSurname); clearTb(tbAddPasport); clearTb(tbAddPinKod);
            tSS2.Text = "Додано клієнта і записано у файл";
        }