/// <summary> /// 更新一条数据 /// </summary> public bool Update(userStateEntity model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update userState set "); strSql.Append("us_state=@us_state,"); strSql.Append("us_name=@us_name"); strSql.Append(" where "); SqlParameter[] parameters = { new SqlParameter("@us_state", SqlDbType.NVarChar, 50), new SqlParameter("@us_name", SqlDbType.NVarChar, 50) }; parameters[0].Value = model.us_state; parameters[1].Value = model.us_name; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public userStateEntity DataRowToModel(DataRow row) { userStateEntity model = new userStateEntity(); if (row != null) { if (row["us_state"] != null) { model.us_state = row["us_state"].ToString(); } if (row["us_name"] != null) { model.us_name = row["us_name"].ToString(); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public userStateEntity GetModel() { //该表无主键信息,请自定义主键/条件字段 StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 us_state,us_name from userState "); strSql.Append(" where "); SqlParameter[] parameters = { }; userStateEntity model = new userStateEntity(); 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(userStateEntity model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(userStateEntity model) { return(dal.Add(model)); }