public Customer FindCustomerById(int IDCust) { Customer c = new Customer(); using (SqlConnection myConnection = new SqlConnection(cnStr)) { string q = " Select * From Customer where IDCust=@IDCust"; SqlCommand myCommand = new SqlCommand(q, myConnection); myCommand.Parameters.AddWithValue("@IDCust", IDCust); myConnection.Open(); using (SqlDataReader myDataReader = myCommand.ExecuteReader()) { if (myDataReader != null) { while (myDataReader.Read()) { string strId = myDataReader["IDCust"].ToString(); c.IDCust = Int32.Parse(strId); c.Name = myDataReader["Name"].ToString(); c.Email = myDataReader["Email"].ToString(); c.Password = myDataReader["Password"].ToString(); } } myConnection.Close(); } } return c; }
public ShoppingCart(int IDShoppingCart, string Date, Customer c) { this.IDShoppingCart = IDShoppingCart; Olp = new List<OrderLinePart>(); Olb = new List<OrderLineBike>(); this.Date = Date; this.c = c; }