Esempio n. 1
0
        /// <summary>
        /// 根据DataTable转换成List对象数组
        /// </summary>
        public List <MultiColorPen.Model.b_promotions> DataTableToList(DataTable dt)
        {
            List <MultiColorPen.Model.b_promotions> modelList = new List <MultiColorPen.Model.b_promotions>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                MultiColorPen.Model.b_promotions model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new MultiColorPen.Model.b_promotions();
                    if (dt.Rows[n]["id"].ToString() != "")
                    {
                        model.id = int.Parse(dt.Rows[n]["id"].ToString());
                    }
                    model.promotioncode = dt.Rows[n]["promotioncode"].ToString();
                    model.caragentcode  = dt.Rows[n]["caragentcode"].ToString();
                    model.caragentname  = dt.Rows[n]["caragentname"].ToString();
                    model.brandcode     = dt.Rows[n]["brandcode"].ToString();
                    model.brandname     = dt.Rows[n]["brandname"].ToString();
                    model.seriescode    = dt.Rows[n]["seriescode"].ToString();
                    model.seriesname    = dt.Rows[n]["seriesname"].ToString();
                    model.title         = dt.Rows[n]["title"].ToString();
                    model.detail        = dt.Rows[n]["detail"].ToString();
                    model.url           = dt.Rows[n]["url"].ToString();
                    model.keywords      = dt.Rows[n]["keywords"].ToString();
                    if (dt.Rows[n]["begintime"].ToString() != "")
                    {
                        model.begintime = DateTime.Parse(dt.Rows[n]["begintime"].ToString());
                    }
                    if (dt.Rows[n]["endtime"].ToString() != "")
                    {
                        model.endtime = DateTime.Parse(dt.Rows[n]["endtime"].ToString());
                    }
                    if (dt.Rows[n]["isenable"].ToString() != "")
                    {
                        model.isenable = int.Parse(dt.Rows[n]["isenable"].ToString());
                    }
                    if (dt.Rows[n]["sort"].ToString() != "")
                    {
                        model.sort = int.Parse(dt.Rows[n]["sort"].ToString());
                    }
                    model.remark = dt.Rows[n]["remark"].ToString();
                    if (dt.Rows[n]["createtime"].ToString() != "")
                    {
                        model.createtime = DateTime.Parse(dt.Rows[n]["createtime"].ToString());
                    }
                    model.createman = dt.Rows[n]["createman"].ToString();
                    if (dt.Rows[n]["updatetime"].ToString() != "")
                    {
                        model.updatetime = DateTime.Parse(dt.Rows[n]["updatetime"].ToString());
                    }
                    model.updateman = dt.Rows[n]["updateman"].ToString();


                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Esempio n. 2
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public int Update(MultiColorPen.Model.b_promotions model)
 {
     return(dal.Update(model) ? 1 : 0);
 }
Esempio n. 3
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(MultiColorPen.Model.b_promotions model)
 {
     return(dal.Add(model)?1:0);
 }