public bool IsAdminLogin() { if (HttpContext.Current.Session[Keys.SESSION_ADMIN_INFO] != null) { admin = HttpContext.Current.Session[Keys.SESSION_ADMIN_INFO] as AdminInfo; return true; } return false; }
public static string Add(string user_name, string password, string e_mail) { AdminInfo admin = new AdminInfo(); admin.User_Name = user_name; admin.Password = password; admin.E_Mail = e_mail; bool successs = AdminBLL.Add(admin); StringBuilder json = new StringBuilder(); json.Append("[{"); json.Append("\"success\":\"" + successs + "\""); json.Append("}]"); return json.ToString(); }
/// <summary> /// 添加一条信息 /// </summary> /// <param name="admin"></param> /// <returns></returns> public bool Add(AdminInfo admin) { StringBuilder sql = new StringBuilder(); sql.Append("insert into BigDog_Admin (User_Name,Password,E_Mail)"); sql.Append(" values(@User_Name,@Password,@E_Mail)"); SqlParameter[] parms = new SqlParameter[] { new SqlParameter("@User_Name",SqlDbType.NVarChar,50), new SqlParameter("@Password",SqlDbType.NVarChar,50), new SqlParameter("@E_Mail",SqlDbType.NVarChar,50) }; parms[0].Value = admin.User_Name; parms[1].Value = admin.Password; parms[2].Value = admin.E_Mail; return SQLHelper.ExecuteNonQuery(CommandType.Text, sql.ToString(), parms) > 0; }
/// <summary> /// 判断管理员是否登录,针对session超时 /// </summary> /// <returns></returns> public bool IsAdminLogin() { //session是否为null if (Session[Keys.SESSION_ADMIN_INFO] != null) { return true; } else { //检查cookie string admin_name = Utils.GetCookie("Admin_Name", "BDAdmin"); string admin_pwd = Utils.GetCookie("Admin_Pwd", "BDAdmin"); if (admin_name != "" && admin_pwd != "") { admin = AdminBLL.GetModel(admin_name, admin_pwd); if (admin != null) { HttpContext.Current.Session[Keys.SESSION_ADMIN_INFO] = admin; return true; } } } return false; }
/// <summary> /// 更新记录 /// </summary> /// <param name="admin"></param> /// <returns></returns> public bool Update(AdminInfo admin) { StringBuilder sql = new StringBuilder(); sql.Append("update BigDog_Admin set User_Name=@User_Name,"); sql.Append("Real_Name=@Real_Name,Password=@Password,User_Photo_Url=@User_Photo_Url,"); sql.Append("E_Mail=@E_Mail,Is_Lock=@Is_Lock,Update_Date=@Update_Date,Updated_By=@Updated_By where Id=@Id"); SqlParameter[] parms = new SqlParameter[] { new SqlParameter("@User_Name",SqlDbType.NVarChar,50), new SqlParameter("@Real_Name",SqlDbType.NVarChar,50), new SqlParameter("@Password",SqlDbType.NVarChar,50), new SqlParameter("@User_Photo_Url",SqlDbType.NVarChar,50), new SqlParameter("@E_Mail",SqlDbType.NVarChar,50), new SqlParameter("@Is_Lock",SqlDbType.NVarChar,1), new SqlParameter("@Update_Date",SqlDbType.DateTime), new SqlParameter("@Updated_By",SqlDbType.NVarChar,50) }; parms[0].Value = admin.User_Name; parms[1].Value = admin.Real_Name; parms[2].Value = admin.Password; parms[3].Value = admin.User_Photo_Url; parms[4].Value = admin.E_Mail; parms[5].Value = admin.Is_Lock; parms[6].Value = admin.Updated_Date; parms[7].Value = admin.Updated_By; parms[8].Value = admin.Id; return SQLHelper.ExecuteNonQuery(CommandType.Text, sql.ToString(), parms) > 0; }
/// <summary> /// 根据Id获取信息 /// </summary> /// <param name="id"></param> /// <returns></returns> public AdminInfo GetById(int id) { StringBuilder sql = new StringBuilder(); sql.Append("select User_Name,Real_Name,Password,User_Photo_Url,E_Mail,Is_Lock from BigDog_Admin where id='" + id + "'"); AdminInfo admin = new AdminInfo(); DataTable dt = new DataTable(); dt = SQLHelper.GetDs(sql.ToString()).Tables[0]; if (dt.Rows.Count > 0) { admin.User_Name = dt.Rows[0]["User_Name"].ToString(); admin.Real_Name = dt.Rows[0]["Real_Name"].ToString(); admin.Password = dt.Rows[0]["Password"].ToString(); admin.User_Photo_Url = dt.Rows[0]["User_Photo_Url"].ToString(); admin.E_Mail = dt.Rows[0]["E_Mail"].ToString(); admin.Is_Lock = dt.Rows[0]["Is_Lock"].ToString(); return admin; } else { return null; } }
public static string Update(string id, string user_name, string password, string e_mail, string is_lock) { AdminInfo admin = new AdminInfo(); admin.User_Name = user_name; admin.Password = password; admin.Is_Lock = is_lock; admin.Id = Convert.ToInt32(id); bool success = AdminBLL.Update(admin); StringBuilder json = new StringBuilder(); json.Append("[{"); json.Append("\"success\":\"" + success + "\""); json.Append("}]"); return json.ToString(); }
public static bool Update(AdminInfo admin) { return Dal.Update(admin); }
public static bool Add(AdminInfo admin) { return Dal.Add(admin); }