예제 #1
0
 protected void loginButton_Click(object sender, EventArgs e)
 {
     LoginModel loginModel = new LoginModel();
     loginModel.ID = idTextBox.Text;
     loginModel.Email = emailTextBox.Text;
     loginModel.Password = passwordTextBox.Text;
     if (idTextBox.Text.Length <20 && emailTextBox.Text.Length <30 && passwordTextBox.Text.Length <20)
     {
         LoginModel loginModelFromDB = adminBll.GetLoginInformation(loginModel.ID, loginModel.Email);
         SHA256 sha256 = SHA256.Create();
         string passwordToCompare = Convert.ToBase64String(sha256.ComputeHash(System.Text.UnicodeEncoding.Unicode.GetBytes(loginModel.Password + loginModelFromDB.Salt)));
         if (passwordToCompare == loginModelFromDB.Hash)
         {
             Session["loginInformation"] = loginModelFromDB;
             Response.Redirect("Home.aspx");
         }
         else
         {
             failStatusLabel.InnerText = "Login information is incorrect.";
         }
     }
     else
     {
         failStatusLabel.InnerText = "Please enter the information in correct format";
         successStatusLabel.InnerText = "";
     }
 }
        public void GetDeptIdAndSessionId()
        {
            LoginModel loginModel = new LoginModel();
            if (Session["loginInformation"] != null)
            {
                loginModel = (LoginModel)Session["loginInformation"];
                string email = loginModel.Email;
                string studentId = loginModel.ID;
                StudentModel studentModel = new StudentModel();
                studentModel = studentBll.GetStudentInfirmation(studentId);
                AddStudentModel addStudentModel = new AddStudentModel();
                addStudentModel = studentBll.GetDeptIdAndSessionIdByStudentIdAndEmail(studentId, email);
                int maxValueOfYearTerm = adminBll.GetMaxValueOfYearTermIdFromRegPermission(addStudentModel.DeptId,
                    addStudentModel.SessionId);
                if (maxValueOfYearTerm == 0)
                {
                    registerButton.Enabled = false;
                    headerTextLabel.Text = "Registration not available";
                    regStatusLabel.Text = "Not registered for first semister";
                    studentIdLabel.Text = studentId;
                    departmentNameLabel.Text = studentModel.DepartmentName;
                    sessionLabel.Text = studentModel.Session;
                    //yearTermLabel.Text = studentBll.GetYearTermByYearTermId(maxValueOfYearTerm);
                    yearTermLabel.Text = "1st year;1st term";
                }
                else
                {
                    RegistrationPermissionModel registrationPermissionModel = new RegistrationPermissionModel();
                    registrationPermissionModel.studentId = studentId;
                    registrationPermissionModel.DeptId = addStudentModel.DeptId;
                    registrationPermissionModel.SessionId = addStudentModel.SessionId;
                    registrationPermissionModel.YearTermId = maxValueOfYearTerm;
                    if (adminBll.IsSemisterRegisteredForStudentId(registrationPermissionModel))
                    {
                        registerButton.Enabled = false;
                        regStatusLabel.Text = "You are registered for the current semister";
                        studentIdLabel.Text = studentId;
                        departmentNameLabel.Text = studentModel.DepartmentName;
                        sessionLabel.Text = studentModel.Session;
                        yearTermLabel.Text = studentBll.GetYearTermByYearTermId(maxValueOfYearTerm);
                    }
                    else
                    {
                        registerButton.Enabled = true;
                    }

                }
            }
        }
        public void GetDeptIdAndSessionId()
        {
            LoginModel loginModel = new LoginModel();
            if (Session["loginInformation"] != null)
            {
                loginModel = (LoginModel)Session["loginInformation"];
                string email = loginModel.Email;
                string studentId = loginModel.ID;
                StudentModel studentModel = new StudentModel();
                studentModel = studentBll.GetStudentInfirmation(studentId);
                AddStudentModel addStudentModel = new AddStudentModel();
                addStudentModel = studentBll.GetDeptIdAndSessionIdByStudentIdAndEmail(studentId, email);
                int maxValueOfYearTerm = adminBll.GetMaxValueOfYearTermIdFromRegPermission(addStudentModel.DeptId,
                    addStudentModel.SessionId);

                if (maxValueOfYearTerm == 0)
                {
                    registerButton.Enabled = false;
                    headerTextLabel.Text = "Registration not available now.";
                    headerTextLabel.CssClass = "text-danger";
                    headerTextLabel.CssClass = "glyphicon glyphicon-hand-right";
                    regStatusLabel.Text = "Not registered for first semister";
                    studentIdLabel.Text = studentId;
                    departmentNameLabel.Text = studentModel.DepartmentName;
                    sessionLabel.Text = studentModel.Session;
                    //yearTermLabel.Text = studentBll.GetYearTermByYearTermId(maxValueOfYearTerm);
                    yearTermLabel.Text = "1st year;1st term";
                }
                else
                {
                    RegistrationPermissionModel registrationPermissionModel = new RegistrationPermissionModel();
                    registrationPermissionModel.studentId = studentId;
                    registrationPermissionModel.DeptId = addStudentModel.DeptId;
                    registrationPermissionModel.SessionId = addStudentModel.SessionId;
                    registrationPermissionModel.YearTermId = maxValueOfYearTerm;
                    if (studentBll.IsSemisterRegisteredForStudentId(registrationPermissionModel))
                    {
                        registerButton.Enabled = false;
                        regStatusLabel.Text = "You are registered for the current semister";
                        studentIdLabel.Text = studentId;
                        departmentNameLabel.Text = studentModel.DepartmentName;
                        sessionLabel.Text = studentModel.Session;
                        yearTermLabel.Text = studentBll.GetYearTermByYearTermId(maxValueOfYearTerm);
                    }
                    else
                    {
                        registerButton.Enabled = true;
                        studentIdLabel.Text = studentId;
                        departmentNameLabel.Text = studentModel.DepartmentName;
                        sessionLabel.Text = studentModel.Session;
                        yearTermLabel.Text = studentBll.GetYearTermByYearTermId(maxValueOfYearTerm);
                        regStatusLabel.Text = "Not registered yet";
                        List<CourseModel> courseModels = new List<CourseModel>();
                        courseModels = studentBll.GetAllCoursesByDeptIdAndYearTermId(addStudentModel.DeptId,
                            maxValueOfYearTerm);
                        decimal totalCredit = 0;
                        int totalSubject = 0;
                        foreach (CourseModel courseModel in courseModels)
                        {
                            totalCredit = courseModel.Credit + totalCredit;
                            totalSubject++;
                        }
                        courseGridView.DataSource = courseModels;
                        courseGridView.DataBind();
                        totalCreditTextBox.Text = Convert.ToString(totalCredit);
                        courseNumberTextBox.Text = Convert.ToString(totalSubject);
                    }

                }
            }
        }
예제 #4
0
        public LoginModel GetLoginInformation(string id1, string email1)
        {
            LoginModel loginModel = null;
            string query = String.Format("Select * from tblLogin where id=@id and email=@email");
            using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings[1].ConnectionString))
            {
                using (SqlCommand command = new SqlCommand(query,connection))
                {
                    command.Parameters.Clear();
                    command.Parameters.AddWithValue("@id",id1);
                    command.Parameters.AddWithValue("@email", email1);
                    connection.Open();
                    SqlDataReader rdr = command.ExecuteReader();
                    while (rdr.Read())
                    {
                        loginModel =  new LoginModel();
                        loginModel.Salt = rdr[0].ToString();
                        loginModel.Hash = rdr[1].ToString();
                        loginModel.ID = rdr[2].ToString();
                        loginModel.Email = rdr[3].ToString();
                        loginModel.Type = Convert.ToInt32(rdr[4]);
                        loginModel.Name = rdr[5].ToString();

                    }
                    connection.Close();
                }
            }
            return loginModel;
        }
        protected void registerButton_Click(object sender, EventArgs e)
        {
            if (Session["loginInformation"] != null)
            {
                LoginModel loginModel = new LoginModel();
                loginModel = (LoginModel)Session["loginInformation"];
                string studentId = loginModel.ID;
                string email = loginModel.Email;
                AddStudentModel addStudentModel = new AddStudentModel();
                addStudentModel = studentBll.GetDeptIdAndSessionIdByStudentIdAndEmail(studentId, email);
                RegistrationPermissionModel registrationPermissionModel = new RegistrationPermissionModel();
                registrationPermissionModel.studentId = studentId;
                registrationPermissionModel.DeptId = addStudentModel.DeptId;
                registrationPermissionModel.SessionId = addStudentModel.SessionId;

                int maxValueOfYearTerm = adminBll.GetMaxValueOfYearTermIdFromRegPermission(addStudentModel.DeptId,
                    addStudentModel.SessionId);
                registrationPermissionModel.YearTermId = maxValueOfYearTerm;

                if (studentBll.IsSemisterRegisteredForStudentId(registrationPermissionModel))
                {
                    failStatusLabel.InnerText = "You are already registered";
                    successStatusLabel.InnerText = "";
                }
                else
                {
                    if (studentBll.SaveSemisterRegistrationForStudent(registrationPermissionModel) >0)
                    {
                        failStatusLabel.InnerText = "";
                        successStatusLabel.InnerText = "Your registration completed";
                        regStatusLabel.Text = "You are registered for current semister";
                        registerButton.Enabled = false;
                    }
                }
            }
        }