コード例 #1
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <Hownet.Model.BAS_Country> DataTableToList(DataTable dt)
        {
            List <Hownet.Model.BAS_Country> modelList = new List <Hownet.Model.BAS_Country>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                Hownet.Model.BAS_Country model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model        = new Hownet.Model.BAS_Country();
                    model.Code   = dt.Rows[n]["Code"].ToString();
                    model.EnName = dt.Rows[n]["EnName"].ToString();
                    model.CnName = dt.Rows[n]["CnName"].ToString();
                    if (dt.Rows[n]["RegionID"] != null && dt.Rows[n]["RegionID"].ToString() != "")
                    {
                        model.RegionID = int.Parse(dt.Rows[n]["RegionID"].ToString());
                    }
                    if (dt.Rows[n]["IsDef"] != null && dt.Rows[n]["IsDef"].ToString() != "")
                    {
                        if ((dt.Rows[n]["IsDef"].ToString() == "1") || (dt.Rows[n]["IsDef"].ToString().ToLower() == "true"))
                        {
                            model.IsDef = true;
                        }
                        else
                        {
                            model.IsDef = false;
                        }
                    }
                    if (dt.Rows[n]["IsValid"] != null && dt.Rows[n]["IsValid"].ToString() != "")
                    {
                        if ((dt.Rows[n]["IsValid"].ToString() == "1") || (dt.Rows[n]["IsValid"].ToString().ToLower() == "true"))
                        {
                            model.IsValid = true;
                        }
                        else
                        {
                            model.IsValid = false;
                        }
                    }
                    model.CreditRank = dt.Rows[n]["CreditRank"].ToString();
                    if (dt.Rows[n]["ID"] != null && dt.Rows[n]["ID"].ToString() != "")
                    {
                        model.ID = int.Parse(dt.Rows[n]["ID"].ToString());
                    }
                    if (dt.Rows[n]["IsEnd"] != null && dt.Rows[n]["IsEnd"].ToString() != "")
                    {
                        model.IsEnd = int.Parse(dt.Rows[n]["IsEnd"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
コード例 #2
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Hownet.Model.BAS_Country model)
 {
     return(dal.Update(model));
 }
コード例 #3
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(Hownet.Model.BAS_Country model)
 {
     return(dal.Add(model));
 }