Ejemplo n.º 1
0
        /// <summary>
        /// Created By : Satish Verma
        /// Created Date : 11-Dec-2014
        /// Purpose : To get user details
        /// </summary>
        /// <param name="objUserManagementBO"></param>
        /// <returns></returns>
        public DataTable GetUserDetails(UserManagementBO objUserManagementBO)
        {
            DataTable objDataTable = new DataTable();

            try
            {
                sqlConnection.Open();
                sqlCommand             = new SqlCommand();
                sqlCommand.Connection  = sqlConnection;
                sqlCommand.CommandText = "Sp_GetUserDetails";
                sqlCommand.CommandType = CommandType.StoredProcedure;
                sqlCommand.Parameters.AddWithValue("@PageNumber", objUserManagementBO.PageNumber);
                sqlCommand.Parameters.AddWithValue("@PageSize", objUserManagementBO.PageSize);
                sqlCommand.Parameters.AddWithValue("@Sort", objUserManagementBO.Sort);
                sqlCommand.Parameters.AddWithValue("@SearchText", objUserManagementBO.SearchText);
                sqlDataAdapter = new SqlDataAdapter(sqlCommand);
                sqlDataAdapter.Fill(objDataTable);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                sqlDataAdapter.Dispose();
                sqlCommand.Dispose();
                sqlConnection.Close();
                sqlConnection.Dispose();
            }
            return(objDataTable);
        }
Ejemplo n.º 2
0
        public void GenerateSubmissionView(int numSubs)
        {
            SubmissionManagementBO bo     = new SubmissionManagementBO();
            UserManagementBO       userBO = new UserManagementBO();
            List <SubmissionVO>    subList;
            string sortType = Request.QueryString["sort"];

            if (sortType == "top")
            {
                subList = bo.GetListOfSubmissionsTop(NUMBER_OF_SUBMISSIONS);
            }
            if (sortType == "popular")
            {
                subList = bo.GetListOfSubmissionsPopular(NUMBER_OF_SUBMISSIONS);
            }
            else
            {
                subList = bo.GetListOfSubmissionsNew(NUMBER_OF_SUBMISSIONS);
            }

            foreach (SubmissionVO sub in subList)
            {
                Submission submission = new Submission();
                submission.ID           = "submission" + sub.SubmissionID;
                submission.submissionID = sub.SubmissionID;

                subPanel.Controls.Add(submission);
            }
        }
Ejemplo n.º 3
0
        public void LoadUserDetails()
        {
            UserManagementBO bo = new UserManagementBO();
            UserVO           vo = null;

            if (Username != null)
            {
                vo     = bo.GetUser(Username);
                UserID = vo.UserID;
            }
            else if (UserID != 0)
            {
                vo       = bo.GetUser(UserID);
                Username = vo.Username;
            }

            usernameLabel.Text = "<h1>" + vo.Username + "</h1>";
            ratingLabel.Text   = vo.Rating + " collective positive rating";
            joinDateLabel.Text = "Joined on " + vo.RegisterDate.ToLongDateString();

            if (Session["login"] != null)
            {
                if (Session["login"].ToString() == Username)
                {
                    passwordChangePanel.Visible = true;
                }
            }

            //Load the content in the first time we visit
            if (!Page.IsPostBack)
            {
                GenerateRecentContent("submissions");
            }
        }
        public void Insert(UserManagementBO userBO)
        {
            string userQueryString = "";

            userQueryString = @"SBPSaveUserInfo";
            try
            {
                _dbConnection.ConnectDatabase();
                _dbConnection.ActiveStoredProcedure();
                _dbConnection.AddParameter("@userName", SqlDbType.NVarChar, userBO.UserName);
                _dbConnection.AddParameter("@roleName", SqlDbType.NVarChar, userBO.RoleName);
                _dbConnection.AddParameter("@password", SqlDbType.NVarChar, userBO.Password);
                _dbConnection.AddParameter("@name", SqlDbType.VarChar, userBO.Name);
                _dbConnection.AddParameter("@address", SqlDbType.VarChar, userBO.Address);
                _dbConnection.AddParameter("@contact", SqlDbType.VarChar, userBO.ContactNo);
                _dbConnection.AddParameter("@remark", SqlDbType.VarChar, userBO.Remarks);
                _dbConnection.AddParameter("@isActive", SqlDbType.Bit, userBO.IsActive);
                _dbConnection.AddParameter("@branchID", SqlDbType.Int, userBO.BranchId);
                _dbConnection.AddParameter("@entryBy", SqlDbType.VarChar, GlobalVariableBO._userName);
                _dbConnection.AddParameter("@employeeCode", SqlDbType.VarChar, userBO.EmployeeCode);
                _dbConnection.ExecuteNonQuery(userQueryString);
            }
            catch (Exception exception)
            {
                throw exception;
            }
            finally
            {
                _dbConnection.CloseDatabase();
            }
        }
Ejemplo n.º 5
0
        protected void SubmitVote(int vote)
        {
            UserManagementBO userBO = new UserManagementBO();
            UserVO           userVO;

            if (Session["login"] != null)
            {
                userVO = userBO.GetUser(Session["login"].ToString());
                if (userBO.CheckIfVoted(submissionID, userVO.UserID) == 0)
                {
                    userBO.SubmitVote(submissionID, userVO.UserID, vote);
                    int i = int.Parse(submissionRating.Text);
                    i += vote;
                    submissionRating.Text = i.ToString();
                    if (vote == 1)
                    {
                        upArrow.ImageUrl = "~/Images/uparrow_voted.png";
                    }
                    else if (vote == -1)
                    {
                        downArrow.ImageUrl = "~/Images/downarrow_voted.png";
                    }
                }
            }
        }
Ejemplo n.º 6
0
        public List <UserManagementBO> GetUserDetails(string pageNumber, string pageSize, string sort, string searchText)
        {
            try
            {
                if (string.IsNullOrEmpty(pageNumber))
                {
                    pageNumber = "0";
                }

                if (string.IsNullOrEmpty(pageSize))
                {
                    pageSize = "0";
                }

                UserManagementBO objUserManagementBO = new UserManagementBO();
                objUserManagementBO.PageNumber = Convert.ToInt32(pageNumber);
                objUserManagementBO.PageSize   = Convert.ToInt32(pageSize);
                objUserManagementBO.Sort       = sort;
                objUserManagementBO.SearchText = searchText;

                List <UserManagementBO> lstUserManagementBO = new UserManagementBL().GetUserDetails(objUserManagementBO);
                return(lstUserManagementBO);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 7
0
        protected void GenerateLoggedInText()
        {
            UserManagementBO userBO = new UserManagementBO();
            UserVO           userVO = userBO.GetUser(Session["login"].ToString());

            viewProfile.Text   = userVO.Username;
            loggedInLabel.Text = " [" + userVO.Rating.ToString() + "] | ";
        }
Ejemplo n.º 8
0
        protected void LoadCommentDetails()
        {
            CommentManagementBO bo     = new CommentManagementBO();
            UserManagementBO    userBO = new UserManagementBO();
            CommentVO           vo     = bo.GetComment(commentID);

            comVO = vo;

            //Give comment space for its depth
            for (int i = 0; i < commentDepth; i++)
            {
                spacingLabel.Text = spacingLabel.Text + "<td width=\"25px\"></td>";
            }

            commentRating = vo.Rating;
            string username = userBO.GetUser(vo.UserID).Username;

            userLink.Text = username;

            commentInfo.Text = " rated at " +
                               commentRating + " points, posted " +
                               bo.FormatePostTime(vo.PostDate);

            commentContents.Text = "<p>" + vo.CommentContents + "</p>";

            //Choose which controls to display
            if (Session["login"] == null)
            {
                editButton.Visible   = false;
                deleteButton.Visible = false;
                replyButton.Visible  = false;
            }
            else if (!username.Equals(Session["login"].ToString()))
            {
                editButton.Visible   = false;
                deleteButton.Visible = false;
            }

            //Change vote image based on whether or not it's been voted on
            if (Session["login"] != null)
            {
                int i = bo.CheckIfVoted(commentID, userBO.GetUser(Session["login"].ToString()).UserID);
                if (i == 1)
                {
                    upArrow.ImageUrl = "~/Images/uparrow_voted.png";
                }
                else if (i == -1)
                {
                    downArrow.ImageUrl = "~/Images/downarrow_voted.png";
                }
            }
        }
Ejemplo n.º 9
0
        protected void CreateUser_Submit(object sender, EventArgs e)
        {
            UserManagementBO userBO = new UserManagementBO();

            //Make sure username isn't already taken
            try {
                //For starters, make sure they've entered info in all the fields.
                if (createUserUsername.Text.Equals("") || createUserPassword.Text.Equals(""))
                {
                    throw new Exception(MISSING_INFO_EXCEPTION);
                }
                //Check if there are any illegal characters.
                if (createUserUsername.Text.IndexOfAny(ILLEGAL_CHAR_ARRAY) >= 0)
                {
                    throw new Exception(ILLEGAL_CHARACTER_EXCEPTION);
                }

                //Check if name taken
                try {
                    userBO.GetUser(createUserUsername.Text);
                    //If it's found in the db, it won't throw the exception, causing it
                    //to hit this exception
                    throw new Exception(USERNAME_ALREADY_TAKEN_EXCEPTION);
                }
                catch (Exception exce) {
                    //If the exception we caught was the username taken, throw it again
                    if (exce.Message.Equals(USERNAME_ALREADY_TAKEN_EXCEPTION))
                    {
                        throw new Exception(USERNAME_ALREADY_TAKEN_EXCEPTION);
                    }
                }

                //Make sure the passwords are the same
                if (createUserPassword.Text != createUserPassword2.Text)
                {
                    throw new Exception(PASSWORD_MISMATCH_EXCEPTION);
                }

                //And if their info passed all of that, we make their account
                userBO.CreateNewUser(createUserUsername.Text, createUserPassword.Text);
                Session["login"] = createUserUsername.Text;
                Response.Redirect(WebConstants.HOME_PAGE);
            }
            catch (Exception exc) {
                errorMessage.Text = exc.Message;
            }
        }
Ejemplo n.º 10
0
        protected void GenerateSubmissionDetails()
        {
            CommentManagementBO    comBO  = new CommentManagementBO();
            SubmissionManagementBO bo     = new SubmissionManagementBO();
            SubmissionVO           sub    = bo.GetSubmission(submissionID);
            UserManagementBO       userBO = new UserManagementBO();
            UserVO vo = userBO.GetUser(sub.UserID);

            submissionRating.Text      = sub.Rating.ToString();
            submissionCommentLink.Text = (comBO.GetListOfSubmissionComments(submissionID).Count + " comments");

            Uri url;

            try {
                url = new Uri(sub.Link);
            }
            catch (Exception e) {
                try {
                    url = new Uri("http://" + sub.Link);
                }
                catch (Exception exc) {
                    url = new Uri("http://CouldntParseUrl");
                }
            }

            submissionTitle.Text = "<a href=\"" + url + "\">" + sub.Title + "</a> (" + url.Host.ToString() + ")";

            submissionDetails.Text = bo.FormatePostTime(sub.PostTime);

            userLink.Text = vo.Username;

            //Change arrow based on voting
            if (Session["login"] != null)
            {
                int i = userBO.CheckIfVoted(submissionID, userBO.GetUser(Session["login"].ToString()).UserID);
                if (i == 1)
                {
                    upArrow.ImageUrl = "~/Images/uparrow_voted.png";
                }
                else if (i == -1)
                {
                    downArrow.ImageUrl = "~/Images/downarrow_voted.png";
                }
            }
        }
Ejemplo n.º 11
0
        protected void SubmitVote(int vote)
        {
            CommentManagementBO comBO  = new CommentManagementBO();
            UserManagementBO    userBO = new UserManagementBO();
            CommentVO           comVO  = comBO.GetComment(commentID);
            UserVO userVO;

            if (Session["login"] != null)
            {
                userVO = userBO.GetUser(Session["login"].ToString());
                if (comBO.CheckIfVoted(commentID, userVO.UserID) == 0)
                {
                    comBO.SubmitVote(commentID, userVO.UserID, vote);
                    commentRating += vote;
                    Response.Redirect(Request.Url.ToString());
                }
            }
        }
Ejemplo n.º 12
0
        protected void Login_Submit(object sender, EventArgs e)
        {
            UserManagementBO umbo = new UserManagementBO();

            try {
                if (umbo.CheckIfValidLogin(loginUsername.Text, loginPassword.Text))
                {
                    Session["login"] = loginUsername.Text;
                    System.Diagnostics.Trace.WriteLine(Session["login"]);
                    Session.Timeout = 1000;
                    Response.Redirect(Request.Url.ToString());
                }
            }
            catch (Exception exc) {
                loginErrorMessage.Visible = true;

                loginErrorMessage.Text = exc.Message;
            }
        }
Ejemplo n.º 13
0
        protected void SubmitReply_Click(object sender, EventArgs e)
        {
            CommentManagementBO bo     = new CommentManagementBO();
            UserManagementBO    userBO = new UserManagementBO();

            try {
                if (replyTextBox.Text == "")
                {
                    throw new Exception("You must enter text to reply");
                }

                bo.CreateNewComment(userBO.GetUser(Session["login"].ToString()).Username, replyTextBox.Text,
                                    Convert.ToInt32(Request.QueryString["subid"]), Convert.ToInt32(parentCommentID.Text));

                Response.Redirect(Request.Url.ToString());
            }
            catch (Exception exc) {
                errorLabel.Text = exc.Message;
            }
        }
Ejemplo n.º 14
0
        protected void PasswordChange_Click(object sender, EventArgs e)
        {
            UserManagementBO bo = new UserManagementBO();
            UserVO           vo = bo.GetUser(UserID);

            //Look for invalid inputs
            try {
                if (newPassword.Text != newPasswordConfirm.Text)
                {
                    throw new Exception("Both new password fields must match");
                }

                if (!bo.CheckIfValidLogin(Username, oldPassword.Text))
                {
                    throw new Exception("Invalid entry for current password");
                }

                bo.ChangePassword(UserID, newPassword.Text);
                errorLabel.Text = "Password succesfully changed";
            }
            catch (Exception exc) {
                errorLabel.Text = exc.Message;
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Created By : Satish Verma
        /// Created Date : 11-Dec-2014
        /// Purpose : To get user details
        /// </summary>
        /// <param name="objUserManagementBO"></param>
        /// <returns></returns>
        public List <UserManagementBO> GetUserDetails(UserManagementBO objUserManagementBO)
        {
            DataTable objDataTable = new UserManagementDA().GetUserDetails(objUserManagementBO);
            List <UserManagementBO> lstUserManagementBO = new List <UserManagementBO>();

            foreach (DataRow Row in objDataTable.Rows)
            {
                UserManagementBO obUserManagementBO = new UserManagementBO();
                obUserManagementBO.UserDetailId = Convert.ToInt32(Row["UserDetailId"]);

                if (string.IsNullOrEmpty(Convert.ToString(Row["FirstName"])))
                {
                    obUserManagementBO.FirstName = string.Empty;
                }
                else
                {
                    obUserManagementBO.FirstName = Convert.ToString(Row["FirstName"]);
                }

                if (string.IsNullOrEmpty(Convert.ToString(Row["LastName"])))
                {
                    obUserManagementBO.LastName = string.Empty;
                }
                else
                {
                    obUserManagementBO.LastName = Convert.ToString(Row["LastName"]);
                }

                if (string.IsNullOrEmpty(Convert.ToString(Row["CountryId"])))
                {
                    obUserManagementBO.CountryId = null;
                }
                else
                {
                    obUserManagementBO.CountryId = Convert.ToInt32(Row["CountryId"]);
                }

                if (string.IsNullOrEmpty(Convert.ToString(Row["Phone"])))
                {
                    obUserManagementBO.Phone = null;
                }
                else
                {
                    obUserManagementBO.Phone = Convert.ToInt64(Row["Phone"]);
                }

                if (string.IsNullOrEmpty(Convert.ToString(Row["Email"])))
                {
                    obUserManagementBO.Email = string.Empty;
                }
                else
                {
                    obUserManagementBO.Email = Convert.ToString(Row["Email"]);
                }

                obUserManagementBO.DOB = Convert.ToDateTime(Row["DOB"]).ToString("dd-MMM-yyyy");

                if (string.IsNullOrEmpty(Convert.ToString(Row["Balance"])))
                {
                    obUserManagementBO.Balance = string.Empty;
                }
                else
                {
                    obUserManagementBO.Balance = Convert.ToString(Row["Balance"]);
                }


                obUserManagementBO.IsActive    = Convert.ToBoolean(Row["IsActive"]);
                obUserManagementBO.UserLoginId = (Guid)Row["UserLoginId"];
                obUserManagementBO.UserName    = Convert.ToString(Row["UserName"]);
                obUserManagementBO.Email       = Convert.ToString(Row["Email"]);
                obUserManagementBO.RoleId      = Convert.ToInt32(Row["RoleId"]);
                obUserManagementBO.Total       = Convert.ToInt32(Row["Total"]);
                lstUserManagementBO.Add(obUserManagementBO);
            }
            return(lstUserManagementBO);
        }