Exemplo n.º 1
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <ZhangWei.Model.Supplier> DataTableToList(DataTable dt)
        {
            List <ZhangWei.Model.Supplier> modelList = new List <ZhangWei.Model.Supplier>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                ZhangWei.Model.Supplier model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new ZhangWei.Model.Supplier();
                    if (dt.Rows[n]["Supplier_ID"] != null && dt.Rows[n]["Supplier_ID"].ToString() != "")
                    {
                        model.Supplier_ID = int.Parse(dt.Rows[n]["Supplier_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);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(ZhangWei.Model.Supplier model)
 {
     return(dal.Update(model));
 }
Exemplo n.º 3
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(ZhangWei.Model.Supplier model)
 {
     return(dal.Add(model));
 }