Esempio n. 1
0
    protected void RegisterUser_CreatedUser(object sender, EventArgs e)
    {
        ProfileCommon p = new ProfileCommon();

        p.Initialize(RegisterUser.UserName, true);

        p.Address = ((TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("TextAddress")).Text;
        p.Name = ((TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("TextName")).Text;
        p.Phone = ((TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("TextPhone")).Text;

        //// Save the profile - must be done since we explicitly created this profile instance
        p.Save();

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

        if (RegisterUser.UserName == "admin")
        {
            Roles.AddUserToRole(RegisterUser.UserName, "admin");
        }
        else
        {
            Roles.AddUserToRole(RegisterUser.UserName, "customer");
        }

        string continueUrl = RegisterUser.ContinueDestinationPageUrl;
        if (String.IsNullOrEmpty(continueUrl))
        {
            continueUrl = "~/FirstPage.aspx";
        }
        Response.Redirect(continueUrl);
    }
    //
    protected void GetUserInfo()
    {
        ProfileCommon pf = new ProfileCommon();

        pf.Initialize(TextUserName.Text, true);
        this.TextName.Text    = pf.Name;
        this.TextAddress.Text = pf.Address;
        this.TextPhone.Text   = pf.Phone;

        Literal2.Text = "";
        foreach (ListItem item in cblRoles.Items)
        {
            item.Selected = false;
        }

        string[] sa = Roles.GetRolesForUser(TextUserName.Text);
        foreach (string s in sa)
        {
            int      idx  = 1;
            ListItem item = cblRoles.Items.FindByText(s);
            if (item != null)
            {
                idx = cblRoles.Items.IndexOf(item);
                cblRoles.Items[idx].Selected = true;
                Literal2.Text += s + ";";
            }
        }
    }
Esempio n. 3
0
    protected void RegisterUser_CreatedUser(object sender, EventArgs e)
    {
        ProfileCommon p = new ProfileCommon();

        p.Initialize(RegisterUser.UserName, true);

        p.Address = ((TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("TextAddress")).Text;
        p.Name    = ((TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("TextName")).Text;
        p.Phone   = ((TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("TextPhone")).Text;

        //// Save the profile - must be done since we explicitly created this profile instance
        p.Save();

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

        if (RegisterUser.UserName == "admin")
        {
            Roles.AddUserToRole(RegisterUser.UserName, "admin");
        }
        else
        {
            Roles.AddUserToRole(RegisterUser.UserName, "customer");
        }

        string continueUrl = RegisterUser.ContinueDestinationPageUrl;

        if (String.IsNullOrEmpty(continueUrl))
        {
            continueUrl = "~/FirstPage.aspx";
        }
        Response.Redirect(continueUrl);
    }
Esempio n. 4
0
    protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
    {
        ProfileCommon pc = new ProfileCommon();

        pc.Initialize(CreateUserWizard1.UserName.ToString(), true);

        pc.FirstName = Firstname.Text;
        pc.LastName  = Lastname.Text;
        pc.Age       = Age.Text;

        pc.Save();
    }
Esempio n. 5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            btnSubmit.OnClientClick = "return confirm('Do you really want to submit this order?');";
            if (!Context.User.IsInRole("customer"))
            {
                Utils.ShowMessageBox(this, "not a customer,the order can't be submitted");
                LabelRslt.Text = "The user is not a customer,the order can't be submitted";
            }

            DataTable dtOrder = (DataTable)Session["order"];
            if (dtOrder != null)
            {
                for (int i = 0; i < dtOrder.Rows.Count; i++)
                {
                    for (int j = 0; j < dtOrder.Columns.Count; j++)
                    {
                        GvOrderDetail.TableOrder.Rows[i][j] = dtOrder.Rows[i][j];
                    }
                }
            }

            // get the order types data
            foreach (TOrderType item in RestaurantBiz.AllOrderTypes)
            {
                ddlOrderType.Items.Add(new ListItem(item.Text, item.Id.ToString()));
            }
            //select the first as default
            ddlOrderType.Items[0].Selected = true;

            ProfileCommon pf = new ProfileCommon();
            pf.Initialize(Context.User.Identity.Name, true);
            tbAdd.Text   = pf.Address;
            tbPhone.Text = pf.Phone;
            tbName.Text  = pf.Name;

            LabelRslt.Text = "";
        }
    }
Esempio n. 6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            btnSubmit.OnClientClick = "return confirm('Do you really want to submit this order?');";
            if (!Context.User.IsInRole("customer"))
            {
                Utils.ShowMessageBox(this, "not a customer,the order can't be submitted");
                LabelRslt.Text = "The user is not a customer,the order can't be submitted";
            }

            DataTable dtOrder = (DataTable)Session["order"];
            if (dtOrder != null)
            {
                for (int i = 0; i < dtOrder.Rows.Count; i++)
                    for (int j = 0; j < dtOrder.Columns.Count; j++)
                    {
                        GvOrderDetail.TableOrder.Rows[i][j] = dtOrder.Rows[i][j];
                    }
            }

            // get the order types data
            foreach (TOrderType item in RestaurantBiz.AllOrderTypes)
            {
                ddlOrderType.Items.Add(new ListItem(item.Text, item.Id.ToString()));
            }
            //select the first as default
            ddlOrderType.Items[0].Selected = true;

            ProfileCommon pf = new ProfileCommon();
            pf.Initialize(Context.User.Identity.Name, true);
            tbAdd.Text = pf.Address;
            tbPhone.Text = pf.Phone;
            tbName.Text = pf.Name;

            LabelRslt.Text = "";

        }
    }
Esempio n. 7
0
    protected void Register_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            try
            {
                // Create account and assign role 'Patient'
                string pswd = Password.Text;
                if (RndPswd.Checked)
                {
                    pswd = Membership.GeneratePassword(Membership.MinRequiredPasswordLength,
                                                       Membership.MinRequiredNonAlphanumericCharacters);
                }

                Membership.CreateUser(UserName.Text, pswd, Email.Text);
                ProfileCommon pc = new ProfileCommon();
                pc.Initialize(UserName.Text, true);
                pc.Name = PatientName.Text;
                pc.Save();
                Roles.AddUserToRole(UserName.Text, "Patient");


                // Send account confirmation email
                string fileName = Server.MapPath("~/App_Data/AccountConfirmation.txt");
                string mailBody = File.ReadAllText(fileName);
                mailBody = mailBody.Replace("##Name##", PatientName.Text);
                mailBody = mailBody.Replace("##Role##", "Patient");
                mailBody = mailBody.Replace("##Username##", UserName.Text);
                mailBody = mailBody.Replace("##Password##", pswd);

                MailMessage emailMessage = new MailMessage();
                emailMessage.Subject = "New Account Confirmation";
                emailMessage.Body    = mailBody;
                emailMessage.From    = new MailAddress("*****@*****.**", "NMHC");
                emailMessage.To.Add(new MailAddress(Email.Text, PatientName.Text));

                SmtpClient mySmtpClient = new SmtpClient();
                mySmtpClient.Send(emailMessage);


                // Register above patient
                using (NMHCDatabaseEntities myEntities = new NMHCDatabaseEntities())
                {
                    Patient__Profile profile = new Patient__Profile();
                    profile.Registration_ID      = UserName.Text;
                    profile.PatientName          = PatientName.Text;
                    profile.RegistrationDateTime = DateTime.Now;
                    profile.Email = Email.Text;
                    profile.H_ID  = (from r in myEntities.Hospital__Staff
                                     where r.Staff_ID == Profile.UserName
                                     select r.H_ID).SingleOrDefault();

                    profile.UpdatedBy      = Profile.UserName;
                    profile.UpdateUserName = Profile.Name;
                    profile.UpdateDateTime = profile.RegistrationDateTime;

                    myEntities.AddToPatient__Profile(profile);
                    myEntities.SaveChanges();
                }

                Notification.Text = "Your account has been created successfully. " +
                                    "An email has been sent to " + Email.Text + " containing your Username and Password.";
            }
            catch (Exception ex)
            {
                Notification.Text = ex.Message;
                Back.Visible      = true;
                Continue.Visible  = false;

                // Delete partially created user data in case of exception
                using (NMHCDatabaseEntities myEntities = new NMHCDatabaseEntities())
                {
                    var profile = (from r in myEntities.Patient__Profile
                                   where r.Registration_ID == UserName.Text
                                   select r).SingleOrDefault();
                    if (profile != null)
                    {
                        myEntities.Patient__Profile.DeleteObject(profile);
                    }
                    myEntities.SaveChanges();
                }

                if (Membership.GetUser(UserName.Text) != null)
                {
                    Membership.DeleteUser(UserName.Text, true);
                }
            }

            MultiView1.ActiveViewIndex = 1;
        }
    }
    //
    protected void GetUserInfo()
    {
        ProfileCommon pf = new ProfileCommon();
        pf.Initialize(TextUserName.Text, true);
        this.TextName.Text = pf.Name;
        this.TextAddress.Text = pf.Address;
        this.TextPhone.Text = pf.Phone;

        Literal2.Text = "";
        foreach (ListItem item in cblRoles.Items)
        {
            item.Selected = false;
        }

        string[] sa = Roles.GetRolesForUser(TextUserName.Text);
        foreach (string s in sa)
        {
            int idx = 1;
            ListItem item = cblRoles.Items.FindByText(s);
            if (item != null)
            {
                idx = cblRoles.Items.IndexOf(item);
                cblRoles.Items[idx].Selected = true;
                Literal2.Text += s+";";
            }
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        //

        if (Roles.IsUserInRole(Context.User.Identity.Name, "admin"))
        {
            if ( (Membership.FindUsersByName(TextUserName.Text) !=null) && (Membership.FindUsersByName(TextUserName.Text).Count>0) )
            {

            }
            else
            {
                Literal1.Text = "no such user:"******"Detail Information Saved Successfully!";

        }
        else
        {

            ProfileCommon p = new ProfileCommon();

            p.Initialize(Context.User.Identity.Name, true);
            p.Address = TextName.Text;
            p.Phone = TextPhone.Text;
            p.Name = TextName.Text;

            //// Save the profile - must be done since we explicitly created this profile instance
            p.Save();

            Literal1.Text = "Detail Information Saved Successfully!";
        }
    }
Esempio n. 10
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        //

        if (Roles.IsUserInRole(Context.User.Identity.Name, "admin"))
        {
            if ((Membership.FindUsersByName(TextUserName.Text) != null) && (Membership.FindUsersByName(TextUserName.Text).Count > 0))
            {
            }
            else
            {
                Literal1.Text = "no such user:"******"Detail Information Saved Successfully!";
        }
        else
        {
            ProfileCommon p = new ProfileCommon();

            p.Initialize(Context.User.Identity.Name, true);
            p.Address = TextName.Text;
            p.Phone   = TextPhone.Text;
            p.Name    = TextName.Text;

            //// Save the profile - must be done since we explicitly created this profile instance
            p.Save();

            Literal1.Text = "Detail Information Saved Successfully!";
        }
    }