public static List <CREDIT> DataToCredit(DataTable dt) { List <CREDIT> list = new List <CREDIT>(); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { CREDIT d = new CREDIT { id = dt.Rows[i]["ID"].ToString(), accounttype = dt.Rows[i]["ACCOUNTTYPE"].ToString(), amount = dt.Rows[i]["AMOUNT"].ToString(), paytype = dt.Rows[i]["PAYTYPE"].ToString(), date = dt.Rows[i]["DATE"].ToString(), pid = dt.Rows[i]["PID"].ToString(), cid = dt.Rows[i]["CID"].ToString(), uid = dt.Rows[i]["UID"].ToString(), count = dt.Rows[i]["COUNT"].ToString(), customer = DB_Customer.C_Customer(dt.Rows[i]["CID"].ToString()), product = DB_Product.C_Product(dt.Rows[i]["PID"].ToString()) }; list.Add(d); } } return(list); }