/// <summary> /// Load all werkbonnen from a local file</summary> public static List <Werkbon> LoadWerkbonnen() { BinaryFormatter bformatter = new BinaryFormatter(); List <Werkbon> werkbonnen = new List <Werkbon>(); //Open the file and read values from client. FileStream streamClient = new FileStream(@"C:\SealFlexBeheerSysteem\werkbonnen.data", FileMode.Open); bformatter = new BinaryFormatter(); Console.WriteLine("Reading werkbon Information"); while (streamClient.Position < streamClient.Length) { try { Werkbon werkbon = (Werkbon)bformatter.Deserialize(streamClient); Console.WriteLine(werkbon.werkbon); if (werkbon is Werkbon) { werkbonnen.Add(werkbon); } else { Console.WriteLine("error loading werkbon" + werkbon.werkbon); } } catch (Exception e) { Console.WriteLine(e.ToString()); } } Console.WriteLine("{0} werkbonnen loaded", werkbonnen.Count); streamClient.Close(); return(werkbonnen); }
/// <summary> /// Check if the werkbon exist, if not add the werkbon to the werkbon file, otherwise update werkbon.</summary> /// <param name="werkbon">The werkbon to be added/updated</param> public void SaveWerkbon(Werkbon werkbon) { int werkbonID = -1; bool newWerkbon = true; //Check if werkbon already exists, if so, update werkbon with existing ID foreach (Werkbon oldWerkbon in server.werkbonnen) { werkbonID++; if (werkbon.werkbon == oldWerkbon.werkbon) { newWerkbon = false; break; } } if (newWerkbon) { server.AddNewWerkbon(werkbon); //NetworkCommunication.SendPacket(new PacketSaveWerkbonResponse(true, user.accessRights), stream); } else { server.UpdateWerkbon(werkbon, werkbonID); //NetworkCommunication.SendPacket(new PacketSaveWerkbonResponse(true, user.accessRights), stream); } }
private void addButon_Click(object sender, EventArgs e) { DateTime day = werkbonCalander.SelectionRange.Start; Werkbon werkbon = (Werkbon)werkbonComboBox.SelectedItem; System.Diagnostics.Debug.WriteLine(werkbon.werkbon); //alter the datetime field in werkbon werkbon.uitvoerDatum = day; network.SaveWerkbonnen(werkbonnen); fillWerkbonList(); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Werkbon = await _context.Werkbon.FirstOrDefaultAsync(m => m.WerkbonID == id); if (Werkbon == null) { return(NotFound()); } return(Page()); }
private void SetComboBox(Werkbon werkbon) { if (werkbonList.InvokeRequired) { try { SetComboBoxCallBack d = new SetComboBoxCallBack(SetComboBox); this.Invoke(d, new object[] { werkbon }); } catch (Exception e) { } } else { werkbonComboBox.Items.Add(werkbon); } }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Werkbon = await _context.Werkbon.FindAsync(id); if (Werkbon != null) { _context.Werkbon.Remove(Werkbon); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnGetAsync(int?id) { Werkbonpersoneels = await _context.Werkbonpersoneel .Include(w => w.personeel) .Include(w => w.werkbon).ToListAsync(); if (id == null) { return(NotFound()); } Werkbon = await _context.Werkbon.FirstOrDefaultAsync(m => m.WerkbonID == id); if (Werkbon == null) { return(NotFound()); } return(Page()); }
/// <summary> /// Update werkbon with given index and save werkbonlist to local file</summary> /// <param name="index">The index in the werkbonnenlist that needs to be updated</param> public void UpdateWerkbon(Werkbon werkbon, int werkbonIndex) { werkbonnen.RemoveAt(werkbonIndex); werkbonnen.Add(werkbon); FileIO.SaveWerkbonnen(werkbonnen); }
/// <summary> /// Add a new werkbon.</summary> /// <param name="newWerkbon">The new werkbon that will be added</param> public void AddNewWerkbon(Werkbon newWerkbon) { werkbonnen.Add(newWerkbon); FileIO.SaveWerkbonnen(werkbonnen); }
public PacketSaveWerkbon(Werkbon werkbon) { this.werkbon = werkbon; }
public bool SaveWerkbon(Werkbon werkbon) { network.sendPacket(new PacketSaveWerkbon(werkbon)); Thread.Sleep(1000); return(true); }