public static CartPayment GetCartPaymentByPaymentID(int payment_id) { CartDB db = new CartDB(); DataSet ds = db.GetPaymentFromPaymentId(payment_id); if (ds != null) { using (DataTableReader data = ds.CreateDataReader()) { while (data.Read()) { int cartid = data.GetInt32(data.GetOrdinal("CartId")); int paymenttype = data.GetInt32(data.GetOrdinal("PaymentType")); string cctype = Helper.IsString(data.GetValue(data.GetOrdinal("CCType")), ""); string cclastfourdigits = Helper.IsString(data.GetValue(data.GetOrdinal("CCLastFourDigits")), ""); string encryptedcc = Helper.IsString(data.GetValue(data.GetOrdinal("EncryptedCC")), ""); string encryptedccexpiration = Helper.IsString(data.GetValue(data.GetOrdinal("EncryptedCCExpiration")), ""); string encryptedcccvv = Helper.IsString(data.GetValue(data.GetOrdinal("EncryptedCCCVV")), ""); string pofilename = Helper.IsString(data.GetValue(data.GetOrdinal("POFileName")), ""); object obj_pofileupload = data.GetValue(data.GetOrdinal("POFileUpload")); byte[] pofileupload = null; if (obj_pofileupload != null && obj_pofileupload.GetType().Equals(typeof(byte[]))) { pofileupload = (byte[])obj_pofileupload; } int ord_id = 0, ord_payment_id = 0; object obj_ord_id = data.GetValue(data.GetOrdinal("ORD_ID")); if (obj_ord_id != null && obj_ord_id.GetType().Equals(typeof(int))) { ord_id = (int)obj_ord_id; } object obj_ord_payment_id = data.GetValue(data.GetOrdinal("ORD_Payment_ID")); if (obj_ord_payment_id != null && obj_ord_payment_id.GetType().Equals(typeof(int))) { ord_payment_id = (int)obj_ord_payment_id; } DateTime datecreated = data.GetDateTime(data.GetOrdinal("DateCreated")); DateTime lastupdated = data.GetDateTime(data.GetOrdinal("LastUpdated")); return new CartPayment(cartid, paymenttype, cctype, cclastfourdigits, encryptedcc, encryptedccexpiration, encryptedcccvv, pofilename, pofileupload, ord_id, ord_payment_id, datecreated, lastupdated); } } } return null; }