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

            if (rowsCount > 0)
            {
                ClassLibrary.Model.Customers model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new ClassLibrary.Model.Customers();
                    if (dt.Rows[n]["ID"].ToString() != "")
                    {
                        model.ID = int.Parse(dt.Rows[n]["ID"].ToString());
                    }
                    model.Name = dt.Rows[n]["Name"].ToString();
                    model.QQ   = dt.Rows[n]["QQ"].ToString();
                    if (dt.Rows[n]["QQorder"].ToString() != "")
                    {
                        model.QQorder = int.Parse(dt.Rows[n]["QQorder"].ToString());
                    }
                    if (dt.Rows[n]["CreatedTime"].ToString() != "")
                    {
                        model.CreatedTime = DateTime.Parse(dt.Rows[n]["CreatedTime"].ToString());
                    }
                    if (dt.Rows[n]["InUse"].ToString() != "")
                    {
                        if ((dt.Rows[n]["InUse"].ToString() == "1") || (dt.Rows[n]["InUse"].ToString().ToLower() == "true"))
                        {
                            model.InUse = true;
                        }
                        else
                        {
                            model.InUse = false;
                        }
                    }
                    if (dt.Rows[n]["QQtype"].ToString() != "")
                    {
                        model.QQtype = Convert.ToInt32(dt.Rows[n]["QQtype"].ToString());
                    }
                    model.Phone = dt.Rows[n]["Phone"].ToString();
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
コード例 #2
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(ClassLibrary.Model.Customers model)
 {
     return(dal.Update(model));
 }
コード例 #3
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(ClassLibrary.Model.Customers model)
 {
     return(dal.Add(model));
 }