Пример #1
0
 /// <summary>
 /// this is used to update the user credential info   //swaraj on 18 feb 2010
 /// </summary>
 public void update()
 {
     try
     {
         //update membership information of user
         objMembershipUser = Membership.GetUser(User.Identity.Name);
         objMembershipUser.Email = txtEmail.Text;
         Membership.UpdateUser(objMembershipUser);
         if (!User.IsInRole("user"))
         {
             //update profile information of user
             objProfileBase = ProfileBase.Create(User.Identity.Name, true);
             objProfileBase.SetPropertyValue("FName", txtFirstname.Text);
             objProfileBase.SetPropertyValue("LName", txtLastname.Text);
             objProfileBase.SetPropertyValue("MobilePhone", txtMobilePhone.Text);
             objProfileBase.SetPropertyValue("Fax", txtFax.Text);
             objProfileBase.SetPropertyValue("Address", txtAddress.Text);
             objProfileBase.SetPropertyValue("ModifiedBy", User.Identity.Name);
             objProfileBase.SetPropertyValue("PostalCode", txtPostalCode.Text);
             objProfileBase.SetPropertyValue("State", txtState.Text);
             objProfileBase.SetPropertyValue("Country", txtCountry.Text);
             objProfileBase.SetPropertyValue("Fax", txtFax.Text);
             objProfileBase.SetPropertyValue("WorkPhone", txtWorkPhone.Text);
             objProfileBase.SetPropertyValue("HomePhone", txtHomePhone.Text);
             objProfileBase.Save();
         }
         else
         {
             UserInfoPrimaryKey objUserInfoPrimaryKey = new UserInfoPrimaryKey(objMembershipUser.ProviderUserKey.ToString());
             userInfo = UserInfo.SelectOne(objUserInfoPrimaryKey, ConnectionString);
             userInfo.UserName = txtUsername.Text;
             userInfo.FirstName = txtFirstname.Text;
             userInfo.LastName = txtLastname.Text;
             userInfo.Address1 = txtAddress.Text;
             userInfo.WorkPhone = txtWorkPhone.Text;
             userInfo.CellPhone = txtMobilePhone.Text;
             userInfo.State = txtState.Text;
             userInfo.Country = txtCountry.Text;
             userInfo.PostalCode = txtPostalCode.Text;
             userInfo.EmailAddress = txtEmail.Text;
             userInfo.Fax = txtFax.Text;
             userInfo.HomePhone = txtHomePhone.Text;
             UserInfos objUserInfos = UserInfo.SelectByField("UserId", objMembershipUser.ProviderUserKey.ToString(), ConnectionString);
             if (objUserInfos.Count > 0)
             {
                 userInfo.ListTab = objUserInfos[0].ListTab;
                 userInfo.CampaignTab = objUserInfos[0].CampaignTab;
                 userInfo.AdvancedTab = objUserInfos[0].AdvancedTab;
                 userInfo.ReportsTab = objUserInfos[0].ReportsTab;
             }
             userInfo.UpdateUserDetails();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #2
0
        /// <summary>
        /// This method will return an object representing the record matching the primary key information specified.
        /// </summary>
        ///
        /// <param name="pk" type="UserInfoPrimaryKey">Primary Key information based on which data is to be fetched.</param>
        ///
        /// <returns>object of class UserInfo</returns>
        ///
        /// <remarks>
        ///
        /// <RevisionHistory>
        /// Author				Date			Description
        /// DLGenerator			2/15/2012 12:52:22 PM		Created function
        /// 
        /// </RevisionHistory>
        ///
        /// </remarks>
        ///
        public static UserInfo SelectOne(UserInfoPrimaryKey pk, string ConnectionString)
        {
            DatabaseHelper oDatabaseHelper = new DatabaseHelper(ConnectionString);
            bool ExecutionState = false;

            // Pass the values of all key parameters to the stored procedure.
            System.Collections.Specialized.NameValueCollection nvc = pk.GetKeysAndValues();
            foreach (string key in nvc.Keys)
            {
                oDatabaseHelper.AddParameter("@" + key,nvc[key] );
            }
            // The parameter '@ErrorCode' will contain the status after execution of the stored procedure.
            oDatabaseHelper.AddParameter("@ErrorCode", -1, System.Data.ParameterDirection.Output);

            IDataReader dr=oDatabaseHelper.ExecuteReader("sp_UserInfo_SelectbyPrimaryKey", ref ExecutionState);
            if (dr.Read())
            {
                UserInfo obj = new UserInfo(ConnectionString);
                PopulateObjectFromReader(obj,dr);
                dr.Close();
                oDatabaseHelper.Dispose();
                return obj;
            }
            else
            {
                dr.Close();
                oDatabaseHelper.Dispose();
                return null;
            }
        }
Пример #3
0
        /// <summary>
        /// This method will Delete one row from the database using the primary key information
        /// </summary>
        ///
        /// <param name="pk" type="UserInfoPrimaryKey">Primary Key information based on which data is to be fetched.</param>
        ///
        /// <returns>True if succeeded</returns>
        ///
        /// <remarks>
        ///
        /// <RevisionHistory>
        /// Author				Date			Description
        /// DLGenerator			2/15/2012 12:52:22 PM		Created function
        /// 
        /// </RevisionHistory>
        ///
        /// </remarks>
        ///
        public static bool Delete(UserInfoPrimaryKey pk)
        {
            DatabaseHelper oDatabaseHelper = new DatabaseHelper();
            bool ExecutionState = false;

            // Pass the values of all key parameters to the stored procedure.
            System.Collections.Specialized.NameValueCollection nvc = pk.GetKeysAndValues();
            foreach (string key in nvc.Keys)
            {
                oDatabaseHelper.AddParameter("@" + key,nvc[key] );
            }
            // The parameter '@ErrorCode' will contain the status after execution of the stored procedure.
            oDatabaseHelper.AddParameter("@ErrorCode", -1, System.Data.ParameterDirection.Output);

            oDatabaseHelper.ExecuteScalar("sp_UserInfo_Delete", ref ExecutionState);
            oDatabaseHelper.Dispose();
            return ExecutionState;
        }
Пример #4
0
        /// <summary>
        ///  To update the user
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void lbtnUpdateUser_Click(object sender, EventArgs e)
        {
            try
            {

                objMembershipUser = Membership.GetUser(txtUsername.Text);
                objMembershipUser.Email = txtEmail.Text;
                objMembershipUser.IsApproved = chkStatus.Checked;
                Membership.UpdateUser(objMembershipUser);

                UserInfoPrimaryKey objUserInfoPrimaryKey = new UserInfoPrimaryKey(objMembershipUser.ProviderUserKey.ToString());
                userInfo = UserInfo.SelectOne(objUserInfoPrimaryKey, ConnectionString);
                userInfo.UserName = txtUsername.Text;
                userInfo.FirstName = txtEFName.Text;
                userInfo.LastName = txtELName.Text;
                userInfo.Address1 = txtEAddress1.Text;
                userInfo.Address2 = txtEAddress2.Text;
                userInfo.WorkPhone = txtEWPhone.Text;
                userInfo.CellPhone = txtECellPhone.Text;
                userInfo.City = txtECity.Text;
                userInfo.State = txtEState.Text;
                userInfo.Country = txtECountry.Text;
                userInfo.PostalCode = txtEPCode.Text;
                userInfo.EmailAddress = txtEmail.Text;

                userInfo.ListTab = true;
                userInfo.CampaignTab = true;
                userInfo.AdvancedTab = true;

                userInfo.ReportsTab = false;
                userInfo.CampaignReportsTab = false;

                userInfo.UpdateUserDetails();
                fillGrid("");
                lblMainMsg.Text = string.Format("User: "******" updated successfully");
                lblMainMsg.Style.Add("color", "Green");
                txtEmail.Text = "";
            }
            catch (Exception ex)
            {
                lblEditPopupMsg.Style.Add("color", "Red");
                lblEditPopupMsg.Text = "Already existed Email";
                UpdateUserModalPopupExtender.Show();

            }
        }
Пример #5
0
        /// <summary>
        ///  To delete the user
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void lbtnDeleteUser_Click(object sender, EventArgs e)
        {
            try
            {
                for (int i = 0; i < gviewUsers.Rows.Count; i++)
                {
                    CheckBox grdaddchkSelectUser = (CheckBox)gviewUsers.Rows[i].FindControl("grdaddchkSelectUser");
                    if (grdaddchkSelectUser != null && grdaddchkSelectUser.Checked == true)
                    {
                        LinkButton lblUsername = (LinkButton)gviewUsers.Rows[i].FindControl("lblUsername");
                        objMembershipUser = Membership.GetUser(lblUsername.Text.ToString());
                        Usernames.Append(lblUsername.Text + ", ");
                        UserIds.Append(objMembershipUser.ProviderUserKey.ToString() + ", ");
                    }
                }
                Usernames.Remove(Usernames.Length - 2, 1);
                UserIds.Remove(UserIds.Length - 2, 1);
                string[] uNames = Usernames.ToString().Split(',');
                string[] uIds = UserIds.ToString().Split(',');
                foreach (string User in uNames)
                {
                    //Delete that particular user in UserInfo Table
                    objMembershipUser = Membership.GetUser(User.ToString());
                    UserInfoPrimaryKey objUserInfoPrimaryKey = new UserInfoPrimaryKey(objMembershipUser.ProviderUserKey.ToString());
                    userInfo = UserInfo.SelectOne(objUserInfoPrimaryKey, ConnectionString);
                    userInfo.Delete();

                    //Delete that particular user in UserPermissions Table also
                    UserPermissionPrimaryKey objUserPermissionPrimaryKey = new UserPermissionPrimaryKey(objMembershipUser.ProviderUserKey.ToString());
                    UserPermission objUserPermission = UserPermission.SelectOne(objUserPermissionPrimaryKey, ConnectionString);
                    objUserPermission.Delete();

                    //Delete User in Membership
                    status = Membership.DeleteUser(User.ToString());
                    if (status == true)
                        delUsers.Append(User + ", ");
                    else
                        unDelUsers.Append(User + ", ");
                }
                if (delUsers.Length != 0)
                    delUsers.Remove(delUsers.Length - 2, 1);
                if (unDelUsers.Length != 0)
                    unDelUsers.Remove(unDelUsers.Length - 2, 1);

                DeleteUserModalPopupExtender.Hide();
                fillGrid("sort");

                if (delUsers.Length != 0)
                {
                    lblMainMsg.Style.Add("color", "Green");
                    lblMainMsg.Text = string.Format("User: "******" deleted successfully");
                    Session["SelectedContacts"] = null;
                }
                else
                {
                    lblMainMsg.Style.Add("color", "Red");
                    lblMainMsg.Text = "Unable to delete the user";
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }