protected void Page_Load(object sender, EventArgs e)
 {
     clsCookies.CookieCheckSession();
     var user = new clsUser();
     clsCookies.CookieGetSession(user);
     lbAdminName.Text = user.UserName;
 }
Пример #2
0
 public static void CookieCreateSession(clsUser AdminUser)
 {
     string strValue = HttpContext.Current.Session.SessionID.ToString() + "#" + AdminUser.UserId.ToString() +
                       "#" + AdminUser.TypeId.ToString() + "#" + AdminUser.UserName.ToString();
     HttpCookie LoginCookies = new HttpCookie("LoginCookies");
     LoginCookies.Value = strValue;
     LoginCookies.Expires = DateTime.Now.AddHours(2);
     HttpContext.Current.Response.Cookies.Add(LoginCookies);
 }
        protected void lkbSubmit_OnClick(object sender, EventArgs e)
        {
            try
            {
                var objUser = new clsUser();
                if (!string.IsNullOrEmpty(Convert.ToString(Request.QueryString["Id"])))
                    objUser.UserId = TypeConversionUtility.ToInteger(Request.QueryString["Id"]);
                else
                    objUser.UserId = 0;
                objUser.UserName = TypeConversionUtility.ToStringWithNull(txtName.Text.Trim());
                objUser.EmailId = TypeConversionUtility.ToStringWithNull(txtEmailId.Text.Trim());
                objUser.LoginId = TypeConversionUtility.ToStringWithNull(txtLoginId.Text.Trim());
                objUser.LoginPwd = TypeConversionUtility.ToStringWithNull(txtPwd.Text.Trim());
                objUser.Status = TypeConversionUtility.ToInteger(ddlStatus.SelectedValue);
                objUser.TypeId = Convert.ToInt32(ddUserLevel.SelectedValue);

                if (UserRepository.CheckUserExits(objUser.UserId, objUser.LoginId))
                {
                    lblMsg.Text = "Login Id already exist. Try using different login id.";
                    pnlMsg.Visible = true;
                }
                else if (UserRepository.UserAddUpdate(objUser)) // Add/Update Login Details
                {
                    if (objUser.UserId == 0)
                    {
                        pnlMsg.Visible = true;
                        lblMsg.Text = "Record has been successfully inserted.";
                        lblMsg.CssClass = "success";
                        txtName.Text = "";
                        txtEmailId.Text = "";
                        txtPwd.Text = "";
                        txtLoginId.Text = "";
                        ddlStatus.SelectedValue = "0";
                    }
                    else
                        Response.Redirect("userList.aspx?msg=Record has been successfully updated.");
                }
            }
            catch (Exception ex)
            {
                lblMsg.Text = string.Format("<p class=\"error\">{0}</p>", ex);
                pnlMsg.Visible = true;
            }
        }
Пример #4
0
        public static void CookieGetSession(clsUser AdminUser)
        {
            if (HttpContext.Current.Request.Cookies["LoginCookies"] != null)
            {
                string strValue = HttpContext.Current.Request.Cookies["LoginCookies"].Value;
                string[] sValue = strValue.Split('#');
                if (sValue.Length > 3)
                {
                    AdminUser.UserId = Convert.ToInt32(sValue[1]);
                    AdminUser.TypeId = Convert.ToInt32(sValue[2]);
                    AdminUser.UserName = sValue[3].ToString();

                }
                else
                    HttpContext.Current.Response.Redirect("logout.aspx");
            }
            else
                HttpContext.Current.Response.Redirect("logout.aspx");
        }
Пример #5
0
        /// <summary>
        /// Add/Update User Details
        /// </summary>
        /// <param name="objUser"></param>
        /// <returns></returns>
        public bool UserAddUpdate(clsUser objUser)
        {
            bool flag = false;
            SqlParameter[] sqlParameters =
            {
                new SqlParameter("@QueryType", 4),
                new SqlParameter("@UserId", objUser.UserId),
                new SqlParameter("@UserName", objUser.UserName),
                new SqlParameter("@EmailId", objUser.EmailId),
                new SqlParameter("@LoginId", objUser.LoginId),
                new SqlParameter("@LoginPwd", objUser.LoginPwd),
                new SqlParameter("@Status", objUser.Status),
                new SqlParameter("@TypeId", objUser.TypeId)
            };

            int iRow = objSql.ExecuteSP_NonQuery(spName, sqlParameters);
            if (iRow > 0)
                flag = true;

            return flag;
        }
Пример #6
0
 /// <summary>
 /// Get and Set Login Validate
 /// </summary>
 /// <returns></returns>
 public clsUser UserLoginValidate(string loginId, string loginPwd)
 {
     var objuser = new clsUser();
     SqlParameter[] sqlParameters =
     {
         new SqlParameter("@LoginId", loginId),
         new SqlParameter("@LoginPwd", loginPwd),
         new SqlParameter("@QueryType", 1)
     };
     using (SqlDataReader dr = objSql.SP_GetDataReader(spName, sqlParameters))
     {
         if (dr.HasRows)
         {
             if (dr.Read())
             {
                 objuser.UserId = Convert.ToInt32(dr["UserId"]);
                 objuser.UserName = Convert.ToString(dr["UserName"]);
                 objuser.EmailId = Convert.ToString(dr["EmailId"]);
                 objuser.LoginId = Convert.ToString(dr["LoginId"]);
                 objuser.Status = Convert.ToInt32(dr["Status"]);
                 objuser.TypeId = Convert.ToInt32(dr["TypeId"]);
             }
         }
         dr.Close();
     }
     objSql.CloseConnection();
     objSql.DisposeConnection();
     return objuser;
 }
Пример #7
0
 /// <summary>
 /// Get User List With Paged
 /// </summary>
 /// <returns></returns>
 public List<clsUser> UserListPaged(bool? status, int startPage, int pageLength, out int noOfPages,
     out int totalRecords)
 {
     var lstUser = new List<clsUser>();
     SqlParameter[] sqlParameters =
     {
         new SqlParameter("@Status", status),
         new SqlParameter("@StartPage", startPage),
         new SqlParameter("@PageLength", pageLength),
         new SqlParameter("@noOfPages", noOfPages = 0) {Direction = ParameterDirection.Output},
         new SqlParameter("@TotalRecords", totalRecords = 0) {Direction = ParameterDirection.Output},
     };
     using (SqlDataReader dr = objSql.SP_GetDataReader("usp_GetUsersPaged", sqlParameters))
     {
         if (dr.HasRows)
         {
             while (dr.Read())
             {
                 var objUser = new clsUser();
                 objUser.UserId = Convert.ToInt32(dr["UserId"]);
                 objUser.UserName = Convert.ToString(dr["UserName"]);
                 objUser.EmailId = Convert.ToString(dr["EmailId"]);
                 objUser.LoginId = Convert.ToString(dr["LoginId"]);
                 objUser.LoginPwd = Convert.ToString(dr["LoginPwd"]);
                 objUser.Status = Convert.ToInt32(dr["Status"]);
                 objUser.CreatedDate = Convert.ToDateTime(dr["CreatedDate"]);
                 objUser.TypeId = Convert.ToInt32(dr["TypeId"]);
                 lstUser.Add(objUser);
             }
         }
         dr.Close();
     }
     objSql.CloseConnection();
     objSql.DisposeConnection();
     noOfPages = Convert.ToInt32(sqlParameters[3].Value);
     totalRecords = Convert.ToInt32(sqlParameters[4].Value);
     return lstUser;
 }
Пример #8
0
        /// <summary>
        /// Get User List 
        /// </summary>
        /// <returns></returns>
        public List<clsUser> UserList()
        {
            var lstUser = new List<clsUser>();
            SqlParameter[] sqlParameters =
            {
                new SqlParameter("@QueryType", 6)
            };
            using (SqlDataReader dr = objSql.SP_GetDataReader(spName, sqlParameters))
            {
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        var objUser = new clsUser();
                        objUser.UserId = Convert.ToInt32(dr["UserId"]);
                        objUser.UserName = Convert.ToString(dr["UserName"]);
                        objUser.EmailId = Convert.ToString(dr["EmailId"]);
                        objUser.LoginId = Convert.ToString(dr["LoginId"]);
                        objUser.LoginPwd = Convert.ToString(dr["LoginPwd"]);
                        objUser.Status = Convert.ToInt32(dr["Status"]);
                        objUser.CreatedDate = Convert.ToDateTime(dr["CreatedDate"]);
                        objUser.TypeId = Convert.ToInt32(dr["TypeId"]);
                        lstUser.Add(objUser);
                    }
                }
                dr.Close();
            }
            objSql.CloseConnection();
            objSql.DisposeConnection();

            return lstUser;
        }
Пример #9
0
        /// <summary>
        /// Get User Details By User Id
        /// </summary>
        /// <param name="UserId"></param>
        /// <returns></returns>
        public clsUser UserDetails(int userId)
        {
            var objUser = new clsUser();
            SqlParameter[] selectParam =
            {
                new SqlParameter("@UserId", userId),
                new SqlParameter("@QueryType", 3)
            };

            using (SqlDataReader dr = objSql.SP_GetDataReader(spName, selectParam))
            {
                if (dr.HasRows)
                {
                    if (dr.Read())
                    {
                        objUser.UserId = Convert.ToInt32(dr["UserId"]);
                        objUser.UserName = Convert.ToString(dr["UserName"]);
                        objUser.EmailId = Convert.ToString(dr["EmailId"]);
                        objUser.LoginId = Convert.ToString(dr["LoginId"]);
                        objUser.LoginPwd = Convert.ToString(dr["LoginPwd"]);
                        objUser.Status = Convert.ToInt32(dr["Status"]);
                        objUser.CreatedDate = Convert.ToDateTime(dr["CreatedDate"]);
                        objUser.TypeId = Convert.ToInt32(dr["TypeId"]);
                    }
                }
                dr.Close();
            }

            objSql.CloseConnection();
            objSql.DisposeConnection();
            return objUser;
        }
 public static bool UserAddUpdate(clsUser userInfo)
 {
     var objUser = new sqlUser();
     return objUser.UserAddUpdate(userInfo);
 }