Esempio n. 1
0
        public override void SaveCUPEParticipants()
        {
            Random rnd = new Random();
            List<Person> personList = ClientDataControl.GetParticipants();
            CLIENT client = ClientDataControl.Client.EntityObject as CLIENT;
            GROUP busGrp;
            GROUP itGrp;
            if(!GetGroup("Business", client, out busGrp))
            {
                AddGroup("Business", client);
                GetGroup("Business", client, out busGrp);
            }
            if(!GetGroup("IT", client, out itGrp))
            {
                AddGroup("IT", client);
                GetGroup("IT", client, out itGrp);
            }
            CONTACT contact;
            CUPERESPONSE response;
            CUPE cupe;

            List<CONTACT> contactsToDelete = busGrp.CONTACT.ToList();
            List<CUPERESPONSE> responsesToDelete;
            foreach (CONTACT contactToDelete in contactsToDelete)
            {
                responsesToDelete = contactToDelete.CUPERESPONSE.ToList();
                foreach (CUPERESPONSE responseToDelete in responsesToDelete)
                {
                    dbo.DeleteObject(responseToDelete);
                }
                dbo.DeleteObject(contactToDelete);
            }
            contactsToDelete = itGrp.CONTACT.ToList();
            foreach (CONTACT contactToDelete in contactsToDelete)
            {
                responsesToDelete = contactToDelete.CUPERESPONSE.ToList();
                foreach (CUPERESPONSE responseToDelete in responsesToDelete)
                {
                    dbo.DeleteObject(responseToDelete);
                }
                dbo.DeleteObject(contactToDelete);
            }
            foreach (Person person in personList)
            {
                if (person.Type == Person.EmployeeType.Business)
                {
                    contact = new CONTACT();
                    contact.ID = rnd.Next();
                    busGrp.CONTACT.Add(contact);
                    dbo.AddToCONTACT(contact);

                    List<CupeQuestionStringData> questionList = ClientDataControl.GetCupeQuestions();
                    for (int i = 0; i < questionList.Count; i++)
                    {
                        CupeQuestionStringData data = questionList[i];
                        if (!GetCUPE(data.QuestionText, client, out cupe))
                        {
                            MessageBox.Show("Error: couldn't find cupe: " + data.QuestionText);
                            continue;
                        }

                        response = new CUPERESPONSE();
                        response.CONTACT = contact;
                        response.CUPE = cupe;
                        dbo.AddToCUPERESPONSE(response);

                        response.CURRENT = person.cupeDataHolder.CurrentAnswers.ContainsKey("Question " + (i + 1).ToString()) ? person.cupeDataHolder.CurrentAnswers["Question " + (i + 1).ToString()].ToString() : "";
                        response.FUTURE = person.cupeDataHolder.FutureAnswers.ContainsKey("Question " + (i + 1).ToString()) ? person.cupeDataHolder.FutureAnswers["Question " + (i + 1).ToString()].ToString() : "";
                    }
                }

                else if(person.Type == Person.EmployeeType.IT)
                {
                    contact = new CONTACT();
                    contact.ID = rnd.Next();
                    itGrp.CONTACT.Add(contact);
                    dbo.AddToCONTACT(contact);

                    List<CupeQuestionStringData> questionList = ClientDataControl.GetCupeQuestions();
                    for(int i = 0; i < questionList.Count; i++)
                    {
                        CupeQuestionStringData data = questionList[i];
                        if (!GetCUPE(data.QuestionText, client, out cupe))
                        {
                            MessageBox.Show("Error: couldn't find cupe: " + data.QuestionText);
                            continue;
                        }

                        response = new CUPERESPONSE();
                        response.CONTACT = contact;
                        response.CUPE = cupe;
                        dbo.AddToCUPERESPONSE(response);

                        response.CURRENT = person.cupeDataHolder.CurrentAnswers.ContainsKey("Question " + (i+1).ToString()) ? person.cupeDataHolder.CurrentAnswers["Question " + (i+1).ToString()].ToString() : "";
                        response.FUTURE = person.cupeDataHolder.FutureAnswers.ContainsKey("Question " + (i+1).ToString()) ? person.cupeDataHolder.FutureAnswers["Question " + (i+1).ToString()].ToString() : "";
                    }
                }
            }
        }
Esempio n. 2
0
        public bool GetCUPEResponse(string cupeName, CONTACT contact, out CUPERESPONSE response)
        {
            CLIENT client = ClientDataControl.Client.EntityObject as CLIENT;
            try
            {
                response = (from ent in contact.CUPERESPONSE
                            where ent.CUPE.NAME.TrimEnd() == cupeName
                            select ent).Single();
            }

            catch
            {
                response = null;
                return false;
            }

            return true;
        }
Esempio n. 3
0
        public bool GetContact(int id, out CONTACT contact)
        {
            try
            {
                contact = (from ent in dbo.CONTACT
                          where ent.ID == id
                          select ent).Single();
            }

            catch
            {
                contact = null;
                return false;
            }

            return true;
        }
Esempio n. 4
0
        public bool AddContact(int id, GROUP grp)
        {
            if ((from ent in grp.CONTACT
                 where ent.ID == id
                 select ent).Count() != 0)
            {
                return false;
            }

            CONTACT contact = new CONTACT();
            contact.ID = id;
            grp.CONTACT.Add(contact);
            dbo.AddToCONTACT(contact);

            return true;
        }
Esempio n. 5
0
 /// <summary>
 /// Deprecated Method for adding a new object to the CONTACT EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToCONTACT(CONTACT cONTACT)
 {
     base.AddObject("CONTACT", cONTACT);
 }
Esempio n. 6
0
 /// <summary>
 /// Create a new CONTACT object.
 /// </summary>
 /// <param name="cONTACTID">Initial value of the CONTACTID property.</param>
 /// <param name="id">Initial value of the ID property.</param>
 public static CONTACT CreateCONTACT(global::System.Int32 cONTACTID, global::System.Int32 id)
 {
     CONTACT cONTACT = new CONTACT();
     cONTACT.CONTACTID = cONTACTID;
     cONTACT.ID = id;
     return cONTACT;
 }