Пример #1
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <ZhangWei.Model.Customer> DataTableToList(DataTable dt)
        {
            List <ZhangWei.Model.Customer> modelList = new List <ZhangWei.Model.Customer>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                ZhangWei.Model.Customer model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new ZhangWei.Model.Customer();
                    if (dt.Rows[n]["Customer_ID"] != null && dt.Rows[n]["Customer_ID"].ToString() != "")
                    {
                        model.Customer_ID = int.Parse(dt.Rows[n]["Customer_ID"].ToString());
                    }
                    if (dt.Rows[n]["Name"] != null && dt.Rows[n]["Name"].ToString() != "")
                    {
                        model.Name = dt.Rows[n]["Name"].ToString();
                    }
                    if (dt.Rows[n]["Address"] != null && dt.Rows[n]["Address"].ToString() != "")
                    {
                        model.Address = dt.Rows[n]["Address"].ToString();
                    }
                    if (dt.Rows[n]["Phone"] != null && dt.Rows[n]["Phone"].ToString() != "")
                    {
                        model.Phone = dt.Rows[n]["Phone"].ToString();
                    }
                    if (dt.Rows[n]["Fax"] != null && dt.Rows[n]["Fax"].ToString() != "")
                    {
                        model.Fax = dt.Rows[n]["Fax"].ToString();
                    }
                    if (dt.Rows[n]["PostalCode"] != null && dt.Rows[n]["PostalCode"].ToString() != "")
                    {
                        model.PostalCode = dt.Rows[n]["PostalCode"].ToString();
                    }
                    if (dt.Rows[n]["ConstactPerson"] != null && dt.Rows[n]["ConstactPerson"].ToString() != "")
                    {
                        model.ConstactPerson = dt.Rows[n]["ConstactPerson"].ToString();
                    }
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Пример #2
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(ZhangWei.Model.Customer model)
 {
     return(dal.Update(model));
 }
Пример #3
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(ZhangWei.Model.Customer model)
 {
     return(dal.Add(model));
 }