Ejemplo n.º 1
0
 public ModelCustomer getCustomerByID(string ID)
 {
     using (DBAccess.DBAccess db = new DBAccess.DBAccess())
     {
         string[,] param = { { "@Id", ID } };
         using (SqlDataReader rdr = db.ExecuteReader("sprSelectCustomerByID", param))
         {
             ModelCustomer item = new ModelCustomer();
             while (rdr.Read())
             {
                 item.Id = Convert.ToInt32(rdr["Id"]);
                 item.Name = rdr["Name"].ToString();
                 item.Address = rdr["Address"].ToString();
             }
             return item;
         }
     }
 }
Ejemplo n.º 2
0
        public DataTable getAllCustomer(string strWhere, string strOrderBy)
        {
            using (DBAccess.DBAccess db = new DBAccess.DBAccess())
            {
                if (strOrderBy == "") { strOrderBy = " ORDER BY Id"; }

                string[,] param =   {
                                        { "@strWhere", strWhere },
                                        { "@strOrderBy", strOrderBy }
                                    };
                using (SqlDataReader rdr = db.ExecuteReader("sprSelectAllCustomer", param))
                {
                    DataTable DT = new DataTable();
                    DT.Load(rdr);
                    return DT;
                }
            }
        }