Exemple #1
0
    protected void btnsubmitstudent_Click(object sender, EventArgs e)
    {
        MembershipCreateStatus status;
        Membership.CreateUser(txtstudentemailid.Text, txtstudentpassword.Text, txtstudentemailid.Text, "Que", "Ans", true, out status);
        if (status == MembershipCreateStatus.Success)
        {

            Roles.AddUserToRole(txtstudentemailid.Text, "student");
            clsStudent s = new clsStudent();

            s.Student_name = txtstudentname.Text;
            s.Admission_Year_ID = Convert.ToInt32(ddCourse.SelectedValue);
            s.Contact_No = txtstudentcontactno.Text;
            s.Email = txtstudentemailid.Text;
            s.Password = txtstudentpassword.Text;
            s.Class_ID = Convert.ToInt32(drp_ClassID.SelectedValue);
            s.Current_Subject_ID =1;
            s.Faculty_ID =Convert.ToInt32(drpFaculty.SelectedValue);
            if (!string.IsNullOrEmpty(s.Student_name) && !string.IsNullOrEmpty(s.Contact_No) && !string.IsNullOrEmpty(s.Email) && !string.IsNullOrEmpty(s.Password) && !string.IsNullOrEmpty(drp_ClassID.SelectedValue)  && !string.IsNullOrEmpty(drpFaculty.SelectedValue))
            {
                try
                {
                    s.addStudent(s);
                    string body = "Congratulations" + s.Student_name + "You are successfully registered.Welcome to Hare Krishna Diamond Institute";
                    mailing ms = new mailing();
                    ms.SendEmail(s.Email, "Admission Registered", body);
                }
                catch (Exception ex)
                {
                    Membership.DeleteUser(txtstudentemailid.Text);
                }
                bindstudentgrid();
                pnldata.Visible = true;
                pnlform.Visible = false;
                txtstudentname.Text = "";
                txtstudentemailid.Text = "";
                txtstudentpassword.Text = "";
                txtstudentcontactno.Text = "";

                //ddCourse.SelectedValue= "";

                drpFaculty.SelectedIndex= 0;
                txtCurrentSubject.Text = "";

            }
        }
    }