添加酒电用户信息
DAL层
public static int add(Model.VIP model)
{
string sql = string.Format("insert into VIP values('{0}','{1}','{2}','{3}','{4}','{5}','{6}',null)", model.VIP_name, model.Sex, model.Pid, model.Tel, model.Rzjl, model.Address, model.R_id, null) ;
return DBHelper.ExecuteNonQuery(sql);
}
BLL层
public static int add(Model.VIP model)
{
return VIPDAL.add(model);
}
UI层
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
}
}
protected void btn_add_Click(object sender, EventArgs e)
{
VIP model = new VIP();
model.VIP_name = this.tb_VIP_name.Text;
model.Sex = this.rbl_Sex.SelectedValue;
model.Pid = this.tb_Pid.Text;
model.Tel = this.tb_Tel.Text;
model.Rzjl = this.tb_Rzjl.Text;
model.Address = this.tb_Address.Text;
model.R_id = Convert.ToInt32(this.tb_R_id.Text);
model.Remark = this.tb_remark.Text;
//调用添加
if (VIPBLL.add(model) > 0)
{
Response.Write("");
}
else
{
Response.Write("");
}
}
展示
vs提供了六种验证方法发,介绍四种:
1.CompareValidator
比较两个文本框填写的内容,一般用于确认密码之类的操作:
把这个控件拖到自己想放到的地方,点击右键,选择属性:
ID:给这个控件命名
ControlToCompare:需要比较的第一个文本的id
ControlToValidate:需要比较的第二个文本的id
Operator:比较大小等操作
Display:Dynamic
ErrorMessage:设置错误时控件显示的内容
2.RangeValidator
控制所选类型的数据范围:
ID:给这个控件命名
ControlToValidate:要检测的控件的id
Display:Dynamic
Type:设置检查的数据类型
MaximumValue:范围内的最大值
MinimumValue:范围内的最小值
ErrorMessage:设置错误时控件显示的内容
3.RequiredFieldValidator
检测数据是否为空
ID:给这个控件命名
ControlToValidate:需要检测的控件的id
Display:Dynamic
ErrorMessage:设置错误时控件显示的内容
4…RequiredFieldValidator
检测输入数据的格式,这个一般自定义,直接用控件自带的设置如下
ID:给这个控件命名
ControlToValidate:需要检测的控件的id
Display:Dynamic
ValdationExpression:选择输入的文本格式
ErrorMessage:设置错误时控件显示的内容



