Example #1
0
 private static void FillData(SupplierManager SupplierData, DataRow dr)
 {
     Type tp = typeof(SupplierManager);
     for (int i = 0; i < dr.Table.Columns.Count; i++)
     {
         string propertyName = dr.Table.Columns[i].ColumnName;
         PropertyInfo propertyinfo = tp.GetProperty(propertyName);
         if (propertyinfo != null && dr[i] != DBNull.Value)
         {
             propertyinfo.SetValue(SupplierData, dr[i], null);
         }
     }
 }
Example #2
0
        public static List<SupplierManager> GetDetail(string ID)
        {
            string strSql = "SELECT * FROM V_Supplier WHERE ID = @ID";
            DataTable dt = DbHelperSQL.Query(strSql, new SqlParameter("@ID", ID)).Tables[0];

            List<SupplierManager> SupplierData = new List<SupplierManager>();

            foreach (DataRow dr in dt.Rows)
            {
                SupplierManager Detail = new SupplierManager();

                //for (int i = 0; i < dr.Table.Columns.Count; i++)
                // {
                FillData(Detail, dr);
                //}
                SupplierData.Add(Detail);

            }

            return SupplierData;
        }