Пример #1
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            using (var frm = new ForTeacher())
            {
                frm.ShowDialog();
            }
            try
            {
                string hashPassword = txtPassword.Text.Hash();
                spCheckUserTableAdapter1.Fill(DataSet.spCheckUser, txtEmail.Text, hashPassword);

                if (DataSet.spCheckUser.Count < 1)
                {
                    MessageBox.Show("Dont found user", "Error!", 0, MessageBoxIcon.Error);
                    return;
                }

                spCheckUserRow user = DataSet.spCheckUser.FirstOrDefault();

                Program.UserId = user.Id;
                //Program.CategoryId =Category.Id;

                switch (user.RoleId)
                {
                case 1:
                    //admin

                    using (var frm = new Admin.AdminMainForm())
                    {
                        frm.ShowDialog();
                    }
                    break;

                case 2:
                    //admin
                    using (var frm = new User.UserMainForm())
                    {
                        frm.ShowDialog();
                    }
                    break;

                default:
                    MessageBox.Show("This role is not considered", "Error!", 0, MessageBoxIcon.Error);
                    return;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {

            if (string.IsNullOrWhiteSpace(textBoxLogin.Text)) {
                errorProvider1.SetError(textBoxLogin,"Login bos buraxila bilmez");
            }

            if (string.IsNullOrWhiteSpace(textBoxPassword.Text))
            {
                errorProvider1.SetError(textBoxPassword, "Password bos buraxila bilmez");
            }

            try
            {
                spCheckUserTableAdapter1.Fill(dataSet.spCheckUser,textBoxLogin.Text,textBoxPassword.Text);
                if (dataSet.spCheckUser.Count < 1)
                {
                    MessageBox.Show("Istifadeci tapilmadi", "Xeta", 0, MessageBoxIcon.Error);
                    return;
                }
                spCheckUserRow user = dataSet.spCheckUser.FirstOrDefault();
                switch (user.RoleId)
                {
                    case 1:
                        //admin
                        using (var frm=new Admin.MainFormAdmin())
                        {
                            frm.ShowDialog();
                        }
                        break;

                    case 2:
                        //user
                        using (var frm = new User.MainFormUser())
                        {
                            frm.ShowDialog();
                        }
                        break;
                    default:
                        MessageBox.Show("Daxil edilen istifadeci yoxdur", "Xeta", 0, MessageBoxIcon.Error);
                        break;
                }
                Program.UserId = user.Id; 
            }

            catch (System.Exception)
            {

                ////throw;
            }
        }