/// <summary> /// 得到一个对象实体 /// </summary> public static Model.AboutMenu DataRowToModel(DataRow row) { Model.AboutMenu model = new Model.AboutMenu(); if (row != null) { if (row["id"] != null && row["id"].ToString() != "") { model.id = int.Parse(row["id"].ToString()); } if (row["proName"] != null) { model.proName = row["proName"].ToString(); } if (row["proValue"] != null) { model.proValue = row["proValue"].ToString(); } if (row["infoType"] != null && row["infoType"].ToString() != "") { model.infoType = int.Parse(row["infoType"].ToString()); } if (row["remark"] != null) { model.remark = row["remark"].ToString(); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public static bool Update(Model.AboutMenu model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update AboutMenu set "); strSql.Append("proName=@proName,"); strSql.Append("proValue=@proValue,"); strSql.Append("infoType=@infoType,"); strSql.Append("remark=@remark"); strSql.Append(" where id=@id "); SqlParameter[] parameters = { new SqlParameter("@proName", SqlDbType.VarChar, 150), new SqlParameter("@proValue", SqlDbType.NText), new SqlParameter("@infoType", SqlDbType.Int, 4), new SqlParameter("@remark", SqlDbType.VarChar, 150), new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = model.proName; parameters[1].Value = model.proValue; parameters[2].Value = model.infoType; parameters[3].Value = model.remark; parameters[4].Value = model.id; int rows = DBHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public static bool Add(Model.AboutMenu model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into AboutMenu("); strSql.Append("proName,proValue,infoType,remark)"); strSql.Append(" values ("); strSql.Append("@proName,@proValue,@infoType,@remark)"); SqlParameter[] parameters = { new SqlParameter("@proName", SqlDbType.VarChar, 150), new SqlParameter("@proValue", SqlDbType.NText), new SqlParameter("@infoType", SqlDbType.Int, 4), new SqlParameter("@remark", SqlDbType.VarChar, 150) }; parameters[0].Value = model.proName; parameters[1].Value = model.proValue; parameters[2].Value = model.infoType; parameters[3].Value = model.remark; int rows = DBHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public static Model.AboutMenu GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,proName,proValue,infoType,remark from AboutMenu "); strSql.Append(" where id=@id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; Model.AboutMenu model = new Model.AboutMenu(); DataSet ds = DBHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }