Пример #1
0
        protected void CreateUserButton_Click(object sender, EventArgs e)
        {
            try
            {
                // Create new user.
                MembershipCreateStatus status;
                MembershipUser         newUser = Membership.CreateUser(Email.Text, Password.Text, Email.Text, null, null, false, out status);


                try
                {
                    //if (!Roles.IsUserInRole("Manager"))
                    //{
                    if (!Roles.RoleExists("Manager"))
                    {
                        Roles.CreateRole("Manager");
                        Roles.AddUserToRole(Email.Text, "Manager");
                    }
                    else
                    {
                        Roles.AddUserToRole(Email.Text, "Manager");
                    }

                    //}
                    // FormsAuthentication.SetAuthCookie(RegisterUser.UserName, false /* createPersistentCookie */);



                    clsESPSql.ExecNonQuery("update aspnet_Users set mobilealias='" + Mobile.Text + "' where username='******'");
                    try
                    {
                        LIBtblOrgBasicInfo         objLIBtblOrgBasicInfo = new LIBtblOrgBasicInfo();
                        DALtblOrgBasicInfo         objDALtblOrgBasicInfo = new DALtblOrgBasicInfo();
                        MyCLS.TransportationPacket tp = new MyCLS.TransportationPacket();

                        objLIBtblOrgBasicInfo.id          = -1;
                        objLIBtblOrgBasicInfo.username    = Email.Text;
                        objLIBtblOrgBasicInfo.Name        = Name.Text;
                        objLIBtblOrgBasicInfo.Email       = Email.Text;
                        objLIBtblOrgBasicInfo.phone       = Mobile.Text;
                        objLIBtblOrgBasicInfo.designation = Designation.Text;
                        objLIBtblOrgBasicInfo.OrgName     = Orgnaisation.Text;
                        objLIBtblOrgBasicInfo.industry    = Industry.Text;
                        objLIBtblOrgBasicInfo.dt          = DateTime.Now.ToShortDateString();
                        tp.MessagePacket = objLIBtblOrgBasicInfo;
                        tp = objDALtblOrgBasicInfo.InserttblOrgBasicInfo(tp);

                        //if (tp.MessageId > -1)
                        //{
                        //    string[] strOutParamValues = (string[])tp.MessageResultset;

                        //    Response.Redirect("~/Manager/Default.aspx", false);
                        //}
                        MembershipUser userInfo = Membership.GetUser(Email.Text);

                        //Construct the verification URL
                        //  string verifyUrl = Request.Url.GetLeftPart(UriPartial.Authority) + Page.ResolveUrl("~/Verify.aspx?ID=" + userInfo.ProviderUserKey.ToString());

                        DALCommon cmn     = new DALCommon();
                        string    strBody = cmn.prcFindInFile(Server.MapPath("mail.html").ToString(), "#UserName#", Name.Text);
                        strBody = cmn.prcFindInString(strBody, "#VerificationUrl#", "http://localhost:56941/EmailConfirmation.aspx?ID=" + userInfo.ProviderUserKey.ToString());


                        // strBody = "Hello " + Name.Text + "!. You or someone with your id signed up at this site, Your new account is almost ready, but before you can login you need to confirm your email id by visitng the link below: http://localhost:56941/EmailConfirmation.aspx?ID=" + userInfo.ProviderUserKey.ToString() + " Once you have visited the verification URL, your account will be activated. If you have any problems or questions, please reply to this email. Thanks!";
                        cmn.SendHtmlFormattedEmail(Email.Text, "Verification Code", strBody);
                        Response.Redirect("Verification.aspx", false);
                        //RegisterUser.LoginCreatedUser = false;
                        // lblmsg.Text = " An email has been sent to your account. Please view the email and confirm your account to complete the registration process.";
                    }
                    catch (Exception ex)
                    {
                        MyCLS.clsHandleException.HandleEx(ex, System.Reflection.MethodBase.GetCurrentMethod().ToString(), true);
                    }
                }
                catch (Exception ex)
                {
                }
                // If user created successfully, set password question and answer (if applicable) and
                // redirect to login page. Otherwise return an error message.

                //if (Membership.RequiresQuestionAndAnswer)
                //{
                //    newUser.ChangePasswordQuestionAndAnswer(Password.Text,
                //                                            PasswordQuestionTextbox.Text,
                //                                            PasswordAnswerTextbox.Text);
                //}
            }
            catch (MembershipCreateUserException ex)
            {
                lblErrorMessage.Text = GetErrorMessage(ex.StatusCode);
            }
            catch (HttpException ex)
            {
                lblErrorMessage.Text = ex.Message;
            }
        }
Пример #2
0
        protected void CreateUserButton_Click(object sender, EventArgs e)
        {
            try
            {
                // Create new user.
                MembershipCreateStatus status;
                string         Password = GeneratePWD();
                MembershipUser newUser  = Membership.CreateUser(Email.Text, Password, Email.Text, null, null, true, out status);

                //if (!Roles.IsUserInRole("Manager"))
                //{
                string role = "Manager";
                if (!Roles.RoleExists(role))
                {
                    Roles.CreateRole(role);
                    Roles.AddUserToRole(Email.Text, role);
                }
                else
                {
                    //Roles.RemoveUserFromRole(Email.Text, role);

                    Roles.AddUserToRole(Email.Text, role);
                }
                clsESPSql.ExecNonQuery("update aspnet_Users set pwd='" + Password + "', mobilealias='" + Mobile.Text + "' where username='******'");



                try
                {
                    LIBtblOrgBasicInfo         objLIBtblOrgBasicInfo = new LIBtblOrgBasicInfo();
                    DALtblOrgBasicInfo         objDALtblOrgBasicInfo = new DALtblOrgBasicInfo();
                    MyCLS.TransportationPacket tp = new MyCLS.TransportationPacket();

                    objLIBtblOrgBasicInfo.id          = -1;
                    objLIBtblOrgBasicInfo.username    = Email.Text;
                    objLIBtblOrgBasicInfo.Name        = Name.Text;
                    objLIBtblOrgBasicInfo.Email       = Email.Text;
                    objLIBtblOrgBasicInfo.phone       = Mobile.Text;
                    objLIBtblOrgBasicInfo.designation = Designation.Text;
                    objLIBtblOrgBasicInfo.OrgName     = Orgnaisation.Text;
                    objLIBtblOrgBasicInfo.industry    = Industry.SelectedItem.Text;
                    objLIBtblOrgBasicInfo.Orglevel    = ddlLevel.SelectedValue;
                    objLIBtblOrgBasicInfo.dt          = DateTime.Now.ToShortDateString();
                    tp.MessagePacket = objLIBtblOrgBasicInfo;
                    tp = objDALtblOrgBasicInfo.InserttblOrgBasicInfo(tp);

                    DataTable dt = clsESPSql.ExecQuery("SP_GetManager ");

                    rptuserlist.DataSource = dt;

                    rptuserlist.DataBind();
                    ViewState["dt"] = dt;
                }
                catch (Exception ex)
                {
                    MyCLS.clsHandleException.HandleEx(ex, System.Reflection.MethodBase.GetCurrentMethod().ToString(), true);
                }
                DALCommon cmn     = new DALCommon();
                string    strBody = cmn.prcFindInFile(Server.MapPath("mail.html").ToString(), "#UserName#", Email.Text);
                strBody = cmn.prcFindInString(strBody, "#Password#", Password);

                cmn.SendHtmlFormattedEmail(Email.Text, "User Created", strBody);
                // Response.Redirect("user.aspx", false);
                UserName.Text             = "";
                Email.Text                = "";
                Mobile.Text               = "";
                Designation.Text          = "";
                Orgnaisation.Text         = "";
                Industry.SelectedIndex    = 0;
                ddlLevel.SelectedIndex    = 0;
                lblErrorMessage.Text      = "User Created  successfully";
                lblErrorMessage.ForeColor = System.Drawing.Color.Green;
            }


            catch (MembershipCreateUserException ex)
            {
                lblErrorMessage.Text = GetErrorMessage(ex.StatusCode);
            }
        }
        protected void RegisterUser_CreatedUser(object sender, EventArgs e)
        {
            try
            {
                if (!Roles.IsUserInRole(RegisterUser.UserName, "Manager"))
                {
                    if (!Roles.RoleExists("Manager"))
                    {
                        Roles.CreateRole("Manager");
                        Roles.AddUserToRole(RegisterUser.UserName, "Manager");
                    }
                    else
                    {
                        Roles.AddUserToRole(RegisterUser.UserName, "Manager");
                    }
                }

                FormsAuthentication.SetAuthCookie(RegisterUser.UserName, false /* createPersistentCookie */);


                Label  lblmsg       = (Label)RegisterUserWizardStep.ContentTemplateContainer.FindControl("lblErrorMessage");
                string Name         = ((TextBox)RegisterUserWizardStep.ContentTemplateContainer.FindControl("Name")).Text;
                string Designation  = ((TextBox)RegisterUserWizardStep.ContentTemplateContainer.FindControl("Designation")).Text;
                string Mobile       = ((TextBox)RegisterUserWizardStep.ContentTemplateContainer.FindControl("Mobile")).Text;
                string Industry     = ((DropDownList)RegisterUserWizardStep.ContentTemplateContainer.FindControl("Industry")).Text;
                string Orgnaisation = ((TextBox)RegisterUserWizardStep.ContentTemplateContainer.FindControl("Orgnaisation")).Text;
                string pwd          = ((TextBox)RegisterUserWizardStep.ContentTemplateContainer.FindControl("Password")).Text;
                clsESPSql.ExecNonQuery("update aspnet_Users set pwd='" + pwd + "', mobilealias='" + Mobile + "' where username='******'");
                try
                {
                    LIBtblOrgBasicInfo         objLIBtblOrgBasicInfo = new LIBtblOrgBasicInfo();
                    DALtblOrgBasicInfo         objDALtblOrgBasicInfo = new DALtblOrgBasicInfo();
                    MyCLS.TransportationPacket tp = new MyCLS.TransportationPacket();

                    objLIBtblOrgBasicInfo.id          = -1;
                    objLIBtblOrgBasicInfo.username    = RegisterUser.UserName;
                    objLIBtblOrgBasicInfo.Name        = Name;
                    objLIBtblOrgBasicInfo.Email       = RegisterUser.UserName;
                    objLIBtblOrgBasicInfo.phone       = Mobile;
                    objLIBtblOrgBasicInfo.designation = Designation;
                    objLIBtblOrgBasicInfo.OrgName     = Orgnaisation;
                    objLIBtblOrgBasicInfo.industry    = Industry;
                    objLIBtblOrgBasicInfo.dt          = DateTime.Now.ToShortDateString();
                    tp.MessagePacket = objLIBtblOrgBasicInfo;
                    tp = objDALtblOrgBasicInfo.InserttblOrgBasicInfo(tp);

                    //if (tp.MessageId > -1)
                    //{
                    //    string[] strOutParamValues = (string[])tp.MessageResultset;

                    Response.Redirect("Verification.aspx", false);
                    //}

                    // Page.ClientScript.RegisterStartupScript(GetType(), "Message", "<SCRIPT LANGUAGE='javascript'>javascript:   document.getElementById('ahrfcreate').click();</script>");
                    RegisterUser.LoginCreatedUser = true;
                    // lblmsg.Text = " An email has been sent to your account. Please view the email and confirm your account to complete the registration process.";
                }
                catch (Exception ex)
                {
                    MyCLS.clsHandleException.HandleEx(ex, System.Reflection.MethodBase.GetCurrentMethod().ToString(), true);
                }
            }
            catch (Exception ex)
            {
            }
        }
Пример #4
0
        protected void UpdateUserButton_Click(object sender, EventArgs e)
        {
            try
            {
                // Create new user.

                clsESPSql.ExecNonQuery("update aspnet_Users set  mobilealias='" + Mobile.Text + "' where username='******'");



                try
                {
                    LIBtblOrgBasicInfo         objLIBtblOrgBasicInfo = new LIBtblOrgBasicInfo();
                    DALtblOrgBasicInfo         objDALtblOrgBasicInfo = new DALtblOrgBasicInfo();
                    MyCLS.TransportationPacket tp = new MyCLS.TransportationPacket();

                    objLIBtblOrgBasicInfo.id          = -1;
                    objLIBtblOrgBasicInfo.username    = Email.Text;
                    objLIBtblOrgBasicInfo.Name        = Name.Text;
                    objLIBtblOrgBasicInfo.Email       = Email.Text;
                    objLIBtblOrgBasicInfo.phone       = Mobile.Text;
                    objLIBtblOrgBasicInfo.designation = Designation.Text;
                    objLIBtblOrgBasicInfo.OrgName     = Orgnaisation.Text;
                    objLIBtblOrgBasicInfo.industry    = Industry.SelectedItem.Text;
                    objLIBtblOrgBasicInfo.dt          = DateTime.Now.ToShortDateString();
                    objLIBtblOrgBasicInfo.Orglevel    = ddlLevel.SelectedValue;
                    tp.MessagePacket = objLIBtblOrgBasicInfo;
                    tp = objDALtblOrgBasicInfo.InserttblOrgBasicInfo(tp);
                }
                catch (Exception ex)
                {
                    MyCLS.clsHandleException.HandleEx(ex, System.Reflection.MethodBase.GetCurrentMethod().ToString(), true);
                }

                // Response.Redirect("user.aspx", false);
                UserName.Text          = "";
                Email.Text             = "";
                Mobile.Text            = "";
                Designation.Text       = "";
                Orgnaisation.Text      = "";
                Industry.SelectedIndex = 0;

                lblErrorMessage.Text      = "user details updated successfully";
                lblErrorMessage.ForeColor = System.Drawing.Color.Green;

                CreateUserButton.Visible = true;
                UpdateUser.Visible       = false;
                DataTable dt = clsESPSql.ExecQuery("SP_GetManager ");

                rptuserlist.DataSource = dt;

                rptuserlist.DataBind();
                ViewState["dt"] = dt;
            }


            catch (MembershipCreateUserException ex)
            {
                //lblErrorMessage.Text = GetErrorMessage(ex.StatusCode);
            }
        }