public void Save(string projectFile, SubTasks s) { StreamWriter writer; writer = File.AppendText(projectFile); String st = new String('-', 4); writer.WriteLine(st + " SubTask Name: " + s.name); writer.WriteLine(st + " Employee: " + s.employee); writer.WriteLine(st + " Description: " + s.description); writer.WriteLine(st + " Duration: " + s.duration); writer.WriteLine(st + " Priority: " + s.taskpriority); writer.Close(); }
public void TrySave(string projectFile, SubTasks s) { try { if (!File.Exists(projectFile)) { MessageBox.Show("Error in project " + projectFile + ". " + "File not Exists."); } else { Save(projectFile, s); } } catch (PathTooLongException e) { MessageBox.Show(e.Message); } catch (FileNotFoundException e) { MessageBox.Show(e.Message); } catch (IOException e) { MessageBox.Show(e.Message); } catch (Exception e) { MessageBox.Show(e.Message); } }
private void SaveSubTasks(object sender, EventArgs e) { if (txtSTName.Text.Length > 0 && bxEmployeers.Text.Length > 0 && txtSTDescription.Text.Length > 0 && lstBxProjects.CheckedItems.Count > 0) { SubTasks subtasks = new SubTasks(txtSTName.Text, bxEmployeers.Text, txtSTDescription.Text, txtBxSTDuration.Text, TaskPriority.Value); foreach (var st in lstBxProjects.CheckedItems) { subtasks.TrySave(st.ToString(), subtasks); } MessageBox.Show("Save!"); } else { MessageBox.Show("You must select a project."); } }