public VisitForm(Project project, Visit visit) { InitializeComponent(); _currentVisit = visit; _project = project; this.Text = project.Name; // putting the project title _observations = new List<Observation>(); var currentdir = AppDomain.CurrentDomain.BaseDirectory + @"../../"; pbMap.ImageLocation = currentdir + project.FilePath; // Loading comboboxes cmbBirds.Items.Clear(); cmbObservationType.Items.Clear(); foreach (var bird in LogicCollection.BirdLogic.GetAll()) { cmbBirds.Items.Add(bird); } foreach (var observationType in LogicCollection.ObservationTypeLogic.GetAll()) { cmbObservationType.Items.Add(observationType); } }
/// <summary> /// Add project to database /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAddProject_Click(object sender, EventArgs e) { var projectname = txtProjectName.Text; if (string.IsNullOrEmpty(_filePath) || string.IsNullOrEmpty(projectname)) { MessageBox.Show("Eerst een plattegrond uploaden of projectnaam invullen"); return; } var filename = Path.GetFileName(_filePath); // Making object project var project = new Project(0, projectname, "Files/" + filename); // INSERT PROJECT INTO DATABASE project = LogicCollection.ProjectLogic.Insert(project); if (project != null) { var exists = Directory.Exists("Files"); if (!exists) { Directory.CreateDirectory("Files"); } File.Copy(_filePath, "Files/" + filename); MessageBox.Show("Je hebt een project succesvol toegevoegd!"); var startxUp = new StartUp(); startxUp.RefreshList(); Close(); } else { MessageBox.Show("Er is iets misgegaan bij het toevoegen."); } }
/// <summary> /// Update status of project /// </summary> /// <param name="entity"></param> /// <returns></returns> public bool UpdateStatus(Project entity) { return _context.UpdateStatus(entity); }
/// <summary> /// Insert project /// </summary> /// <param name="entity"></param> /// <returns></returns> public Project Insert(Project entity) { return _context.Insert(entity); }
public void InsertProject() { var project = new Project(0, "Project test", "Files/lege_map.png"); var insertedProject = LogicCollection.ProjectLogic.Insert(project); Assert.IsNotNull(insertedProject, "Inserting an project failed"); }