private void InvoiceDG_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (InvoiceDG.SelectedItem != null) { FC_Invoice SelectedInvoice = (FC_Invoice)InvoiceDG.SelectedItem; ContractsPreInvouce.ItemsSource = PlannerClass.GetContracts_PreInvoice(SelectedInvoice); } }
public static int InsertInvoice(FC_Invoice inInvoice, FC_LocalContract InContract) { inInvoice.FC_InvoiceID = SQL.GetNextID("FC_Invoice"); SQL.Insert(inInvoice); FC_InvoiceContractLine newLine = new FC_InvoiceContractLine(InContract.FC_LocalContractID, inInvoice.FC_InvoiceID); SQL.Insert(newLine); return(inInvoice.FC_InvoiceID); }
public static List <FC_LocalContract> GetContracts_PreInvoice(FC_Invoice inInvoice) { string query = "select c.FC_LocalContractID, c.Client_Name, c.Job_type, c.Quantity, c.Origin, c.Destination, c.Van_type, c.Contract_Status " + "from FC_Invoice as inn " + "left join FC_InvoiceContractLine as cl on cl.FC_InvoiceID = inn.FC_InvoiceID " + "left join FC_LocalContract as c on c.FC_LocalContractID = cl.FC_LocalContractID " + "where inn.FC_InvoiceID = " + inInvoice.FC_InvoiceID.ToString() + ";"; FC_LocalContract c = new FC_LocalContract(); return(c.ObjToTable(SQL.Select(c, query))); }
private void ConfirmInvoice_Click(object sender, RoutedEventArgs e) { if (BuyerClass.SelectedForInvoice != null && BuyerClass.SelectedForInvoice.Count > 0) { FC_Invoice invTemp = PlannerClass.GenerateInvoice(BuyerClass.SelectedForInvoice[0]); PlannerClass.InsertInvoice(invTemp, BuyerClass.SelectedForInvoice[0]); PlannerClass.UpdateContratState(BuyerClass.SelectedForInvoice[0], 4); BuyerClass.SelectedForInvoice.Remove(BuyerClass.SelectedForInvoice[0]); foreach (FC_LocalContract c in BuyerClass.SelectedForInvoice) { PlannerClass.AddContractToInvoices(invTemp, c); PlannerClass.UpdateContratState(c, 4); } InvoiceForFileSystem fsIn = new InvoiceForFileSystem(invTemp); try { string invoiceDir = Directory.GetCurrentDirectory() + "\\Invoices"; FileInfo fi = new FileInfo(invoiceDir); if (fi.Exists == false) { Directory.CreateDirectory(invoiceDir); } string filePath = "\\invoice_" + fsIn.FC_InvoiceID + ".txt"; /// Open the filestream to append to the file. FileStream fileStream = new FileStream(invoiceDir + filePath, FileMode.Create, FileAccess.Write); StreamWriter fileWriter = new StreamWriter(fileStream); /// Add each log entry from the working list to the file as a BSV fileWriter.WriteLine(fsIn.ToString()); fileWriter.Flush(); /// Close the file fileWriter.Close(); fileStream.Close(); } /// If an exception is thrown here, catch it catch (Exception ex) { TMSLogger.LogIt("|" + "/InvoiceSelection.xaml.cs" + "|" + "InvoiceSelection" + "|" + "ConfirmInvoice_Click" + "|" + ex.GetType().ToString() + "|" + ex.Message + "|"); } BuyerPage newpage = new BuyerPage(); this.NavigationService.Navigate(newpage); } }
public static void AddContractToInvoices(FC_Invoice inInvoice, FC_LocalContract InContract) { double OtherContractCost = GenerateInvoiceTotal(InContract); string query = "update FC_Invoice set TotalCost = " + Math.Round((inInvoice.TotalCost + OtherContractCost), 2) + " where FC_InvoiceID = " + inInvoice.FC_InvoiceID.ToString() + ";"; SQL.GenericFunction(query); FC_InvoiceContractLine newLine = new FC_InvoiceContractLine(InContract.FC_LocalContractID, inInvoice.FC_InvoiceID); SQL.Insert(newLine); TMSLogger.LogIt(" | " + "PlannerClass.cs" + " | " + "PlannerClass" + " | " + "AddContractToInvoices" + " | " + "Confirmation" + " | " + "Contract added to invoices" + " | "); }
public static List <FC_Invoice> TwoWeekInvoices() { FC_Invoice i = new FC_Invoice(); List <FC_Invoice> AllInvoices = i.ObjToTable(SQL.Select(i)); List <FC_Invoice> TwoWeek = new List <FC_Invoice>(); foreach (FC_Invoice x in AllInvoices) { bool withinRange = false; List <FC_LocalContract> contracts = GetContracts_PreInvoice(x); foreach (FC_LocalContract y in contracts) { List <FC_TripTicket> tickets = ConnectedTickets_Populate(y); foreach (FC_TripTicket z in tickets) { if (z.Days_Passes <= 14) { withinRange = true; break; } } if (withinRange) { TwoWeek.Add(x); break; } } } return(TwoWeek); }
public static List <FC_Invoice> GetAllInvoices() { FC_Invoice i = new FC_Invoice(); return(i.ObjToTable(SQL.Select(i))); }