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

            if (rowsCount > 0)
            {
                MultiColorPen.Model.base_userinfo model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new MultiColorPen.Model.base_userinfo();
                    if (dt.Rows[n]["id"].ToString() != "")
                    {
                        model.id = int.Parse(dt.Rows[n]["id"].ToString());
                    }
                    if (dt.Rows[n]["pid"].ToString() != "")
                    {
                        model.pid = int.Parse(dt.Rows[n]["pid"].ToString());
                    }
                    model.username = dt.Rows[n]["username"].ToString();
                    model.password = dt.Rows[n]["password"].ToString();
                    model.usercode = dt.Rows[n]["usercode"].ToString();
                    model.rolecode = dt.Rows[n]["rolecode"].ToString();
                    if (dt.Rows[n]["isenable"].ToString() != "")
                    {
                        model.isenable = int.Parse(dt.Rows[n]["isenable"].ToString());
                    }
                    model.pname = dt.Rows[n]["pname"].ToString();
                    model.sex   = dt.Rows[n]["sex"].ToString();
                    model.age   = dt.Rows[n]["age"].ToString();
                    if (dt.Rows[n]["birthday"].ToString() != "")
                    {
                        model.birthday = DateTime.Parse(dt.Rows[n]["birthday"].ToString());
                    }
                    model.phone  = dt.Rows[n]["phone"].ToString();
                    model.avatar = dt.Rows[n]["avatar"].ToString();
                    model.qq     = dt.Rows[n]["qq"].ToString();
                    model.wechat = dt.Rows[n]["wechat"].ToString();
                    model.email  = dt.Rows[n]["email"].ToString();
                    model.token  = dt.Rows[n]["token"].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);
        }
Beispiel #2
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public int Update(MultiColorPen.Model.base_userinfo model)
 {
     return(dal.Update(model) ? 1 : 0);
 }
Beispiel #3
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(MultiColorPen.Model.base_userinfo model)
 {
     return(dal.Add(model)?1:0);
 }