Beispiel #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            this.dataGridView2.DataSource = null;
            this.dataGridView2.Rows.Clear();

            Repository repository4 = new Repository();
            List<ProjectUser> project4 = repository4.GetAll<ProjectUser>();
            ProjectUser prj4 = new ProjectUser();

            Repository repository5 = new Repository();
            List<ActivityModel> project5 = repository5.GetAll<ActivityModel>();
            ActivityModel prj5 = new ActivityModel();

            Repository repository6 = new Repository();
            List<ProjectUser> project6 = repository6.GetAll<ProjectUser>();
            ProjectUser prj6 = new ProjectUser();

            Repository repository7 = new Repository();
            List<UserActivity> project7 = repository7.GetAll<UserActivity>();
            UserActivity prj7 = new UserActivity();

            string idproyecto = comboBox4.SelectedIndex + "";
            string role;
            string usname;
            string prname;
            string practive;

            foreach (ProjectUser pr in project4){
                if(pr.Project.Id==(comboBox4.SelectedIndex + 1)){
                    foreach (ActivityModel am in project5)
                    {
                        if (pr.Project.Id == am.projectid )
                        {
                            idfinal = am.Id + "";
                            proact = am.Name + "";

                            foreach (UserActivity ua in project7)
                            {

                                if ((idfinal.Equals(ua.ActivityId + "")) && pr.Project.Id == ua.ProjectId)
                                {

                                    userfinal = ua.UserId + "";

                                    if ((pr.User.Id + "").Equals(userfinal))
                                    {
                                        role = pr.Role + "";
                                        usname = pr.User.Name + "";
                                        prname = pr.Project.Name + "";
                                        practive = pr.Project.Active + "";

                                        dataGridView2.Rows.Add(new object[] { prname, usname, role, proact, practive });

                                    }

                                }

                            }

                        }
                    }

                }
            }
        }
Beispiel #2
0
        private void comboBox5_SelectedIndexChanged(object sender, EventArgs e)
        {
            comboBox7.Items.Clear();
            progressBar1.Increment(0);
            contador = 0;
            acum = 0;
            progressBar1.Value = 0;

            Repository repository2 = new Repository();
            List<UserActivity> project2 = repository2.GetAll<UserActivity>();
            UserActivity prj2 = new UserActivity();

            Repository repository3 = new Repository();
            List<ProjectUser> project3 = repository3.GetAll<ProjectUser>();
            ProjectUser prj3 = new ProjectUser();

            Repository repository4 = new Repository();
            List<ActivityModel> project4 = repository4.GetAll<ActivityModel>();
            ActivityModel prj4 = new ActivityModel();

            Repository repository10 = new Repository();
            List<ProjectModel> project10 = repository10.GetAll<ProjectModel>();
            ProjectModel prj10 = new ProjectModel();

            foreach (ProjectModel amo1 in project10)
            {
                string ab = comboBox5.SelectedItem + "";
                if (ab.Equals(amo1.Name))
                {
                    idactividadt3 = amo1.Id + "";

                }
            }

            foreach (UserActivity uact in project2)
            {
                if (idactividadt3.Equals(uact.ProjectId+"")&&m_currentUser.Id == uact.UserId)
                {

                    acum = acum +  Convert.ToInt32(uact.Progress);
                    contador = contador + 1;

                }
            }
            if (contador == 0)
            {
                acum =0;
            }
            else
            {
                acum /= contador;

            }

            progressBar1.Increment(acum);

            foreach (ProjectUser pm in project3)
            {
                if (pm.Project.Name == comboBox5.Text)
                {
                    foreach (UserActivity ua in project2)
                    {
                        if (m_currentUser.Id == ua.UserId)
                        {
                            foreach (ActivityModel act in project4)
                            {
                                if (ua.ActivityId == act.Id && ua.ProjectId == pm.Project.Id)
                                {
                                    comboBox7.Items.Add(act.Name);
                                    comboBox7.SelectedItem = act.Id;
                                }
                            }
                            //break;
                        }

                    } break;

                }
            }
        }
Beispiel #3
0
        private void comboBox7_SelectedIndexChanged(object sender, EventArgs e)
        {
            Repository repository9 = new Repository();
            List<ActivityModel> project9 = repository9.GetAll<ActivityModel>();
            ActivityModel prj9 = new ActivityModel();

            foreach (ActivityModel amo in project9)
            {
                string ab = comboBox7.SelectedItem + "";
                if (ab.Equals(amo.Name))
                {
                    idactividadt2 = amo.Id + "";
                }
            }

            Repository repository6 = new Repository();
            List<UserActivity> project6 = repository6.GetAll<UserActivity>();
            UserActivity prj6 = new UserActivity();

            foreach (UserActivity ua in project6)
            {
                if (ua.ActivityId == Convert.ToInt32(idactividadt2))
                {
                    textBox7.Text = ua.Progress + "";
                }
            }
        }
Beispiel #4
0
        private void button7_Click(object sender, EventArgs e)
        {
            Repository repository8 = new Repository();
            List<ActivityModel> project8 = repository8.GetAll<ActivityModel>();
            ActivityModel prj8 = new ActivityModel();

            foreach (ActivityModel amo in project8)
            {
                string ab = comboBox7.SelectedItem + "";
                if (ab.Equals(amo.Name))
                {
                    idactividadt = amo.Id + "";
                }
            }

            string dbConnectionString = "Server=localhost;Database=pmsys_db;Uid=root;Password=MySQL";
            int temp = Convert.ToInt32(textBox7.Text);
                MySqlConnection db = new MySqlConnection(dbConnectionString);
                MySqlCommand dbCommand = db.CreateCommand();
                dbCommand.CommandText = "UPDATE users_has_activities SET usr_act_progress=" + temp + " WHERE activities_act_id=" + idactividadt + " AND users_usr_id=" + m_currentUser.Id;
                db.Open();
                dbCommand.ExecuteNonQuery();
                db.Close();

            Repository repository4 = new Repository();
            List<UserActivity> project4 = repository4.GetAll<UserActivity>();
            UserActivity prj4 = new UserActivity();

            Repository repository5 = new Repository();
            List<ProjectModel> project5 = repository5.GetAll<ProjectModel>();
            ProjectModel prj5 = new ProjectModel();

            Repository repository6 = new Repository();
            List<ActivityModel> project6 = repository6.GetAll<ActivityModel>();
            ActivityModel prj6 = new ActivityModel();

               foreach(UserActivity ua in project4)
               {
                   if (ua.ActivityId == (comboBox7.SelectedIndex)+1)
                   {
                      // ua.Progress = Convert.ToInt32(textBox7.Text);
                       prj6.UpdateProgress(ua.UserId,Convert.ToInt32(textBox7.Text),"yeah");
                       //UpdateProgress(Int32? userId, int progress, string comments)
                      // ua.Activities[0].UpdateProgress(user.Id, 100, "finish");
                   }
               }
                //comboBox7
        }
Beispiel #5
0
 public void UpdateProgress(Int32? userId, int progress, string comments)
 {
     UserActivity u = new UserActivity();
     u.UserId = userId;
     u.ProjectId = this.ProjectId;
     u.ActivityId = this.Id;
     u.Progress = progress;
     u.Comments = comments;
     Persist(u);
 }
Beispiel #6
0
 public void RemoveUser(Int32? userId)
 {
     UserActivity u = new UserActivity();
     u.UserId = userId;
     u.ProjectId = this.ProjectId;
     u.ActivityId = this.Id;
     u.Progress = 0;
     u.Comments = "";
     Remove<UserActivity>(u);
 }
Beispiel #7
0
 public void AssignUser(Int32? userId)
 {
     UserActivity u = new UserActivity();
     u.UserId = userId;
     u.ProjectId = this.ProjectId;
     u.ActivityId = this.Id;
     u.Progress = 0;
     u.Comments = "";
     Persist(u);
 }
Beispiel #8
0
        private T CreateModel <T>(MySqlDataReader dataReader)
        {
            Type modelType = typeof(T);

            if (modelType == typeof(UserModel))
            {
                UserModel user = new UserModel();
                user.Id   = dataReader.GetInt32(0);
                user.Name = dataReader.GetString(1);
                user.Pswd = dataReader.GetString(2);

                user.Privileges = (UserModel.UserPrivileges)
                                  Enum.Parse(typeof(UserModel.UserPrivileges), dataReader.GetString(4));
                return((T)Convert.ChangeType(user, typeof(T)));
            }
            else if (modelType == typeof(ProjectModel))
            {
                ProjectModel projectModel = new ProjectModel();
                projectModel.Id          = dataReader.GetInt32(0);
                projectModel.Name        = dataReader.GetString(1);
                projectModel.Description = dataReader.IsDBNull(2) ? null : dataReader.GetString(2);
                return((T)Convert.ChangeType(projectModel, typeof(T)));
            }
            else if (modelType == typeof(ActivityModel))
            {
                ActivityModel activity = new ActivityModel();
                activity.Id            = dataReader.GetInt32(0);
                activity.Name          = dataReader.GetString(1);
                activity.Description   = dataReader.IsDBNull(2) ? null : dataReader.GetString(2);
                activity.PlannedStart  = dataReader.GetDateTime(3);
                activity.PlannedFinish = dataReader.GetDateTime(4);
                activity.ActualStart   = dataReader.IsDBNull(5) ?  (DateTime?)null : dataReader.GetDateTime(5);
                activity.ActualFinish  = dataReader.IsDBNull(6) ? (DateTime?)null : dataReader.GetDateTime(6);
                activity.projectid     = dataReader.GetInt32(7);
                return((T)Convert.ChangeType(activity, typeof(T)));
            }
            else if (modelType == typeof(ProjectUser))
            {
                ProjectUser projectUser = new ProjectUser();
                projectUser.Project.Id          = dataReader.GetInt32(0);
                projectUser.Project.Name        = dataReader.GetString(1);
                projectUser.Project.Description = dataReader.IsDBNull(2) ? null : dataReader.GetString(2);
                projectUser.Project.Active      = dataReader.GetBoolean(3);

                projectUser.User.Name = dataReader.IsDBNull(5) ? null : dataReader.GetString(5);


                projectUser.User.Id = dataReader.IsDBNull(4)? (int?)null : dataReader.GetInt32(4);

                projectUser.User.Privileges = dataReader.IsDBNull(6) ? (UserModel.UserPrivileges?) null:
                                              (UserModel.UserPrivileges)Enum.Parse(typeof(UserModel.UserPrivileges), dataReader.GetString(6));

                projectUser.Role = dataReader.IsDBNull(7) ?(Role?)null :
                                   (Role)Enum.Parse(typeof(Role), dataReader.GetString(7));

                projectUser.User.Active = dataReader.IsDBNull(8) ? false : dataReader.GetBoolean(8);



                return((T)Convert.ChangeType(projectUser, typeof(T)));
            }
            else if (modelType == typeof(UserActivity))
            {
                UserActivity userAct = new UserActivity();
                userAct.UserId     = dataReader.GetInt32(0);
                userAct.ActivityId = dataReader.GetInt32(1);
                userAct.ProjectId  = dataReader.GetInt32(2);
                userAct.Progress   = dataReader.GetInt32(3);
                userAct.Comments   = dataReader.IsDBNull(4) ? null : dataReader.GetString(4);

                return((T)Convert.ChangeType(userAct, typeof(T)));
            }

            return(default(T));
        }