/// <summary> /// 回复 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnRepeat_Click(object sender, EventArgs e) { if (txtPubContext.Text == "") { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "msgShow('系统提示','回复内容不能为空','info');", true); return; } lgk.Model.tb_admin admin = adminBLL.GetModel(getLoginID()); lgk.Model.tb_leaveReMsg leaveReMsg = new lgk.Model.tb_leaveReMsg(); leaveReMsg.LeaveID = Convert.ToInt64(Request.QueryString["id"]); leaveReMsg.UserType = 2; leaveReMsg.UserID = admin.ID; leaveReMsg.UserCode = admin.UserName; leaveReMsg.ReContent = txtPubContext.Text; leaveReMsg.ReTime = DateTime.Now; if (leaveReMsgBLL.Add(leaveReMsg) > 0 && UpdateState(leaveReMsg.LeaveID, "IsReply") > 0) { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "msgShow('系统提示','回复成功!','info');", true); txtPubContext.Text = ""; BindData(getStringRequest("id")); BindReply(getStringRequest("id")); } else { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "msgShow('系统提示','回复失败!','info');", true); } }
protected void rpAdmin_ItemCommand(object source, RepeaterCommandEventArgs e) { int ID = Convert.ToInt32(e.CommandArgument); if (ID == getLoginID()) { MessageBox.Show(this, "无法操作"); return; } if (e.CommandName.Equals("del"))//删除 { //spd.jumpAdminUrl1(this.Page, 1);//跳转三级密码 lgk.Model.tb_admin admin = adminBLL.GetModel(ID); if (adminBLL.Delete(admin.ID)) { MessageBox.ShowAndRedirect(this, "删除成功", "AdminManage.aspx"); } else { MessageBox.Show(this, "删除失败"); } } else if (e.CommandName.Equals("modify")) { // spd.jumpAdminUrl1(this.Page, 1);//跳转三级密码 Response.Redirect("AdminEdit.aspx?id=" + ID); } }
/// <summary> /// 验证添加 /// </summary> /// <returns></returns> public bool ValidateAdd() { if (txtUserCode.Text.Trim().Length == 0) { MessageBox.Show(this, "管理员编号不能为空"); return(false); } lgk.Model.tb_admin admin = adminBLL.GetModel(txtUserCode.Text); if (admin != null) { MessageBox.Show(this, "已存在的管理员编号"); return(false); } if (txtName.Text.Trim().Length == 0) { MessageBox.Show(this, "管理员姓名不能为空"); return(false); } if (txtPass.Text.Trim().Length == 0) { MessageBox.Show(this, "登录密码不能为空"); return(false); } if (txtPass.Text != txtRPass.Text) { MessageBox.Show(this, "两次输入的登录密码不一致"); return(false); } if (txtSecondPass.Text.Trim().Length == 0) { MessageBox.Show(this, "二级密码不能为空"); return(false); } if (txtSecondPass.Text != txtRSecondPass.Text) { MessageBox.Show(this, "两次输入的二级密码不一致"); return(false); } if (txtThirdPass.Text.Trim().Length == 0) { MessageBox.Show(this, "三级密码不能为空"); return(false); } if (txtThirdPass.Text != txtRThirdPass.Text) { MessageBox.Show(this, "两次输入的三级密码不一致"); return(false); } return(true); }
protected void btnSubmit_Click(object sender, EventArgs e) { lgk.Model.tb_admin fromAdmin = adminBLL.GetModel(getLoginID()); lgk.Model.tb_user user = null;//收件人 if (textUserCode.Value == "") { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('留言对象不能为空!');", true); return; } //验证是否存在会员 user = userBLL.GetModel(GetUserID(textUserCode.Value.Trim())); if (user == null) { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('不存在的账号!');", true); return; } if (user.IsOpend == 0) { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('会员未开通!');", true); return; } if (textTitle.Value == "") { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('标题不能为空!');", true); return; } if (txtPubContext.Text == "") { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('内容不能为空!');", true); return; } lgk.Model.tb_leaveMsg leaveMsg = new lgk.Model.tb_leaveMsg() { MsgTitle = textTitle.Value, MsgContent = txtPubContext.Text, LeaveTime = DateTime.Now, IsRead = 0, IsReply = 0, FromUserType = 2, UserID = 1, UserCode = "admin", FromIDIsDel = 0, ToIDIsDel = 0, }; leaveMsg.ToUserType = 1; leaveMsg.ToUserID = user.UserID; leaveMsg.ToUserCode = user.UserCode; if (leaveMsgBLL.Add(leaveMsg) > 0) { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('发送成功!');window.location.href='LeaveOut.aspx';", true); } else { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('发送失败!');", true); } }
/// <summary> /// 得到一个对象实体 /// </summary> public lgk.Model.tb_admin GetModel(string code) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,UserName,TrueName,Password,SecondPassword,ThirdPassword,Limits,AddDate from tb_admin "); strSql.Append(" where UserName=@UserName"); SqlParameter[] parameters = { new SqlParameter("@UserName", SqlDbType.VarChar, 50) }; parameters[0].Value = code; lgk.Model.tb_admin model = new lgk.Model.tb_admin(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["ID"] != null && ds.Tables[0].Rows[0]["ID"].ToString() != "") { model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString()); } if (ds.Tables[0].Rows[0]["UserName"] != null && ds.Tables[0].Rows[0]["UserName"].ToString() != "") { model.UserName = ds.Tables[0].Rows[0]["UserName"].ToString(); } if (ds.Tables[0].Rows[0]["TrueName"] != null && ds.Tables[0].Rows[0]["TrueName"].ToString() != "") { model.TrueName = ds.Tables[0].Rows[0]["TrueName"].ToString(); } if (ds.Tables[0].Rows[0]["Password"] != null && ds.Tables[0].Rows[0]["Password"].ToString() != "") { model.Password = ds.Tables[0].Rows[0]["Password"].ToString(); } if (ds.Tables[0].Rows[0]["SecondPassword"] != null && ds.Tables[0].Rows[0]["SecondPassword"].ToString() != "") { model.SecondPassword = ds.Tables[0].Rows[0]["SecondPassword"].ToString(); } if (ds.Tables[0].Rows[0]["ThirdPassword"] != null && ds.Tables[0].Rows[0]["ThirdPassword"].ToString() != "") { model.ThirdPassword = ds.Tables[0].Rows[0]["ThirdPassword"].ToString(); } if (ds.Tables[0].Rows[0]["Limits"] != null && ds.Tables[0].Rows[0]["Limits"].ToString() != "") { model.Limits = ds.Tables[0].Rows[0]["Limits"].ToString(); } if (ds.Tables[0].Rows[0]["AddDate"] != null && ds.Tables[0].Rows[0]["AddDate"].ToString() != "") { model.AddDate = DateTime.Parse(ds.Tables[0].Rows[0]["AddDate"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 获得編號 /// </summary> /// <param name="userid">會員id</param> /// <returns>編號</returns> protected string GetUserCode(string userid, int type) { if (type == 1) { lgk.Model.tb_user user = userBLL.GetModel(Convert.ToInt64(userid)); return(user.UserCode); } else { lgk.Model.tb_admin admin = adminBLL.GetModel(int.Parse(userid)); return("【管理员】" + admin.UserName); } }
/// <summary> /// 在页面Page_Load事件执行结束后执行 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void PageBase_Load(object sender, System.EventArgs e) { LoginAdmin = adminBLL.GetModel(getLoginID()); //结算系统和网站共用域名,当前根目录被移到/jsxt下 string strNewUrl = Request.Url.ToString().Replace("/admin/finance/", "/").Replace("/admin/business/", "/").Replace("/admin/product/", "/").Replace("/admin/info/", "/").Replace("/admin/team/", "/").Replace("/admin/system/", "/").Replace("/admin/cash/", "/").Replace("/admin/", "/"); //取得当前的外网 strNewUrl = strNewUrl.Substring(0, strNewUrl.LastIndexOf("/") + 1); //当前页面的根路径 //检测Session["User"] 是否存在,如果存在,把它转换成UserInfo类,如果不存在,初始化一个UserInfo类,并存储到Session["User"] if (Request.Cookies["A128076_admin"] == null) { Response.Write("<script>window.top.location='" + strNewUrl + "ManageLogin.aspx'</script>"); Response.End(); } }
/// <summary> /// 保存登录密码 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnPassWord_Click(object sender, EventArgs e) { lgk.Model.tb_admin admin = adminBLL.GetModel(getLoginID()); if (validatePass(admin.Password)) { if (UpdateAdminPwd(admin.UserName, "Password", PageValidate.GetMd5(textNewPassWord.Value)) > 0) { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('登录密码修改成功!');", true); } else { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('登录密码修改失败!');", true); } } }
protected void Button1_Click(object sender, EventArgs e) { lgk.Model.tb_admin model = adminBLL.GetModel(getLoginID()); if (validateTPass(model.ThirdPassword)) { if (UpdateAdminPwd(model.UserName, "ThirdPassword", PageValidate.GetMd5(Password2.Value)) > 0) { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('三级密码修改成功!');", true); } else { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('三级密码修改失败!');", true); } } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(lgk.Model.tb_admin model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update tb_admin set "); strSql.Append("UserName=@UserName,"); strSql.Append("TrueName=@TrueName,"); strSql.Append("Password=@Password,"); strSql.Append("SecondPassword=@SecondPassword,"); strSql.Append("ThirdPassword=@ThirdPassword,"); strSql.Append("Limits=@Limits,"); strSql.Append("AddDate=@AddDate"); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@UserName", SqlDbType.VarChar, 50), new SqlParameter("@TrueName", SqlDbType.VarChar, 50), new SqlParameter("@Password", SqlDbType.VarChar, 50), new SqlParameter("@SecondPassword", SqlDbType.VarChar, 50), new SqlParameter("@ThirdPassword", SqlDbType.VarChar, 50), new SqlParameter("@Limits", SqlDbType.VarChar), new SqlParameter("@AddDate", SqlDbType.DateTime), new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = model.UserName; parameters[1].Value = model.TrueName; parameters[2].Value = model.Password; parameters[3].Value = model.SecondPassword; parameters[4].Value = model.ThirdPassword; parameters[5].Value = model.Limits; parameters[6].Value = model.AddDate; parameters[7].Value = model.ID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 填充留言表 /// </summary> /// <param name="id">显示的留言id</param> protected void BindData(string id) { long value = 0; if (long.TryParse(id, out value)) { lgk.Model.tb_leaveMsg leaveMsg = leaveMsgBLL.GetModel(value); lblSendTitle.Text = leaveMsg.MsgTitle; lblSendContent.Text = leaveMsg.MsgContent; lblSendDate.Text = leaveMsg.LeaveTime.ToString("yyyy-MM-dd HH:mm:ss"); if (leaveMsg.FromUserType == 1) { lgk.Model.tb_user user = userBLL.GetModel(Convert.ToInt64(leaveMsg.UserID)); lblSendMember.Text = user.UserCode; } else { lgk.Model.tb_admin admin = adminBLL.GetModel(Convert.ToInt32(leaveMsg.UserID)); lblSendMember.Text = admin.UserName; } } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(lgk.Model.tb_admin model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into tb_admin("); strSql.Append("UserName,TrueName,Password,SecondPassword,ThirdPassword,Limits,AddDate)"); strSql.Append(" values ("); strSql.Append("@UserName,@TrueName,@Password,@SecondPassword,@ThirdPassword,@Limits,@AddDate)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@UserName", SqlDbType.VarChar, 50), new SqlParameter("@TrueName", SqlDbType.VarChar, 50), new SqlParameter("@Password", SqlDbType.VarChar, 50), new SqlParameter("@SecondPassword", SqlDbType.VarChar, 50), new SqlParameter("@ThirdPassword", SqlDbType.VarChar, 50), new SqlParameter("@Limits", SqlDbType.VarChar), new SqlParameter("@AddDate", SqlDbType.DateTime) }; parameters[0].Value = model.UserName; parameters[1].Value = model.TrueName; parameters[2].Value = model.Password; parameters[3].Value = model.SecondPassword; parameters[4].Value = model.ThirdPassword; parameters[5].Value = model.Limits; parameters[6].Value = model.AddDate; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
void getDataSource() { DataTable dt = powerBLL.GetList("").Tables[0]; ViewState["dt"] = dt; if (Request.QueryString["id"] != "" && Request.QueryString["id"] != null && Request.QueryString["id"] != "1") { lgk.Model.tb_admin admin = adminBLL.GetModel(int.Parse(Request.QueryString["id"])); if (admin.Limits != null && admin.Limits != "") { ViewState["limits"] = admin.Limits.Split(','); } else { ViewState["limits"] = new string[] { "0" }; } } else { ViewState["limits"] = new string[] { "0" }; } }
protected void BindInfo(string id) { lgk.Model.tb_admin admin = adminBLL.GetModel(int.Parse(id)); txtUserCode.Text = admin.UserName; txtName.Text = admin.TrueName; }
/// <summary> /// 保存按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { spd.jumpAdminUrl1(this.Page, 1);//跳转三级密码 string limitsid = ""; foreach (TreeNode node in tvAdminTree.Nodes) { if (node.Checked == true) { limitsid += node.Value; limitsid += ","; } foreach (TreeNode childNode in node.ChildNodes) { if (childNode.Checked == true) { limitsid += childNode.Value; limitsid += ","; } } } if (limitsid.Length > 0) { limitsid = limitsid.Substring(0, limitsid.Length - 1); } if (Request.QueryString["id"] != "" && Request.QueryString["id"] != null && Request.QueryString["id"] != "1") { if (ValidateUpdate())//更新 { lgk.Model.tb_admin admin = adminBLL.GetModel(int.Parse(Request.QueryString["id"])); admin.TrueName = txtName.Text; if (txtPass.Text.Trim().Length > 0) { admin.Password = PageValidate.GetMd5(txtPass.Text); } if (txtSecondPass.Text.Trim().Length > 0) { admin.SecondPassword = PageValidate.GetMd5(txtSecondPass.Text); } if (txtThirdPass.Text.Trim().Length > 0) { admin.ThirdPassword = PageValidate.GetMd5(txtThirdPass.Text); } admin.Limits = limitsid; if (adminBLL.Update(admin)) { MessageBox.ShowAndRedirect(this, "修改成功!", "AdminManage.aspx"); //ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "succeed", "alert('修改成功!')window.location='AdminManage.aspx'", true); //Response.Redirect("AdminManage.aspx"); } else { MessageBox.Show(this, "修改失败!"); return; //ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "fail", "alert('修改失败!')", true); } } } else { if (ValidateAdd())//添加 { lgk.Model.tb_admin admin = new lgk.Model.tb_admin(); admin.UserName = txtUserCode.Text.Trim(); admin.TrueName = txtName.Text.Trim(); admin.Password = PageValidate.GetMd5(txtPass.Text.Trim()); admin.SecondPassword = PageValidate.GetMd5(txtSecondPass.Text.Trim()); admin.Limits = limitsid; admin.AddDate = DateTime.Now; admin.ThirdPassword = PageValidate.GetMd5(this.txtThirdPass.Text.Trim()); if (adminBLL.Add(admin) > 0) { MessageBox.ShowAndRedirect(this, "管理员添加成功!", "AdminManage.aspx"); //ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "succeed", "alert('管理员添加成功!');window.location='AdminManage.aspx'", true); } else { MessageBox.Show(this, "管理员添加失败!"); return; //ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "fail", "alert('管理员添加失败!')", true); } } } }
protected void btnLogin_Click(object sender, EventArgs e) { if (this.txtUserName.Value.Trim() == "") { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('请输入用户名!');", true); //MessageBox.Show(this, "请输入用户名!"); return; } if (this.txtUserName.Value.Trim() == "用户名") { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('请输入用户名!');", true); //MessageBox.Show(this, "请输入用户名!"); return; } if (this.txtPwd.Value.Trim() == "") { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('请输入密码!');", true); //MessageBox.Show(this, "请输入密码!"); return; } if (this.txtVa.Value.Trim() == "") { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('验证码不能为空!');", true); return; } if (this.txtVa.Value.Trim().ToLower() != Session["CheckCode"].ToString().ToLower()) { WriteDBLog("验证码错误:" + this.txtVa.Value, 1); ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('验证码错误!');", true); return; } if (!ExistsAdmin(txtUserName.Value.Trim(), PageValidate.GetMd5(txtPwd.Value.Trim()))) { WriteDBLog("账号或密码错误:" + txtPwd.Value, 1); ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('账号或密码错误!');", true); //MessageBox.Show(this, "账号或密码错误"); return; } WriteDBLog("登录成功", 0); //string xd = Session["CheckCode"] != null && Session["CheckCode"].ToString() != "" ? Session["CheckCode"].ToString() : ""; //if (xd.ToLower() != txtfield.Text.ToLower()) //{ // MessageBox.Show(this, "验证码错误"); // return; //} lgk.Model.tb_admin admin = adminBLL.GetModel(txtUserName.Value.Trim()); //if (admin.Limits == null) //{ // MessageBox.Show(this, "您的权限不足,请联系超级管理员"); // return; //} UserUtil.Login(this.txtUserName.Value.Trim(), "A128076_admin", false); //放入cookie HttpCookie UserCookie = new HttpCookie("A128076_admin"); DataSet ds = GetAdminModel(txtUserName.Value, PageValidate.GetMd5(txtPwd.Value)); UserCookie["Id"] = ds.Tables[0].Rows[0]["ID"].ToString(); UserCookie["name"] = Convert.ToString(txtUserName.Value); Response.AppendCookie(UserCookie); Response.Redirect("admin/index.aspx"); }