public bool addWorkPackage(string Name, DateTime CreatedDate, DateTime Enddate, string Description) { if (mID == "") return true; else{ WorkPackage w = new WorkPackage(); w.ProjectID = mID; w.Name = Name; w.Description = Description; w.EndDate = Enddate; w.CreatedDate = CreatedDate; w.Save(); return false; } }
public WorkPackages loadWorkPackages() { if (mID != "") { SqlCommand cmd = new SqlCommand("select w.Name, w.Description, w.CreatedDate, w.EndDate, w.ProjectID, w.WorkPackageID from Workpackage as w where ProjectID = @id", Main.GetConnection()); cmd.Parameters.Add(new SqlParameter("id", mID)); SqlDataReader reader = cmd.ExecuteReader(); WorkPackages ws = new WorkPackages(); while (reader.Read()) { WorkPackage w = new WorkPackage(); w.Name = reader.GetString(0); w.Description = reader.GetString(1); w.CreatedDate = Convert.ToDateTime(reader["CreatedDate"]); w.EndDate = Convert.ToDateTime(reader["EndDate"]); w.ProjectID = reader.GetString(4); w.ID = reader.GetString(5); ws.Add(w); } return ws; } else return null; }