protected void saveButton_Click(object sender, EventArgs e)
        {
            AddStudentModel addStudentModel = new AddStudentModel();
            addStudentModel.StudentId = studentIdTextBox.Text;
            addStudentModel.Name = studentNameTextBox.Text;
            addStudentModel.Phone = phoneNumberTextBox.Text;
            addStudentModel.Email = emailTextBox.Text;
            addStudentModel.PresentAddress = presentAddressTextBox.Text;
            addStudentModel.PermanentAddress = permanentAddressTextBox.Text;
            addStudentModel.GenderId = Convert.ToInt32(genderDropDownList.SelectedValue);
            addStudentModel.NationalityId = Convert.ToInt32(nationalityDropDownList.SelectedValue);
            addStudentModel.DeptId = Convert.ToInt32(departmentDropDownList.SelectedValue);
            addStudentModel.YearTermId = Convert.ToInt32(yearTermDropDownList.SelectedValue);
            addStudentModel.SessionId = Convert.ToInt32(sessionDropDownList.SelectedValue);
            addStudentModel.Salt = GenerateSalt();
            string passwordStd = GeneratePassword();
            Session["studentPassword"] = passwordStd;
            addStudentModel.Password = GenerateHashValue(passwordStd, addStudentModel.Salt);
            addStudentModel.Type = 2;

            if (IsTextBoxEmpty())
            {
                failStatusLabel.InnerText = "Please enter the value";
                successStatusLabel.InnerText = "";
            }
            else
            {
                if (CheckSelectedValue())
                {
                    failStatusLabel.InnerText = "Please select a value";
                    successStatusLabel.InnerText = "";
                }
                else
                {
                    if (addStudentBll.IsStudenrExist(addStudentModel))
                    {
                        failStatusLabel.InnerText = "This student already exist";
                        successStatusLabel.InnerText = "";
                    }
                    else
                    {
                        if (addStudentBll.SaveNewStudentInformation(addStudentModel)>0)
                        {
                            //successStatusLabel.InnerText = "Student information saved";
                            //failStatusLabel.InnerText = "";
                            Response.Redirect("AddedStudentInformation.aspx");
                        }
                        else
                        {
                            failStatusLabel.InnerText = "Not saved";
                            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;
                    }

                }
            }
        }
 protected void saveButton_Click(object sender, EventArgs e)
 {
     AddStudentModel addStudentModel = new AddStudentModel();
     addStudentModel.StudentId = studentIdTextBox.Text;
     addStudentModel.Name = studentNameTextBox.Text;
     addStudentModel.Phone = phoneNumberTextBox.Text;
     addStudentModel.Email = emailTextBox.Text;
     addStudentModel.PresentAddress = presentAddressTextBox.Text;
     addStudentModel.PermanentAddress = permanentAddressTextBox.Text;
     addStudentModel.GenderId = Convert.ToInt32(genderDropDownList.SelectedValue);
     addStudentModel.NationalityId = Convert.ToInt32(nationalityDropDownList.SelectedValue);
     addStudentModel.DeptId = Convert.ToInt32(departmentDropDownList.SelectedValue);
     addStudentModel.YearTermId = Convert.ToInt32(yearTermDropDownList.SelectedValue);
     addStudentModel.SessionId = Convert.ToInt32(sessionDropDownList.SelectedValue);
 }
Exemple #4
0
        public AddStudentModel GetDeptIdAndSessionIdByStudentIdAndEmail(string studentId, string email)
        {
            AddStudentModel addStudentModel= new AddStudentModel();
            string query = String.Format("Select deptId, sessionId from tblStudent where studentId=@studentId 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("@studentId", studentId);
                    command.Parameters.AddWithValue("@email", email);

                    connection.Open();
                    SqlDataReader rdr = command.ExecuteReader();
                    while (rdr.Read())
                    {
                        addStudentModel.DeptId = Convert.ToInt32(rdr[0]);
                        addStudentModel.SessionId = Convert.ToInt32(rdr[1]);
                    }
                    connection.Close();
                }
            }
            return addStudentModel;
        }
 public int SaveNewStudentInformation(AddStudentModel addStudentModel)
 {
     return addStudentDal.SaveStudentInformation(addStudentModel);
 }
 public bool IsStudenrExist(AddStudentModel addStudentModel)
 {
     return addStudentDal.IsStudentIdAndDeptIdExist(addStudentModel);
 }
        public int SaveStudentInformation(AddStudentModel addStudentModel)
        {
            int rowsInserted = 0;
            string query = String.Format("spSaveNewStudentInformation");

            using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings[1].ConnectionString))
            {
                using (SqlCommand command = new SqlCommand(query, connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@studentId",addStudentModel.StudentId);
                    command.Parameters.AddWithValue("@studentName", addStudentModel.Name);
                    command.Parameters.AddWithValue("@phone", addStudentModel.Phone);
                    command.Parameters.AddWithValue("@email", addStudentModel.Email);
                    command.Parameters.AddWithValue("@presentAddress", addStudentModel.PresentAddress);
                    command.Parameters.AddWithValue("@permanentAddress", addStudentModel.PermanentAddress);
                    command.Parameters.AddWithValue("@genderId", addStudentModel.GenderId);
                    command.Parameters.AddWithValue("@nationality", addStudentModel.NationalityId);
                    command.Parameters.AddWithValue("@departmentId", addStudentModel.DeptId);
                    command.Parameters.AddWithValue("@sessionId", addStudentModel.SessionId);
                    command.Parameters.AddWithValue("@yearTermId", addStudentModel.YearTermId);
                    command.Parameters.AddWithValue("@salt", addStudentModel.Salt);
                    command.Parameters.AddWithValue("@password", addStudentModel.Password);
                    command.Parameters.AddWithValue("@type", addStudentModel.Type);
                    connection.Open();
                    rowsInserted = command.ExecuteNonQuery();
                    connection.Close();
                    command.Parameters.Clear();
                }
            }
            return rowsInserted;
        }
        public bool IsStudentIdAndDeptIdExist(AddStudentModel addStudentModel)
        {
            bool isStudentIdAndDeptIdExist = false;
            string query = String.Format("spGetStudentByIdAndDeptId");

            using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings[1].ConnectionString))
            {
                using (SqlCommand command = new SqlCommand(query,connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@studentId", addStudentModel.StudentId);
                    command.Parameters.AddWithValue("@deptId", addStudentModel.DeptId);
                    connection.Open();
                    SqlDataReader rdr = command.ExecuteReader();
                    while (rdr.Read())
                    {
                        isStudentIdAndDeptIdExist = true;
                    }
                    command.Parameters.Clear();
                    connection.Close();
                }
            }
            return isStudentIdAndDeptIdExist;
        }
        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);
                    }

                }
            }
        }
        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;
                    }
                }
            }
        }