/// <summary> /// 得到一个对象实体 /// </summary> public kyfly.Model.jichu_renyuanxinxiB GetModel(int Id) { //该表无主键信息,请自定义主键/条件字段 StringBuilder strSql = new StringBuilder(); strSql.Append("select * from 基础_人员信息表 "); strSql.Append(" where Id=@Id LIMIT 1"); MySqlParameter[] parameters = { new MySqlParameter("@Id", MySql.Data.MySqlClient.MySqlDbType.Int16, 11) }; parameters[0].Value = Id; kyfly.Model.jichu_renyuanxinxiB model = new kyfly.Model.jichu_renyuanxinxiB(); DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(kyfly.Model.jichu_renyuanxinxiB model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update 基础_人员信息表 set "); strSql.Append("姓名=@姓名,"); strSql.Append("手机号=@手机号,"); strSql.Append("OpenId=@OpenId,"); strSql.Append("密码=@密码,"); strSql.Append("地址=@地址,"); strSql.Append("状态=@状态,"); strSql.Append("类别=@类别,"); strSql.Append("权限=@权限,"); strSql.Append("会员级别=@会员级别,"); strSql.Append("配送次数=@配送次数,"); strSql.Append("备注=@备注"); strSql.Append(" where Id=@Id"); MySqlParameter[] parameters = { new MySqlParameter("@姓名", MySqlDbType.VarChar, 30), new MySqlParameter("@手机号", MySqlDbType.VarChar, 11), new MySqlParameter("@OpenId", MySqlDbType.VarChar, 30), new MySqlParameter("@密码", MySqlDbType.VarChar, 30), new MySqlParameter("@地址", MySqlDbType.VarChar, 100), new MySqlParameter("@状态", MySqlDbType.VarChar, 20), new MySqlParameter("@类别", MySqlDbType.VarChar, 20), new MySqlParameter("@权限", MySqlDbType.VarChar, 20), new MySqlParameter("@会员级别", MySqlDbType.VarChar, 20), new MySqlParameter("@配送次数", MySqlDbType.Int32, 11), new MySqlParameter("@备注", MySqlDbType.VarChar, 30), new MySqlParameter("@Id", MySqlDbType.Int16, 6) }; parameters[0].Value = model.姓名; parameters[1].Value = model.手机号; parameters[2].Value = model.OpenId; parameters[3].Value = model.密码; parameters[4].Value = model.地址; parameters[5].Value = model.状态; parameters[6].Value = model.类别; parameters[7].Value = model.权限; parameters[8].Value = model.会员级别; parameters[9].Value = model.配送次数; parameters[10].Value = model.备注; parameters[11].Value = model.Id; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public kyfly.Model.jichu_renyuanxinxiB DataRowToModel(DataRow row) { kyfly.Model.jichu_renyuanxinxiB model = new kyfly.Model.jichu_renyuanxinxiB(); if (row != null) { if (row["Id"] != null && row["Id"].ToString() != "") { model.Id = int.Parse(row["Id"].ToString()); } if (row["姓名"] != null) { model.姓名 = row["姓名"].ToString(); } if (row["手机号"] != null) { model.手机号 = row["手机号"].ToString(); } if (row["OpenId"] != null) { model.OpenId = row["OpenId"].ToString(); } if (row["密码"] != null) { model.密码 = row["密码"].ToString(); } if (row["地址"] != null) { model.地址 = row["地址"].ToString(); } if (row["状态"] != null) { model.状态 = row["状态"].ToString(); } if (row["类别"] != null) { model.类别 = row["类别"].ToString(); } if (row["权限"] != null) { model.权限 = row["权限"].ToString(); } if (row["会员级别"] != null) { model.会员级别 = row["会员级别"].ToString(); } if (row["配送次数"] != null && row["配送次数"].ToString() != "") { model.配送次数 = int.Parse(row["配送次数"].ToString()); } if (row["备注"] != null) { model.备注 = row["备注"].ToString(); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(kyfly.Model.jichu_renyuanxinxiB model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into 基础_人员信息表("); strSql.Append("姓名,手机号,OpenId,密码,地址,状态,类别,权限,会员级别,配送次数,备注) values ("); strSql.Append("@姓名,@手机号,@OpenId,@密码,@地址,@状态,@类别,@权限,@会员级别,@配送次数,@备注)"); strSql.Append(";"); MySqlParameter[] parameters = { new MySqlParameter("@姓名", MySqlDbType.VarChar, 30), new MySqlParameter("@手机号", MySqlDbType.VarChar, 11), new MySqlParameter("@OpenId", MySqlDbType.VarChar, 30), new MySqlParameter("@密码", MySqlDbType.VarChar, 30), new MySqlParameter("@地址", MySqlDbType.VarChar, 100), new MySqlParameter("@状态", MySqlDbType.VarChar, 20), new MySqlParameter("@类别", MySqlDbType.VarChar, 20), new MySqlParameter("@权限", MySqlDbType.VarChar, 20), new MySqlParameter("@会员级别", MySqlDbType.VarChar, 20), new MySqlParameter("@配送次数", MySqlDbType.Int32, 11), new MySqlParameter("@备注", MySqlDbType.VarChar, 30) }; parameters[0].Value = model.姓名; parameters[1].Value = model.手机号; parameters[2].Value = model.OpenId; parameters[3].Value = model.密码; parameters[4].Value = model.地址; parameters[5].Value = model.状态; parameters[6].Value = model.类别; parameters[7].Value = model.权限; parameters[8].Value = model.会员级别; parameters[9].Value = model.配送次数; parameters[10].Value = model.备注; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(rows); } else { return(0); } }