protected void Button1_Click(object sender, EventArgs e) { Model.H_User user = new Model.H_User(); Model.H_Student student = new Model.H_Student(); user.username = this.TextUser.Value.Trim(); user.password = this.TextPwd.Value.Trim(); user.qxid = 4; user.isoccupy = 1; student.username = this.TextUser.Value.Trim(); student.name = this.TextName.Value.Trim(); student.email = this.TextEmail.Value.Trim(); student.telphone = this.TextTel.Value.Trim(); student.zhifubao = this.TextZhifubao.Value.Trim(); student.bank = this.TextBank.Value.Trim(); student.bank_name = this.TextBank_name.Value.Trim(); student.bank_num = this.TextBank_number.Value.Trim(); student.region_province = this.HiddenProvince.Value.ToString(); student.region_city = this.HiddenCity.Value.ToString(); student.region_county = this.HiddenArea.Value.ToString(); if (H_UserClass.Add(user) && H_StudentClass.Add(student)) { JScript.Alert("操作成功", "a2", this); Response.Redirect("AdminLogin.aspx"); } else { JScript.Alert("操作失败", "a2", this); } }
/// <summary> /// 更新一条数据 /// </summary> public static bool Update(Model.H_User model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update H_User set "); strSql.Append("username=@username,"); strSql.Append("password=@password,"); strSql.Append("qxid=@qxid,"); strSql.Append("isoccupy=@isoccupy"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@username", SqlDbType.NVarChar, 50), new SqlParameter("@password", SqlDbType.NVarChar, 50), new SqlParameter("@qxid", SqlDbType.TinyInt, 1), new SqlParameter("@isoccupy", SqlDbType.TinyInt, 1), new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = model.username; parameters[1].Value = model.password; parameters[2].Value = model.qxid; parameters[3].Value = model.isoccupy; parameters[4].Value = model.id; return(DbHelperSQL.ExecuteSql(strSql.ToString(), parameters) > 0); }
protected void Button1_Click(object sender, EventArgs e) { Model.H_User user = new Model.H_User(); user.username = this.TextUser.Value.Trim(); user.qxid = int.Parse(this.SelectAuth.Value); user.password = this.TextPwd.Value.Trim(); user.isoccupy = 0; if (H_UserClass.Add(user)) { JScript.AlertAndRedirect("操作成功", "UserList.aspx", this); } else { JScript.Alert("操作失败", "a2", this); } }
/// <summary> /// 得到一个对象实体 /// </summary> public static Model.H_User GetModel(string id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,username,password,qxid,isoccupy from H_User "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; Model.H_User model = new Model.H_User(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["id"].ToString() != "") { model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } model.username = ds.Tables[0].Rows[0]["username"].ToString(); model.password = ds.Tables[0].Rows[0]["password"].ToString(); if (ds.Tables[0].Rows[0]["qxid"].ToString() != "") { model.qxid = int.Parse(ds.Tables[0].Rows[0]["qxid"].ToString()); } if (ds.Tables[0].Rows[0]["isoccupy"].ToString() != "") { model.isoccupy = int.Parse(ds.Tables[0].Rows[0]["isoccupy"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 增加一条数据 /// </summary> public static bool Add(Model.H_User model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into H_User("); strSql.Append("username,password,qxid,isoccupy)"); strSql.Append(" values ("); strSql.Append("@username,@password,@qxid,@isoccupy)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@username", SqlDbType.NVarChar, 50), new SqlParameter("@password", SqlDbType.NVarChar, 50), new SqlParameter("@qxid", SqlDbType.TinyInt, 1), new SqlParameter("@isoccupy", SqlDbType.TinyInt, 1) }; parameters[0].Value = model.username; parameters[1].Value = model.password; parameters[2].Value = model.qxid; parameters[3].Value = model.isoccupy; return(DbHelperSQL.ExecuteSql(strSql.ToString(), parameters) > 0); }