Ejemplo n.º 1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.District DataRowToModel(DataRow row)
 {
     Maticsoft.Model.District model=new Maticsoft.Model.District();
     if (row != null)
     {
         if(row["DistrictID"]!=null)
         {
             model.DistrictID=row["DistrictID"].ToString();
         }
         if(row["DistrictName"]!=null)
         {
             model.DistrictName=row["DistrictName"].ToString();
         }
         if(row["CityID"]!=null)
         {
             model.CityID=row["CityID"].ToString();
         }
         if(row["SortID"]!=null && row["SortID"].ToString()!="")
         {
             model.SortID=int.Parse(row["SortID"].ToString());
         }
     }
     return model;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.District GetModel(string DistrictID)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 DistrictID,DistrictName,CityID,SortID from District ");
            strSql.Append(" where DistrictID=@DistrictID ");
            SqlParameter[] parameters = {
                    new SqlParameter("@DistrictID", SqlDbType.NVarChar,50)			};
            parameters[0].Value = DistrictID;

            Maticsoft.Model.District model=new Maticsoft.Model.District();
            DataSet ds=ServerDbHelperSQL.Query(strSql.ToString(),parameters);
            if(ds.Tables[0].Rows.Count>0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }