Пример #1
0
 public void Remove()
 {
     Repository repository = new Repository();
     UserModel user = new UserModel();
     user.Id = 4;
     repository.Remove<UserModel>(user);
 }
Пример #2
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);
        }
Пример #3
0
        public Form1(UserModel user)
        {
            //Form2 login = new Form2();
            //login.m
            m_currentUser = user;
               // m_projectUser = projUser;

            InitializeComponent();
        }
Пример #4
0
        public void GetUsersTest()
        {
            Report report = new Report();

            UserModel user = new UserModel();
            user.Name = "user";

            //List<UserModel> users = report.GetUsers(user);
        }
Пример #5
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 + "");
                        }
                    }
                }
            }
        }
Пример #6
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");
                    }
                }
            }
        }
Пример #7
0
 public void AssignUser(UserModel user, Role role)
 {
     LinkUserToProject(this.Id, user.Id, role.ToString());
 }
Пример #8
0
        private void button1_Click(object sender, EventArgs e)
        {
            Repository repository = new Repository();

            List<UserModel> users =  repository.GetAll<UserModel>();

            bool valid = false;
            bool exist = false;

            UserModel test = new UserModel();

                if (checkBox1.Checked)
                {
                    foreach (UserModel ex in users)
                    {
                        if (ex.Name.Equals(textBox1.Text))
                        {
                            System.Windows.Forms.MessageBox.Show("User already exists.");
                            valid = true;
                            exist = true;
                            break;
                        }
                        else
                        {
                            exist = false;
                        }
                    }

                    if (exist == false)
                    {

                        if ((textBox1.Text == "") || (textBox2.Text == "") || (textBox3.Text == ""))
                        {
                            System.Windows.Forms.MessageBox.Show("Invalid data.");
                       	}
                       	else
                        {
                            if (textBox2.Text == textBox3.Text)
                            {
                                UserModel user = new UserModel();

                                user.Name = textBox1.Text;
                                user.Pswd = textBox2.Text;
                                user.Privileges = UserModel.UserPrivileges.USER;
                                user.Id = user.Persist();
                                System.Windows.Forms.MessageBox.Show("User correctly created.");

                                textBox1.Clear();
                                textBox2.Clear();
                                textBox3.Clear();
                                checkBox1.Checked = false;

                                var ventana = new Form1(user);
                                ventana.Show();
                            }
                            else
                            {
                                System.Windows.Forms.MessageBox.Show("Password does not mach.");
                                 }
                         	}
                         	valid = true;
                        }
                }
                else
                {
                    foreach (UserModel us in users)
                    {
                        if( us.Name.Equals(textBox1.Text))
                        {
                            valid = true;
                            if (us.Pswd.Equals(textBox2.Text))
                            {
                                var ventana = new Form1(us);
                                ventana.Show();
                                break;
                            }
                            else
                            {
                                System.Windows.Forms.MessageBox.Show("incorrect password");
                                break;
                            }
                        }
                    }
                }
                if (!valid)
                {
                    System.Windows.Forms.MessageBox.Show("User does not exist");
                }
        }
Пример #9
0
 public ProjectUser()
 {
     m_project = new ProjectModel();
     m_user = new UserModel();
 }