/// <summary> /// 按钮事件:下载信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnGuanZhu_Click(object sender, EventArgs e) { if (Request.Cookies["logininfo"] != null) { int memberid = new ManagerBase().mbId; string content = ""; var dt = DB.getDataTable("select * from GuanZhu where memberid=" + memberid + " and InfoId=" + id); if (dt.Rows.Count == 0) { content = "<a href=\"/ProductShow.aspx?id=" + id + "\" target=\"_blank\">" + productname.Text + "</a>"; DB.ExecuteSql("insert into GuanZhu values('" + memberid + "','" + content + "','" + id + "',getdate())"); } var dr = DB.getDataReader("select * from Product where Id=" + id); if (dr.Read()) { DB.ExecuteSql("update Product set Hits=Hits+1 where Id=" + id); Response.Redirect(dr["simg"].ToString()); } } else { JavaScriptHelper.Alert("请先登录。"); return; } }
/// <summary> /// 获取数据 /// </summary> private void BindData() { var dr = DB.getDataReader("select * from Product where Id=" + id); if (dr.Read()) { productname.Text = dr["ProductName"].ToString(); reName.Text = dr["reName"].ToString(); FileType.Text = dr["FileType"].ToString(); content.Text = Common.ConvertStringToHtml(dr["Content"].ToString()); hits.Text = dr["Hits"].ToString(); simg = dr["simg"].ToString(); zanNum.Text = dr["zanNum"].ToString(); FenLeiName.Text = dr["FenLeiName"].ToString(); //更新浏览量 //DB.ExecuteSql("update Product set Hits=Hits+1 where Id=" + id); if (Request.Cookies["logininfo"] == null) { btnSave.Enabled = false; btnSave.Text = "请先登录才能评论!!"; } else { PingJiaUser.Text = new ManagerBase().mbUserName; } rptList.DataSource = DB.getDataTable("select * from PingJia where IsAudit=1 and InfoId=" + id + " order by Id desc"); rptList.DataBind(); } }
/// <summary> /// 获取数据 /// </summary> private void BindData() { rptList1.DataSource = DB.getDataTable("select top 5 * from Product where State='通过' order by newid()"); rptList1.DataBind(); rptList2.DataSource = DB.getDataTable("select top 5 * from Product where State='通过' order by hits desc"); rptList2.DataBind(); var sql = @"SELECT UserName,COUNT(0) num FROM Product group by UserName order by num desc"; rptList3.DataSource = DB.getDataTable(sql); rptList3.DataBind(); }
/// <summary> /// 按钮事件:提交信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { //验证重复 if (DB.getDataTable("select * from Manager where ManagerName='" + ManagerName.Text.Trim() + "'").Rows.Count > 0) { ManagerName.Focus(); JavaScriptHelper.Error(this, "此 帐号 已存在"); return; } if (ManagerName.Text.Trim() == "") { ManagerName.Focus(); JavaScriptHelper.Error(this, "账号不能为空!"); return; } if (ManagerPwd.Text.Trim() == "" || SuerPwd.Text.Trim() == "") { ManagerName.Focus(); JavaScriptHelper.Error(this, "登录密码和确认登录密码不能为空!请填写登录密码和确认登录密码!"); return; } else { string managerPwd = ManagerPwd.Text; string suerPwd = SuerPwd.Text; if (managerPwd != suerPwd) { JavaScriptHelper.Error(this, "登录密码和确认登录密码不一致,请检查!"); } else { Regex reg = new Regex("^[a-zA-Z0-9]{6,12}$", RegexOptions.IgnoreCase); var size = suerPwd.ToUpper(); if (!reg.IsMatch(size)) { Email.Focus(); JavaScriptHelper.Error(this, "密码格式不正确!"); return; } } } if (Title.Text.Trim() == "") { ManagerName.Focus(); JavaScriptHelper.Error(this, "名称不能为空!"); return; } if (Email.Text.Trim() == "") { ManagerName.Focus(); JavaScriptHelper.Error(this, "邮箱不能为空!"); return; } else { string email = Email.Text; Regex reg = new Regex("^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$", RegexOptions.IgnoreCase); var size = email.ToUpper(); if (!reg.IsMatch(size)) { Email.Focus(); JavaScriptHelper.Error(this, "请输入正确格式的邮箱!"); return; } } string mobile = Tel.Text; if (mobile != "") { Regex reg = new Regex("^((13[0-9])|(14[5,7])|(15[0-3,5-9])|(17[0,3,5-8])|(18[0-9])|166|198|199|(147))\\d{8}$", RegexOptions.IgnoreCase); var size = mobile.ToUpper(); if (!reg.IsMatch(size)) { Email.Focus(); JavaScriptHelper.Error(this, "请输入正确格式的手机号!"); return; } } StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Manager("); strSql.Append("Tel,ManagerPwd,ManagerName,Email,Title,RegTime,LoginCount,Grade"); strSql.Append(") values ("); strSql.Append("'" + Tel.Text + "','" + ManagerPwd.Text + "','" + ManagerName.Text + "','" + Email.Text + "','" + Title.Text + "',getdate(),0,2"); strSql.Append(") "); DB.ExecuteSql(strSql.ToString()); JavaScriptHelper.Success(this, "注册成功,将转向登录页!", "SysManage/Login.aspx?grade=2"); }