Beispiel #1
0
    protected void CreateNewUserButton_Click(object sender, EventArgs e)
    {
        MultiView1.SetActiveView(CreateNewUserView);
        WizardStep   AdditionalInfo = RegisterUser.FindControl("AdditionalInfo") as WizardStep;
        CheckBoxList RoleList       = AdditionalInfo.FindControl("RoleList") as CheckBoxList;

        RoleList.DataSource = Roles.GetAllRoles();
        RoleList.DataBind();
    }
Beispiel #2
0
    protected void RegisterUser_CreatedUser(object sender, EventArgs e)
    {
        aspnet_UserProfilesBLL = new aspnet_UserProfilesBLL();

        TextBox txtFullname = RegisterUser.FindControl("CreateUserStepContainer").FindControl("txtFullname") as TextBox;
        TextBox txtPhone    = RegisterUser.FindControl("CreateUserStepContainer").FindControl("Phone") as TextBox;

        aspnet_UserProfilesBLL.NewProfile(RegisterUser.UserName, txtFullname.Text, txtPhone.Text);
    }
Beispiel #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        CreateUserWizardStep step = (CreateUserWizardStep)RegisterUser.FindControl("step1");

        if (step != null)
        {
            // bind-uva so javascript delot za da se pojavi slikata pri upload :)
            FileUpload uploadedPicture = (FileUpload)step.ContentTemplateContainer.FindControl("profilePicture");
            uploadedPicture.Attributes["onchange"] = "UploadFile(this)";
        }
    }
Beispiel #4
0
    protected void RegisterUser_CreatedUser(object sender, EventArgs e)
    {
        step = (CreateUserWizardStep)RegisterUser.FindControl("step1");
        if (step != null)
        {
            FileUpload uploadedPicture = (FileUpload)step.ContentTemplateContainer.FindControl("profilePicture");
            if (uploadedPicture.HasFile)
            {
                Debug.WriteLine("***** FILE FIELD HAS FILE *****");
                string   profilePic = uploadedPicture.FileName;
                string[] chopped    = profilePic.Split('.');
                string   extension  = chopped.ElementAt(chopped.Count() - 1);

                // ja zacuvuvam original
                string path = Server.MapPath("~/User/ProfilePictures/" + RegisterUser.UserName + "." + extension);
                uploadedPicture.PostedFile.SaveAs(path);

                // resizing thumbs
                System.Drawing.Image img       = System.Drawing.Image.FromFile(path);
                ImageFormat          imgFormat = img.RawFormat;

                List <float> scaledSize = scaleSize(200, 200, img.Width, img.Height);
                Bitmap       newImg     = new Bitmap(img, (int)scaledSize[0], (int)scaledSize[1]);
                string       destPath   = Server.MapPath("~/User/ProfilePictures/thumbs/" + RegisterUser.UserName + "." + extension);
                newImg.Save(destPath, imgFormat);

                // resizing standard
                img       = System.Drawing.Image.FromFile(path);
                imgFormat = img.RawFormat;

                scaledSize = scaleSize(300, 300, img.Width, img.Height);
                newImg     = new Bitmap(img, (int)scaledSize[0], (int)scaledSize[1]);
                destPath   = Server.MapPath("~/User/ProfilePictures/standard/" + RegisterUser.UserName + "." + extension);
                newImg.Save(destPath, imgFormat);



                // username-ovite se unique :) po difolt
                storeExtra(RegisterUser.UserName + "." + extension);
            }
            else
            {
                // se stava default profilePicture.png
                storeExtra("profilePicture.png");
            }
        }
        else
        {
            Debug.WriteLine("step is null");
        }
    }
Beispiel #5
0
 protected void RegisterUser_ActiveStepChanged(object sender, EventArgs e)
 {
     // Have we JUST reached the Complete step?
     if (RegisterUser.ActiveStep.Title == "Complete")
     {
         // Reference the SpecifyRolesStep WizardStep
         WizardStep SpecifyRolesStep = RegisterUser.FindControl("SpecifyRolesStep") as WizardStep;
         // Reference the RoleList CheckBoxList
         CheckBoxList RoleList = SpecifyRolesStep.FindControl("RoleList") as CheckBoxList;
         // Add the checked roles to the just-added user
         foreach (ListItem li in RoleList.Items)
         {
             if (li.Selected)
             {
                 Roles.AddUserToRole(RegisterUser.UserName, li.Text);
             }
         }
     }
 }
Beispiel #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //if (!User.IsInRole("SysAdmin"))
        //{
        //    Response.Redirect("~/AccessDenied.aspx", true);
        //}

        if (!Page.IsPostBack)
        {
            // Reference the SpecifyRolesStep WizardStep
            WizardStep SpecifyRolesStep = RegisterUser.FindControl("SpecifyRolesStep") as WizardStep;

            // Reference the RoleList CheckBoxList
            CheckBoxList RoleList = SpecifyRolesStep.FindControl("RoleList") as CheckBoxList;

            // Bind the set of roles to RoleList
            RoleList.DataSource = Roles.GetAllRoles();
            RoleList.DataBind();
        }
    }
Beispiel #7
0
    protected void RegisterUser_ActiveStepChanged(object sender, EventArgs e)
    {
        if (RegisterUser.ActiveStep.Title == "Gotowe")
        {
            WizardStep   SpecifyRolesStep = RegisterUser.FindControl("AdditionalInfo") as WizardStep;
            CheckBoxList RoleList         = SpecifyRolesStep.FindControl("RoleList") as CheckBoxList;
            string       userName         = RegisterUser.UserName;

            foreach (ListItem li in RoleList.Items)
            {
                if (li.Selected)
                {
                    Roles.AddUserToRole(userName, li.Text);
                }
            }

            if (Roles.IsUserInRole(userName, "doctor"))
            {
                string         connectingStringAddDoctor = ConfigurationManager.ConnectionStrings["BBB"].ConnectionString;
                string         addDoctorUrl = "INSERT INTO Cadre(UserId) VALUES  (@UserId)";
                MembershipUser newDoctor    = Membership.GetUser(userName);
                Guid           newDoctorId  = (Guid)newDoctor.ProviderUserKey;

                using (SqlConnection myConnection = new SqlConnection(connectingStringAddDoctor))
                {
                    myConnection.Open();
                    SqlCommand myCommand = new SqlCommand(addDoctorUrl, myConnection);
                    myCommand.Parameters.AddWithValue("@UserId", newDoctorId);
                    myCommand.ExecuteNonQuery();
                    myConnection.Close();
                }
            }

            WizardStep UserInfo = RegisterUser.FindControl("AdditionalInfo") as WizardStep;

            TextBox Name         = UserInfo.FindControl("NameTB") as TextBox;
            TextBox Town         = UserInfo.FindControl("TownTB") as TextBox;
            TextBox Street       = UserInfo.FindControl("StreetTB") as TextBox;
            TextBox StreetNumber = UserInfo.FindControl("StreetNumberTB") as TextBox;
            TextBox PostalCode   = UserInfo.FindControl("PostalCodeTB") as TextBox;
            String  calendar     = DateOfBirth.SelectedDate.Year.ToString() + "-" + DateOfBirth.SelectedDate.Month.ToString() + "-" + DateOfBirth.SelectedDate.Day.ToString();

            MembershipUser newUser   = Membership.GetUser(RegisterUser.UserName);
            Guid           newUserId = (Guid)newUser.ProviderUserKey;

            string connectingString = ConfigurationManager.ConnectionStrings["BBB"].ConnectionString;
            string updateUrl        = "INSERT INTO UserProfiles(NameAndSurname, Town, Street, StreetNumber, PostalCode, DateOfBirth, UserId) VALUES  (@NameAndSurname, @Town, @Street, @StreetNumber, @PostalCode, @DateOfBirth, @UserId)";

            using (SqlConnection myConnection = new SqlConnection(connectingString))
            {
                myConnection.Open();
                SqlCommand myCommand = new SqlCommand(updateUrl, myConnection);
                myCommand.Parameters.AddWithValue("@NameAndSurname", Name.Text.Trim());
                myCommand.Parameters.AddWithValue("@Town", Town.Text.Trim());
                myCommand.Parameters.AddWithValue("@Street", Street.Text.Trim());
                myCommand.Parameters.AddWithValue("@StreetNumber", Int32.Parse(StreetNumber.Text.Trim()));
                myCommand.Parameters.AddWithValue("@PostalCode", PostalCode.Text.Trim());
                myCommand.Parameters.AddWithValue("@DateOfBirth", calendar);
                myCommand.Parameters.AddWithValue("@UserId", newUserId);
                myCommand.ExecuteNonQuery();
                myConnection.Close();
            }
        }
    }
Beispiel #8
0
    protected void RegisterUser_ActiveStepChanged(object sender, EventArgs e)
    {
        // Have we JUST reached the Complete step?
        if (RegisterUser.ActiveStep.Title == "Complete")
        {
            WizardStep ProfileData = RegisterUser.FindControl("ProfileData") as WizardStep;

            // Programmatically reference the TextBox controls
            TextBox      txtFullName          = ProfileData.FindControl("txtFullName") as TextBox;
            DropDownList ddlGender            = ProfileData.FindControl("ddlGender") as DropDownList;
            TextBox      txtAge               = ProfileData.FindControl("txtAge") as TextBox;
            TextBox      txtCareer            = ProfileData.FindControl("txtCareer") as TextBox;
            TextBox      txtCareerDescription = ProfileData.FindControl("txtCareerDescription") as TextBox;

            // Update the UserProfiles record for this user
            // Get the UserId of the just-added user
            MembershipUser newUser   = Membership.GetUser(RegisterUser.UserName);
            Guid           newUserId = (Guid)newUser.ProviderUserKey;

            // Insert a new record into UserProfiles
            string connectionString =
                ConfigurationManager.ConnectionStrings["SecurityConnectionString"].ConnectionString;
            string updateSql = "UPDATE UserProfiles SET FullName = @FullName, Gender = @Gender, Age = @Age, Career = @Career, CareerDescription = @CareerDescription WHERE UserId = @UserId";

            using (SqlConnection myConnection = new SqlConnection(connectionString))
            {
                myConnection.Open();
                SqlCommand myCommand = new SqlCommand(updateSql, myConnection);
                myCommand.Parameters.AddWithValue("@FullName", txtFullName.Text.Trim());
                myCommand.Parameters.AddWithValue("@Gender", ddlGender.SelectedItem.Text.Trim());
                myCommand.Parameters.AddWithValue("@Age", txtAge.Text.Trim());
                myCommand.Parameters.AddWithValue("@Career", txtCareer.Text.Trim());
                myCommand.Parameters.AddWithValue("@CareerDescription", txtCareerDescription.Text.Trim());
                myCommand.Parameters.AddWithValue("@UserId", newUserId);
                myCommand.ExecuteNonQuery();
                myConnection.Close();
            }

            string connectionString2 = ConfigurationManager.ConnectionStrings["SecurityConnectionString"].ConnectionString;
            string insertSql         = "INSERT INTO PhotoAlbums(Name, UserId) VALUES(@Name, @UserId)";

            using (SqlConnection myConnection = new SqlConnection(connectionString2))
            {
                myConnection.Open();
                SqlCommand myCommand = new SqlCommand(insertSql, myConnection);
                myCommand.Parameters.AddWithValue("@UserId", newUserId);
                myCommand.Parameters.AddWithValue("@Name", "ProfilePictures");

                myCommand.ExecuteNonQuery();
                myConnection.Close();
            }

            string connectionString3 = ConfigurationManager.ConnectionStrings["SecurityConnectionString"].ConnectionString;
            string insertSql2        = "INSERT INTO PhotoAlbums(Name, UserId) VALUES(@Name, @UserId)";

            using (SqlConnection myConnection = new SqlConnection(connectionString3))
            {
                myConnection.Open();
                SqlCommand myCommand = new SqlCommand(insertSql2, myConnection);
                myCommand.Parameters.AddWithValue("@UserId", newUserId);
                myCommand.Parameters.AddWithValue("@Name", "CoverPhotos");

                myCommand.ExecuteNonQuery();
                myConnection.Close();
            }

            //string connectionString4 = ConfigurationManager.ConnectionStrings["SecurityConnectionString"].ConnectionString;
            //string insertSql3 = "INSERT INTO UserCircles(Name, UserId) VALUES(@Name, @UserId)";

            //using (SqlConnection myConnection = new SqlConnection(connectionString4))
            //{
            //    myConnection.Open();
            //    SqlCommand myCommand = new SqlCommand(insertSql3, myConnection);
            //    myCommand.Parameters.AddWithValue("@UserId", newUserId);
            //    myCommand.Parameters.AddWithValue("@Name", "All");

            //    myCommand.ExecuteNonQuery();
            //    myConnection.Close();
            //}
            //using (SqlConnection myConnection = new SqlConnection(connectionString4))
            //{
            //    myConnection.Open();
            //    SqlCommand myCommand = new SqlCommand(insertSql3, myConnection);
            //    myCommand.Parameters.AddWithValue("@UserId", newUserId);
            //    myCommand.Parameters.AddWithValue("@Name", "Friends");

            //    myCommand.ExecuteNonQuery();
            //    myConnection.Close();
            //}
            //using (SqlConnection myConnection = new SqlConnection(connectionString4))
            //{
            //    myConnection.Open();
            //    SqlCommand myCommand = new SqlCommand(insertSql3, myConnection);
            //    myCommand.Parameters.AddWithValue("@UserId", newUserId);
            //    myCommand.Parameters.AddWithValue("@Name", "Family");

            //    myCommand.ExecuteNonQuery();
            //    myConnection.Close();
            //}
            //using (SqlConnection myConnection = new SqlConnection(connectionString4))
            //{
            //    myConnection.Open();
            //    SqlCommand myCommand = new SqlCommand(insertSql3, myConnection);
            //    myCommand.Parameters.AddWithValue("@UserId", newUserId);
            //    myCommand.Parameters.AddWithValue("@Name", "Acquaintances");

            //    myCommand.ExecuteNonQuery();
            //    myConnection.Close();
            //}
        }
    }