5 Star 42 Fork 3

maxinehehe / 网上订餐系统

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Register.aspx.cs 2.85 KB
一键复制 编辑 原始数据 按行查看 历史
maxinehehe 提交于 2018-02-04 20:18 . 提交课程设计 网上订餐
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
public partial class Register : System.Web.UI.Page
{
/*验证码处理*/
public void RandomCheckCode()
{
Random r = new Random();
yanzhengma.Text = Convert.ToString(r.Next(1000, 9999));
}
protected void Page_Load(object sender, EventArgs e)
{
//if (!IsPostBack)
RandomCheckCode();
TxtAccount.Focus();
}
protected void BtnReset_Click(object sender, EventArgs e)
{
TxtAccount.Text = "";
TxtCheck.Text = "";
TxtPwd.Text = "";
TxtRePwd.Text = "";
TxtTel.Text = "";
TxTAdress.Text = "";
CBAgree.Checked = false;
}
protected void TxtRePwd_TextChanged(object sender, EventArgs e)
{
if (TxtPwd.Text != TxtRePwd.Text)
{
BtnRgister.Enabled = false;
}
else
{
BtnRgister.Enabled = true;
}
}
protected void BtnRgister_Click(object sender, EventArgs e)
{
SqlHelper sh = new SqlHelper();
IDbConnection con = sh.getCon();
String sql = String.Format("Insert into users(username,password,tel,address)Values('{0}','{1}','{2}','{3}')",TxtAccount.Text,TxtPwd.Text,TxtTel.Text,TxTAdress.Text);
if (CBAgree.Checked)
{
bool flag = sh.ExeNonQuery(sql);
if (flag)
{
Response.Write("<script>alert('恭喜您注册成功!');location.href='ShowFoods.aspx';</script>");
//Response.Write("<script>document.location=document.location;alert('恭喜您注册成功!')</script>");
}
}
else
{
Response.Write("<script>alert('请阅读相关协议!')</script>");
}
/*
if (CBAgree.Checked)
{
TxtPolicy.Text = "你选中了同意条款";
}else
TxtPolicy.Text = "你没选中了同意条款";
* /
/*
String ConnString = "Data Source=.;Initial Catalog=MySmart;User Id=sa;Pwd=123456;";
SqlConnection con = new SqlConnection();
con.ConnectionString = ConnString;
con.Open(); //连接并打开数据库
TxtPolicy.Text = "连接成功";
SqlCommand cmd = new SqlCommand();
cmd.Connection = con; //拿到连接
String sql = String.Format("Insert into T_Customer Values('{0}','{1}','{2}','{3}','{4}')", TxtAccount.Text, TxtPwd.Text, TxtTel.Text, TxtMail.Text, TxtAge.Text);
cmd.CommandText = sql;
cmd.ExecuteNonQuery();
con.Close();
Response.Write("<Script>alert('
*/
}
}
ASP
1
https://gitee.com/maxinehehe/asp_project.git
git@gitee.com:maxinehehe/asp_project.git
maxinehehe
asp_project
网上订餐系统
master

搜索帮助