Exemple #1
0
 public List<ExtractInfo> WorkOfUserAtProject(int projId, int userId)
 {
     List<ExtractInfo> L = new List<ExtractInfo>();
     string query = "SELECT start_time, description, type, duration FROM activity WHERE user_id = " + userId + " AND project_id = " + projId;
     MySqlDataAdapter adapter = new MySqlDataAdapter(query, connection);
     DataSet dataset = new DataSet();
     adapter.Fill(dataset);
     foreach (DataRow row in dataset.Tables[0].Rows)
     {
         ExtractInfo ei = new ExtractInfo();
         ei.StartTime = Convert.ToDateTime(row["start_time"].ToString());
         ei.Description = Convert.ToString(row["description"]);
         ei.Type =Convert.ToInt32(row["type"].ToString());
         ei.Duration=Convert.ToInt64(row["duration"].ToString());
         L.Add(ei);
     }
     return L;
 }
Exemple #2
0
 public List<ExtractInfo> ActivityExtract(int uid, DateTime date1, DateTime date2)
 {
     List<Project> P = this.AllProjects(true);//toate proiectele sau nu?
     List<ExtractInfo> L = new List<ExtractInfo>();
     string query = "SELECT * FROM activity WHERE user_id = @user_id AND @date1 <= start_time AND start_time <= @date2 ORDER BY start_time ASC";
     MySqlCommand command = new MySqlCommand(query, connection);
     command.Parameters.AddWithValue("@user_id", uid);
     command.Parameters.AddWithValue("@date1", date1);
     command.Parameters.AddWithValue("@date2", date2);
     DataSet dataset = new DataSet();
     MySqlDataAdapter adapter = new MySqlDataAdapter(command);
     adapter.Fill(dataset);
     DataTable table = dataset.Tables[0];
     if (table.Rows.Count > 0)
     {
         foreach (DataRow row in table.Rows)
         {
             ExtractInfo A = new ExtractInfo();
             A.StartTime = Convert.ToDateTime(row["start_time"].ToString());
             A.Description = Convert.ToString(row["description"]);
             A.Type = Convert.ToInt32(row["type"].ToString());
             A.Duration = Convert.ToInt64(row["duration"].ToString());
             int pid = Convert.ToInt32(row["project_id"].ToString());
             A.ProjectName = String.Empty;
             foreach (Project proj in P)
                 if (proj.Id == pid)
                     A.ProjectName = proj.Name;
             if (A.ProjectName != String.Empty)
                 L.Add(A);
         }
         command.Dispose();
         adapter.Dispose();
         dataset.Dispose();
         table.Dispose();
         return L;
     }
     command.Dispose();
     adapter.Dispose();
     dataset.Dispose();
     table.Dispose();
     return null;
 }