Ejemplo n.º 1
0
        private void GetPrevious()
        {
            Person per = currentPerson;

            LinkedListNode<Person> p = persons.Find(per);
            if (p.Previous != null)
            {
                currentPerson = p.Previous.Value;
                ChangePerson();
            }
            else
                return;
        }
Ejemplo n.º 2
0
        public override void LoadParticipants()
        {
            CLIENT client = ClientDataControl.Client.EntityObject as CLIENT;
            GROUP busGrp;
            GROUP itGrp;
            GetGroup("Business", client, out busGrp);
            GetGroup("IT", client, out itGrp);
            Person person;
            CupeData cupeData;
            int id = 1;
            int questionIndex = 1;
            foreach (CONTACT contact in busGrp.CONTACT)
            {
                person = new Person(id);
                person.Type = Person.EmployeeType.Business;
                person.CodeName = "Business" + (id).ToString();
                cupeData = new CupeData(id);
                foreach (CUPERESPONSE response in contact.CUPERESPONSE)
                {
                    questionIndex = ClientDataControl.cupeQuestions.FindIndex(delegate(CupeQuestionStringData question)
                                                                              {
                                                                                  return question.QuestionText == response.CUPE.NAME.TrimEnd();
                                                                              });
                    if (questionIndex != -1)
                    {
                        try
                        {
                            cupeData.CurrentAnswers.Add("Question " + (questionIndex + 1).ToString(), response.CURRENT[0]);
                            cupeData.FutureAnswers.Add("Question " + (questionIndex + 1).ToString(), response.FUTURE[0]);
                        }
                        catch
                        {

                        }

                    }
                }
                person.cupeDataHolder = cupeData;
                ClientDataControl.AddParticipant(person);
                id++;
            }

            foreach (CONTACT contact in itGrp.CONTACT)
            {
                person = new Person(id);
                person.Type = Person.EmployeeType.IT;
                person.CodeName = "IT" + (id).ToString();
                cupeData = new CupeData(id);
                foreach (CUPERESPONSE response in contact.CUPERESPONSE)
                {
                    questionIndex = ClientDataControl.cupeQuestions.FindIndex(delegate(CupeQuestionStringData question)
                                                                              {
                                                                                  return question.QuestionText == response.CUPE.NAME.TrimEnd();
                                                                              });
                    if (questionIndex != -1)
                    {
                        if(response.CURRENT.Length > 0)
                        {
                            cupeData.CurrentAnswers.Add("Question " + (questionIndex + 1).ToString(), response.CURRENT[0]);
                        }
                        if (response.FUTURE.Length > 0)
                        {
                            cupeData.FutureAnswers.Add("Question " + (questionIndex + 1).ToString(), response.FUTURE[0]);
                        }
                    }
                }
                person.cupeDataHolder = cupeData;
                ClientDataControl.AddParticipant(person);
                id++;
            }
        }
Ejemplo n.º 3
0
 public void personListBox_SelectedValueChanged(object sender, EventArgs e)
 {
     ListBox box = (ListBox)sender;
     int selectedindex = box.SelectedIndex;
        // Console.WriteLine(selectedindex.ToString());
     currentPerson = persons.ElementAt<Person>(selectedindex);
     ChangePerson();
 }
Ejemplo n.º 4
0
        private void addPersonButton_Click(object sender, EventArgs e)
        {
            Person person = new Person(persons.Count);
            persons.AddLast(person);
            currentPerson = person;
            person.Owner = this;
            personNameLabel.Text = "Person " + persons.Count.ToString();
            person.PopulateQuestionData();
            ResetQuestions();
            personListBox.Items.Add(person);

            personListBox.MouseDown +=new MouseEventHandler(personListBox_MouseDown);
            personListBox.SelectedValueChanged += new EventHandler(personListBox_SelectedValueChanged);
        }
Ejemplo n.º 5
0
        private void SaveParticipantButton_Click(object sender, EventArgs e)
        {
            int count = 1;
            List<Person> tempList = new List<Person>();
            foreach (DataGridViewRow row in participantsGrid.Rows)
            {
                if(Convert.ToBoolean( row.Cells[2].Value) && Convert.ToBoolean( row.Cells[1].Value))
                {
                    MessageBox.Show("Participants must be either Business or IT", "Error");
                    return;
                }
                else if (!Convert.ToBoolean(row.Cells[2].Value) && !Convert.ToBoolean(row.Cells[1].Value))
                {
                    continue;
                }
                try
                {
                    //Create the new person
                    Person tempPerson = new Person(count++);

                    if (row.Cells[0].Value != null)
                    {
                        tempPerson.Email = row.Cells[0].Value.ToString();
                    }

                    if (Convert.ToBoolean( row.Cells[2].Value) == true)
                    {
                       tempPerson.Type = Person.EmployeeType.IT;
                       tempPerson.CodeName = "Business" + count.ToString();
                    }
                    if ( Convert.ToBoolean( row.Cells[1].Value) == true )
                    {
                       tempPerson.Type = Person.EmployeeType.Business;
                       tempPerson.CodeName = "IT" + count.ToString();
                    }
                   //See if there are answers for the current person

                   CupeData data = null;
                   try
                   {
                       data = ClientDataControl.GetCupeAnswers().Where(x => x.ParticipantId == tempPerson.ID).Single();
                   }
                   catch
                   {

                   }
                   if (data != null)
                   {
                       tempPerson.cupeDataHolder = data;
                   }
                   //If not create new cupedata object
                   else
                   {
                       tempPerson.cupeDataHolder = new CupeData(tempPerson.ID);
                   }

                   tempList.Add(tempPerson);
                }
                catch
                {

                }

            }

            tempList.OrderBy(o => o.ID);

            ClientDataControl.SetParticipants(tempList);
            this.Close();
        }
Ejemplo n.º 6
0
        public void GetNext()
        {
            Person per = currentPerson;
            LinkedListNode<Person> p = persons.Find(per);
            if (p.Next != null)
            {
                currentPerson = p.Next.Value;

                ChangePerson();
            }
            else
                return;
        }
Ejemplo n.º 7
0
        public static bool AddParticipant(Person person)
        {
            participants.Add(person);

            return true;
        }
Ejemplo n.º 8
0
        public void ReadSurveyCUPE(List<Person> people)
        {
            int count = 1;
            var FD = new System.Windows.Forms.FolderBrowserDialog();
            if (FD.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }

            var files = Directory.EnumerateFiles(FD.SelectedPath);
            var badFiles = 0;

            foreach (var file in files)
            {

                if (file.Contains("~$"))
                {
                    badFiles++;
                    continue;
                }
                //Start Word and open the word document.
                Word._Application oWord;
                Word._Document oDoc;
                oWord = new Word.Application();
                oWord.Visible = false;

                oDoc = oWord.Documents.Open(file, Type.Missing, Type.Missing, Type.Missing,
                    Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                    Type.Missing, Type.Missing, false, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
                //oWord.Activate();

                //Loop through the forms. If the person doesn't exist in the participant list then create a new person
                try
                {

                    if (oDoc.Paragraphs.First.Range.Text != "IT Provider Relationship Survey\r")
                    {
                        continue;
                    }

                    //Find the person object the form is related to, otherwise create a new one
                    Person currentPerson = null;
                    foreach (Word.FormField form in oDoc.FormFields)
                    {
                        //Find the person and their type
                        if (form.Name == "Name")
                        {
                            currentPerson = new Person(count++);
                            if (form.Result.ToString() == "Business")
                            {
                                currentPerson.Type = Person.EmployeeType.Business;
                                currentPerson.CodeName = "Business" + count.ToString();
                            }
                            else
                            {
                                currentPerson.Type = Person.EmployeeType.IT;
                                currentPerson.CodeName = "IT" + count.ToString();
                            }
                            ClientDataControl.AddParticipant(currentPerson);
                            break;
                        }
                        else
                        {
                            break;
                        }
                    }

                    int q = 1, c = 1;
                    foreach (Word.FormField form in oDoc.FormFields)
                    {
                        if (form.Name != "Name")
                        {
                            if (c == 1)
                            {
                                currentPerson.cupeDataHolder.CurrentAnswers.Add("Question " + q, form.Result.ToCharArray()[0]);
                                c = 2;
                            }
                            else if (c == 2)
                            {
                                currentPerson.cupeDataHolder.FutureAnswers.Add("Question " + q, form.Result.ToCharArray()[0]);
                                c = 1;
                                q++;
                            }
                        }
                    }
                    ClientDataControl.AddCupeAnswers(currentPerson.cupeDataHolder);
                    oDoc.Close(Word.WdSaveOptions.wdDoNotSaveChanges);
                }
                catch
                {
                    oDoc.Close(Word.WdSaveOptions.wdDoNotSaveChanges);
                }
            }
        }
Ejemplo n.º 9
0
        //creates a new person from the edit participants window
        public void CreatePerson()
        {
            personCount++;
            DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn();
            Person person = new Person(personCount);

            //person.Type = Person.EmployeeType.Business;
            col.HeaderText = "Person  " + (currentGrid.ColumnCount - 6).ToString();

            col.Name = person.CodeName;

            col.Width = 60;

            currentGrid.Columns.Insert(currentGrid.ColumnCount -6, col);
        }
Ejemplo n.º 10
0
        public void ReadSurveyCUPE(List <Person> people)
        {
            int count = 1;
            var FD    = new System.Windows.Forms.FolderBrowserDialog();

            if (FD.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }

            var files    = Directory.EnumerateFiles(FD.SelectedPath);
            var badFiles = 0;

            foreach (var file in files)
            {
                if (file.Contains("~$"))
                {
                    badFiles++;
                    continue;
                }
                //Start Word and open the word document.
                Word._Application oWord;
                Word._Document    oDoc;
                oWord         = new Word.Application();
                oWord.Visible = false;


                oDoc = oWord.Documents.Open(file, Type.Missing, Type.Missing, Type.Missing,
                                            Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                                            Type.Missing, Type.Missing, false, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
                //oWord.Activate();


                //Loop through the forms. If the person doesn't exist in the participant list then create a new person
                try
                {
                    if (oDoc.Paragraphs.First.Range.Text != "IT Provider Relationship Survey\r")
                    {
                        continue;
                    }

                    //Find the person object the form is related to, otherwise create a new one
                    Person currentPerson = null;
                    foreach (Word.FormField form in oDoc.FormFields)
                    {
                        //Find the person and their type
                        if (form.Name == "Name")
                        {
                            currentPerson = new Person(count++);
                            if (form.Result.ToString() == "Business")
                            {
                                currentPerson.Type     = Person.EmployeeType.Business;
                                currentPerson.CodeName = "Business" + count.ToString();
                            }
                            else
                            {
                                currentPerson.Type     = Person.EmployeeType.IT;
                                currentPerson.CodeName = "IT" + count.ToString();
                            }
                            ClientDataControl.AddParticipant(currentPerson);
                            break;
                        }
                        else
                        {
                            break;
                        }
                    }

                    int q = 1, c = 1;
                    foreach (Word.FormField form in oDoc.FormFields)
                    {
                        if (form.Name != "Name")
                        {
                            if (c == 1)
                            {
                                currentPerson.cupeDataHolder.CurrentAnswers.Add("Question " + q, form.Result.ToCharArray()[0]);
                                c = 2;
                            }
                            else if (c == 2)
                            {
                                currentPerson.cupeDataHolder.FutureAnswers.Add("Question " + q, form.Result.ToCharArray()[0]);
                                c = 1;
                                q++;
                            }
                        }
                    }
                    ClientDataControl.AddCupeAnswers(currentPerson.cupeDataHolder);
                    oDoc.Close(Word.WdSaveOptions.wdDoNotSaveChanges);
                }
                catch
                {
                    oDoc.Close(Word.WdSaveOptions.wdDoNotSaveChanges);
                }
            }
        }
Ejemplo n.º 11
0
        public override void LoadParticipants()
        {
            XElement client = ClientDataControl.Client.EntityObject as XElement;
            XElement busGrp;
            XElement itGrp;
            GetGroup("Business", client, out busGrp);
            GetGroup("IT", client, out itGrp);
            Person person;
            CupeData cupeData;
            int id = 1;
            int questionIndex = 0;
            List<XElement> busContacts = busGrp.Element("CONTACTS").Elements("CONTACT").ToList();
            List<XElement> itContacts = itGrp.Element("CONTACTS").Elements("CONTACT").ToList();
            foreach (XElement contact in busContacts)
            {
                person = new Person(id);
                person.Type = Person.EmployeeType.Business;
                person.CodeName = "Business" + (id).ToString();
                cupeData = new CupeData(id);
                foreach (XElement response in contact.Element("CUPERESPONSES").Elements("CUPERESPONSE"))
                {
                    questionIndex = ClientDataControl.cupeQuestions.FindIndex(delegate(CupeQuestionStringData question)
                    {
                        return question.QuestionText == response.Element("CUPE").Value;
                    });
                    if (questionIndex != -1)
                    {
                        cupeData.CurrentAnswers.Add("Question " + (questionIndex+1).ToString(), response.Element("CURRENT").Value != "" ? response.Element("CURRENT").Value[0] : ' ');
                        cupeData.FutureAnswers.Add("Question " + (questionIndex+1).ToString(), response.Element("FUTURE").Value != "" ? response.Element("FUTURE").Value[0] : ' ');
                    }
                }
                person.cupeDataHolder = cupeData;
                ClientDataControl.AddParticipant(person);
                id++;
            }

            foreach (XElement contact in itContacts)
            {
                person = new Person(id);
                person.Type = Person.EmployeeType.IT;
                person.CodeName = "IT" + (id).ToString();
                cupeData = new CupeData(id);
                foreach (XElement response in contact.Element("CUPERESPONSES").Elements("CUPERESPONSE"))
                {
                    questionIndex = ClientDataControl.cupeQuestions.FindIndex(delegate(CupeQuestionStringData question)
                    {
                        return question.QuestionText == response.Element("CUPE").Value;
                    });
                    if (questionIndex != -1)
                    {
                        cupeData.CurrentAnswers.Add("Question " + (questionIndex + 1).ToString(), response.Element("CURRENT").Value != "" ? response.Element("CURRENT").Value[0] : ' ');
                        cupeData.FutureAnswers.Add("Question " + (questionIndex + 1).ToString(), response.Element("FUTURE").Value != "" ? response.Element("FUTURE").Value[0] : ' ');
                    }
                }
                person.cupeDataHolder = cupeData;
                ClientDataControl.AddParticipant(person);
                id++;
            }
        }