Exemplo n.º 1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.CodeData DataRowToModel(DataRow row)
 {
     Maticsoft.Model.CodeData model=new Maticsoft.Model.CodeData();
     if (row != null)
     {
         if(row["Code"]!=null)
         {
             model.Code=row["Code"].ToString();
         }
         if(row["Remark"]!=null)
         {
             model.Remark=row["Remark"].ToString();
         }
         if(row["IsValidated"]!=null && row["IsValidated"].ToString()!="")
         {
             if((row["IsValidated"].ToString()=="1")||(row["IsValidated"].ToString().ToLower()=="true"))
             {
                 model.IsValidated=true;
             }
             else
             {
                 model.IsValidated=false;
             }
         }
         if(row["ValidatedTime"]!=null && row["ValidatedTime"].ToString()!="")
         {
             model.ValidatedTime=DateTime.Parse(row["ValidatedTime"].ToString());
         }
         if(row["IsExchanged"]!=null && row["IsExchanged"].ToString()!="")
         {
             if((row["IsExchanged"].ToString()=="1")||(row["IsExchanged"].ToString().ToLower()=="true"))
             {
                 model.IsExchanged=true;
             }
             else
             {
                 model.IsExchanged=false;
             }
         }
         if(row["ExchangeTime"]!=null && row["ExchangeTime"].ToString()!="")
         {
             model.ExchangeTime=DateTime.Parse(row["ExchangeTime"].ToString());
         }
         if(row["PhoneNumber"]!=null)
         {
             model.PhoneNumber=row["PhoneNumber"].ToString();
         }
     }
     return model;
 }
Exemplo n.º 2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.CodeData GetModel(string Code)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 Code,Remark,IsValidated,ValidatedTime,IsExchanged,ExchangeTime,PhoneNumber from CodeData ");
            strSql.Append(" where Code=@Code ");
            SqlParameter[] parameters = {
                    new SqlParameter("@Code", SqlDbType.NVarChar,50)			};
            parameters[0].Value = Code;

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