private void deleteSelectedClientButton_Click(object sender, EventArgs e) { Client selectedClient = (Client)clientListBox.SelectedItem; if (selectedClient != null) { Clients.Remove(selectedClient); TextConnectorProcessor.SaveToClientFile(Clients, TextConnection.ClientFile); List <int> sessionsToRemove = new List <int>(); foreach (Session s in Sessions) { if (s.client.FullName == selectedClient.FullName) { sessionsToRemove.Add(s.Id); } } foreach (int i in sessionsToRemove) { Sessions.RemoveAll(p => p.Id == i); } TextConnectorProcessor.SaveToSessionFile(Sessions, TextConnection.SessionFile); WireUpLists(); } else { MessageBox.Show("There are no clients to delete."); } }
private void ViewSelectedClientButton_Click(object sender, EventArgs e) { Client tempClient = (Client)clientListBox.SelectedItem; if (tempClient != null) { int editedClientPosition = 0; using (var v = new viewClientForm(tempClient)) { var result = v.ShowDialog(); if (result == DialogResult.OK) { returnClient = v.returnClient; editedClientPosition = returnClient.Id; Clients.Insert(editedClientPosition, returnClient); Clients.RemoveAt(editedClientPosition - 1); TextConnectorProcessor.SaveToClientFile(Clients, TextConnection.ClientFile); v.FormClosing += new FormClosingEventHandler(this.V_FormClosing); } if (result == DialogResult.Cancel) { returnClient = tempClient; } } WireUpLists(); //TODO: (bEFORE!!) On session delete, remove session Id from client's Session Id list //TODO: Set selected item based on last one used. /*foreach (Client c in clientListBox.Items) * { * if(c.Id == editedClientPosition) * { * clientListBox.SelectedItems.Add(c); * } * } */ //clientListBox.SetSelected(editedClientPosition, true); } else { MessageBox.Show("There are no clients available to view."); } //TODO: Fix error of x'ing out of add client box. Changes record to NULL in JSON? - or replaces model with last edited one?? //TODO: list client sessions by Id instead of namesearch }
private void deleteSelectedSessionButton_Click(object sender, EventArgs e) { Session selectedSession = (Session)sessionListBox.SelectedItem; if (selectedSession != null) { Sessions.Remove(selectedSession); TextConnectorProcessor.SaveToSessionFile(Sessions, TextConnection.SessionFile); WireUpLists(); } else { MessageBox.Show("There are no clients to delete."); } }
public async Task AddProductAsync(ProductModel product) { string sourceFilePath = TextConnectorProcessor.fullFilePath(_productfile); await EnsureCreated(); await EnsureLoaded(); await Task.Run(() => { using (TextWriter textWriter = new StreamWriter(sourceFilePath, true)) using (var csv = new CsvWriter(textWriter)) { csv.WriteRecord(product); csv.NextRecord(); _products.Add(product); } }); }
private void viewSelectedSessionButton_Click(object sender, EventArgs e) { Session tempSession = (Session)sessionListBox.SelectedItem; if (tempSession != null) { using (var v = new viewSessionForm(tempSession)) { var result = v.ShowDialog(); if (result == DialogResult.OK) { returnSession = v.returnSession; v.FormClosing += new FormClosingEventHandler(this.V_FormClosing); } if (result == DialogResult.Cancel) { returnSession = tempSession; } } int editedSessionPosition = Sessions.IndexOf(tempSession); Sessions.Insert(editedSessionPosition, returnSession); Sessions.Remove(tempSession); TextConnectorProcessor.SaveToClientFile(Clients, TextConnection.ClientFile); TextConnectorProcessor.SaveToSessionFile(Sessions, TextConnection.SessionFile); WireUpLists(); sessionListBox.SetSelected(editedSessionPosition, true); } else { MessageBox.Show("There are no sessions available to view."); } //TODO: Fix error of x'ing out of add client box. Changes record to NULL in JSON? - or replaces model with last edited one?? }
private void CreateSessionButton_Click(object sender, EventArgs e) { Client returnClient = new Client(); int clientId = 0; using (var s = new addSessionForm()) { var result = s.ShowDialog(); if (result == DialogResult.OK) { returnClient = s.returnClient; clientId = returnClient.Id; Clients.Insert(clientId, returnClient); Clients.RemoveAt(clientId - 1); TextConnectorProcessor.SaveToClientFile(Clients, TextConnection.ClientFile); s.FormClosing += new FormClosingEventHandler(this.F_FormClosing); } } WireUpLists(); }
public UserModel GetUserById(string AuthUserId) { return(TextConnectorProcessor.LookupUserById(AuthUserId)); }
public ProductModel GetProductById(int ProductId) { return(TextConnectorProcessor.LookupProductById(ProductId.ToString())); }
public BasketModel GetBasketById(int Id) { return(TextConnectorProcessor.LookupBasketById(Id.ToString())); }