Пример #1
0
        private void ButAdd_Click(object sender, RoutedEventArgs e)
        {
            SQLDataBase dataBase = new SQLDataBase();

            if (TextIsDate(BoxBirthday.Text))
            {
                if (BoxName.Text != string.Empty && BoxSum.Text != string.Empty)
                {
                    var temp = new SimpleLegalEnity(BoxName.Text, "Юридическое лицо",
                                                    DateTime.Parse(BoxBirthday.Text), decimal.Parse(BoxSum.Text));
                    Bank.Add(temp);
                    dataBase.GoToDataBase(dataBase.CreateSQL(temp) + $@"
(
{temp.ID}, N'{temp.Name}', '{Convert.ToDateTime(temp.DateofBirth).ToString("yyyy-MM-dd")}', N'{temp.reputation}',N'{temp.Department}', {temp.AccountNumber},
{temp.AmountOfMoney}, {temp.CheckContribution}, {temp.CheckDebt}
)
");
                    Close();
                }
                else
                {
                    MessageBox.Show("Не все поля заполнены", "WARNING", MessageBoxButton.OK,
                                    MessageBoxImage.Warning);
                }
            }
            else
            {
                MessageBox.Show("Введите корректную дату создания", "WARNING", MessageBoxButton.OK,
                                MessageBoxImage.Warning);
            }
        }
Пример #2
0
        /// <summary>
        /// Добавить клиента
        /// </summary>
        private void AddClient()
        {
            SQLDataBase dataBase = new SQLDataBase();

            if (RadioNatural.IsChecked == true)
            {
                if (TextIsDate(BoxBirthday.Text))
                {
                    if (BoxFirstName.Text != string.Empty && BoxLastName.Text != string.Empty &&
                        BoxBirthday.Text != string.Empty && BoxSumNatur.Text != string.Empty)
                    {
                        var temp = new VipNaturalClient(BoxFirstName.Text, BoxLastName.Text, "VIP",
                                                        DateTime.Parse(BoxBirthday.Text), decimal.Parse(BoxSumNatur.Text));
                        Bank.Add(temp);
                        dataBase.GoToDataBase(dataBase.CreateSQL(temp) + $@"
(
{temp.ID}, N'{temp.FirstName}', N'{temp.LastName}', '{Convert.ToDateTime(temp.DateofBirth).ToString("yyyy-MM-dd")}',
N'{temp.Department}', {temp.AccountNumber},
{temp.AmountOfMoney}, {temp.CheckContribution}, {temp.CheckDebt}
)
");
                        Close();
                    }
                    else
                    {
                        MessageBox.Show("Не все поля введены!", "WARNING", MessageBoxButton.OK,
                                        MessageBoxImage.Warning);
                    }
                }
                else
                {
                    MessageBox.Show("введите дату в формате dd.MM.yyyy", "WARNING", MessageBoxButton.OK,
                                    MessageBoxImage.Warning);
                }
            }
            else
            {
                if (TextIsDate(BoxCreateDate.Text))
                {
                    if (BoxName.Text != string.Empty &&
                        BoxCreateDate.Text != string.Empty && BoxSumLegal.Text != string.Empty)
                    {
                        var temp = new VipLegalEnity(BoxName.Text, "VIP",
                                                     DateTime.Parse(BoxCreateDate.Text), decimal.Parse(BoxSumLegal.Text));
                        Bank.Add(temp);
                        dataBase.GoToDataBase(dataBase.CreateSQL(temp) + $@"
(
{temp.ID}, N'{temp.Name}', '{Convert.ToDateTime(temp.DateofBirth).ToString("yyyy-MM-dd")}', N'{temp.Department}', {temp.AccountNumber},
{temp.AmountOfMoney}, {temp.CheckContribution}, {temp.CheckDebt}
)
");
                        Close();
                    }
                    else
                    {
                        MessageBox.Show("Не все поля введены!", "WARNING", MessageBoxButton.OK,
                                        MessageBoxImage.Warning);
                    }
                }
                else
                {
                    MessageBox.Show("введите дату в формате dd.MM.yyyy", "WARNING", MessageBoxButton.OK,
                                    MessageBoxImage.Warning);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Запуск процесса генерации сотрудников
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ButGoToMass_Click(object sender, RoutedEventArgs e)
        {
            List <string> Client_FirstNames = new List <string>();

            Client_FirstNames = LoadNames("../../../resources/Names.txt");
            List <string> Client_LastNames = new List <string>();

            Client_LastNames = LoadNames("../../../resources/LastNames.txt");
            int count_workers = 0;

            try
            {
                count_workers = int.Parse(RandomBox.Text); //количество рабочих
            }
            catch (FormatException)
            {
                count_workers = default(int);
                MessageBox.Show("Неверный формат, можно вводить только цифры!", "ERROR", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            Random      r           = new Random();
            Random      random_spec = new Random(); //специальность
            Random      random_name = new Random();
            Random      random_dep  = new Random();
            SQLDataBase dataBase    = new SQLDataBase();

            while (count_workers > 0)
            {
                int count = Bank.Count;
                switch (random_spec.Next(1, 5))
                {
                case 1:
                {
                    var temp = new SimpleNaturalClient($"{Client_FirstNames[random_name.Next(Client_FirstNames.Count)]}",
                                                       $"{Client_LastNames[random_name.Next(Client_LastNames.Count)]}",
                                                       "Физический",
                                                       DateTime.Now.AddYears(-r.Next(16, 80)), (decimal)r.Next(20000, 2000000));
                    Bank.Add(temp);
                    dataBase.GoToDataBase(dataBase.CreateSQL(temp) + $@"
(
{temp.ID}, N'{temp.FirstName}', N'{temp.LastName}', '{Convert.ToDateTime(temp.DateofBirth).ToString("yyyy-MM-dd")}', N'{temp.reputation}',
N'{temp.Department}', {temp.AccountNumber},
{temp.AmountOfMoney}, {temp.CheckContribution}, {temp.CheckDebt}
)
");
                    break;
                }

                case 2:
                {
                    var temp = new SimpleLegalEnity($"{Client_FirstNames[random_name.Next(Client_FirstNames.Count)]}",
                                                    "Юридический",
                                                    DateTime.Now.AddYears(-r.Next(18, 80)), (decimal)r.Next(20000, 2000000));
                    Bank.Add(temp);
                    dataBase.GoToDataBase(dataBase.CreateSQL(temp) + $@"
(
{temp.ID}, N'{temp.Name}', '{Convert.ToDateTime(temp.DateofBirth).ToString("yyyy-MM-dd")}', N'{temp.reputation}',N'{temp.Department}', {temp.AccountNumber},
{temp.AmountOfMoney}, {temp.CheckContribution}, {temp.CheckDebt}
)
");
                    break;
                }

                case 3:
                {
                    var temp = new VipNaturalClient($"{Client_FirstNames[random_name.Next(Client_FirstNames.Count)]}",
                                                    $"{Client_LastNames[random_name.Next(Client_LastNames.Count)]}",
                                                    "VIP",
                                                    DateTime.Now.AddYears(-r.Next(18, 80)), (decimal)r.Next(20000, 2000000));

                    Bank.Add(temp);
                    dataBase.GoToDataBase(dataBase.CreateSQL(temp) + $@"
(
{temp.ID}, N'{temp.FirstName}', N'{temp.LastName}', '{Convert.ToDateTime(temp.DateofBirth).ToString("yyyy-MM-dd")}',
N'{temp.Department}', {temp.AccountNumber},
{temp.AmountOfMoney}, {temp.CheckContribution}, {temp.CheckDebt}
)
");
                    break;
                }

                case 4:
                {
                    var temp = new VipLegalEnity($"{Client_FirstNames[random_name.Next(Client_FirstNames.Count)]}",
                                                 "VIP",
                                                 DateTime.Now.AddYears(-r.Next(16, 80)), (decimal)r.Next(20000, 2000000));

                    Bank.Add(temp);
                    dataBase.GoToDataBase(dataBase.CreateSQL(temp) + $@"
(
{temp.ID}, N'{temp.Name}', '{Convert.ToDateTime(temp.DateofBirth).ToString("yyyy-MM-dd")}', N'{temp.Department}', {temp.AccountNumber},
{temp.AmountOfMoney}, {temp.CheckContribution}, {temp.CheckDebt}
)
");
                    break;
                }

                default:
                    break;
                }
                count_workers--;
            }
            MessageBox.Show("Готово", "Complite", MessageBoxButton.OK, MessageBoxImage.Asterisk);
            Close();
        }