コード例 #1
0
        private void buttonSignIn_Click(object sender, EventArgs e)
        {
            string login;
            String password;

            if (textBoxLogin.TextLength != 0 && textBoxPass.TextLength != 0)
            {
                login    = textBoxLogin.Text;
                password = textBoxPass.Text;

                try
                {
                    using (LoginContext db = new LoginContext())
                    {
                        var search = db.Employees.Where(c => c.Login == login & c.Password == password).Select(c => c.accesslvl).First();

                        switch (search)
                        {
                        case 1:
                            WorkerForm w = new WorkerForm();
                            w.Show();
                            this.Hide();
                            break;

                        case 2:
                            ManagerForm m = new ManagerForm();
                            m.Show();
                            this.Hide();
                            break;

                        case 3:
                            AdminForm f = new AdminForm();
                            f.Show();
                            this.Hide();
                            break;
                        }
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("Неверный логин или пароль", "Ошибка");
                    textBoxPass.Clear();
                }
            }
            else
            {
                MessageBox.Show("Ошибка! Все поля должны быть заполнены.", "Ошибка");
            }
        }
コード例 #2
0
ファイル: AdminForm.cs プロジェクト: slayway/TP
        public AdminForm()
        {
            InitializeComponent();
            try
            {
                using (LoginContext db = new LoginContext())
                {
                    db.Employees.Load();
                    List <Employee> list = new List <Employee>(db.Employees.Local.ToList());

                    bs.DataSource            = list;
                    dataGridView1.DataSource = bs;
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }