Ejemplo n.º 1
0
        public void Enter(TextBox textBox1, TextBox textBox2, Form1 form1)
        {
            List <client> query = (from client in db.client
                                   select client).ToList();

            if ((textBox1.Text == "") || (textBox2.Text == ""))
            {
                MessageBox.Show("Введите данные");
            }
            else
            {
                try
                {
                    client client1 = query.First(p =>
                                                 (p.login.ToString() == textBox1.Text.ToString()) && (p.password.ToString() == textBox2.Text.ToString()));
                    personal_account_of_Client FormClient = new personal_account_of_Client(client1, form1);
                    FormClient.Show();
                    form1.Hide();
                }
                catch (InvalidOperationException) //Если не входит как клиент
                {
                    try
                    {
                        List <employee> employees = (from employee in db.employee
                                                     select employee).ToList();
                        employee employee1 = employees.First(p => (p.login.ToString() == textBox1.Text.ToString()) &&
                                                             (p.password.ToString() == textBox2.Text.ToString()));
                        if (employee1.post == "Администратор")
                        {
                            personal_account_of_Admin FormAdmin = new personal_account_of_Admin(employee1, form1);
                            FormAdmin.Show();
                            form1.Hide();
                        }
                        else
                        {
                            personal_account_of_Doctor FormDoctor = new personal_account_of_Doctor(employee1, form1);
                            FormDoctor.Show();
                            form1.Hide();
                        }
                    }
                    catch (InvalidOperationException) //Если не входит ни как клиент, ни как сотрудник
                    {
                        MessageBox.Show("Неверны логин или пароль");
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public void AddNewClientFromReg(List <string> info)
 {
     try
     {
         try
         {
             number_of_client = db.client.Max(n => n.id_client) + 1;
         }
         catch (InvalidOperationException)
         {
             number_of_client = 1;
         }
         if (!DataView.CheckLoginPassword(info[6], Convert.ToInt32(info[7])))
         {
             MessageBox.Show("Пользователь с таким логином или паролем уже существует. Укажите другой");
         }
         else
         {
             newclient = new client
             {
                 id_client  = number_of_client,
                 surname    = info[0],
                 name       = info[1],
                 lastlename = info[2],
                 email      = info[5],
                 number     = Convert.ToInt64(info[4]),
                 dateofborn = Convert.ToDateTime(info[3]),
                 login      = info[6],
                 password   = Convert.ToInt32(info[7]),
             };
             db.client.Add(newclient);
             db.SaveChanges();
             MessageBox.Show("Регистрация завершена. Ради приветствовать вас!");
             Registration.Close();
             personal_account_of_Client personal_Account_Of_Client = new personal_account_of_Client(newclient, form1);
             personal_Account_Of_Client.Show();
         }
     }
     catch
     {
         MessageBox.Show("Некорректно введенные данные");
     }
 }