示例#1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Model.Pchannel DataRowToModel(DataRow row)
 {
     Model.Pchannel model = new Model.Pchannel();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["CatalogID"] != null && row["CatalogID"].ToString() != "")
         {
             model.CatalogID = int.Parse(row["CatalogID"].ToString());
         }
         if (row["Title"] != null)
         {
             model.Title = row["Title"].ToString();
         }
         if (row["ParentId"] != null && row["ParentId"].ToString() != "")
         {
             model.ParentId = int.Parse(row["ParentId"].ToString());
         }
         if (row["ClassList"] != null)
         {
             model.ClassList = row["ClassList"].ToString();
         }
         if (row["ClassLayer"] != null && row["ClassLayer"].ToString() != "")
         {
             model.ClassLayer = int.Parse(row["ClassLayer"].ToString());
         }
         if (row["UserID"] != null && row["UserID"].ToString() != "")
         {
             model.UserID = int.Parse(row["UserID"].ToString());
         }
         if (row["IsShow"] != null && row["IsShow"].ToString() != "")
         {
             if ((row["IsShow"].ToString() == "1") || (row["IsShow"].ToString().ToLower() == "true"))
             {
                 model.IsShow = true;
             }
             else
             {
                 model.IsShow = false;
             }
         }
         if (row["IsLock"] != null && row["IsLock"].ToString() != "")
         {
             if ((row["IsLock"].ToString() == "1") || (row["IsLock"].ToString().ToLower() == "true"))
             {
                 model.IsLock = true;
             }
             else
             {
                 model.IsLock = false;
             }
         }
         if (row["IsMenu"] != null && row["IsMenu"].ToString() != "")
         {
             if ((row["IsMenu"].ToString() == "1") || (row["IsMenu"].ToString().ToLower() == "true"))
             {
                 model.IsMenu = true;
             }
             else
             {
                 model.IsMenu = false;
             }
         }
         if (row["Name"] != null)
         {
             model.Name = row["Name"].ToString();
         }
         if (row["Url"] != null)
         {
             model.Url = row["Url"].ToString();
         }
         if (row["status"] != null && row["status"].ToString() != "")
         {
             model.Status = int.Parse(row["status"].ToString());
         }
         if (row["Bak1"] != null)
         {
             model.Bak1 = row["Bak1"].ToString();
         }
         if (row["Bak2"] != null)
         {
             model.Bak2 = row["Bak2"].ToString();
         }
         if (row["Bak3"] != null)
         {
             model.Bak3 = row["Bak3"].ToString();
         }
         if (row["Bak4"] != null)
         {
             model.Bak4 = row["Bak4"].ToString();
         }
     }
     return model;
 }
示例#2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.Pchannel GetModel(int ID)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 ID,CatalogID,Title,ParentId,ClassList,ClassLayer,UserID,IsShow,IsLock,IsMenu,Name,Url,status,Bak1,Bak2,Bak3,Bak4 from Pchannel ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters = {
					new SqlParameter("@ID", SqlDbType.Int,4)
			};
            parameters[0].Value = ID;

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