Esempio n. 1
0
        public void PersistProject()
        {
            UserModel user = new UserModel();

            user.Name = "admin";
            user.Pswd = "admin";
            user.Privileges = UserModel.UserPrivileges.ADMIN;
            user.Id = user.Persist();

            ProjectModel project = new ProjectModel();
            project.Name = "projectName";
            project.Description = "description";
            project.Active = true;

            ActivityModel activity = new ActivityModel();
            activity.Name = "name";
            activity.Description = "desc";
            activity.PlannedStart = new DateTime();
            activity.PlannedFinish = new DateTime();
            activity.ActualStart = new DateTime();
            activity.ActualFinish = new DateTime();

            project.Activities.Add(activity);
            project.Persist();

            project.AssignUser(user, Role.LEAD);

            project.Activities[0].AssignUser(user.Id);

            project.Activities[0].UpdateProgress(user.Id, 100, "finish");

            //project.Activities[0].RemoveUser(user.Id);
        }
Esempio n. 2
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 });

                                    }

                                }

                            }

                        }
                    }

                }
            }
        }
Esempio n. 3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            Repository repository2 = new Repository();
            List<ProjectModel> project2 = repository2.GetAll<ProjectModel>();
            ProjectModel prj2 = new ProjectModel();

            Repository repositoryallus = new Repository();
            List<UserModel> allusers = repositoryallus.GetAll<UserModel>();
            UserModel allus = new UserModel();

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

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

            if (m_connection == null)
            {
                m_connection = new MySqlConnection(string.Format("SERVER={0};DATABASE={1};UID={2};PASSWORD={3}",
                    SERVER, DATABASE, USERNAME, PASSWORD));
            }

            foreach (UserModel usr2 in allusers)
            {
                comboBox10.Items.Add(usr2.Name);
                comboBox10.SelectedItem = usr2.Id;
            }
            foreach (ProjectUser pr in project4)
            {
                string idchingon = pr.User.Id + "" ;
                string idchingon2 = pr.Project.Id + "";
                string idcurrent = m_currentUser.Id + "";

                if (pr.User.Id== m_currentUser.Id)
                {
                    foreach (ProjectModel pm in project2)
                    {
                        if (pm.Id == pr.Project.Id)
                        {
                            comboBox5.Items.Add(pm.Name);
                            comboBox5.SelectedItem = comboBox5.FindStringExact(pm.Id +"");
                            comboBox11.Items.Add(pm.Name);
                            comboBox11.SelectedItem = comboBox5.FindStringExact(pm.Id + "");
                            comboBox4.Items.Add(pm.Name);
                            comboBox4.SelectedItem = comboBox4.FindStringExact(pm.Id + "");
                        }
                    }
                }
            }
        }
Esempio n. 4
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 + "";
                }
            }
        }
Esempio n. 5
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;

                }
            }
        }
Esempio n. 6
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
        }
Esempio n. 7
0
        private void button6_Click(object sender, EventArgs e)
        {
            bool valid = false;
            bool exist = false;
            ProjectModel project = new ProjectModel();
            if (comboBox11.Text == "" || label19.Text == "DEVELOPER")
            {
                System.Windows.Forms.MessageBox.Show("You must select a project and have the LEAD role");
            }
            else
            {
                if (m_currentUser.Privileges.Equals(UserModel.UserPrivileges.ADMIN))
                {
                    if (monthCalendar4.SelectionEnd.Date <= monthCalendar3.SelectionEnd.Date)
                    {
                        Repository repository = new Repository();
                        List<ProjectModel> projects = repository.GetAll<ProjectModel>();
                        ProjectModel prj7 = new ProjectModel();

                        Repository repository2 = new Repository();
                        List<UserModel> userList = repository2.GetAll<UserModel>();
                        UserModel prj8 = new UserModel();

                        foreach (ProjectModel pr in projects)
                        {
                            if(pr.Name.Equals(comboBox11.Text))
                            {
                                ActivityModel activity = new ActivityModel();
                                activity.Name = textBox6.Text;
                                activity.Description = textBox5.Text;
                                activity.PlannedStart = monthCalendar1.SelectionEnd;
                                activity.PlannedFinish = monthCalendar2.SelectionEnd;

                                pr.Activities.Add(activity);
                                pr.Persist();

                                foreach (UserModel usr in userList)
                                {
                                    if(usr.Name.Equals(comboBox10.Text))
                                    {
                                        usr2 = usr;
                                        activity.AssignUser(usr.Id);

                                         Repository repository3 = new Repository();
                                         List<ProjectUser> users = repository3.GetAll<ProjectUser>();
                                         ProjectUser prj9 = new ProjectUser();

                                         foreach (ProjectUser ex in users)
                                            {
                                                if (ex.User.Name.Equals(comboBox10.Text))
                                                {
                                                        if (ex.Project.Id == (1 + comboBox11.SelectedIndex))
                                                        {
                                                            //System.Windows.Forms.MessageBox.Show("User already exists.");
                                                            valid = true;
                                                            exist = true;
                                                            break;
                                                        }

                                                }

                                            } break;
                                    }
                                }

                                if (exist == false)
                                {
                                    pr.AssignUser(usr2, pmsys_sim_engine.models.Role.DEVELOPER);

                                }

                            }
                        }
                    }
                    else
                    {
                        System.Windows.Forms.MessageBox.Show("End date can not be prior to Start date");
                    }
                }
            }
        }
Esempio n. 8
0
        private void button5_Click(object sender, EventArgs e)
        {
            ProjectModel project2 = new ProjectModel();
             ActivityModel activity = new ActivityModel();
            activity.Name = textBox3.Text;
            activity.Description = textBox4.Text;
            activity.PlannedStart = new DateTime();
            activity.PlannedFinish = new DateTime();
            activity.ActualStart = new DateTime();
            activity.ActualFinish = new DateTime();

            project2.Activities.Add(activity);
            //project2.Activities[0].AssignUser();
        }
Esempio n. 9
0
        private void button4_Click(object sender, EventArgs e)
        {
            if (m_currentUser.Privileges.Equals(UserModel.UserPrivileges.ADMIN))
            {
                if (monthCalendar1.SelectionEnd.Date <= monthCalendar2.SelectionEnd.Date)
                    {
                        ProjectUser user1 = new ProjectUser();
                        ProjectModel project1 = new ProjectModel();
                        project1.Name = textBox1.Text;
                        project1.Description = textBox2.Text;
                        project1.Active = true;

                        ActivityModel activity = new ActivityModel();
                        activity.Name = textBox3.Text;
                        activity.Description = textBox4.Text;
                        activity.PlannedStart = monthCalendar1.SelectionEnd;
                        activity.PlannedFinish = monthCalendar2.SelectionEnd;

                        project1.Activities.Add(activity);
                        project1.Persist();
                        project1.Activities[0].AssignUser(m_currentUser.Id);
                        project1.AssignUser(m_currentUser, pmsys_sim_engine.models.Role.LEAD);
                        System.Windows.Forms.MessageBox.Show("Project correctly created");
                    }
                    else
                    {
                        System.Windows.Forms.MessageBox.Show("End date can not be prior to Start date");
                    }
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("Just the admin can create projects");
            }
        }
Esempio n. 10
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));
        }