using System; using System.Collections.Generic; using System.Linq; using System.Text; using Model; using System.Data.SqlClient; using System.Data; using Common; namespace DAL { public class ProclassServer { public DataSet GetAllModel(string strWhere, string filedOrder) { StringBuilder strSql = new StringBuilder(); strSql.Append("select "); strSql.Append(" * from productClass "); if (strWhere.Trim() != "") { strSql.Append(" where " + strWhere); } strSql.Append(" order by " + filedOrder); return DbHelperSQL.Query(strSql.ToString()); } public Model.ProClass GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from productClass "); strSql.Append(" where ClassID=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = id; Model.ProClass model = new Model.ProClass(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["ClassID"] != null && ds.Tables[0].Rows[0]["ClassID"].ToString() != "") { model.ClassID = int.Parse(ds.Tables[0].Rows[0]["ClassID"].ToString()); } if (ds.Tables[0].Rows[0]["ParentID"] != null && ds.Tables[0].Rows[0]["ParentID"].ToString() != "") { model.ParentID = int.Parse(ds.Tables[0].Rows[0]["ParentID"].ToString()); } if (ds.Tables[0].Rows[0]["ClassName"] != null && ds.Tables[0].Rows[0]["ClassName"].ToString() != "") { model.ClassName = ds.Tables[0].Rows[0]["ClassName"].ToString(); } if (ds.Tables[0].Rows[0]["D_Picture"] != null && ds.Tables[0].Rows[0]["D_Picture"].ToString() != "") { model.D_Picture = ds.Tables[0].Rows[0]["D_Picture"].ToString(); } return model; } else { return null; } } } } |
|