public Project addProject(string Name, DateTime Startdate, DateTime Enddate, string Desc) { if (mUsername == "") return null; else{ Project p = new Project(); p.OwnerName = mUsername; p.Name = Name; p.Description = Desc; p.EndDate = Enddate; p.CreatedDate = Startdate; if(p.Save()) return p; else return null; } }
internal static Users LoadProjectUsers(Project p) { if (p.ID != "") { SqlCommand cmd = new SqlCommand("select u.Firstname, u.Lastname, u.Username, u.Email from UserProject as up inner join [User] as u on up.Username = u.Username where ProjectID = @pid", Main.GetConnection()); cmd.Parameters.Add(new SqlParameter("pid", p.ID)); SqlDataReader reader = cmd.ExecuteReader(); Users projectUsers = new Users(); while (reader.Read()) { User u = new User(); u.Firstname = reader.GetString(0); u.Lastname = reader.GetString(1); u.Username = reader.GetString(2); u.Email = reader.GetString(3); projectUsers.Add(u); } return projectUsers; } else return null; }
internal static Projects LoadUserProjects(string username) { if (username != "") { SqlCommand cmd = new SqlCommand("select p.ProjectID, p.OwnerName, p.Name, p.Description, p.CreatedDate, p.EndDate from UserProject as up inner join Project as p on p.ProjectID = up.ProjectID where up.Username = @un", Main.GetConnection()); cmd.Parameters.Add(new SqlParameter("un", username)); SqlDataReader reader = cmd.ExecuteReader(); Projects userProjects = new Projects(); while (reader.Read()) { Project p = new Project(); p.ID = reader.GetString(0); p.OwnerName = reader.GetString(1); p.Name = reader.GetString(2); p.Description = reader.GetString(3); p.CreatedDate = Convert.ToDateTime(reader["CreatedDate"]); p.EndDate = Convert.ToDateTime(reader["EndDate"]); userProjects.Add(p); } return userProjects; } else return null; }
public static Users getProjectUsers(Project p) { return User.LoadProjectUsers(p); }
internal static Project load(string ID) { if (ID != ""){ SqlCommand cmd = new SqlCommand("select p.ProjectID, p.OwnerName, p.Name, p.Description, p.CreatedDate, p.EndDate from Project where ID = @id", Main.GetConnection()); cmd.Parameters.Add(new SqlParameter("id", ID)); SqlDataReader reader = cmd.ExecuteReader(); Project p = new Project(); p.ID = reader.GetString(0); p.OwnerName = reader.GetString(1); p.Name = reader.GetString(2); p.Description = reader.GetString(3); p.CreatedDate = Convert.ToDateTime(reader["CreatedDate"]); p.EndDate = Convert.ToDateTime(reader["EndDate"]); return p; } else return null; }