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

            if (rowsCount > 0)
            {
                MultiColorPen.Model.b_msg model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new MultiColorPen.Model.b_msg();
                    if (dt.Rows[n]["id"].ToString() != "")
                    {
                        model.id = int.Parse(dt.Rows[n]["id"].ToString());
                    }
                    model.msgtypecode = dt.Rows[n]["msgtypecode"].ToString();
                    model.msgtypename = dt.Rows[n]["msgtypename"].ToString();
                    model.msgcode     = dt.Rows[n]["msgcode"].ToString();
                    model.title       = dt.Rows[n]["title"].ToString();
                    model.detail      = dt.Rows[n]["detail"].ToString();
                    model.url         = dt.Rows[n]["url"].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_msg model)
 {
     return(dal.Update(model) ? 1 : 0);
 }
Esempio n. 3
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(MultiColorPen.Model.b_msg model)
 {
     return(dal.Add(model)?1:0);
 }