예제 #1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public webs_YueyxShop.Model.ShoppingCartBase GetModel(int sc_ID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 sc_ID,sku_ID,m_ID,sc_pCount,sc_pPric,sc_CreateOn,sc_IsDel,sc_Status,sc_IsGP,sc_chima,sc_yanse from ShoppingCartBase ");
            strSql.Append(" where sc_ID=@sc_ID");
            SqlParameter[] parameters = {
                    new SqlParameter("@sc_ID", SqlDbType.Int,4)
            };
            parameters[0].Value = sc_ID;

            webs_YueyxShop.Model.ShoppingCartBase model = new webs_YueyxShop.Model.ShoppingCartBase();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }
예제 #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public webs_YueyxShop.Model.ShoppingCartBase DataRowToModel(DataRow row)
 {
     webs_YueyxShop.Model.ShoppingCartBase model = new webs_YueyxShop.Model.ShoppingCartBase();
     if (row != null)
     {
         if (row["sc_ID"] != null && row["sc_ID"].ToString() != "")
         {
             model.sc_ID = int.Parse(row["sc_ID"].ToString());
         }
         if (row["sku_ID"] != null && row["sku_ID"].ToString() != "")
         {
             model.sku_ID = int.Parse(row["sku_ID"].ToString());
         }
         if (row["m_ID"] != null && row["m_ID"].ToString() != "")
         {
             model.m_ID = int.Parse(row["m_ID"].ToString());
         }
         if (row["sc_pCount"] != null && row["sc_pCount"].ToString() != "")
         {
             model.sc_pCount = int.Parse(row["sc_pCount"].ToString());
         }
         if (row["sc_pPric"] != null && row["sc_pPric"].ToString() != "")
         {
             model.sc_pPric = decimal.Parse(row["sc_pPric"].ToString());
         }
         if (row["sc_CreateOn"] != null && row["sc_CreateOn"].ToString() != "")
         {
             model.sc_CreateOn = DateTime.Parse(row["sc_CreateOn"].ToString());
         }
         if (row["sc_IsDel"] != null && row["sc_IsDel"].ToString() != "")
         {
             if ((row["sc_IsDel"].ToString() == "1") || (row["sc_IsDel"].ToString().ToLower() == "true"))
             {
                 model.sc_IsDel = true;
             }
             else
             {
                 model.sc_IsDel = false;
             }
         }
         if (row["sc_Status"] != null && row["sc_Status"].ToString() != "")
         {
             if ((row["sc_Status"].ToString() == "1") || (row["sc_Status"].ToString().ToLower() == "true"))
             {
                 model.sc_Status = true;
             }
             else
             {
                 model.sc_Status = false;
             }
         }
         if (row["sc_IsGP"] != null && row["sc_IsGP"].ToString() != "")
         {
             if ((row["sc_IsGP"].ToString() == "1") || (row["sc_IsGP"].ToString().ToLower() == "true"))
             {
                 model.sc_IsGP = true;
             }
             else
             {
                 model.sc_IsGP = false;
             }
         }
         if (row["sc_chima"] != null && row["sc_chima"].ToString() != "")
         {
             model.sc_chima = row["sc_chima"].ToString();
         }
         if (row["sc_yanse"] != null && row["sc_yanse"].ToString() != "")
         {
             model.sc_yanse = row["sc_yanse"].ToString();
         }
     }
     return model;
 }