Exemplo n.º 1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Model.Regional DataRowToModel(DataRow row)
 {
     Model.Regional model=new Model.Regional();
     if (row != null)
     {
         if (row["RegionalID"] != null)
         {
             model.RegionalID = row["RegionalID"].ToString();
         }
         if(row["RegionalName"]!=null)
         {
             model.RegionalName=row["RegionalName"].ToString();
         }
         if(row["RegionalCode"]!=null)
         {
             model.RegionalCode=row["RegionalCode"].ToString();
         }
         if(row["SubRegionalID"]!=null)
         {
             model.SubRegionalID=row["SubRegionalID"].ToString();
         }
         if(row["RegionalLevel"]!=null)
         {
             model.RegionalLevel=row["RegionalLevel"].ToString();
         }
         if (row["Orders"] != null)
         {
             model.Orders = int.Parse(row["Orders"].ToString());
         }
         if(row["LastModifyTime"]!=null && row["LastModifyTime"].ToString()!="")
         {
             model.LastModifyTime=DateTime.Parse(row["LastModifyTime"].ToString());
         }
         if(row["IsValid"]!=null && row["IsValid"].ToString()!="")
         {
             if((row["IsValid"].ToString()=="1")||(row["IsValid"].ToString().ToLower()=="true"))
             {
                 model.IsValid=true;
             }
             else
             {
                 model.IsValid=false;
             }
         }
         if(row["Memo"]!=null)
         {
             model.Memo=row["Memo"].ToString();
         }
     }
     return model;
 }
Exemplo n.º 2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.Regional GetModel(string RegionalID)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select RegionalID,RegionalName,RegionalCode,SubRegionalID,RegionalLevel,Orders,LastModifyTime,IsValid,Memo from regional ");
            strSql.Append(" where RegionalID=@RegionalID limit 1");
            MySqlParameter[] parameters = {
                    new MySqlParameter("@RegionalID", MySqlDbType.VarChar,50)
            };
            parameters[0].Value = RegionalID;

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