Example #1
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Light.Model.cityinfo> DataTableToList(DataTable dt)
        {
            List<Light.Model.cityinfo> modelList = new List<Light.Model.cityinfo>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Light.Model.cityinfo model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Light.Model.cityinfo();
                                                    if(dt.Rows[n]["id"].ToString()!="")
                {
                    model.id=int.Parse(dt.Rows[n]["id"].ToString());
                }
                                                                                                                                if(dt.Rows[n]["regionid"].ToString()!="")
                {
                    model.regionid=int.Parse(dt.Rows[n]["regionid"].ToString());
                }
                                                                                                                                                model.cityname= dt.Rows[n]["cityname"].ToString();
                                                                                                                if(dt.Rows[n]["creatman"].ToString()!="")
                {
                    model.creatman=int.Parse(dt.Rows[n]["creatman"].ToString());
                }
                                                                                                                                if(dt.Rows[n]["creattime"].ToString()!="")
                {
                    model.creattime=DateTime.Parse(dt.Rows[n]["creattime"].ToString());
                }
                                                                                                                                                model.remark= dt.Rows[n]["remark"].ToString();

                    modelList.Add(model);
                }
            }
            return modelList;
        }
Example #2
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <Light.Model.cityinfo> DataTableToList(DataTable dt)
        {
            List <Light.Model.cityinfo> modelList = new List <Light.Model.cityinfo>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                Light.Model.cityinfo model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Light.Model.cityinfo();
                    if (dt.Rows[n]["id"].ToString() != "")
                    {
                        model.id = int.Parse(dt.Rows[n]["id"].ToString());
                    }
                    if (dt.Rows[n]["regionid"].ToString() != "")
                    {
                        model.regionid = int.Parse(dt.Rows[n]["regionid"].ToString());
                    }
                    model.cityname = dt.Rows[n]["cityname"].ToString();
                    if (dt.Rows[n]["creatman"].ToString() != "")
                    {
                        model.creatman = int.Parse(dt.Rows[n]["creatman"].ToString());
                    }
                    if (dt.Rows[n]["creattime"].ToString() != "")
                    {
                        model.creattime = DateTime.Parse(dt.Rows[n]["creattime"].ToString());
                    }
                    model.remark = dt.Rows[n]["remark"].ToString();


                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Example #3
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Light.Model.cityinfo model)
 {
     return(dal.Update(model));
 }
Example #4
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public void  Add(Light.Model.cityinfo model)
 {
     dal.Add(model);
 }