示例#1
0
        private void btnLogIn_Click(object sender, EventArgs e)
        {
            string fname  = txtFirstname.Text;
            string suname = txtSurname.Text;
            string pass   = txtPassword.Text;

            if (Utilities.isEmpty(new string[] { fname, suname, pass }))
            {
                Users_ selectedUser = db.Users_.FirstOrDefault(c => c.Firstname == fname);
                if (selectedUser != null)
                {
                    if (selectedUser.Password == pass.HashMe())
                    {
                        if (ckRemember.Checked)
                        {
                            Properties.Settings.Default.firstname = fname;
                            Properties.Settings.Default.surname   = suname;
                            Properties.Settings.Default.password  = pass;
                            Properties.Settings.Default.isChecked = true;
                            Properties.Settings.Default.Save();
                        }
                        else
                        {
                            Properties.Settings.Default.firstname = "";
                            Properties.Settings.Default.surname   = "";
                            Properties.Settings.Default.password  = "";
                            Properties.Settings.Default.isChecked = false;
                            Properties.Settings.Default.Save();
                        }
                        if (selectedUser.RoleID == 1)
                        {
                            this.Hide();
                            var ds = new  Rezervation_Form(selectedUser);
                            ds.FormClosed += (s, args) => this.Close();
                            ds.ShowDialog();
                        }
                        if (selectedUser.RoleID == 2)
                        {
                            this.Hide();
                            var ds = new AdminForm(selectedUser);
                            ds.FormClosed += (s, args) => this.Close();
                            ds.ShowDialog();
                        }
                    }
                    else
                    {
                        lblError.Text    = "password doesn't correct!";
                        lblError.Visible = true;
                    }
                }
                else
                {
                    lblError.Text    = "username doesn't correct";
                    lblError.Visible = true;
                }
            }
            else
            {
                lblError.Text    = "Please,all the fiel";
                lblError.Visible = true;
            }
        }