Beispiel #1
0
        public List <UserPerson> GetUser_PersonByPerson_ID(Guid person_ID)
        {
            List <UserPerson> retVal = new List <UserPerson>();

            try
            {
                UserPersonBL person = new UserPersonBL(_connString);
                lnkUserPerson = person.GetUser_PersonByPerson_ID(person_ID);

                if (lnkUserPerson != null && lnkUserPerson.Rows.Count > 0)
                {
                    foreach (DataRow row in lnkUserPerson.Rows)
                    {
                        UserPerson userPerson = new UserPerson(_connString, Utils.DBNullToGuid(row["User_Person_ID"]));
                        retVal.Add(userPerson);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(retVal);
        }
Beispiel #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!FoundSystemAdmin())
            {
                MembershipCreateStatus outstatus;
                MembershipUser newUser = Membership.CreateUser(AdminName, AdminPW, AdminEmail, PWQuestion, PWAnswer, true, out outstatus);
                if (!Roles.RoleExists(AdminRole))
                {
                    Roles.CreateRole(AdminRole);
                }
                Roles.AddUserToRole(AdminName, AdminRole);

                string strUser_ID = newUser.ProviderUserKey.ToString();
                Guid newUserId = new Guid(strUser_ID);
                //Guid newUserId = (Guid)newUser.ProviderUserKey;

                Addresses address = new Addresses();
                address.Address_1 = "Grasmere";
                address.Address_2 = "Findon Road";
                address.Address_Town = "Findon";
                address.Address_City = string.Empty;
                address.Address_County = "West Sussex";
                address.Address_Postcode = "BN14 0RD";

                Guid? address_ID = (Guid?)address.Insert_Address(newUserId);

                if (address_ID != null)
                {
                    People person = new People();
                    person.Person_Forename = "Daren";
                    person.Person_Surname = "Cantrell";
                    person.Address_ID = address_ID;
                    person.Person_Mobile = "07880 883089";
                    person.Person_Landline = "01903 877336";
                    person.Person_Email = AdminEmail;

                    Guid? person_ID = person.Insert_Person(newUserId);

                    if (person_ID != null)
                    {
                        UserPerson userPerson = new UserPerson();
                        userPerson.User_ID = newUserId;
                        userPerson.Person_ID = (Guid)person_ID;

                        Guid? user_Person_ID = userPerson.Insert_User_Person(newUserId);
                    }
                }
                RunOnceMessage.Text = string.Format("System Admin setup correctly {0}", "");
            }
            else
                RunOnceMessage.Text = string.Format("System Admin already setup {0}", "");
        }
Beispiel #3
0
        public List<UserPerson> GetUser_PersonByPerson_ID(Guid person_ID)
        {
            List<UserPerson> userPersonList = new List<UserPerson>();
            UserPersonBL person = new UserPersonBL();
            lnkUserPerson = person.GetUser_PersonByUser_Person_ID(person_ID);

            if (lnkUserPerson != null && lnkUserPerson.Count > 0)
            {
                foreach (sss.lnkUser_PersonRow row in lnkUserPerson)
                {
                    UserPerson userPerson = new UserPerson(row.User_Person_ID);
                    userPersonList.Add(userPerson);
                }
            }

            return userPersonList;
        }
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(User_Person_ID))
        {
            MembershipUser userInfo = Membership.GetUser();
            Guid user_ID = (Guid)userInfo.ProviderUserKey;
            Guid person_ID = new Guid(Person_ID);

            Guid user_Person_ID = new Guid(User_Person_ID);
            UserPerson userPerson = new UserPerson(user_Person_ID);
            if (userPerson.Person_ID.ToString() != Person_ID)
            {
                userPerson.User_ID = user_ID;
                userPerson.Person_ID = person_ID;
                bool success = userPerson.Update_User_Person(user_Person_ID, user_ID);
                if (success)
                    MessageLabel.Text = "Updated Successfully.";
            }
            else
            {
                MessageLabel.Text = "No changes made. - Update cancelled.";
            }
        }
        else
        {
            MembershipUser userInfo = Membership.GetUser();
            Guid user_ID = (Guid)userInfo.ProviderUserKey;
            Guid person_ID = new Guid(Person_ID);

            UserPerson userPerson = new UserPerson();
            userPerson.User_ID = user_ID;
            userPerson.Person_ID = person_ID;
            Guid? user_Person_ID = userPerson.Insert_User_Person(user_ID);
            if (user_Person_ID != null)
            {
                User_Person_ID = user_Person_ID.ToString();
                MessageLabel.Text = "Added Successfully.";
                StoreCommon();
                divUpdateDetails.Visible = false;
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        MessageLabel.Text = string.Empty;
        GetCommon();

        if (!Page.IsPostBack)
        {
            Guid person_ID;
            if (!string.IsNullOrEmpty(User_Person_ID))
            {
                divUpdateDetails.Visible = false;
            }
            else
            {
                MembershipUser userInfo = Membership.GetUser();
                Guid user_ID = (Guid)userInfo.ProviderUserKey;
                UserPerson userPerson = new UserPerson();
                List<UserPerson> lnkUserPerson;
                lnkUserPerson = userPerson.GetUser_PersonByUser_ID(user_ID);
                if (lnkUserPerson.Count > 0)
                {
                    Guid? user_Person_ID = (Guid?)lnkUserPerson[0].User_Person_ID;
                    Guid? newPerson_ID = (Guid?)lnkUserPerson[0].Person_ID;
                    if (user_Person_ID != null)
                    {
                        User_Person_ID = user_Person_ID.ToString();
                        Common.User_Person_ID = User_Person_ID;
                    }
                    if (newPerson_ID != null)
                    {
                        Person_ID = newPerson_ID.ToString();
                        Common.New_User_ID = Person_ID;
                    }
                    divUpdateDetails.Visible = false;
                }
            }
            if (!string.IsNullOrEmpty(Person_ID))
            {
                person_ID = new Guid(Person_ID);
                PopulatePerson(person_ID);
            }
            else
            {
                string returnChars = Common.AppendReturnChars(Request.QueryString, "upi");
                Server.Transfer("~/ShowAdmin/PersonSetup.aspx?" + returnChars + "&p=nu");
            }
        }
    }