Ejemplo n.º 1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public TextileCity.Entity.Category DataRowToModel(DataRow row)
        {
            TextileCity.Entity.Category model=new TextileCity.Entity.Category();

            if (row != null)
            {
                foreach (DataColumn col in row.Table.Columns)
                {
                    if (row[col] != null && row[col].ToString() != "")
                    {
                        switch (col.ColumnName)
                        {
                            case "id":
                                model.CategoryID = int.Parse(row[col].ToString());
                                break;
                            case "parentid":
                                model.ParentID = int.Parse(row["parentid"].ToString());
                                break;
                            case "name":
                                model.Name = row["name"].ToString();
                                break;
                            case "type":
                                model.Type = row["type"].ToString();
                                break;
                            case "order_index":
                                model.OrderIndex = int.Parse(row["order_index"].ToString());
                                break;
                        }
                    }
                    //if (row["id"] != null && row["id"].ToString() != "")
                    //{
                    //    model.CategoryID = int.Parse(row["id"].ToString());
                    //}
                    //if (row["parentid"] != null && row["parentid"].ToString() != "")
                    //{
                    //    model.ParentID = int.Parse(row["parentid"].ToString());
                    //}
                    //if (row["name"] != null)
                    //{
                    //    model.Name = row["name"].ToString();
                    //}
                    //if (row["type"] != null)
                    //{
                    //    model.Type = row["type"].ToString();
                    //}
                    //if (row["order_index"] != null && row["order_index"].ToString() != "")
                    //{
                    //    model.OrderIndex = int.Parse(row["order_index"].ToString());
                    //}
                }
            }
            return model;
        }
Ejemplo n.º 2
0
 public List<Material> GetMaterialsMin(int categoryID, int page, out int count)
 {
     count = 0;
     List<Material> materials = new List<Material>();
     DataSet ds = null;
     Category category = new Category();
     CategoryOperation cop = new CategoryOperation();
     category = cop.GetModel(categoryID);
     if (category != null)
     {
         if (category.ParentID == 0)
         {
             List<int> ids = cop.GetChildIdList(category.CategoryID);
             ds = dal.GetMaterialsMin(ids, page, Common.TextileConfig.MaterialPageSize, out count);
         }
         else
         {
             ds = dal.GetMaterialsMin(categoryID, page, Common.TextileConfig.MaterialPageSize, out count);
         }
         if (ds != null && ds.Tables.Count > 0)
         {
             materials = DataTableToList(ds.Tables[0]);
         }
     }
     return materials;
 }
Ejemplo n.º 3
0
        public TextileCity.Entity.Category GetTopParentModel(string categoryType)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select id,parentid,name,type,order_index from category ");
            strSql.Append(" where type=?type and parentid = 0 order by order_index asc limit 0,1  ");
            MySqlParameter[] parameters = {
                    new MySqlParameter("?type", MySqlDbType.Enum)
            };

            parameters[0].Value = categoryType;

            TextileCity.Entity.Category model = new TextileCity.Entity.Category();
            DataSet ds = MysqlHelper.ExecuteDataSet(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public TextileCity.Entity.Category GetModel(int id)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select id,parentid,name,type,order_index from category ");
            strSql.Append(" where id=?id");
            MySqlParameter[] parameters = {
                    new MySqlParameter("?id", MySqlDbType.Int32)
            };

            parameters[0].Value = id;

            TextileCity.Entity.Category model=new TextileCity.Entity.Category();
            DataSet ds=MysqlHelper.ExecuteDataSet(strSql.ToString(),parameters);
            if(ds.Tables[0].Rows.Count>0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(Category model)
 {
     return dal.Add(model);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Category model)
 {
     return dal.Update(model);
 }