Esempio n. 1
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <dbamet.Model.Resourse> DataTableToList(DataTable dt)
        {
            List <dbamet.Model.Resourse> modelList = new List <dbamet.Model.Resourse>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                dbamet.Model.Resourse model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new dbamet.Model.Resourse();
                    if (dt.Rows[n]["resourceId"] != null && dt.Rows[n]["resourceId"].ToString() != "")
                    {
                        model.resourceId = int.Parse(dt.Rows[n]["resourceId"].ToString());
                    }
                    if (dt.Rows[n]["customId"] != null && dt.Rows[n]["customId"].ToString() != "")
                    {
                        model.customId = dt.Rows[n]["customId"].ToString();
                    }
                    if (dt.Rows[n]["resourceName"] != null && dt.Rows[n]["resourceName"].ToString() != "")
                    {
                        model.resourceName = dt.Rows[n]["resourceName"].ToString();
                    }
                    if (dt.Rows[n]["resourcePath"] != null && dt.Rows[n]["resourcePath"].ToString() != "")
                    {
                        model.resourcePath = dt.Rows[n]["resourcePath"].ToString();
                    }
                    if (dt.Rows[n]["resourceType"] != null && dt.Rows[n]["resourceType"].ToString() != "")
                    {
                        model.resourceType = dt.Rows[n]["resourceType"].ToString();
                    }
                    if (dt.Rows[n]["category"] != null && dt.Rows[n]["category"].ToString() != "")
                    {
                        model.category = dt.Rows[n]["category"].ToString();
                    }
                    if (dt.Rows[n]["size"] != null && dt.Rows[n]["size"].ToString() != "")
                    {
                        model.size = dt.Rows[n]["size"].ToString();
                    }
                    if (dt.Rows[n]["info"] != null && dt.Rows[n]["info"].ToString() != "")
                    {
                        model.info = dt.Rows[n]["info"].ToString();
                    }
                    if (dt.Rows[n]["uploadTime"] != null && dt.Rows[n]["uploadTime"].ToString() != "")
                    {
                        model.uploadTime = DateTime.Parse(dt.Rows[n]["uploadTime"].ToString());
                    }
                    if (dt.Rows[n]["downloadTimes"] != null && dt.Rows[n]["downloadTimes"].ToString() != "")
                    {
                        model.downloadTimes = int.Parse(dt.Rows[n]["downloadTimes"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Esempio n. 2
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(dbamet.Model.Resourse model)
 {
     return(dal.Update(model));
 }
Esempio n. 3
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(dbamet.Model.Resourse model)
 {
     return(dal.Add(model));
 }