out的作用
来源:互联网 发布:最常用编程语言 编辑:程序博客网 时间:2024/04/29 02:58
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
this.btnSumbitVote.Attributes.Add("onclick","return checkForm()");
this.VoteId = Request["id"]+"";
if(this.VoteId== string.Empty)
{
Response.End();
}
else if((Request.UrlReferrer+"").ToString().ToLower().IndexOf("event/ishow/2006/")<0)
{
Response.End();
}
else if(Request.Cookies["vote"] != null && Validate_Cookies(Request.Cookies["vote"].Value+"", this.VoteId))
{
Response.Write(@"<script>alert(""10分钟内不能重复投票同一作品!""); history.back();</script>");
}
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.btnSumbitVote.Click += new System.EventHandler(this.btnSumbitVote_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
public bool Validate_Cookies(string oldstring,string voteId)
{
bool result=false;
string[] arr = oldstring.Split(',');
for(int i=0;i<arr.Length;i++)
{
if(arr[i]==voteId)
result = true;
}
return result;
}
public bool ValidateInput(out string errStr)
{
if(this.UserNameValue ==string.Empty)
{
errStr = "用户名不能为空。";
}
else if (this.MobileValue == string.Empty)
{
errStr = "手机号不能为空。";
}
else if (this.ValidateMobile(this.MobileValue))
{
errStr = "一个手机号只能投一次票。";
}
else if(this.PassWordValue == string.Empty)
{
errStr = "学校代码不能为空";
}
else if(!this.ValidatePWD(this.VoteId, this.PassWordValue))
{
errStr = "学校代码输入不正确。";
}
else if(this.CheckCodeValue == string.Empty)
{
errStr = "验证码不能为空。";
}
else if(this.CheckCodeValue.ToUpper() != Session["chkcode"]+"")
{
errStr = "验证码输入不正确。";
}
else
{
errStr = string.Empty;
return true;
}
return false;
}
public bool ValidatePWD(string voteid, string finalpassword)
{
//密码存在返回true;
string strSql="SELECT * FROM vote WHERE id='"+ voteid +"' AND finalpassword='"+ finalpassword +"'";
string connStr = System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];
SqlConnection sqlConn = new SqlConnection(connStr);
SqlCommand sqlCmd = new SqlCommand(strSql,sqlConn);
sqlConn.Open();
SqlDataReader dr = sqlCmd.ExecuteReader();
if(dr.Read())
{
return true;
}
else
{
return false;
}
}
public bool ValidateMobile(string mobile)
{
//手机已存在返回true;
string strSql="SELECT * FROM votefinal WHERE telephone ='"+ mobile +"'";
string connStr = System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];
SqlConnection sqlConn = new SqlConnection(connStr);
SqlCommand sqlCmd = new SqlCommand(strSql,sqlConn);
sqlConn.Open();
SqlDataReader dr = sqlCmd.ExecuteReader();
if(dr.Read())
{
return true;
}
else
{
return false;
}
}
public void VoteFinal()
{
//投票数据更新
bool blnResult;
CVote _CVote = new CVote();
blnResult = _CVote.AddVoteFinal(Convert.ToInt32(this.VoteId), Request.Url.ToString().ToLower(), Request.UrlReferrer.ToString().ToLower(), Request.UserHostAddress, Request.UserAgent, this.UserNameValue, this.MobileValue);
if(blnResult)
{
//写Cookies
HttpCookie vote = new HttpCookie("vote");
DateTime now = DateTime.Now;
if(Request.Cookies["vote"] != null)
{
vote.Value = Request.Cookies["vote"].Value + this.VoteId+ ",";
}
else
{
vote.Value = this.VoteId + ",";
}
vote.Expires = now.AddMinutes(10);
Response.Cookies.Add(vote);
Response.Write("<script>alert('您已投票成功!'); window.open('http://www.yocity.cn/blog/'); window.location.href='VoteList_final.aspx';</script>");
}
}
private void btnSumbitVote_Click(object sender, System.EventArgs e)
{
this.UserNameValue= Request["txtuserName"]+"";
this.MobileValue= Request["txtmobile"]+"";
this.PassWordValue= Request["txtpassword"]+"";
this.CheckCodeValue= Request["txtCheckCode"]+"";
string errStr;
if(this.ValidateInput(out errStr))
{
this.VoteFinal();
}
else
{
Response.Write(@"<script>alert('"+ errStr +"');history.back();</script>");
}
}
- out的作用
- ref和out的作用
- ref、out的区别和作用
- C#中in,out,ref的作用
- C#中in,out,ref的作用
- ref和out的作用和区别
- C#中in,out,ref的作用
- C#中in,out,ref的作用和区别
- C#中ref和out的作用和区别
- 大话C#中in,out,ref的作用和区别
- C#基础in,out,ref的作用和区别
- C#中in、out和ref的作用与区别
- c# 中ref ,out ,params 三种修饰符的作用与区别
- MySQL——存储过程参数in,out,inout的作用
- MSDN中[in]和[out]作用
- Unattended terminals (timed out waiting for input)AIX TMOUT 和TIMEOUT的含义 作用 以及区别
- out.print和out.write的区别
- out.print和out.write的区别
- VB中各种数据类型转换函数
- JAVA常用数据库JDBC连接写法
- 轻松解决 'MSISR.PRODUCTNAME' 错误
- 什么是HTMLArea
- WPF/E技术公布了第一个CTP版本下载
- out的作用
- 在Tomcat 5.5.20中配置JNDI的体会
- 在SAP中设计自动刷新的报表代码 (又一例)
- Visual C#常用函数和方法集汇总
- PL/Sql循序渐进全面学习教程--Oracle
- 将动态aspx页面转换成为静态html页面的几种方法
- 在 ASP.NET 2.0 中创建 Web 应用程序主题【微软】
- 最佳开源软件一览
- Hello ,CSDN