예제 #1
0
        /// <summary>
        /// This method will return an object representing the record matching the primary key information specified.
        /// </summary>
        ///
        /// <param name="pk" type="UserPermissionPrimaryKey">Primary Key information based on which data is to be fetched.</param>
        ///
        /// <returns>object of class UserPermission</returns>
        ///
        /// <remarks>
        ///
        /// <RevisionHistory>
        /// Author				Date			Description
        /// DLGenerator			7/5/2012 11:05:31 AM		Created function
        /// 
        /// </RevisionHistory>
        ///
        /// </remarks>
        ///
        public static UserPermission SelectOne(UserPermissionPrimaryKey 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_UserPermissions_SelectbyPrimaryKey", ref ExecutionState);
            if (dr.Read())
            {
                UserPermission obj = new UserPermission(ConnectionString);
                PopulateObjectFromReader(obj,dr);
                dr.Close();
                oDatabaseHelper.Dispose();
                return obj;
            }
            else
            {
                dr.Close();
                oDatabaseHelper.Dispose();
                return null;
            }
        }
예제 #2
0
        /// <summary>
        /// This method will Delete one row from the database using the primary key information
        /// </summary>
        ///
        /// <param name="pk" type="UserPermissionPrimaryKey">Primary Key information based on which data is to be fetched.</param>
        ///
        /// <returns>True if succeeded</returns>
        ///
        /// <remarks>
        ///
        /// <RevisionHistory>
        /// Author				Date			Description
        /// DLGenerator			7/5/2012 11:05:31 AM		Created function
        /// 
        /// </RevisionHistory>
        ///
        /// </remarks>
        ///
        public static bool Delete(UserPermissionPrimaryKey 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_UserPermissions_Delete", ref ExecutionState);
            oDatabaseHelper.Dispose();
            return ExecutionState;
        }
예제 #3
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;
            }
        }
        /// <summary>
        /// To display all modules in Treeview based on ClientID
        /// </summary>
        /// <param name="UserName"></param>
        public void poplateTreeViewBasedOnClient(string UserName)
        {
            objMembershipUser = Membership.GetUser(UserName);
            UserPermissionPrimaryKey objUserPerPrimaryKey = new UserPermissionPrimaryKey(objMembershipUser.ProviderUserKey.ToString());
            objPopulateUserPer = UserPermission.SelectOne(objUserPerPrimaryKey, ConnectionString);
            if (objPopulateUserPer != null)
            {
                RTAccountSettings.Nodes[0].Visible = (bool)objPopulateUserPer.IsMList;
                //List SubTabs
                RTAccountSettings.Nodes[0].Nodes[0].Visible = (bool)objPopulateUserPer.IsList;
                RTAccountSettings.Nodes[0].Nodes[1].Visible = (bool)objPopulateUserPer.IsContact;
                RTAccountSettings.Nodes[0].Nodes[2].Visible = (bool)objPopulateUserPer.IsImport;
                RTAccountSettings.Nodes[0].Nodes[3].Visible = (bool)objPopulateUserPer.IsSegments;
                RTAccountSettings.Nodes[0].Nodes[4].Visible = (bool)objPopulateUserPer.IsDownloadContacts;

                RTAccountSettings.Nodes[1].Visible = (bool)objPopulateUserPer.IsMCampaigns;
                //Campaign SubTabs
                RTAccountSettings.Nodes[1].Nodes[0].Visible = (bool)objPopulateUserPer.IsMailing;
                RTAccountSettings.Nodes[1].Nodes[1].Visible = (bool)objPopulateUserPer.IsCampaigns;
                RTAccountSettings.Nodes[1].Nodes[2].Visible = (bool)objPopulateUserPer.IsTemplates;
                RTAccountSettings.Nodes[1].Nodes[3].Visible = (bool)objPopulateUserPer.IsAgedCampaigns;

                RTAccountSettings.Nodes[2].Visible = (bool)objPopulateUserPer.IsMAdvanced;
                //Advanced SubTabs
                RTAccountSettings.Nodes[2].Nodes[0].Visible = (bool)objPopulateUserPer.IsMangeFields;
                RTAccountSettings.Nodes[2].Nodes[1].Visible = (bool)objPopulateUserPer.IsMergeLists;
                RTAccountSettings.Nodes[2].Nodes[2].Visible = (bool)objPopulateUserPer.IsSuppressAddress;
                RTAccountSettings.Nodes[2].Nodes[3].Visible = (bool)objPopulateUserPer.IsBounceSettings;

                RTAccountSettings.Nodes[3].Visible = (bool)objPopulateUserPer.IsMActivity;
                //Activity SubTabs
                RTAccountSettings.Nodes[3].Nodes[0].Visible = (bool)objPopulateUserPer.IsAccountActivity;
                RTAccountSettings.Nodes[3].Nodes[1].Visible = (bool)objPopulateUserPer.IsCompareCampaign;
                RTAccountSettings.Nodes[3].Nodes[2].Visible = (bool)objPopulateUserPer.IsBounceReport;

                RTAccountSettings.Nodes[4].Visible = (bool)objPopulateUserPer.IsMCampReports;
                //CampaignReports SubTabs
                RTAccountSettings.Nodes[4].Nodes[0].Visible = (bool)objPopulateUserPer.IsDashboard;
                RTAccountSettings.Nodes[4].Nodes[1].Visible = (bool)objPopulateUserPer.IsContactActivity;
                RTAccountSettings.Nodes[4].Nodes[2].Visible = (bool)objPopulateUserPer.IsClickPerformance;
                RTAccountSettings.Nodes[4].Nodes[3].Visible = (bool)objPopulateUserPer.IsAdvancedReports;

                RTAccountSettings.Nodes[5].Visible = (bool)objPopulateUserPer.IsMicrositeManager;
                RTAccountSettings.Nodes[6].Visible = (bool)objPopulateUserPer.IsCustomizedAMMForms;
                RTAccountSettings.Nodes[7].Visible = (bool)objPopulateUserPer.IsAMMAdvanceReprot;
            }
        }
        /// <summary>
        /// To display all modules in Treeview
        /// </summary>
        /// <param name="UserName"></param>
        public void poplateTreeView(string UserName)
        {
            objMembershipUser = Membership.GetUser(UserName);
            UserPermissionPrimaryKey objUserPerPrimaryKey = new UserPermissionPrimaryKey(objMembershipUser.ProviderUserKey.ToString());
            objPopulateUserPer = UserPermission.SelectOne(objUserPerPrimaryKey, ConnectionString);
            if (objPopulateUserPer != null)
            {
                RTAccountSettings.Nodes[0].Checked = (bool)objPopulateUserPer.IsMList;
                //List SubTabs
                RTAccountSettings.Nodes[0].Nodes[0].Checked = (bool)objPopulateUserPer.IsList;
                RTAccountSettings.Nodes[0].Nodes[1].Checked = (bool)objPopulateUserPer.IsContact;
                RTAccountSettings.Nodes[0].Nodes[2].Checked = (bool)objPopulateUserPer.IsImport;
                RTAccountSettings.Nodes[0].Nodes[3].Checked = (bool)objPopulateUserPer.IsSegments;
                RTAccountSettings.Nodes[0].Nodes[4].Checked = (bool)objPopulateUserPer.IsDownloadContacts;

                RTAccountSettings.Nodes[1].Checked = (bool)objPopulateUserPer.IsMCampaigns;
                //Campaign SubTabs
                RTAccountSettings.Nodes[1].Nodes[0].Checked = (bool)objPopulateUserPer.IsMailing;
                RTAccountSettings.Nodes[1].Nodes[1].Checked = (bool)objPopulateUserPer.IsCampaigns;
                RTAccountSettings.Nodes[1].Nodes[2].Checked = (bool)objPopulateUserPer.IsTemplates;
                RTAccountSettings.Nodes[1].Nodes[3].Checked = (bool)objPopulateUserPer.IsAgedCampaigns;

                RTAccountSettings.Nodes[2].Checked = (bool)objPopulateUserPer.IsMAdvanced;
                //Advanced SubTabs
                RTAccountSettings.Nodes[2].Nodes[0].Checked = (bool)objPopulateUserPer.IsMangeFields;
                RTAccountSettings.Nodes[2].Nodes[1].Checked = (bool)objPopulateUserPer.IsMergeLists;
                RTAccountSettings.Nodes[2].Nodes[2].Checked = (bool)objPopulateUserPer.IsSuppressAddress;
                RTAccountSettings.Nodes[2].Nodes[3].Checked = (bool)objPopulateUserPer.IsBounceSettings;

                RTAccountSettings.Nodes[3].Checked = (bool)objPopulateUserPer.IsMActivity;
                //Activity SubTabs
                RTAccountSettings.Nodes[3].Nodes[0].Checked = (bool)objPopulateUserPer.IsAccountActivity;
                RTAccountSettings.Nodes[3].Nodes[1].Checked = (bool)objPopulateUserPer.IsCompareCampaign;
                RTAccountSettings.Nodes[3].Nodes[2].Checked = (bool)objPopulateUserPer.IsBounceReport;

                RTAccountSettings.Nodes[4].Checked = (bool)objPopulateUserPer.IsMCampReports;
                //CampaignReports SubTabs
                RTAccountSettings.Nodes[4].Nodes[0].Checked = (bool)objPopulateUserPer.IsDashboard;
                RTAccountSettings.Nodes[4].Nodes[1].Checked = (bool)objPopulateUserPer.IsContactActivity;
                RTAccountSettings.Nodes[4].Nodes[2].Checked = (bool)objPopulateUserPer.IsClickPerformance;
                RTAccountSettings.Nodes[4].Nodes[3].Checked = (bool)objPopulateUserPer.IsAdvancedReports;

                RTAccountSettings.Nodes[5].Checked = (bool)objPopulateUserPer.IsMicrositeManager;
                RTAccountSettings.Nodes[6].Checked = (bool)objPopulateUserPer.IsCustomizedAMMForms;
                RTAccountSettings.Nodes[7].Checked = (bool)objPopulateUserPer.IsAMMAdvanceReprot;
                if (objPopulateUserPer.ChildLogo != null)
                {
                    ViewState["Logo"] = objPopulateUserPer.ChildLogo;
                    imgLogo.ImageUrl = "ShowLogo.ashx?LogoType=Child&UserName="******"~/Images/NOIMAGE.jpg";
            }
            else
            {
                RTAccountSettings.Nodes[0].Checked = false;
                RTAccountSettings.Nodes[0].Nodes[0].Checked = false;
                RTAccountSettings.Nodes[0].Nodes[1].Checked = false;
                RTAccountSettings.Nodes[0].Nodes[2].Checked = false;
                RTAccountSettings.Nodes[0].Nodes[3].Checked = false;
                RTAccountSettings.Nodes[0].Nodes[4].Checked = false;

                RTAccountSettings.Nodes[1].Checked = false;
                RTAccountSettings.Nodes[1].Nodes[0].Checked = false;
                RTAccountSettings.Nodes[1].Nodes[1].Checked = false;
                RTAccountSettings.Nodes[1].Nodes[2].Checked = false;

                RTAccountSettings.Nodes[2].Checked = false;
                RTAccountSettings.Nodes[2].Nodes[0].Checked = false;
                RTAccountSettings.Nodes[2].Nodes[1].Checked = false;
                RTAccountSettings.Nodes[2].Nodes[2].Checked = false;
                RTAccountSettings.Nodes[2].Nodes[3].Checked = false;

                RTAccountSettings.Nodes[3].Checked = false;
                RTAccountSettings.Nodes[3].Nodes[0].Checked = false;
                RTAccountSettings.Nodes[3].Nodes[1].Checked = false;
                RTAccountSettings.Nodes[3].Nodes[2].Checked = false;

                RTAccountSettings.Nodes[4].Checked = false;
                RTAccountSettings.Nodes[4].Nodes[0].Checked = false;
                RTAccountSettings.Nodes[4].Nodes[1].Checked = false;
                RTAccountSettings.Nodes[4].Nodes[2].Checked = false;
                RTAccountSettings.Nodes[4].Nodes[3].Checked = false;

                RTAccountSettings.Nodes[5].Checked = false;
                RTAccountSettings.Nodes[6].Checked = false;
                RTAccountSettings.Nodes[7].Checked = false;
                imgLogo.ImageUrl = "~/Images/NOIMAGE.jpg";
            }
        }
예제 #6
0
        //this event is used to remove the client
        protected void lbtnYes_Click(object sender, EventArgs e)
        {
            try
            {
                for (int i = 0; i < gviewClients.Rows.Count; i++)
                {
                    CheckBox grdaddchkSelectUser = (CheckBox)gviewClients.Rows[i].FindControl("grdaddchkSelectUser");
                    if (grdaddchkSelectUser != null && grdaddchkSelectUser.Checked == true)
                    {
                        LinkButton lblUsername = (LinkButton)gviewClients.Rows[i].FindControl("lblUsername");
                        Clientnames.Append(lblUsername.Text + ", ");
                    }
                }
                Clientnames.Remove(Clientnames.Length - 2, 1);
                string[] uNames = Clientnames.ToString().Split(',');
                foreach (string User in uNames)
                {
                    #region Bellow code used to Before Delete the user we are take the backup for that Db and drop that DataBase Also
                    SqlCommand comBak, comDel = null;
                    SqlConnection conn = null;
                    string path = ConfigurationManager.AppSettings["RPbackupFile"].ToString();
                    objProfileBase = ProfileBase.Create(User, true);
                    string dbName = objProfileBase.GetPropertyValue("DBName").ToString();
                    string dbServerName = objProfileBase.GetPropertyValue("DBServerName").ToString();
                    string dbUserName = objProfileBase.GetPropertyValue("DBUserID").ToString();
                    string dbPwd = objProfileBase.GetPropertyValue("DBPassword").ToString();
                    string conString = "Data Source= " + dbServerName.ToString() + ";Initial Catalog= master;User ID=" + dbUserName.ToString() + ";Password="******"_" + DateTime.Now.Day + DateTime.Now.ToString("MMM") + DateTime.Now.ToString("yyyy") + ".bak";
                    string strBakCommandText, strDelCommandText;
                    strBakCommandText = "BACKUP DATABASE " + dbName;
                    strBakCommandText += @" TO DISK=N'" + path + "'";

                    comBak = new SqlCommand(strBakCommandText, conn);
                    comBak.CommandType = System.Data.CommandType.Text;
                    int resBak = comBak.ExecuteNonQuery();

                    strDelCommandText = "ALTER DATABASE " + dbName + " SET  SINGLE_USER WITH ROLLBACK IMMEDIATE DROP DATABASE " + dbName;
                    comDel = new SqlCommand(strDelCommandText, conn);
                    comDel.CommandType = System.Data.CommandType.Text;
                    int resDel = comDel.ExecuteNonQuery();
                    conn.Close();
                    #endregion

                    //Delete that particular user in UserPermissions Table also

                    objMembershipUser = Membership.GetUser(User.ToString());
                    UserPermissionPrimaryKey objUserPermissionPrimaryKey = new UserPermissionPrimaryKey(objMembershipUser.ProviderUserKey.ToString());
                    UserPermission objUserPermission = UserPermission.SelectOne(objUserPermissionPrimaryKey, ConnectionString);
                    objUserPermission.Delete();

                    //Delete User in Membership
                    bool isSuccess = Membership.DeleteUser(User, true);
                    ProfileManager.DeleteProfile(User);
                    if (isSuccess == true)
                        delClients.Append(User + ", ");
                    else
                        unDelClients.Append(User + ", ");
                }
                if (delClients.Length != 0)
                    delClients.Remove(delClients.Length - 2, 1);
                if (unDelClients.Length != 0)
                    unDelClients.Remove(unDelClients.Length - 2, 1);
                DeleteModalPopup.Hide();
                FillGrid(string.Empty);
                if (delClients.Length != 0)
                {
                    lblMsg.Style.Add("color", "Green");
                    lblMsg.Text = string.Format("Clients: " + delClients + " deleted successfully");
                    Session["SelectedContacts"] = null;
                    upClientData.Update();
                }
                else
                {
                    lblMsg.Style.Add("color", "Red");
                    lblMsg.Text = "Unable to delete the Clients";
                    upClientData.Update();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }