コード例 #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
ファイル: UserInfoBase.cs プロジェクト: shekar348/1PointOne
        /// <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
ファイル: UserInfoBase.cs プロジェクト: shekar348/1PointOne
        /// <summary>
        /// Populates the fields for multiple objects from the columns found in an open reader.
        /// </summary>
        ///
        /// <param name="rdr" type="IDataReader">An object that implements the IDataReader interface</param>
        ///
        /// <returns>Object of UserInfos</returns>
        ///
        /// <remarks>
        ///
        /// <RevisionHistory>
        /// Author				Date			Description
        /// DLGenerator			2/15/2012 12:52:22 PM		Created function
        /// 
        /// </RevisionHistory>
        ///
        /// </remarks>
        ///
        internal static UserInfos PopulateObjectsFromReaderWithCheckingReader(IDataReader rdr, DatabaseHelper oDatabaseHelper, string ConnectionString)
        {
            UserInfos list = new UserInfos();

            if (rdr.Read())
            {
                UserInfo obj = new UserInfo(ConnectionString);
                PopulateObjectFromReader(obj, rdr);
                list.Add(obj);
                while (rdr.Read())
                {
                    obj = new UserInfo(ConnectionString);
                    PopulateObjectFromReader(obj, rdr);
                    list.Add(obj);
                }
                oDatabaseHelper.Dispose();
                return list;
            }
            else
            {
                oDatabaseHelper.Dispose();
                return null;
            }
        }
コード例 #4
0
ファイル: UserInfoBase.cs プロジェクト: shekar348/1PointOne
        /// <summary>
        /// Populates the fields for multiple objects from the columns found in an open reader.
        /// </summary>
        ///
        /// <param name="rdr" type="IDataReader">An object that implements the IDataReader interface</param>
        ///
        /// <returns>Object of UserInfos</returns>
        ///
        /// <remarks>
        ///
        /// <RevisionHistory>
        /// Author				Date			Description
        /// DLGenerator			2/15/2012 12:52:22 PM		Created function
        /// 
        /// </RevisionHistory>
        ///
        /// </remarks>
        ///
        internal static UserInfos PopulateObjectsFromReader(IDataReader rdr, string ConnectionString)
        {
            UserInfos list = new UserInfos();

            while (rdr.Read())
            {
                UserInfo obj = new UserInfo(ConnectionString);
                PopulateObjectFromReader(obj,rdr);
                list.Add(obj);
            }
            return list;
        }
コード例 #5
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();

            }
        }
コード例 #6
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;
            }
        }
コード例 #7
0
        /// <summary>
        /// This method is used to create user     //Developed on 20 feb 2010
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void lbtnCreate_Click(object sender, EventArgs e)
        {
            try
            {
                MembershipCreateStatus CreateStatus;
                objClientProfile = ProfileBase.Create(User.Identity.Name.ToString());
                objClientMembership = Membership.GetUser(User.Identity.Name.ToString());
                string Password = Membership.GeneratePassword(10, 5);

                Guid uniqueID = Guid.NewGuid();
                byte[] bArr = uniqueID.ToByteArray();
                int FavouritNo = BitConverter.ToInt32(bArr, 0);
                objMembershipUser = Membership.CreateUser(txtCreateUserName.Text.ToString(), Password.ToString(), txtCreateEmail.Text.ToString(), "Favourite Number", FavouritNo.ToString(), chkUStatus.Checked, out CreateStatus);

                //checking whether creation succeeded or not
                switch (CreateStatus.ToString())
                {
                    case "Success":
                        Roles.AddUserToRole(txtCreateUserName.Text.ToString(), "user");
                        objProfileBase = ProfileBase.Create(txtCreateUserName.Text.ToString());
                        objMembershipUser = Membership.GetUser(txtCreateUserName.Text.ToString().Trim());

                        userInfo = new UserInfo(ConnectionString);
                        userInfo.UserId = (Guid)objMembershipUser.ProviderUserKey;
                        userInfo.UserName = txtCreateUserName.Text.ToString();
                        userInfo.FirstName = txtFName.Text.ToString();
                        userInfo.LastName = txtLName.Text.ToString();
                        userInfo.Address1 = txtAddress1.Text.ToString();
                        userInfo.Address2 = txtAddress2.Text.ToString();
                        userInfo.WorkPhone = txtWPhone.Text.ToString();
                        userInfo.CellPhone = txtCellPhone.Text.ToString();
                        userInfo.City = txtCity.Text.ToString();
                        userInfo.State = txtState.Text.ToString();
                        userInfo.Country = txtCountry.Text.ToString();
                        userInfo.PostalCode = txtPCode.Text.ToString();
                        userInfo.EmailAddress = txtCreateEmail.Text.ToString();

                        userInfo.ListTab = true;
                        userInfo.CampaignTab = true;
                        userInfo.AdvancedTab = true;
                        userInfo.ReportsTab = true;
                        userInfo.CampaignReportsTab = true;
                        userInfo.Logo = null;
                        bool status = userInfo.Insert();

                        //Create User in UserPermissions Table
                        insertUserInPermissionsTb(txtCreateUserName.Text.ToString().Trim(), objMembershipUser.ProviderUserKey);

                        if (status)
                        {
                            //setting client properties to user
                            objProfileBase.SetPropertyValue("DBName", objClientProfile.GetPropertyValue("DBName"));
                            objProfileBase.SetPropertyValue("DBUserID", objClientProfile.GetPropertyValue("DBUserID"));
                            objProfileBase.SetPropertyValue("DBPassword", objClientProfile.GetPropertyValue("DBPassword"));
                            objProfileBase.SetPropertyValue("DBServerName", objClientProfile.GetPropertyValue("DBServerName"));
                            objProfileBase.SetPropertyValue("ParentUserName", User.Identity.Name);
                            objProfileBase.Save();

                            //message body
                            StringBuilder body = new StringBuilder();
                            body.Append("<HTML><BODY>");
                            body.Append("<table width=\"100%\"><tr><td align=\"left\" colspan=\"3\" style=\"height:4px; color:green;\"><h3></h3> <td></tr><tr><td colspan=\"3\">&nbsp;</td></tr>");
                            body.Append("<tr><td colspan=\"3\"> Hi&nbsp;" + txtCreateUserName.Text.ToString() + ",</td></tr><tr><td colspan=\"3\">&nbsp;</td></tr>");
                            body.Append("<tr><td colspan=\"3\">Welcome to 1Point</td></tr><tr><td colspan=\"3\">&nbsp;</td></tr>");
                            body.Append("<tr><td colspan=\"3\">You can login in to your Account at:</td></tr>");
                            body.Append("<tr><td colspan=\"3\"><a href=\"" + ConfigurationManager.AppSettings["LoginUrl"] + "\">Login</a></td></tr>");
                            body.Append("<tr><td colspan=\"3\"></td></tr><tr><td colspan=\"3\">&nbsp;</td></tr>");
                            body.Append("<tr><td>User Name :&nbsp;&nbsp; " + txtCreateUserName.Text.ToString() + "</td></tr>");
                            body.Append("\n<tr><td>Password : &nbsp;&nbsp;" + Password + "</td></tr> <tr><td colspan=\"3\">&nbsp;</td></tr>");
                            body.Append("<tr><td colspan=\"3\">If there's anything we can do to help, please get in touch.</td></tr><tr><td colspan=\"3\">&nbsp;</td></tr>");
                            body.Append("<tr><td colspan=\"3\">Regards,</td></tr>");
                            body.Append("<tr><td colspan=\"3\">1Point team</td></tr>");
                            body.Append("<tr><td colspan=\"3\">" + ConfigurationManager.AppSettings["SuperAdminEmail"].ToString().Split(',').GetValue(0) + "</td></tr>");
                            body.Append("<tr></tr>");
                            body.Append("<tr><td colspan=\"3\" style=\"color:red;\">This is an automated Email, please don't Reply.</td></tr>");

                            MailMessage SendMessageToUser = new MailMessage();
                            SendMessageToUser.To.Add(txtCreateEmail.Text.ToString());
                            SendMessageToUser.Body = body.ToString();
                            SendMessageToUser.Subject = "Welcome to 1Point.";

                            SendMessageToUser.IsBodyHtml = true;
                            //To add SuperAdmin email as CC if appsettings contains more than one email seperated by comma
                            ConfigurationManager.AppSettings["SuperAdminEmail"].ToString().Split(',').ToList().ForEach(delegate(string mail) { SendMessageToUser.CC.Add(mail); });

                            SmtpClient SmtpMail = new SmtpClient();
                            SmtpMail.Send(SendMessageToUser);

                            lblMainMsg.ForeColor = System.Drawing.Color.Green;
                            lblMainMsg.Text = "User Account: " + txtCreateUserName.Text + "  created successfully";
                            txtCreateEmail.Text = "";
                            txtCreateUserName.Text = "";
                            fillGrid("sort");
                            UdpanelGrdUsers.Update();
                            CreateUserModalPopupExtender.Hide();
                            upCreateUser.Update();
                            break;
                        }
                        break;
                    case "DuplicateUserName":
                        lblPopupMsg.Text = "Duplicate User Name";
                        CreateUserModalPopupExtender.Show();
                        break;
                    case "DuplicateEmail":
                        lblPopupMsg.Text = "Duplicate Email";
                        CreateUserModalPopupExtender.Show();
                        break;
                    case "UserRejected":
                        lblPopupMsg.Text = "User Rejected";
                        CreateUserModalPopupExtender.Show();
                        break;

                    case "InvalidEmail":
                    case "InvalidUserName":
                        lblPopupMsg.Text = "Please enter valid user name or email";
                        CreateUserModalPopupExtender.Show();
                        break;
                    default:
                        lblMainMsg.Text = "Please try with other entries";
                        break;
                }
            }
            catch (Exception ex)
            {
                //throw ex;
            }
        }