Пример #1
0
    protected void AddNewTeacher_ActiveStepChanged(object sender, EventArgs e)
    {
        //Get the UserID for the just added user
        MembershipUser newUser = Membership.GetUser(AddNewTeacher.UserName);

        newUser.ChangePassword(AddNewTeacher.Password, "admin123");
        Guid newUserId = (Guid)newUser.ProviderUserKey;

        // Have we JUST reached the Complete step?
        if (AddNewTeacher.ActiveStep.Title == "Complete")
        {
            //CreateUserWizardStep CustStep = AddNewStudent.FindControl("CreateUserWizardStep1") as CreateUserWizardStep;
            //TemplateControl CustStep = CreateUserWizardStep1.ContentTemplate as TemplateControl;
            TextBox FirstName = AddNewTeacher.CreateUserStep.ContentTemplateContainer.FindControl("FirstName") as TextBox;
            TextBox Email     = AddNewTeacher.CreateUserStep.ContentTemplateContainer.FindControl("Email") as TextBox;
            TextBox UserName  = AddNewTeacher.CreateUserStep.ContentTemplateContainer.FindControl("UserName") as TextBox;
            // Programmatically reference the TextBox controls
            // TextBox FirstName = CreateUserWizardStep1.FindControl("FirstName") as TextBox;
            TextBox      LastName    = AddNewTeacher.CreateUserStep.ContentTemplateContainer.FindControl("LastName") as TextBox;
            DropDownList Gender      = AddNewTeacher.CreateUserStep.ContentTemplateContainer.FindControl("Gender") as DropDownList;
            TextBox      Contact     = AddNewTeacher.CreateUserStep.ContentTemplateContainer.FindControl("Contact") as TextBox;
            TextBox      Education   = AddNewTeacher.CreateUserStep.ContentTemplateContainer.FindControl("Education") as TextBox;
            TextBox      Designation = AddNewTeacher.CreateUserStep.ContentTemplateContainer.FindControl("Designation") as TextBox;
            // Insert a new record into student profiles
            string connectionString = ConfigurationManager.ConnectionStrings["EIMSConnectionString"].ConnectionString;
            //string insertSql = "INSERT INTO StudentProfiles(FirstName, LastName, Contact, Department, Batch, RollNo) VALUES(@FirstName, @LastName, @Contact, @Department, @Batch, @RollNo)";
            string insertSql = "INSERT INTO TeacherProfiles(TeacherId, FirstName, LastName, Contact, Education, Designation, Gender) VALUES(@UserId, @FirstName, @LastName, @Contact, @Education, @Designation, @Gender)";

            using (SqlConnection myConnection = new SqlConnection(connectionString))
            {
                myConnection.Open();
                SqlCommand myCommand = new SqlCommand(insertSql, myConnection);
                myCommand.Parameters.AddWithValue("@FirstName", FirstName.Text.Trim());
                myCommand.Parameters.AddWithValue("@LastName", LastName.Text.Trim());
                myCommand.Parameters.AddWithValue("@Contact", Contact.Text.Trim());
                myCommand.Parameters.AddWithValue("@Education", Education.Text.Trim());
                myCommand.Parameters.AddWithValue("@Designation", Designation.Text.Trim());
                myCommand.Parameters.AddWithValue("@Gender", Gender.SelectedItem.Text);
                myCommand.Parameters.AddWithValue("@UserId", newUserId);
                myCommand.ExecuteNonQuery();
                myConnection.Close();
            }

            Roles.AddUserToRole(AddNewTeacher.UserName, "teacher");
            //Email
            EimsHelper.SendMail(Email.Text, "EIMS Registration.", "Hi Mr." + FirstName.Text + " " + LastName.Text + ".\nYou are added as a faculty member on Educational Institute Management System.\nYou can log in with these credentials:\nUsername: "******"\nPassword: "******"admin123" + "\nWe hope to provide you a great experience.");
        }
    }
Пример #2
0
    protected void btnInsert_Click(object sender, ImageClickEventArgs e)
    {
        if (Request.QueryString["id"] != null)
        {
            TextBox      TotalClasses         = (TextBox)gvCrud.FooterRow.FindControl("TotalClassesInsert");
            DropDownList AttendanceWeek       = (DropDownList)gvCrud.FooterRow.FindControl("AttendanceWeekSelect");
            TextBox      ClassesAttended      = (TextBox)gvCrud.FooterRow.FindControl("ClassesAttendedInsert");
            TextBox      ClassesMissed        = (TextBox)gvCrud.FooterRow.FindControl("ClassesMissedInsert");
            float        attendancePercentage = (Convert.ToSingle(ClassesAttended.Text) / Convert.ToSingle(TotalClasses.Text)) * 100;
            sqlcon.Open();
            using (sqlcom = new SqlCommand("insert into attendance values(@Week,@StudentId,@SemesterId,@TotalClasses,@ClassesAttended,@ClassesMissed,@AttendancePercentage)", sqlcon))
            {
                sqlcom.CommandType = CommandType.Text;
                sqlcom.Parameters.AddWithValue("@Week", AttendanceWeek.SelectedValue);
                sqlcom.Parameters.AddWithValue("@StudentId", studentId);
                //TODO semester ID from drop down
                sqlcom.Parameters.AddWithValue("@SemesterId", 8);
                sqlcom.Parameters.AddWithValue("@TotalClasses", TotalClasses.Text);
                sqlcom.Parameters.AddWithValue("@ClassesAttended", ClassesAttended.Text);
                sqlcom.Parameters.AddWithValue("@ClassesMissed", ClassesMissed.Text);
                sqlcom.Parameters.AddWithValue("@AttendancePercentage", attendancePercentage);
                int rows = sqlcom.ExecuteNonQuery();
                if (rows > 0)
                {
                    DataView dvSql2 = (DataView)AssociationDataSource.Select(DataSourceSelectArguments.Empty);
                    foreach (DataRowView drvSql in dvSql2)
                    {
                        //checking if a record is present in the data view, then show the associated parent
                        if (drvSql["ParentId"].ToString() != "")
                        {
                            parent = Membership.GetUser(drvSql["ParentId"]);
                            //Email
                            EimsHelper.SendMail(parent.Email, "EIMS Notification: Child Attendance Added.", "Hi Mr./Miss " + parent.UserName + ".\nYour child has a new attendance record. Take a look at the details:\nAttendance Week: " + AttendanceWeek.Text + " \nTotal Classes: " + TotalClasses.Text + "\nClasses Attended: " + ClassesAttended.Text + "\nClasses Missed: " + ClassesMissed.Text + "\nAttendance Percentage: " + attendancePercentage + "\nFor further information and reports you can always login to the EIMS with credentials you have been provided.");
                            EimsHelper.SendMail(student.Email, "EIMS Notification: Child Attendance Added.", "Dear " + student.UserName + ".\nA new attendance record has been added to your profile and an email notification has been sent to your parent/guardian's email account. Take a look at the details:\nAttendance Week: " + AttendanceWeek.Text + " \nTotal Classes: " + TotalClasses.Text + "\nClasses Attended: " + ClassesAttended.Text + "\nClasses Missed: " + ClassesMissed.Text + "\nAttendance Percentage: " + attendancePercentage + "\nFor further information and reports you can always login to the EIMS with credentials you have been provided.");

                            Session["Notice"] = "Attendance record has been added and Email has been sent to parent/guardian and the student!";
                            Response.Redirect("~/shared/StudentProfile.aspx?id=" + Request.QueryString["id"]);
                        }
                    }
                    EimsHelper.SendMail(student.Email, "EIMS Notification: Child Attendance Added.", "Dear " + student.UserName + ".\nA new attendance record has been added to your profile and an email notification has been sent to your parent/guardian's email account. Take a look at the details:\nAttendance Week: " + AttendanceWeek.Text + " \nTotal Classes: " + TotalClasses.Text + "\nClasses Attended: " + ClassesAttended.Text + "\nClasses Missed: " + ClassesMissed.Text + "\nAttendance Percentage: " + attendancePercentage + "\nFor further information and reports you can always login to the EIMS with credentials you have been provided.");
                    Session["Notice"] = "Attendance record has been added and Email has been sent to the student only because no guardian could be found!";
                    Response.Redirect("~/shared/StudentProfile.aspx?id=" + Request.QueryString["id"]);
                    BindGrid();
                }
            }
        }
    }
Пример #3
0
    protected void UpdateProfile_Click(object sender, EventArgs e)
    {
        MembershipUser student          = Membership.GetUser(User.Identity.Name);
        Guid           studentId        = (Guid)student.ProviderUserKey;
        string         connectionString = ConfigurationManager.ConnectionStrings["EIMSConnectionString"].ConnectionString;

        string updateSql = "UPDATE StudentProfiles SET FirstName=@FirstName,LastName=@LastName,Contact=@Contact,Address=@Address,Gender=@Gender,Avatar=@Avatar WHERE StudentId=@StudentId";
        string fileName;
        string ext = System.IO.Path.GetExtension(this.FUDisplayPic.PostedFile.FileName);

        fileName = Server.MapPath("~/img/StudentAvatars/Display_picture_" + User.Identity.Name + ext);
        using (SqlConnection myConnection = new SqlConnection(connectionString))
        {
            myConnection.Open();
            SqlCommand myCommand = new SqlCommand(updateSql, myConnection);
            myCommand.Parameters.AddWithValue("@FirstName", TxtFirstName.Text);
            myCommand.Parameters.AddWithValue("@LastName", TxtLastName.Text);
            myCommand.Parameters.AddWithValue("@Contact", TxtContact.Text);
            myCommand.Parameters.AddWithValue("@Address", TxtAddress.Text);
            myCommand.Parameters.AddWithValue("@Gender", DDGender.SelectedValue);
            myCommand.Parameters.AddWithValue("@StudentId", studentId);
            if (FUDisplayPic.HasFile)
            {
                myCommand.Parameters.AddWithValue("@Avatar", "~/img/StudentAvatars/Display_picture_" + User.Identity.Name + ext);
                FUDisplayPic.SaveAs(fileName);
            }
            else
            {
                myCommand.Parameters.AddWithValue("@Avatar", DisplayPicture.ImageUrl);
            }
            myCommand.ExecuteNonQuery();
        }
        student.Email = TxtEmail.Text;
        Membership.UpdateUser(student);
        EimsHelper.SendMail("*****@*****.**", "EIMS Notification.", "Hi Mr./Ms." + "Sarmad" + " " + "Sabih" + ".\nYour child has updated his profile settings.\nYou can log in and see his/her profile to verify the changes.\nIn case of any misinformation you can feel free to contact the administrator." + "\nWe hope to provide you a great experience.");
        Session["Notice"] = "Your Profile has been updated! And your Parent/Guardian has been notified about the changes via an Email.";
        Response.Redirect("~/students/settings.aspx");
    }
Пример #4
0
    protected void AddNewStudent_ActiveStepChanged(object sender, EventArgs e)
    {
        //Get the UserID for the just added user
        MembershipUser newUser = Membership.GetUser(AddNewStudent.UserName);

        newUser.ChangePassword(AddNewStudent.Password, "admin123");
        Guid newUserId = (Guid)newUser.ProviderUserKey;

        // Have we JUST reached the Complete step?
        if (AddNewStudent.ActiveStep.Title == "Complete")
        {
            //CreateUserWizardStep CustStep = AddNewStudent.FindControl("CreateUserWizardStep1") as CreateUserWizardStep;
            //TemplateControl CustStep = CreateUserWizardStep1.ContentTemplate as TemplateControl;
            TextBox FirstName = AddNewStudent.CreateUserStep.ContentTemplateContainer.FindControl("FirstName") as TextBox;
            TextBox Email     = AddNewStudent.CreateUserStep.ContentTemplateContainer.FindControl("Email") as TextBox;
            TextBox UserName  = AddNewStudent.CreateUserStep.ContentTemplateContainer.FindControl("UserName") as TextBox;
            //TextBox Password = AddNewStudent.CreateUserStep.ContentTemplateContainer.FindControl("Password") as TextBox;
            // Programmatically reference the TextBox controls
            //TextBox FirstName = CreateUserWizardStep1.FindControl("FirstName") as TextBox;
            TextBox      LastName   = AddNewStudent.CreateUserStep.ContentTemplateContainer.FindControl("LastName") as TextBox;
            TextBox      Contact    = AddNewStudent.CreateUserStep.ContentTemplateContainer.FindControl("Contact") as TextBox;
            DropDownList Department = AddNewStudent.CreateUserStep.ContentTemplateContainer.FindControl("Department") as DropDownList;
            DropDownList Batch      = AddNewStudent.CreateUserStep.ContentTemplateContainer.FindControl("Batch") as DropDownList;
            DropDownList Gender     = AddNewStudent.CreateUserStep.ContentTemplateContainer.FindControl("Gender") as DropDownList;
            TextBox      RollNum    = AddNewStudent.CreateUserStep.ContentTemplateContainer.FindControl("RollNum") as TextBox;
            TextBox      Address    = AddNewStudent.CreateUserStep.ContentTemplateContainer.FindControl("Address") as TextBox;
            //Insert a new record into student profiles
            string connectionString = ConfigurationManager.ConnectionStrings["EIMSConnectionString"].ConnectionString;
            //string insertSql = "INSERT INTO StudentProfiles(FirstName, LastName, Contact, Department, Batch, RollNo) VALUES(@FirstName, @LastName, @Contact, @Department, @Batch, @RollNo)";
            string insertSql = "INSERT INTO StudentProfiles(StudentId, FirstName, LastName, Contact, DepartmentId, BatchId, RollNo, Gender, Address) VALUES(@UserId, @FirstName, @LastName, @Contact, @Department, @Batch, @RollNo, @Gender, @Address)";

            using (SqlConnection myConnection = new SqlConnection(connectionString))
            {
                myConnection.Open();
                SqlCommand myCommand = new SqlCommand(insertSql, myConnection);
                myCommand.Parameters.AddWithValue("@FirstName", FirstName.Text.Trim());
                myCommand.Parameters.AddWithValue("@LastName", LastName.Text.Trim());
                myCommand.Parameters.AddWithValue("@Contact", Contact.Text.Trim());
                myCommand.Parameters.AddWithValue("@Department", Department.SelectedItem.Value);
                myCommand.Parameters.AddWithValue("@Batch", Batch.SelectedItem.Value);
                myCommand.Parameters.AddWithValue("@Gender", Gender.SelectedItem.Value.ToString());
                string   rollNumber = "";
                DataView dvSql      = (DataView)DepartmentsDataSource.Select(DataSourceSelectArguments.Empty);
                foreach (DataRowView drvSql in dvSql)
                {
                    if (drvSql["DepartmentName"].ToString() == Department.SelectedItem.Text)
                    {
                        rollNumber = drvSql["DepartmentInitials"].ToString();
                    }
                }
                rollNumber = rollNumber + "-" + Batch.SelectedItem.Text + "-" + RollNum.Text;
                myCommand.Parameters.AddWithValue("@RollNo", rollNumber);
                myCommand.Parameters.AddWithValue("@Address", Address.Text.Trim());
                myCommand.Parameters.AddWithValue("@UserId", newUserId);
                myCommand.ExecuteNonQuery();
                myConnection.Close();
            }

            Roles.AddUserToRole(AddNewStudent.UserName, "student");
            //Email
            EimsHelper.SendMail(Email.Text, "EIMS Registration.", "Hi Mr." + FirstName.Text + " " + LastName.Text + ".\nYou are added as a student on Educational Institute Management System.\nYou can log in with these credentials:\nUsername: "******"\nPassword: "******"admin123" + "\nWe hope to provide you a great experience.");
        }
    }