/// <summary> /// Get Payment Type /// </summary> /// <param name="paymentTypeID"></param> /// <returns></returns> public PaymentType GetPaymentType(Guid paymentTypeID) { PaymentType paymentType = new PaymentType(); string sql = "SELECT * FROM PaymentTypes WHERE PaymentTypeID = '" + paymentTypeID.ToString() + "'"; SqlCommand sqlCommand = new SqlCommand(); sqlCommand.Connection = dbConnection; sqlCommand.CommandText = sql; SqlDataReader reader = sqlCommand.ExecuteReader(); if (reader.Read()) { DataReader dataReader = new DataReader(reader); paymentType.PaymentTypeID = dataReader.GetGuid("PaymentTypeID"); paymentType.Description = dataReader.GetString("Description"); paymentType.RequiresCreditCard = dataReader.GetInt32("RequiresCreditCard"); } reader.Close(); return(paymentType); }
/// <summary> /// Get Customer By Customer ID /// </summary> /// <param name="customerID"></param> /// <returns></returns> public Customer GetCustomerByCustomerID(Guid customerID) { Customer customer = new Customer(); string sql = "SELECT * FROM CUSTOMERS WHERE CustomerID = '" + customerID.ToString() + "'"; SqlCommand sqlCommand = new SqlCommand(); sqlCommand.Connection = dbConnection; sqlCommand.CommandText = sql; SqlDataReader reader = sqlCommand.ExecuteReader(); if (reader.Read()) { DataReader dataReader = new DataReader(reader); customer.CustomerID = dataReader.GetGuid("CustomerID"); customer.FirstName = dataReader.GetString("FirstName"); customer.LastName = dataReader.GetString("LastName"); customer.EmailAddress = dataReader.GetString("EmailAddress"); customer.Address = dataReader.GetString("Address"); customer.City = dataReader.GetString("City"); customer.Region = dataReader.GetString("Region"); customer.PostalCode = dataReader.GetString("PostalCode"); customer.Country = dataReader.GetString("Country"); customer.PhoneNumber = dataReader.GetString("PhoneNumber"); customer.CreditCardNumber = dataReader.GetString("CreditCardNumber"); customer.PaymentTypeID = dataReader.GetGuid("PaymentTypeID"); if (dataReader.GetDateTime("CreditCardExpirationDate") != DateTime.MinValue) { customer.CreditCardExpirationDate = dataReader.GetDateTime("CreditCardExpirationDate"); } customer.CreditCardSecurityCode = dataReader.GetString("CreditCardSecurityCode"); customer.CreditLimit = dataReader.GetDecimal("CreditLimit"); customer.DateApproved = dataReader.GetDateTime("DateApproved"); customer.ApprovalStatus = dataReader.GetInt32("ApprovalStatus"); customer.DateCreated = dataReader.GetDateTime("DateCreated"); customer.DateUpdated = dataReader.GetDateTime("DateUpdated"); } reader.Close(); return(customer); }
/// <summary> /// Get Payment Type /// </summary> /// <param name="paymentTypeID"></param> /// <returns></returns> public PaymentType GetPaymentType(Guid paymentTypeID) { PaymentType paymentType = new PaymentType(); string sql = "SELECT * FROM PaymentTypes WHERE PaymentTypeID = '" + paymentTypeID.ToString() + "'"; SqlCommand sqlCommand = new SqlCommand(); sqlCommand.Connection = dbConnection; sqlCommand.CommandText = sql; SqlDataReader reader = sqlCommand.ExecuteReader(); if (reader.Read()) { DataReader dataReader = new DataReader(reader); paymentType.PaymentTypeID = dataReader.GetGuid("PaymentTypeID"); paymentType.Description = dataReader.GetString("Description"); paymentType.RequiresCreditCard = dataReader.GetInt32("RequiresCreditCard"); } reader.Close(); return paymentType; }
/// <summary> /// Get Customer By Customer ID /// </summary> /// <param name="customerID"></param> /// <returns></returns> public Customer GetCustomerByCustomerID(Guid customerID) { Customer customer = new Customer(); string sql = "SELECT * FROM CUSTOMERS WHERE CustomerID = '" + customerID.ToString() + "'"; SqlCommand sqlCommand = new SqlCommand(); sqlCommand.Connection = dbConnection; sqlCommand.CommandText = sql; SqlDataReader reader = sqlCommand.ExecuteReader(); if (reader.Read()) { DataReader dataReader = new DataReader(reader); customer.CustomerID = dataReader.GetGuid("CustomerID"); customer.FirstName = dataReader.GetString("FirstName"); customer.LastName = dataReader.GetString("LastName"); customer.EmailAddress = dataReader.GetString("EmailAddress"); customer.Address = dataReader.GetString("Address"); customer.City = dataReader.GetString("City"); customer.Region = dataReader.GetString("Region"); customer.PostalCode = dataReader.GetString("PostalCode"); customer.Country = dataReader.GetString("Country"); customer.PhoneNumber = dataReader.GetString("PhoneNumber"); customer.CreditCardNumber = dataReader.GetString("CreditCardNumber"); customer.PaymentTypeID = dataReader.GetGuid("PaymentTypeID"); if (dataReader.GetDateTime("CreditCardExpirationDate") != DateTime.MinValue) customer.CreditCardExpirationDate = dataReader.GetDateTime("CreditCardExpirationDate"); customer.CreditCardSecurityCode = dataReader.GetString("CreditCardSecurityCode"); customer.CreditLimit = dataReader.GetDecimal("CreditLimit"); customer.DateApproved = dataReader.GetDateTime("DateApproved"); customer.ApprovalStatus = dataReader.GetInt32("ApprovalStatus"); customer.DateCreated = dataReader.GetDateTime("DateCreated"); customer.DateUpdated = dataReader.GetDateTime("DateUpdated"); } reader.Close(); return customer; }