Exemplo n.º 1
0
 /// <summary>
 /// Loads a ProductCode object from the database using the given CodeId
 /// </summary>
 /// <param name="codeId">The primary key value</param>
 /// <returns>A ProductCode object</returns>
 public static ProductCode Load(Guid codeId)
 {
     SqlParameter[] parameterValues = new SqlParameter[] { new SqlParameter("@CodeId", codeId) };
     using (SqlDataReader reader = SqlHelper.Default.ExecuteReader("spProductCode_SelRec", parameterValues))
     {
         if (reader.Read())
         {
             ProductCode result = new ProductCode();
             result.LoadFromReader(reader);
             return(result);
         }
         else
         {
             return(null);
         }
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Loads a ProductCode object from the database using the given where clause
 /// </summary>
 /// <param name="whereClause">The filter expression for the query</param>
 /// <returns>A ProductCode object</returns>
 public static ProductCode LoadWhere(string whereClause)
 {
     SqlParameter[] parameterValues = new SqlParameter[] { new SqlParameter("@WhereClause", whereClause) };
     using (SqlDataReader reader = SqlHelper.Default.ExecuteReader("spProductCode_SelAll", parameterValues))
     {
         if (reader.Read())
         {
             ProductCode result = new ProductCode();
             result.LoadFromReader(reader);
             return(result);
         }
         else
         {
             return(null);
         }
     }
 }
Exemplo n.º 3
0
        private static bool IgnorThis(ProductCode target, string parentFilter)
        {
            bool result = true;

            parentFilter = parentFilter.Replace(" ", "");                       // remove spaces
            parentFilter = parentFilter.Replace("'", "");                       // remove '
            string [] parsed = parentFilter.Split('=');                         // parse

            if (target.ProductId == Guid.Empty)
            {
                PropertyInfo pi          = target.GetType().GetProperty(parsed[0]);
                string       filterField = (string)pi.GetValue(target, null);
                if (filterField.ToLower() == parsed[1].ToLower())
                {
                    result = false;
                }
            }
            else
            {
                ProductCode parentTemplate = ProductCode.Load(target.ProductId);
                result = IgnorThis(parentTemplate, parentFilter);
            }
            return(result);
        }