1 Star 3 Fork 0

Admin/MyWebSms

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
usersearch.aspx.cs 6.69 KB
一键复制 编辑 原始数据 按行查看 历史
Ai鹿子 提交于 2022-04-24 10:09 . 01
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Wuqi.Webdiyer;
using System.Data.SqlClient;
using dal.tooldal;
public partial class usersearch : WebPage
{
public string _username = "";
public string _truename = "";
public string _mobile = "";
public string _date;
protected void Page_Load(object sender, EventArgs e)
{
this.VerifyPage();
try
{
_username = Request.QueryString.Get("u");
_truename = Request.QueryString["t"];
_date = Request.QueryString["d"];
_mobile = Request.QueryString["m"];
}
catch { }
this.sUserName.Value = _username;
this.sTrueName.Value = _truename;
this.sMobile.Value = _mobile;
this.sDate.Value = _date.ToString();
//给操作添加命令属性
this.LockBtn.Attributes.Add("onclick","Lock_Confirm();");
this.DeleteBtn.Attributes.Add("onclick","Delete_Confirm();");
if (!Page.IsPostBack)
{
DataBindlist();
}
}
public bool CheckCurUser(int _u)
{
bool ret = false;
Users us = new Users();
us.UserName = _username;
int ParUserID = us.SelectByUserName(us).UserPID;
if (CurrentUser.UserID == _u || CurrentUser.UserID == ParUserID)
ret = true;
else
ret = false;
return ret;
}
protected void DataBindlist()
{
string mysql = "";
if (CurrentUser.UserPID != -1 && CurrentUser.UserType == 1)
{
mysql += " and UserPID="+CurrentUser.UserID;
}
if (_username != "")
{
mysql += " and UserName like '%"+_username+"%'";
}
if (_truename != "")
{
mysql += " and TrueName like '%" + _truename + "%'";
}
if (_mobile != "")
{
mysql += " and Mobile like '%" + _mobile + "%'";
}
if (_date!= "")
{
mysql += " and CONVERT(VARCHAR, [AddTime], 121) like '%" + _date + "%'";
}
string sqlCount = string.Format("Select Count(1) From [Table_MyUsers] where 1=1" + mysql);
int recordcount = GetData.GetScalar(sqlCount);
if (recordcount == 0)
{
if (CurrentUser.UserPID == -1)
{
this.message0.Visible = true;
}
else
{
this.message.Visible = true;
}
}
pagelist.AlwaysShow = true;
pagelist.RecordCount = recordcount; //读出数据库里一共有多少条数据
string sql = "select * from [Table_MyUsers] where 1=1" + mysql + " order by UserID desc";
SqlDataAdapter ad = new SqlDataAdapter(sql, GetData.strConn);
DataSet ds = new DataSet();
ad.Fill(ds, pagelist.PageSize * (pagelist.CurrentPageIndex - 1), pagelist.PageSize, "temp");
rep_parent.DataSource = ds.Tables["temp"];
rep_parent.DataBind();
}
protected void PageChanging(object src, PageChangingEventArgs e)
{
pagelist.CurrentPageIndex = e.NewPageIndex;
DataBindlist();
}
protected void rep_parent_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
Label mypl = (Label)e.Item.FindControl("plset");
if (CurrentUser.UserPID != -1)
{
mypl.Visible = false;
}
else
{
mypl.Visible = true;
}
if (CurrentUser.UserPID == -1)
{
HtmlTableCell td = e.Item.FindControl("lisprice") as HtmlTableCell;
td.Visible = true;
}
}
protected void rep_parent_ItemCommand(object source, RepeaterCommandEventArgs e)
{
if (e.CommandName == "btnpower")
{
Users us = new Users();
int s = Convert.ToInt32(e.CommandArgument.ToString());
if (us.UpdateUserPower(s))
{
DataBindlist();
}
}
}
protected void LockBtn_Click(object sender, EventArgs e)
{
Users us = new Users();
int s = Convert.ToInt32(this.HidID.Value);
if (us.UpdateUserPower(s))
{
DataBindlist();
}
}
protected void DeleteBtn_Click(object sender, EventArgs e)
{
int s = 0;
s = int.Parse(this.HidID.Value);
Users MyUser = new Users();
MyUser = MyUser.Select(s);
int MyUserID = MyUser.UserID;
int MyUserPID = MyUser.UserPID;
string MyUserName = MyUser.UserName;
int MyCurrentCount = Convert.ToInt32(MyUser.CurrentCount.ToString());
Users TopUser = new Users();
TopUser = TopUser.SelectTopUser(MyUserPID);
int TopUserID = TopUser.UserID;
string TopUserName = TopUser.UserName;
int TopUserCurrentCount = Convert.ToInt32(TopUser.CurrentCount.ToString());
int NewCurrentCount = TopUserCurrentCount + MyCurrentCount;
Users us = new Users();
if (MyCurrentCount > 0)
{
us.UpdateTatal(MyUserID, 0);
us.UpdateTatal(TopUserID, NewCurrentCount);
}
if (us.Delete(MyUserID))
{
if (CurrentUser.UserID == MyUserPID)
{
WebPage.ShowMsgAndFreshTotal("用户 " + MyUserName + " 删除成功!", "lblCurrentCount", NewCurrentCount.ToString(), this.Page);
}
else
{
WebPage.ShowMsg("用户 " + MyUserName + " 删除成功!", this.Page);
}
}
DataBindlist();
}
public string getPriceCount(string s)
{
string ret = "";
int userid = Convert.ToInt32(s);
AddRecord ar = new AddRecord();
ret = ar.ReturnPrices(userid);
return ret;
}
#region 返回用户检索条件语句
public string SearchSqlWord(string _UserName,string _TrueName,string _Mobile,string _Date)
{
string Ret = "";
if (_UserName != "")
{
Ret += " and UserName like '%" + _UserName + "%'";
}
if (_TrueName != "")
{
Ret += " and TrueName like '%" + _TrueName + "%'";
}
if (_Mobile != "")
{
Ret += " and Mobile like '%" + _Mobile + "%'";
}
if (_Date != "")
{
Ret += " and AddTime = '%" + _Date + "%'";
}
return Ret;
}
#endregion
protected void AllBtn_Click(object sender, EventArgs e)
{
Response.Redirect("usermanage.aspx");
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/huanghe_1_0/my-web-sms.git
git@gitee.com:huanghe_1_0/my-web-sms.git
huanghe_1_0
my-web-sms
MyWebSms
master

搜索帮助