private void btnSubmit_Click(object sender, RoutedEventArgs e) { StreamReader file = new StreamReader(FilePath); StringComparison comparer = StringComparison.InvariantCultureIgnoreCase; string line; // Initiates a variable for a line of the file List<string> insertcustomers = new List<string>(); List<string> inserttickets = new List<string>(); List<string> lines = new List<string>(); while ((line = file.ReadLine()) != null) { if (line.StartsWith("Insert into Tickets Values", comparer)) { inserttickets.Add(line); } else if (line.StartsWith("Insert into Customers Values", comparer)) { insertcustomers.Add(line); } else { lines.Add(line); } } foreach (string text in insertcustomers) { ParseLineOfText(text); } foreach (string text in inserttickets) // iterate through all ticket inserts second { TextImporter ti = new TextImporter(); ti.InsertTicketsEoD(text); // goes to TextImport.cs => InsertTicketsEoD } foreach (string text in lines) // iterate through everything else last { ParseLineOfText(text); } }
private void ParseInserts(string text) { // Find the matching string, if found insert items from SQL. // If not found, then output the line into a text file. StringComparison comparer = StringComparison.InvariantCultureIgnoreCase; if (text.StartsWith("Insert INTO Inventory2", comparer)) { // TODO: Write to Inventory // Don't need this one. logger.writeToImports(text); } else if (text.StartsWith("Insert into Sales Values", comparer)) { // TODO: Write to Tickets // This is done through Tickets logger.writeToImports(text); } else if (text.StartsWith("Insert into Tickets Values", comparer)) // !---------Completed----------! { TextImporter ti = new TextImporter(); ti.InsertTicketsEoD(text); // goes to TextImport.cs => InsertTicketsEoD } else if (text.StartsWith("Insert into Customers Values", comparer)) { // TODO: Write to Customers Database logger.writeToImports(text); } else if (text.StartsWith("INSERT Into Approvals Values", comparer)) { // TODO: Write to Approvals logger.writeToImports(text); } else if (text.StartsWith("Insert into Charges Values", comparer)) { // TODO: Write to Charges logger.writeToImports(text); } else if (text.StartsWith("Insert into Credits Values", comparer)) { // (CreditNumber, Amount, CustomerID, DateSold) = Ticket Update (TicketID, PaymentAmount, PaymentType, CompletedDate) // TODO: Write to Credits logger.writeToImports(text); } else if (text.StartsWith("Insert Into Inventory Select TOP 1", comparer)) { // TODO: Write to Inventory logger.writeToImports(text); } else if (text.StartsWith("Insert Into Email Values", comparer)) { // TODO: Write to Person logger.writeToImports(text); } else if (text.StartsWith("INSERT Into Layaway Values", comparer)) { // TODO: Write to Tickets logger.writeToImports(text); } else if (text.StartsWith("Insert Into Styles", comparer)) { // TODO: Write to Items logger.writeToImports(text); } else if (text.StartsWith("INSERT INTO OrderSpecs VALUES", comparer)) { // TODO: Write to Invoices logger.writeToImports(text); } else if (text.StartsWith("INSERT INTO OrderSpecs2 VALUES", comparer)) { // TODO: Write to Invoices logger.writeToImports(text); } else { // TODO: Write to logger.writeToImports(text); } }