/// <summary> /// 得到一个对象实体 /// </summary> public Model.user_groups GetModel(int id, int articleid) { string strWhere = string.Format("article_id={0} AND t1.id={1}", articleid, id); StringBuilder strSql = new StringBuilder(); strSql.Append("SELECT t1.id, title, grade, upgrade_exp, amount, point, discount, is_default, is_upgrade, is_lock,article_id,price FROM dbo.dt_user_groups t1 "); strSql.Append(" LEFT JOIN dbo.dt_user_group_price t2 ON t1.id = t2.group_id"); strSql.Append(" where " + strWhere); BuysingooShop.Model.user_groups model = new BuysingooShop.Model.user_groups(); DataSet ds = DbHelperSQL.Query(strSql.ToString()); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "") { model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } if (ds.Tables[0].Rows[0]["title"] != null && ds.Tables[0].Rows[0]["title"].ToString() != "") { model.title = ds.Tables[0].Rows[0]["title"].ToString(); } if (ds.Tables[0].Rows[0]["grade"] != null && ds.Tables[0].Rows[0]["grade"].ToString() != "") { model.grade = int.Parse(ds.Tables[0].Rows[0]["grade"].ToString()); } if (ds.Tables[0].Rows[0]["upgrade_exp"] != null && ds.Tables[0].Rows[0]["upgrade_exp"].ToString() != "") { model.upgrade_exp = int.Parse(ds.Tables[0].Rows[0]["upgrade_exp"].ToString()); } if (ds.Tables[0].Rows[0]["amount"] != null && ds.Tables[0].Rows[0]["amount"].ToString() != "") { model.amount = decimal.Parse(ds.Tables[0].Rows[0]["amount"].ToString()); } if (ds.Tables[0].Rows[0]["point"] != null && ds.Tables[0].Rows[0]["point"].ToString() != "") { model.point = int.Parse(ds.Tables[0].Rows[0]["point"].ToString()); } if (ds.Tables[0].Rows[0]["discount"] != null && ds.Tables[0].Rows[0]["discount"].ToString() != "") { model.discount = int.Parse(ds.Tables[0].Rows[0]["discount"].ToString()); } if (ds.Tables[0].Rows[0]["is_default"] != null && ds.Tables[0].Rows[0]["is_default"].ToString() != "") { model.is_default = int.Parse(ds.Tables[0].Rows[0]["is_default"].ToString()); } if (ds.Tables[0].Rows[0]["is_upgrade"] != null && ds.Tables[0].Rows[0]["is_upgrade"].ToString() != "") { model.is_upgrade = int.Parse(ds.Tables[0].Rows[0]["is_upgrade"].ToString()); } if (ds.Tables[0].Rows[0]["is_lock"] != null && ds.Tables[0].Rows[0]["is_lock"].ToString() != "") { model.is_lock = int.Parse(ds.Tables[0].Rows[0]["is_lock"].ToString()); } if (ds.Tables[0].Rows[0]["article_id"] != null && ds.Tables[0].Rows[0]["article_id"].ToString() != "") { model.article_id = int.Parse(ds.Tables[0].Rows[0]["article_id"].ToString()); } if (ds.Tables[0].Rows[0]["price"] != null && ds.Tables[0].Rows[0]["price"].ToString() != "") { model.price = decimal.Parse(ds.Tables[0].Rows[0]["price"].ToString()); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.user_groups GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,title,grade,upgrade_exp,amount,point,discount,is_default,is_upgrade,is_lock from " + databaseprefix + "user_groups "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; BuysingooShop.Model.user_groups model = new BuysingooShop.Model.user_groups(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { #region 主表信息 if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "") { model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } if (ds.Tables[0].Rows[0]["title"] != null && ds.Tables[0].Rows[0]["title"].ToString() != "") { model.title = ds.Tables[0].Rows[0]["title"].ToString(); } if (ds.Tables[0].Rows[0]["grade"] != null && ds.Tables[0].Rows[0]["grade"].ToString() != "") { model.grade = int.Parse(ds.Tables[0].Rows[0]["grade"].ToString()); } if (ds.Tables[0].Rows[0]["upgrade_exp"] != null && ds.Tables[0].Rows[0]["upgrade_exp"].ToString() != "") { model.upgrade_exp = int.Parse(ds.Tables[0].Rows[0]["upgrade_exp"].ToString()); } if (ds.Tables[0].Rows[0]["amount"] != null && ds.Tables[0].Rows[0]["amount"].ToString() != "") { model.amount = decimal.Parse(ds.Tables[0].Rows[0]["amount"].ToString()); } if (ds.Tables[0].Rows[0]["point"] != null && ds.Tables[0].Rows[0]["point"].ToString() != "") { model.point = int.Parse(ds.Tables[0].Rows[0]["point"].ToString()); } if (ds.Tables[0].Rows[0]["discount"] != null && ds.Tables[0].Rows[0]["discount"].ToString() != "") { model.discount = int.Parse(ds.Tables[0].Rows[0]["discount"].ToString()); } if (ds.Tables[0].Rows[0]["is_default"] != null && ds.Tables[0].Rows[0]["is_default"].ToString() != "") { model.is_default = int.Parse(ds.Tables[0].Rows[0]["is_default"].ToString()); } if (ds.Tables[0].Rows[0]["is_upgrade"] != null && ds.Tables[0].Rows[0]["is_upgrade"].ToString() != "") { model.is_upgrade = int.Parse(ds.Tables[0].Rows[0]["is_upgrade"].ToString()); } if (ds.Tables[0].Rows[0]["is_lock"] != null && ds.Tables[0].Rows[0]["is_lock"].ToString() != "") { model.is_lock = int.Parse(ds.Tables[0].Rows[0]["is_lock"].ToString()); } #endregion return(model); } else { return(null); } }