public static List <OrderItem> GetOrderReport(string file) { var deliminator = ','; var orderItems = new List <OrderItem>(); using (var reader = new StreamReader(file)) { List <string> listA = new List <string>(); List <string> listB = new List <string>(); var line = reader.ReadLine(); line = reader.ReadLine(); line = reader.ReadLine(); while (!reader.EndOfStream) { var newItem = true; var chararray = reader.ReadLine().ToCharArray(); var skip = false; for (int i = 0; i < chararray.Length; i++) { if (chararray[i] == '"') { skip = !skip; } if (skip) { continue; } if (deliminator == chararray[i]) { chararray[i] = ';'; } } line = new string(chararray); var values = line.Split(';'); OrderItem orderItem = new OrderItem(); if (string.IsNullOrEmpty(values[order_number].Replace($@"""", "")) || values[order_number].Replace($@"""", "") == "record(s) downloaded") { continue; } orderItem.BoughtFrom = "Ebay"; orderItem.DateSold = ExtractDate(values); orderItem.SoldFor = PaymentDetail.ConvertDollarstoPennies(values[sold_for].Replace($@"""", "")) + PaymentDetail.ConvertDollarstoPennies(values[shipping].Replace($@"""", "")) + PaymentDetail.ConvertDollarstoPennies(values[tax].Replace($@"""", "")); orderItem.ItemName = values[title_name].Replace($@"""", ""); orderItem.OrderID = values[order_number].Replace($@"""", ""); orderItem.QuantitySold = int.Parse(values[qauntity].Replace($@"""", "")); orderItem.SalesTax = PaymentDetail.ConvertDollarstoPennies(values[tax].Replace($@"""", "")); orderItem.SKU = values[item_number].Replace($@"""", ""); orderItem.TransID = values[trans_id].Replace($@"""", ""); orderItems.Add(orderItem); } } return(orderItems); }
public int Update(string Table, int row, string column, string value) { switch (column) { case "SKU": column = "sku"; break; case "Order ID": column = "order_id"; break; case "Selling Fees": column = "selling_fee"; value = PaymentDetail.ConvertDollarstoPennies(value).ToString(); break; case "Item Name": column = "item_name"; break; case "Quantity Bought": column = "quantity_bought"; break; case "Ebay SKU": column = "ebay_sku"; break; case "Item Cost": column = "item_cost"; value = PaymentDetail.ConvertDollarstoPennies(value).ToString(); break; case "SalesTax": column = "sale_tax"; value = PaymentDetail.ConvertDollarstoPennies(value).ToString(); break; case "Quantity Sold": column = "quantity_sold"; break; case "Date Sold": column = "date_sold"; break; case "Bought From": column = "bought_from"; break; case "Sold For": column = "sold_for"; value = PaymentDetail.ConvertDollarstoPennies(value).ToString(); break; case "Shipping Cost": column = "shipping_cost"; value = PaymentDetail.ConvertDollarstoPennies(value).ToString(); break; case "Assigned": case "assigned": value = value.ToLower() == "true" ? "1" : "0"; break; default: break; } var result = Database.Update(Table, row, new List <string> { column.ToLower() }, new List <object> { value }); if (result?.Result.ToString() != "SUCCESS") { return(-1); } else { try { var num = int.Parse(result.Message.Split(':')[1]); return(num); } catch { return(-1); } } }