// Action (task) /// <summary> /// New tray task. /// </summary> private void NewTray() { FormNewTray form_new_tray = new FormNewTray(); if (form_new_tray.ShowDialog() == DialogResult.OK && form_new_tray.id != "") { if (db_manager.IsConnected) { foreach (ListViewItem itme_tray in listViewTray.Items) { if (form_new_tray.id == itme_tray.SubItems[0].Text) { MessageBox.Show(this, "This tray id is already use.", "Tray id error", MessageBoxButtons.OK, MessageBoxIcon.Warning); StatusText = "New tray: id error"; return; } } Tray tray = new Tray(form_new_tray.id); AddTrayListView(tray, "Empty"); db_manager.AddTray(tray); StatusText = "New tray: done"; // Create a Fill task and display it Task fill = new Task("Fill", tray.Id); AddTODOListView(fill, new Lot(tray.Id), -1); // Create NewTray Task and save it, display it Task new_tray = new Task("NewTray", form_new_tray.Feedback, DateTime.Now, -1, 0, tray.Id); db_manager.AddTask(new_tray); AddTaskListView(new_tray); } else { MessageBox.Show("Not connected to database."); StatusText = "New tray: failed"; } } else { StatusText = "New tray: aborted"; } }
// Tray /// <summary> /// Insert a <c>Tray</c> in the tray collection. /// </summary> /// <param name="tray">The tray object</param> public void AddTray(Tray tray) { m_tray_collection.InsertOne(tray); }
} // END UpdateTODO // Tray private void AddTrayListView(Tray tray, string state = "Active") { ListViewItem item_new = new ListViewItem(new string[] { tray.Id, state, tray.Date.ToString() }); listViewTray.Items.Add(item_new); }