/* * Input: UserID: Is an int containg the UserID from the cookies * Processing: Reads the relevant details from the database, i.e the details of a specific users projects, and passes them to a list of Project type * Output: Returns a list of Project type to be used in the population of the relevant grid view */ public static List<Project> GetMyProjects(string UserID) { List<Project> listProjects = new List<Project>(); string CS = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; try { using (SqlConnection conn = new SqlConnection(CS)) { int userID = Convert.ToInt32(UserID); SqlCommand cmd = new SqlCommand("SELECT ProjectID, CustomerID, PhotoLocation, ProjectName, ProjectDescription, GuildTypeName, TypeName, MaterialTypeName, Deadline, PublicProject, MaxPrice, MinPrice, StatusType from ProjectInfo where CustomerID = @UserID and StatusType = 'Up for tender';", conn); cmd.Parameters.AddWithValue("@UserID", userID); conn.Open(); SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { Project project = new Project(); project.ProjectID = Convert.ToInt32(rdr["ProjectID"]); project.CustomerID = Convert.ToInt32(rdr["CustomerID"]); //project.ArtisanID = Convert.ToInt32(rdr["ArtisanID"]); project.ProjectPhoto = rdr["PhotoLocation"].ToString(); project.ProjectName = rdr["ProjectName"].ToString(); project.ProjectDescription = rdr["ProjectDescription"].ToString(); project.Guild = rdr["GuildTypeName"].ToString(); project.Type = rdr["TypeName"].ToString(); project.Materials = rdr["MaterialTypeName"].ToString(); project.PublicProject = rdr["StatusType"].ToString(); project.Deadline = rdr["Deadline"].ToString(); project.MaxPrice = Convert.ToDouble(rdr["MaxPrice"]); project.MinPrice = Convert.ToDouble(rdr["MinPrice"]); project.CompleteStatus = rdr["StatusType"].ToString(); listProjects.Add(project); } } } catch (Exception ex) { } return listProjects; }
/* * Input: UserID: Is an int containg the UserID from the cookies * Processing: Reads the relevant details from the database, * i.e the details of a users projects that have active bids, * and passes them to a list of Project type * Output: Returns a list of Project type to be used in the population of the relevant grid view */ public static List<Project> GetMyBids(string UserID) { List<Project> listProjects = new List<Project>(); string CS = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; try { using (SqlConnection conn = new SqlConnection(CS)) { int userID = Convert.ToInt32(UserID); SqlCommand cmd = new SqlCommand("SELECT BidID, ArtisanID, ProjectID, CustomerID, ProjectName, ProjectDescription, Deadline, BidStatusName, StatusType, MaxPrice, MinPrice, ShopName, BidPrice, BidText from ProjectBids where CustomerID = @UserID and BidStatusName != 'Accepted';", conn); cmd.Parameters.AddWithValue("@UserID", userID); conn.Open(); SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { Project project = new Project(); project.BidID = Convert.ToInt32(rdr["BidID"]); project.ArtisanID = Convert.ToInt32(rdr["ArtisanID"]); project.ProjectID = Convert.ToInt32(rdr["ProjectID"]); project.CustomerID = Convert.ToInt32(rdr["CustomerID"]); project.ProjectName = rdr["ProjectName"].ToString(); project.ProjectDescription = rdr["ProjectDescription"].ToString(); project.BidStatus = rdr["BidStatusName"].ToString(); project.CompleteStatus = rdr["StatusType"].ToString(); project.Deadline = rdr["Deadline"].ToString(); project.MaxPrice = Convert.ToDouble(rdr["MaxPrice"]); project.MinPrice = Convert.ToDouble(rdr["MinPrice"]); project.ShopName = rdr["ShopName"].ToString(); project.BidPrice = Convert.ToDouble(rdr["BidPrice"]); project.BidText = rdr["BidText"].ToString(); listProjects.Add(project); } } } catch (Exception ex) { } return listProjects; }