/// <summary> /// 更新一条数据 /// </summary> public bool Update(SoilNutrientSoft.Model.UserInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update UserInfo set "); strSql.Append("UserId=@UserId,"); strSql.Append("UserPassword=@UserPassword,"); strSql.Append("GuidLicense=@GuidLicense"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@UserId", SqlDbType.NVarChar, 100), new SqlParameter("@UserPassword", SqlDbType.NVarChar, 100), new SqlParameter("@GuidLicense", SqlDbType.NVarChar, 100), new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = model.UserId; parameters[1].Value = model.UserPassword; parameters[2].Value = model.GuidLicense; parameters[3].Value = model.id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(SoilNutrientSoft.Model.UserInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into UserInfo("); strSql.Append("UserId,UserPassword,GuidLicense)"); strSql.Append(" values ("); strSql.Append("@UserId,@UserPassword,@GuidLicense)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@UserId", SqlDbType.NVarChar, 100), new SqlParameter("@UserPassword", SqlDbType.NVarChar, 100), new SqlParameter("@GuidLicense", SqlDbType.NVarChar, 100) }; parameters[0].Value = model.UserId; parameters[1].Value = model.UserPassword; parameters[2].Value = model.GuidLicense; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public SoilNutrientSoft.Model.UserInfo DataRowToModel(DataRow row) { SoilNutrientSoft.Model.UserInfo model = new SoilNutrientSoft.Model.UserInfo(); if (row != null) { if (row["id"] != null && row["id"].ToString() != "") { model.id = int.Parse(row["id"].ToString()); } if (row["UserId"] != null) { model.UserId = row["UserId"].ToString(); } if (row["UserPassword"] != null) { model.UserPassword = row["UserPassword"].ToString(); } if (row["GuidLicense"] != null) { model.GuidLicense = row["GuidLicense"].ToString(); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public SoilNutrientSoft.Model.UserInfo GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,UserId,UserPassword,GuidLicense from UserInfo "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; SoilNutrientSoft.Model.UserInfo model = new SoilNutrientSoft.Model.UserInfo(); DataSet ds = DbHelperSQL.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(SoilNutrientSoft.Model.UserInfo model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(SoilNutrientSoft.Model.UserInfo model) { return(dal.Add(model)); }