예제 #1
0
        public bool AddQuestion(string main, string a, string b, string c, string d)
        {
            CupeQuestionStringData data = new CupeQuestionStringData();
            data.ChoiceA = a;
            data.ChoiceB = b;
            data.ChoiceC = c;
            data.ChoiceD = d;
            data.OriginalQuestionText = main;
            data.QuestionText = main;
            if (ClientDataControl.db.AddCupeQuestion(data) && ClientDataControl.db.SaveChanges())
            {
                DataGridViewRow row = row = CUPEQuestionDataGridView.Rows[0].Clone() as DataGridViewRow;
                row.Cells[0].Value = false;
                row.Cells[1].Value = false;
                row.Cells[2].Value = main;
                row.Cells[3].Value = a;
                row.Cells[4].Value = b;
                row.Cells[5].Value = c;
                row.Cells[6].Value = d;
                CUPEQuestionDataGridView.Rows.Add(row);
                return true;
            }

            else
            {
                return false;
            }
        }
예제 #2
0
        public bool AddQuestion(string main, string a, string b, string c, string d)
        {
            CupeQuestionStringData data = new CupeQuestionStringData();

            data.ChoiceA = a;
            data.ChoiceB = b;
            data.ChoiceC = c;
            data.ChoiceD = d;
            data.OriginalQuestionText = main;
            data.QuestionText         = main;
            if (ClientDataControl.db.AddCupeQuestion(data) && ClientDataControl.db.SaveChanges())
            {
                DataGridViewRow row = row = CUPEQuestionDataGridView.Rows[0].Clone() as DataGridViewRow;
                row.Cells[0].Value = false;
                row.Cells[1].Value = false;
                row.Cells[2].Value = main;
                row.Cells[3].Value = a;
                row.Cells[4].Value = b;
                row.Cells[5].Value = c;
                row.Cells[6].Value = d;
                CUPEQuestionDataGridView.Rows.Add(row);
                return(true);
            }

            else
            {
                return(false);
            }
        }
예제 #3
0
 public abstract string UpdateCUPE(CupeQuestionStringData cupeQuestion);
예제 #4
0
        public static bool AddCupeQuestion(CupeQuestionStringData data)
        {
            cupeQuestions.Add(data);

            return(true);
        }
예제 #5
0
        public static bool AddCupeQuestion(CupeQuestionStringData data)
        {
            cupeQuestions.Add(data);

            return true;
        }
예제 #6
0
        public override List<CupeQuestionStringData> GetCUPEQuestionStringDataTwenty()
        {
            List<XElement> cupeQuestionEntList = (from ent in dbo.Element("CUPEQUESTIONS").Elements("CUPEQUESTION")
                                                  where ent.Element("INTWENTY").Value == "Y"
                                                  select ent).ToList();

            List<CupeQuestionStringData> cupeQuestionList = new List<CupeQuestionStringData>();
            CupeQuestionStringData cupeQuestion;
            foreach (XElement cupeQuestionEnt in cupeQuestionEntList)
            {
                cupeQuestion = new CupeQuestionStringData();
                cupeQuestion.OriginalQuestionText = cupeQuestion.QuestionText = cupeQuestionEnt.Element("NAME").Value;
                cupeQuestion.ChoiceA = cupeQuestionEnt.Element("COMMODITY").Value;
                cupeQuestion.ChoiceB = cupeQuestionEnt.Element("UTILITY").Value;
                cupeQuestion.ChoiceC = cupeQuestionEnt.Element("PARTNER").Value;
                cupeQuestion.ChoiceD = cupeQuestionEnt.Element("ENABLER").Value;
                cupeQuestionList.Add(cupeQuestion);
            }

            return cupeQuestionList;
        }
예제 #7
0
        public override string UpdateCUPE(CupeQuestionStringData cupeQuestion)
        {
            CLIENT client = ClientDataControl.Client.EntityObject as CLIENT;
            try
            {
                CUPE cupe = (from ent in client.CUPE
                             where ent.CUPEQUESTION.NAME.TrimEnd() == cupeQuestion.OriginalQuestionText
                             select ent).Single();

                cupe.NAME = cupeQuestion.QuestionText;
                cupe.COMMODITY = cupeQuestion.ChoiceA;
                cupe.UTILITY = cupeQuestion.ChoiceB;
                cupe.PARTNER = cupeQuestion.ChoiceC;
                cupe.ENABLER = cupeQuestion.ChoiceD;

                if (cupe.NAME.TrimEnd() != cupe.CUPEQUESTION.NAME.TrimEnd())
                {
                    CUPEQUESTION cupeQuestionEnt;
                    if(!GetCUPEQuestion(cupe.NAME.TrimEnd(), out cupeQuestionEnt))
                    {
                        cupeQuestionEnt = new CUPEQUESTION();
                        cupeQuestionEnt.NAME = cupe.NAME;
                        cupeQuestionEnt.COMMODITY = cupe.COMMODITY;
                        cupeQuestionEnt.UTILITY = cupe.UTILITY;
                        cupeQuestionEnt.PARTNER = cupe.PARTNER;
                        cupeQuestionEnt.ENABLER = cupe.ENABLER;
                        cupeQuestionEnt.INTWENTY = cupeQuestionEnt.INTEN = "N";
                    }

                    cupe.CUPEQUESTION = cupeQuestionEnt;
                    cupeQuestion.OriginalQuestionText = cupeQuestionEnt.NAME.TrimEnd();
                }
            }

            catch
            {
                MessageBox.Show("Failed to update CUPE: " + cupeQuestion.QuestionText, "Error");
            }

            return cupeQuestion.OriginalQuestionText;
        }
예제 #8
0
        public override bool AddCupeQuestion(CupeQuestionStringData cupeQuestion)
        {
            if ((from ent in dbo.CUPEQUESTION
                 where ent.NAME.TrimEnd() == cupeQuestion.QuestionText
                 select ent).Count() != 0)
            {
                MessageBox.Show("Error adding question: Question already exists", "Error");
                return false;
            }

            CUPEQUESTION cupeQuestionEnt = new CUPEQUESTION();
            cupeQuestionEnt.NAME = cupeQuestion.QuestionText;
            cupeQuestionEnt.COMMODITY = cupeQuestion.ChoiceA;
            cupeQuestionEnt.UTILITY = cupeQuestion.ChoiceB;
            cupeQuestionEnt.PARTNER = cupeQuestion.ChoiceC;
            cupeQuestionEnt.ENABLER = cupeQuestion.ChoiceD;
            cupeQuestionEnt.INTWENTY = cupeQuestionEnt.INTEN = "N";

            dbo.AddToCUPEQUESTION(cupeQuestionEnt);

            return true;
        }
예제 #9
0
        public override List<CupeQuestionStringData> GetCUPEQuestionStringDataTwenty()
        {
            List<CUPEQUESTION> cupeQuestionEntList = (from ent in dbo.CUPEQUESTION
                                                      where ent.INTWENTY == "Y"
                                                      select ent).ToList();

            List<CupeQuestionStringData> cupeQuestionList = new List<CupeQuestionStringData>();
            CupeQuestionStringData cupeQuestion;
            foreach (CUPEQUESTION cupeQuestionEnt in cupeQuestionEntList)
            {
                cupeQuestion = new CupeQuestionStringData();
                cupeQuestion.OriginalQuestionText = cupeQuestionEnt.NAME.TrimEnd();
                cupeQuestion.QuestionText = cupeQuestionEnt.NAME.TrimEnd();
                cupeQuestion.ChoiceA = cupeQuestionEnt.COMMODITY.TrimEnd();
                cupeQuestion.ChoiceB = cupeQuestionEnt.UTILITY.TrimEnd();
                cupeQuestion.ChoiceC = cupeQuestionEnt.PARTNER.TrimEnd();
                cupeQuestion.ChoiceD = cupeQuestionEnt.ENABLER.TrimEnd();
                cupeQuestionList.Add(cupeQuestion);
            }

            return cupeQuestionList;
        }
예제 #10
0
        public override bool AddCupeQuestion(CupeQuestionStringData cupeQuestion)
        {
            string question = cupeQuestion.QuestionText;
            if ((from ent in dbo.Element("CUPEQUESTIONS").Elements("CUPEQUESTION")
                 where ent.Element("NAME").Value == question
                 select ent).Count() != 0)
            {
                MessageBox.Show("Error adding question: Question already exists", "Error");
                return false;
            }

            string commodity = cupeQuestion.ChoiceA;
            string utility = cupeQuestion.ChoiceB;
            string partner = cupeQuestion.ChoiceC;
            string enabler = cupeQuestion.ChoiceD;

            XElement cupeQuestionEnt = new XElement("CUPEQUESTION");
            cupeQuestionEnt.Add(new XElement("NAME", question));
            cupeQuestionEnt.Add(new XElement("COMMODITY", commodity));
            cupeQuestionEnt.Add(new XElement("UTILITY", utility));
            cupeQuestionEnt.Add(new XElement("PARTNER", partner));
            cupeQuestionEnt.Add(new XElement("ENABLER", enabler));
            cupeQuestionEnt.Add(new XElement("INTWENTY", "N"));
            cupeQuestionEnt.Add(new XElement("INTEN", "N"));

            dbo.Element("CUPEQUESTIONS").Add(cupeQuestionEnt);

            changeLog.Add("ADD CUPEQUESTION " + question.Replace(' ', '~') + " " +
                          commodity.Replace(' ', '~') + " " + utility.Replace(' ', '~') + " " +
                          partner.Replace(' ', '~') + " " + enabler.Replace(' ', '~'));

            return true;
        }
예제 #11
0
        public override string UpdateCUPE(CupeQuestionStringData cupeQuestion)
        {
            XElement client = ClientDataControl.Client.EntityObject as XElement;
            try
            {
                XElement cupe = (from ent in client.Element("CUPES").Elements("CUPE")
                             where ent.Element("CUPEQUESTION").Value == cupeQuestion.OriginalQuestionText
                             select ent).Single();
                cupe.Element("NAME").Value = cupeQuestion.QuestionText;
                cupe.Element("COMMODITY").Value = cupeQuestion.ChoiceA;
                cupe.Element("UTILITY").Value = cupeQuestion.ChoiceB;
                cupe.Element("PARTNER").Value = cupeQuestion.ChoiceC;
                cupe.Element("ENABLER").Value = cupeQuestion.ChoiceD;

                if (cupe.Element("NAME").Value != cupe.Element("CUPEQUESTION").Value)
                {
                    XElement cupeQuestionEnt;
                    if (!GetCUPEQuestion(cupe.Element("NAME").Value, out cupeQuestionEnt))
                    {
                        string question = cupe.Element("NAME").Value;
                        string commodity = cupe.Element("COMMODITY").Value;
                        string utility = cupe.Element("UTILITY").Value;
                        string partner = cupe.Element("PARTNER").Value;
                        string enabler = cupe.Element("ENABLER").Value;

                        cupeQuestionEnt = new XElement("CUPEQUESTION");
                        cupeQuestionEnt.Add(new XElement("NAME", question));
                        cupeQuestionEnt.Add(new XElement("COMMODITY", commodity));
                        cupeQuestionEnt.Add(new XElement("UTILITY", utility));
                        cupeQuestionEnt.Add(new XElement("PARTNER", partner));
                        cupeQuestionEnt.Add(new XElement("ENABLER", enabler));
                        cupeQuestionEnt.Add(new XElement("INTWENTY", "N"));
                        cupeQuestionEnt.Add(new XElement("INTEN", "N"));

                        changeLog.Add("ADD CUPEQUESTION " + question.Replace(' ', '~') + " " +
                                      commodity.Replace(' ', '~') + " " + utility.Replace(' ', '~') + " " +
                                      partner.Replace(' ', '~') + " " + enabler.Replace(' ', '~'));
                    }

                    changeLog.Add("UPDATE CUPE " + client.Element("NAME").Value.Replace(' ', '~') + " " +
                              cupeQuestion.OriginalQuestionText.Replace(' ', '~') + " " +
                              cupeQuestion.QuestionText.Replace(' ', '~') + " " +
                              cupeQuestion.ChoiceA.Replace(' ', '~') + " " +
                              cupeQuestion.ChoiceB.Replace(' ', '~') + " " +
                              cupeQuestion.ChoiceC.Replace(' ', '~') + " " +
                              cupeQuestion.ChoiceD.Replace(' ', '~'));

                    cupe.Element("CUPEQUESTION").Value = cupeQuestion.OriginalQuestionText = cupeQuestionEnt.Element("NAME").Value;
                }
            }

            catch
            {
                MessageBox.Show("Failed to update CUPE: " + cupeQuestion.QuestionText, "Error");
            }

            return cupeQuestion.OriginalQuestionText;
        }
예제 #12
0
        public override void PopulateCUPEQuestionsForClient(CUPETool cupeForm)
        {
            XElement client = ClientDataControl.Client.EntityObject as XElement;
            CupeQuestionStringData data = new CupeQuestionStringData();
            List<XElement> cupeList = client.Element("CUPES").Elements("CUPE").ToList();
            if (cupeList.Count != 0)
            {
                foreach (XElement cupe in cupeList)
                {
                    data.QuestionText = cupe.Element("NAME").Value;
                    data.ChoiceA = cupe.Element("COMMODITY").Value;
                    data.ChoiceB = cupe.Element("UTILITY").Value;
                    data.ChoiceC = cupe.Element("PARTNER").Value;
                    data.ChoiceD = cupe.Element("ENABLER").Value;

                    ClientDataControl.AddCupeQuestion(data);
                    data = new CupeQuestionStringData();
                }
            }

            else
            {
                List<XElement> cupeQuestionList = dbo.Element("CUPEQUESTIONS").Elements("CUPEQUESTION").ToList();
                foreach (XElement cupeQuestion in cupeQuestionList)
                {
                    if (cupeQuestion.Element("INTWENTY").Value == "Y")
                    {
                        data.QuestionText = cupeQuestion.Element("NAME").Value;
                        data.ChoiceA = cupeQuestion.Element("COMMODITY").Value;
                        data.ChoiceB = cupeQuestion.Element("UTILITY").Value;
                        data.ChoiceC = cupeQuestion.Element("PARTNER").Value;
                        data.ChoiceD = cupeQuestion.Element("ENABLER").Value;

                        ClientDataControl.AddCupeQuestion(data);
                        data = new CupeQuestionStringData();
                    }
                }
            }
        }
예제 #13
0
        public override List<CupeQuestionStringData> GetCUPESForClient()
        {
            XElement client = ClientDataControl.Client.EntityObject as XElement;
            List<XElement> cupeList = (from ent in client.Element("CUPES").Elements("CUPE")
                                       orderby Convert.ToInt32(ent.Element("QUESTIONNUMBER").Value)
                                       select ent).ToList();
            List<CupeQuestionStringData> cupeQuestions = new List<CupeQuestionStringData>();
            CupeQuestionStringData data;
            foreach (XElement cupe in cupeList)
            {
                data = new CupeQuestionStringData();
                data.QuestionText = cupe.Element("NAME").Value;
                data.OriginalQuestionText = cupe.Element("CUPEQUESTION").Value;
                data.ChoiceA = cupe.Element("COMMODITY").Value;
                data.ChoiceB = cupe.Element("UTILITY").Value;
                data.ChoiceC = cupe.Element("PARTNER").Value;
                data.ChoiceD = cupe.Element("ENABLER").Value;
                cupeQuestions.Add(data);
            }

            return cupeQuestions;
        }
예제 #14
0
 public abstract bool AddCupeQuestion(CupeQuestionStringData cupeQuestion);
예제 #15
0
 // actual function to search through the word documents in the folder specified and loads them into the tool
 private void LoadCupeQuestionsFromDocument()
 {
     CupeQuestionStringData data = new CupeQuestionStringData();
     string path;
     if(is20Question)
     {
         path = @"Resources\Questions.txt";
     }
     else
     {
         path = @"Resources\Questions10.txt";
     }
     foreach (string line in File.ReadLines(path))
     {
         if (!String.IsNullOrEmpty(line))
         {
             if (line[0] == 'A' && line[1] == '.')
             {
                 data.ChoiceA = line;
             }
             else if (line[0] == 'B' && line[1] == '.')
             {
                 data.ChoiceB = line;
             }
             else if (line[0] == 'C' && line[1] == '.')
             {
                 data.ChoiceC = line;
             }
             else if (line[0] == 'D' && line[1] == '.')
             {
                 data.ChoiceD = line;
             }
             else
             {
                 data.QuestionText = line;
             }
         }
         else if (String.IsNullOrEmpty(line))
         {
             ClientDataControl.AddCupeQuestion(data);
             data = new CupeQuestionStringData();
         }
     }
 }
예제 #16
0
        public override List<CupeQuestionData> GetCUPEQuestionData()
        {
            List<CUPEQUESTION> cupeQuestionEntList = (from ent in dbo.CUPEQUESTION
                                                      select ent).ToList();

            List<CupeQuestionData> cupeQuestionDataList = new List<CupeQuestionData>();
            CupeQuestionData cupeQuestionData;
            CupeQuestionStringData cupeQuestionStringData;
            foreach (CUPEQUESTION cupeQuestionEnt in cupeQuestionEntList)
            {
                cupeQuestionStringData = new CupeQuestionStringData();
                cupeQuestionStringData.OriginalQuestionText = cupeQuestionEnt.NAME.TrimEnd();
                cupeQuestionStringData.QuestionText = cupeQuestionEnt.NAME.TrimEnd();
                cupeQuestionStringData.ChoiceA = cupeQuestionEnt.COMMODITY.TrimEnd();
                cupeQuestionStringData.ChoiceB = cupeQuestionEnt.UTILITY.TrimEnd();
                cupeQuestionStringData.ChoiceC = cupeQuestionEnt.PARTNER.TrimEnd();
                cupeQuestionStringData.ChoiceD = cupeQuestionEnt.ENABLER.TrimEnd();
                cupeQuestionData = new CupeQuestionData();
                cupeQuestionData.StringData = cupeQuestionStringData;
                cupeQuestionData.InDefault20 = cupeQuestionEnt.INTWENTY == "Y";
                cupeQuestionData.InDefault10 = cupeQuestionEnt.INTEN == "Y";

                cupeQuestionDataList.Add(cupeQuestionData);
            }

            return cupeQuestionDataList;
        }
예제 #17
0
        //after the tree view in the bottom right hand corner is edited, it registers a new question with the database
        private void QuestionView_AfterLabelEdit(object sender,
         System.Windows.Forms.NodeLabelEditEventArgs e)
        {
            changesMade = true;
            if (e.Label != null)
            {
                if (e.Label.Length > 0)
                {
                    if (e.Label.IndexOfAny(new char[] { '@' }) == -1)
                    {
                        // Stop editing without canceling the label change.
                        e.Node.EndEdit(false);
                        //adds question to database along with all of its avilable answers
                        CupeQuestionStringData data = new CupeQuestionStringData();

                        if ( ClientDataControl.cupeQuestions[indexCurrentQuestionNode].QuestionText == e.Node.Text)
                        {
                            ClientDataControl.cupeQuestions[indexCurrentQuestionNode].QuestionText = e.Label;
                        }
                        else if (ClientDataControl.cupeQuestions[indexCurrentQuestionNode].ChoiceA == e.Node.Text )
                        {
                            ClientDataControl.cupeQuestions[indexCurrentQuestionNode].ChoiceA = e.Label;
                        }
                        else if (ClientDataControl.cupeQuestions[indexCurrentQuestionNode].ChoiceB == e.Node.Text)
                        {
                            ClientDataControl.cupeQuestions[indexCurrentQuestionNode].ChoiceB = e.Label;
                        }
                        else if (ClientDataControl.cupeQuestions[indexCurrentQuestionNode].ChoiceC == e.Node.Text)
                        {
                            ClientDataControl.cupeQuestions[indexCurrentQuestionNode].ChoiceC = e.Label;
                        }
                        else if (ClientDataControl.cupeQuestions[indexCurrentQuestionNode].ChoiceD == e.Node.Text)
                        {
                            ClientDataControl.cupeQuestions[indexCurrentQuestionNode].ChoiceD = e.Label;
                        }

                        //Help / Tutorial Step
                        if (HelpEnabled && HelpCurrentStep == 4)
                        {
                            HelpCurrentStep = 5;
                            StartTutorialMode();
                        }

                    }
                    else
                    {
                        /* Cancel the label edit action, inform the user, and
                           place the node in edit mode again. */
                        e.CancelEdit = true;
                        MessageBox.Show("Invalid multiple choice label.\n" +
                           "The invalid characters are: '@',",
                           "Node Label Edit");
                        e.Node.BeginEdit();
                    }
                }
                else
                {
                    /* Cancel the label edit action, inform the user, and
                       place the node in edit mode again. */
                    e.CancelEdit = true;
                    MessageBox.Show("Invalid multiple choice label.\nThe label cannot be blank",
                       "Node Label Edit");
                    e.Node.BeginEdit();
                }

            }
        }
예제 #18
0
        public override List<CupeQuestionStringData> GetCUPESForClient()
        {
            CLIENT client = ClientDataControl.Client.EntityObject as CLIENT;
            List<CUPE> cupeList = (from ent in client.CUPE
                                   orderby ent.QUESTIONNUMBER
                                   select ent).ToList();
            List<CupeQuestionStringData> cupeQuestions = new List<CupeQuestionStringData>();
            CupeQuestionStringData data;
            foreach (CUPE cupe in cupeList)
            {
                data = new CupeQuestionStringData();
                data.OriginalQuestionText = cupe.CUPEQUESTION.NAME.TrimEnd();
                data.QuestionText = cupe.NAME.TrimEnd();
                data.ChoiceA = cupe.COMMODITY.TrimEnd();
                data.ChoiceB = cupe.UTILITY.TrimEnd();
                data.ChoiceC = cupe.PARTNER.TrimEnd();
                data.ChoiceD = cupe.ENABLER.TrimEnd();
                cupeQuestions.Add(data);
            }

            return cupeQuestions;
        }
예제 #19
0
 public abstract bool AddCupeQuestion(CupeQuestionStringData cupeQuestion);
예제 #20
0
        public override void PopulateCUPEQuestionsForClient(CUPETool cupeForm)
        {
            CLIENT client = ClientDataControl.Client.EntityObject as CLIENT;
            CupeQuestionStringData data = new CupeQuestionStringData();
            List<CupeQuestionStringData> templist = new List<CupeQuestionStringData>();
            if (client.CUPE.Count != 0)
            {
                foreach (CUPE cupe in client.CUPE)
                {
                    data.QuestionText = cupe.NAME.TrimEnd();
                    data.ChoiceA = cupe.COMMODITY.TrimEnd();
                    data.ChoiceB = cupe.UTILITY.TrimEnd();
                    data.ChoiceC = cupe.PARTNER.TrimEnd();
                    data.ChoiceD = cupe.ENABLER.TrimEnd();

                    templist.Add(data);
                    data = new CupeQuestionStringData();
                }
                ClientDataControl.cupeQuestions.RemoveRange(0, templist.Count);
                foreach( CupeQuestionStringData temp in templist)
                {
                    ClientDataControl.AddCupeQuestion(temp);
                }

            }

            else
            {
                foreach (CUPEQUESTION cupeQuestion in dbo.CUPEQUESTION)
                {
                    if (cupeQuestion.INTWENTY == "Y")
                    {
                        data.QuestionText = cupeQuestion.NAME.TrimEnd();
                        data.ChoiceA = cupeQuestion.COMMODITY.TrimEnd();
                        data.ChoiceB = cupeQuestion.UTILITY.TrimEnd();
                        data.ChoiceC = cupeQuestion.PARTNER.TrimEnd();
                        data.ChoiceD = cupeQuestion.ENABLER.TrimEnd();

                        ClientDataControl.AddCupeQuestion(data);
                        ClientDataControl.cupeQuestions.RemoveAt(1);
                        data = new CupeQuestionStringData();
                    }
                }
            }
        }
예제 #21
0
 public abstract string UpdateCUPE(CupeQuestionStringData cupeQuestion);
예제 #22
0
        public void CheckChangeLog(LoadingDatabase loadingScreen = null)
        {
            List<string> failedChanges = new List<string>();

            //string line;
            string[] lineArray;

            CLIENT client;
            REGION region;
            COUNTRY country;
            BUSINESSTYPE busType;
            GROUP grp;
            CONTACT contact;
            CATEGORY category;
            BUSINESSOBJECTIVE objective;
            IMPERATIVE imperative;
            BOM bom;
            CUPEQUESTION cupeQuestion;
            CupeQuestionStringData cupeQuestionStringData;
            CUPE cupe;
            CUPERESPONSE cupeResponse;
            DOMAIN domain;
            CAPABILITY capability;
            ITCAPQUESTION itcapQuestion;
            ITCAP itcap;
            COMMENT comment;
            ITCAPOBJMAP itcapObjMap;
            CAPABILITYGAPINFO capGapInfo;

            if (!Directory.Exists("Resources"))
            {
                Directory.CreateDirectory("Resources");
            }

            if (!Directory.Exists(@"Resources\Clients"))
            {
                Directory.CreateDirectory(@"Resources\Clients");
            }

            if (!File.Exists(@"Resources\Changes.log"))
            {
                FileStream file = File.Create(@"Resources\Changes.log");
                file.Close();
            }

            using (System.IO.StreamReader file = new System.IO.StreamReader(@"Resources\Changes.log"))
            {
                if (loadingScreen != null)
                {
                    loadingScreen.LoadingTextLabel.Text = "Applying offline changes to database... Reading change log";
                    loadingScreen.LoadingTextLabel.Update();
                }
                string allLines = file.ReadToEnd();
                string[] allLinesArray = allLines.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                //while ((line = file.ReadLine()) != null)
                float totalLines = allLinesArray.Length;
                int linesComplete = 0;
                foreach(string line in allLinesArray)
                {
                    lineArray = line.Split(' ');
                    if (lineArray[0] == "ADD")
                    {
                        switch(lineArray[1])
                        {
                            case "CLIENT":
                                client = new CLIENT();
                                client.NAME = lineArray[2].Replace('~', ' ');

                                string regionName = lineArray[3].Replace('~', ' ');
                                try
                                {
                                    region = (from ent in dbo.REGION
                                              where ent.NAME.TrimEnd() == regionName
                                              select ent).Single();
                                }
                                catch
                                {
                                    region = new REGION();
                                    region.NAME = regionName;
                                    dbo.AddToREGION(region);
                                }

                                string countryName = lineArray[4].Replace('~', ' ');
                                try
                                {
                                    country = (from ent in region.COUNTRY
                                              where ent.NAME.TrimEnd() == countryName
                                              select ent).Single();
                                }
                                catch
                                {
                                    country = new COUNTRY();
                                    country.NAME = countryName;
                                    country.REGION = region;
                                    dbo.AddToCOUNTRY(country);
                                }

                                client.COUNTRY = country;

                                client.STARTDATE = DateTime.Parse(lineArray[5].Replace('~', ' '));

                                string busTypeName = lineArray[6].Replace('~', ' ');
                                try
                                {
                                    busType = (from ent in dbo.BUSINESSTYPE
                                              where ent.NAME.TrimEnd() == busTypeName
                                              select ent).Single();
                                }
                                catch
                                {
                                    busType = new BUSINESSTYPE();
                                    busType.NAME = busTypeName;
                                    dbo.AddToBUSINESSTYPE(busType);
                                }
                                client.BUSINESSTYPE = busType;

                                client.BOMCOMPLETE = client.CUPECOMPLETE = client.ITCAPCOMPLETE = "N";

                                if (!AddClient(client))
                                {
                                    MessageBox.Show("Add Client Instruction Failed: Client already exists\n\n" + line, "Error");
                                }
                                break;

                            case "REGION":
                                if (!AddRegion(lineArray[2].Replace('~', ' ')))
                                {
                                    MessageBox.Show("Add Region Instruction Failed: Region already exists\n\n" + line, "Error");
                                }
                                break;

                            case "BUSINESSTYPE":
                                if (!AddBusinessType(lineArray[2].Replace('~', ' ')))
                                {
                                    MessageBox.Show("Add BusinessType Instruction Failed: BusinessType already exists\n\n" + line, "Error");
                                }
                                break;

                            case "CONTACT":
                                if (GetClient(lineArray[2].Replace('~', ' '), out client))
                                {
                                    if (GetGroup(lineArray[3].Replace('~', ' '), client, out grp))
                                    {
                                        if (!AddContact(Convert.ToInt32(lineArray[4]), grp))
                                        {
                                            MessageBox.Show("Add Contact Instruction Failed: Contact ID already exists\n\n" + line, "Error");
                                        }
                                    }
                                    else
                                    {
                                        MessageBox.Show("Add Contact Instruction Failed: Group does not exist\n\n" + line, "Error");
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("Add Contact Instruction Failed: Client does not exist\n\n" + line, "Error");
                                }
                                break;

                            case "CATEGORY":
                                category = new CATEGORY();
                                category.NAME = lineArray[2].Replace('~', ' ');
                                if (!AddCategory(category))
                                {
                                    MessageBox.Show("Add Category Instruction Failed: Category already exists\n\n" + line, "Error");
                                }
                                break;

                            case "BUSINESSOBJECTIVE":
                                if (GetCategory(lineArray[3].Replace('~', ' '), out category))
                                {
                                    objective = new BUSINESSOBJECTIVE();
                                    objective.NAME = lineArray[2].Replace('~', ' ');
                                    objective.CATEGORY = category;
                                    if (!AddObjective(objective))
                                    {
                                        MessageBox.Show("Add BusinessObjective Instruction Failed: BusinessObjective already exists\n\n" + line, "Error");
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("Add BusinessObjective Instruction Failed: Category does not exist\n\n" + line, "Error");
                                }
                                break;

                            case "IMPERATIVE":
                                if (GetObjective(lineArray[3].Replace('~', ' '), out objective))
                                {
                                    imperative = new IMPERATIVE();
                                    imperative.NAME = lineArray[2].Replace('~', ' ');
                                    imperative.BUSINESSOBJECTIVE = objective;
                                    if (!AddImperative(imperative))
                                    {
                                        MessageBox.Show("Add Imperative Instruction Failed: Imperative already exists\n\n" + line, "Error");
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("Add Imperative Instruction Failed: BusinessObjective does not exist\n\n" + line, "Error");
                                }
                                break;

                            case "BOM":
                                if (lineArray[2] == "CLIENT")
                                {
                                    if (GetClient(lineArray[3].Replace('~', ' '), out client))
                                    {
                                        if (GetImperative(lineArray[4].Replace('~', ' '), out imperative))
                                        {
                                            bom = new BOM();
                                            bom.IMPERATIVE = imperative;
                                            if (!AddBOM(bom, client))
                                            {
                                                MessageBox.Show("Add BOM Instruction Failed: BOM already exists\n\n" + line, "Error");
                                            }
                                        }
                                        else
                                        {
                                            MessageBox.Show("Add BOM Instruction Failed: Imperative does not exist\n\n" + line, "Error");
                                        }
                                    }
                                    else
                                    {
                                        MessageBox.Show("Add BOM Instruction Failed: Client does not exist\n\n" + line, "Error");
                                    }
                                }

                                else
                                {
                                    MessageBox.Show("Invalid instruction detected:\n\n" + line, "Error");
                                }
                                break;

                            case "CUPERESPONSE":
                                if (GetClient(lineArray[2].Replace('~', ' '), out client))
                                {
                                    if (GetGroup(lineArray[3].Replace('~', ' '), client, out grp))
                                    {
                                        if (GetContact(Convert.ToInt32(lineArray[4]), out contact))
                                        {
                                            if (GetCUPE(lineArray[5].Replace('~', ' '), client, out cupe))
                                            {
                                                cupeResponse = new CUPERESPONSE();
                                                cupeResponse.CONTACT = contact;
                                                cupeResponse.CUPE = cupe;
                                                cupeResponse.CURRENT = lineArray[6];
                                                cupeResponse.FUTURE = lineArray[7];
                                                dbo.AddToCUPERESPONSE(cupeResponse);
                                            }
                                            else
                                            {
                                                MessageBox.Show("Add CUPEResponse Instruction Failed: CUPE does not exist\n\n" + line, "Error");
                                            }
                                        }
                                        else
                                        {
                                            MessageBox.Show("Add CUPEResponse Instruction Failed: Contact ID does not exist\n\n" + line, "Error");
                                        }
                                    }
                                    else
                                    {
                                        MessageBox.Show("Add CUPEResponse Instruction Failed: Group does not exist\n\n" + line, "Error");
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("Add CUPEResponse Instruction Failed: Client does not exist\n\n" + line, "Error");
                                }
                                break;

                            case "CUPEQUESTION":
                                cupeQuestionStringData = new CupeQuestionStringData();
                                cupeQuestionStringData.QuestionText = lineArray[2].Replace('~', ' ');
                                cupeQuestionStringData.ChoiceA = lineArray[3].Replace('~', ' ');
                                cupeQuestionStringData.ChoiceB = lineArray[4].Replace('~', ' ');
                                cupeQuestionStringData.ChoiceC = lineArray[5].Replace('~', ' ');
                                cupeQuestionStringData.ChoiceD = lineArray[6].Replace('~', ' ');
                                AddCupeQuestion(cupeQuestionStringData);
                                break;

                            case "CUPE":
                                if (lineArray[2] == "CLIENT")
                                {
                                    if (GetClient(lineArray[3].Replace('~', ' '), out client))
                                    {
                                        if (GetCUPEQuestion(lineArray[4].Replace('~', ' '), out cupeQuestion))
                                        {
                                            if (!AddCUPE(cupeQuestion.NAME.TrimEnd(), client, Convert.ToInt32(lineArray[5])))
                                            {
                                                MessageBox.Show("Add CUPEResponse Instruction Failed: CUPE already exists\n\n" + line, "Error");
                                            }
                                        }
                                        else
                                        {
                                            MessageBox.Show("Add CUPEResponse Instruction Failed: CUPEQuestion does not exist\n\n" + line, "Error");
                                        }
                                    }
                                    else
                                    {
                                        MessageBox.Show("Add CUPE Instruction Failed: Client does not exist\n\n" + line, "Error");
                                    }
                                }

                                else
                                {
                                    MessageBox.Show("Invalid instruction detected:\n\n" + line, "Error");
                                }
                                break;

                            case "DOMAIN":
                                domain = new DOMAIN();
                                domain.NAME = lineArray[2].Replace('~', ' ');
                                domain.DEFAULT = "N";
                                if (!AddDomain(domain))
                                {
                                    MessageBox.Show("Add Domain Instruction Failed: Domain already exists\n\n" + line, "Error");
                                }
                                break;

                            case "CAPABILITY":
                                if (GetDomain(lineArray[3].Replace('~', ' '), out domain))
                                {
                                    capability = new CAPABILITY();
                                    capability.NAME = lineArray[2].Replace('~', ' ');
                                    capability.DEFAULT = "N";
                                    capability.DOMAIN = domain;
                                    if (!AddCapability(capability))
                                    {
                                        MessageBox.Show("Add Capability Instruction Failed: Capability already exists\n\n" + line, "Error");
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("Add Capability Instruction Failed: Domain does not exist\n\n" + line, "Error");
                                }
                                break;

                            case "ITCAPQUESTION":
                                if (GetCapability(lineArray[3].Replace('~', ' '), out capability))
                                {
                                    itcapQuestion = new ITCAPQUESTION();
                                    itcapQuestion.NAME = lineArray[2].Replace('~', ' ');
                                    itcapQuestion.DEFAULT = "N";
                                    itcapQuestion.CAPABILITY = capability;
                                    if (!AddITCAPQuestion(itcapQuestion))
                                    {
                                        MessageBox.Show("Add ITCAPQuestion Instruction Failed: ITCAPQuestion already exists\n\n" + line, "Error");
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("Add ITCAPQuestion Instruction Failed: Capability does not exist\n\n" + line, "Error");
                                }
                                break;

                            case "ITCAP":
                                if (lineArray[2] == "CLIENT")
                                {
                                    if (GetClient(lineArray[3].Replace('~', ' '), out client))
                                    {
                                        if (GetITCAPQuestion(lineArray[4].Replace('~', ' '), out itcapQuestion))
                                        {
                                            itcap = new ITCAP();
                                            itcap.ITCAPQUESTION = itcapQuestion;
                                            if (!AddITCAP(itcap, client))
                                            {
                                                MessageBox.Show("Add ITCAP Instruction Failed: ITCAP already exists\n\n" + line, "Error");
                                            }
                                        }
                                        else
                                        {
                                            MessageBox.Show("Add ITCAP Instruction Failed: ITCAPQuestion does not exist\n\n" + line, "Error");
                                        }
                                    }
                                    else
                                    {
                                        MessageBox.Show("Add ITCAP Instruction Failed: Client does not exist\n\n" + line, "Error");
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("Invalid instruction detected:\n\n" + line, "Error");
                                }
                                break;

                            case "ITCAPOBJMAP":
                                if (GetClient(lineArray[3].Replace('~', ' '), out client))
                                {
                                    int temp;
                                    if (!GetITCAPOBJMAPScore(client, lineArray[4].Replace('~', ' '), lineArray[5].Replace('~', ' '), out temp))
                                    {
                                        if (!GetCapability(lineArray[4].Replace('~', ' '), out capability))
                                        {
                                            MessageBox.Show("Add ITCAPOBJMAP Instruction Failed: Capability does not exist\n\n" + line, "Error");
                                            break;
                                        }

                                        if (!GetObjective(lineArray[5].Replace('~', ' '), out objective))
                                        {
                                            MessageBox.Show("Add ITCAPOBJMAP Instruction Failed: BusinessObjective does not exist\n\n" + line, "Error");
                                            break;
                                        }

                                        itcapObjMap = new ITCAPOBJMAP();
                                        itcapObjMap.CLIENT = client;
                                        itcapObjMap.CAPABILITY = capability;
                                        itcapObjMap.BUSINESSOBJECTIVE = objective;
                                        itcapObjMap.SCORE = 0;

                                    }
                                    else
                                    {
                                        MessageBox.Show("Add CapabilityObjectiveMap Instruction Failed: CapabilityObjectiveMap already exists\n\n" + line, "Error");
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("Add CapabilityObjectiveMapping Instruction Failed: Client does not exist\n\n" + line, "Error");
                                }
                                break;
                            case "CAPABILITYGAPINFO":
                                if (GetClient(lineArray[2].Replace('~', ' '), out client))
                                {
                                    if (GetCapability(lineArray[3].Replace('~', ' '), out capability))
                                    {
                                        capGapInfo = new CAPABILITYGAPINFO();
                                        capGapInfo.CLIENT = client;
                                        capGapInfo.CAPABILITY = capability;
                                        capGapInfo.GAP = 0;
                                        capGapInfo.PRIORITIZEDGAP = 0;
                                        capGapInfo.GAPTYPE = "None";
                                        capGapInfo.PRIORITIZEDGAPTYPE = "None";
                                        dbo.AddToCAPABILITYGAPINFO(capGapInfo);
                                    }
                                    else
                                    {
                                        MessageBox.Show("Add CapabilityGapInfo Instruction Failed: Capability does not exist\n\n" + line, "Error");
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("Add CapabilityGapInfo Instruction Failed: Client does not exist\n\n" + line, "Error");
                                }
                                break;
                            default:
                                MessageBox.Show("Invalid instruction detected:\n\n" + line, "Error");
                                break;
                        }
                    }

                    else if (lineArray[0] == "UPDATE")
                    {
                        switch (lineArray[1])
                        {
                            case "CLIENT":
                                if (GetClient(lineArray[3].Replace('~', ' '), out client))
                                {
                                    if (lineArray[2] == "BOMCOMPLETE")
                                    {
                                        client.BOMCOMPLETE = "Y";
                                    }
                                    else if (lineArray[2] == "CUPECOMPLETE")
                                    {
                                        client.CUPECOMPLETE = "Y";
                                    }
                                    else if (lineArray[2] == "ITCAPCOMPLETE")
                                    {
                                        client.ITCAPCOMPLETE = "Y";
                                    }
                                    else
                                    {
                                        MessageBox.Show("Invalid instruction detected:\n\n" + line, "Error");
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("Update Client Instruction Failed: Client does not exist\n\n" + line, "Error");
                                }
                                break;
                            case "BOM":
                                if (GetClient(lineArray[2].Replace('~', ' '), out client))
                                {
                                    if (GetBOM(lineArray[3].Replace('~', ' '), client, out bom))
                                    {
                                        bom.EFFECTIVENESS = Convert.ToSingle(lineArray[4]);
                                        bom.CRITICALITY = Convert.ToSingle(lineArray[5]);
                                        bom.DIFFERENTIAL = Convert.ToSingle(lineArray[6]);
                                    }
                                    else
                                    {
                                        MessageBox.Show("Update BOM Instruction Failed: BOM does not exist\n\n" + line, "Error");
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("Update BOM Instruction Failed: Client does not exist\n\n" + line, "Error");
                                }
                                break;
                            case "CUPE":
                                if (GetClient(lineArray[2].Replace('~', ' '), out client))
                                {
                                    if (GetCUPE(lineArray[3].Replace('~', ' '), client, out cupe))
                                    {
                                        if (GetCUPEQuestion(lineArray[4].Replace('~', ' '), out cupeQuestion))
                                        {
                                            cupe.NAME = lineArray[4].Replace('~', ' ');
                                            cupe.COMMODITY = lineArray[5].Replace('~', ' ');
                                            cupe.UTILITY = lineArray[6].Replace('~', ' ');
                                            cupe.PARTNER = lineArray[7].Replace('~', ' ');
                                            cupe.ENABLER = lineArray[8].Replace('~', ' ');
                                            cupe.CUPEQUESTION = cupeQuestion;
                                        }
                                        else
                                        {
                                            MessageBox.Show("Update CUPE Instruction Failed: CUPEQuestion does not exist\n\n" + line, "Error");
                                        }
                                    }
                                    else
                                    {
                                        MessageBox.Show("Update CUPE Instruction Failed: CUPE does not exist\n\n" + line, "Error");
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("Update CUPE Instruction Failed: Client does not exist\n\n" + line, "Error");
                                }
                                break;
                            case "CUPEQUESTION":
                                if (GetCUPEQuestion(lineArray[2].Replace('~', ' '), out cupeQuestion))
                                {
                                    cupeQuestion.INTWENTY = lineArray[3];
                                    cupeQuestion.INTEN = lineArray[4];
                                }
                                else
                                {
                                    MessageBox.Show("Update CUPEQuestion Instruction Failed: CUPEQuestion does not exist\n\n" + line, "Error");
                                }
                                break;
                           case "ITCAP":
                                if (GetClient(lineArray[2].Replace('~', ' '), out client))
                                {
                                    if (GetITCAP(lineArray[3].Replace('~', ' '), client, out itcap))
                                    {
                                        itcap.ASIS = Convert.ToSingle(lineArray[4]);
                                        itcap.TOBE = Convert.ToSingle(lineArray[5]);
                                        itcap.ASISZEROS = Convert.ToInt32(lineArray[6]);
                                        itcap.TOBEZEROS = Convert.ToInt32(lineArray[7]);
                                        itcap.ASISONES = Convert.ToInt32(lineArray[8]);
                                        itcap.TOBEONES = Convert.ToInt32(lineArray[9]);
                                        itcap.ASISTWOS = Convert.ToInt32(lineArray[10]);
                                        itcap.TOBETWOS = Convert.ToInt32(lineArray[11]);
                                        itcap.ASISTHREES = Convert.ToInt32(lineArray[12]);
                                        itcap.TOBETHREES = Convert.ToInt32(lineArray[13]);
                                        itcap.ASISFOURS = Convert.ToInt32(lineArray[14]);
                                        itcap.TOBEFOURS = Convert.ToInt32(lineArray[15]);
                                        itcap.ASISFIVES = Convert.ToInt32(lineArray[16]);
                                        itcap.TOBEFIVES = Convert.ToInt32(lineArray[17]);
                                        List<COMMENT> commentsToDelete = itcap.COMMENT.ToList();
                                        foreach (COMMENT commentToDelete in commentsToDelete)
                                        {
                                            dbo.DeleteObject(commentToDelete);
                                        }
                                        for (int i = 18; i < lineArray.Count(); i++)
                                        {
                                            comment = new COMMENT();
                                            comment.NAME = lineArray[i].Replace('~', ' ');
                                            comment.ITCAP = itcap;
                                            dbo.AddToCOMMENT(comment);
                                        }
                                    }
                                    else
                                    {
                                        MessageBox.Show("Update ITCAP Instruction Failed: ITCAP does not exist\n\n" + line, "Error");
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("Update ITCAP Instruction Failed: Client does not exist\n\n" + line, "Error");
                                }
                                break;
                            case "ITCAPOBJMAP":
                                if (GetClient(lineArray[2].Replace('~', ' '), out client))
                                {
                                    if (GetITCAPOBJMAP(client, lineArray[3].Replace('~', ' '), lineArray[4].Replace('~', ' '), out itcapObjMap))
                                    {
                                        itcapObjMap.SCORE = Convert.ToInt32(lineArray[5]);
                                    }
                                    else
                                    {
                                        MessageBox.Show("Update CapabilityObjectiveMap Instruction Failed: CapabilityObjectiveMap does not exist\n\n" + line, "Error");
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("Update CapabilityObjectiveMap Instruction Failed: Client does not exist\n\n" + line, "Error");
                                }
                                break;
                            case "CAPABILITYGAPINFO":
                                if (GetClient(lineArray[2].Replace('~', ' '), out client))
                                {
                                    if (GetCapabilityGapInfo(lineArray[3].Replace('~', ' '), client, out capGapInfo))
                                    {
                                        capGapInfo.GAPTYPE = lineArray[4];
                                        capGapInfo.PRIORITIZEDGAPTYPE = lineArray[5];
                                        capGapInfo.GAP = Convert.ToSingle(lineArray[6]);
                                        capGapInfo.PRIORITIZEDGAP = Convert.ToSingle(lineArray[7]);
                                    }
                                    else
                                    {
                                        MessageBox.Show("Update CapabilityGapInfo Instruction Failed: CapabilityGapInfo does not exist\n\n" + line, "Error");
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("Update CapabilityGapInfo Instruction Failed: Client does not exist\n\n" + line, "Error");
                                }
                                break;
                            default:
                                MessageBox.Show("Invalid instruction detected:\n\n" + line, "Error");
                                break;
                        }
                    }

                    else if (lineArray[0] == "DELETE")
                    {
                        switch (lineArray[1])
                        {
                            case "BOM":
                                if (GetClient(lineArray[2].Replace('~', ' '), out client))
                                {
                                    if (GetBOM(lineArray[3].Replace('~', ' '), client, out bom))
                                    {
                                        dbo.DeleteObject(bom);
                                    }
                                    else
                                    {
                                        MessageBox.Show("Delete BOM Instruction Failed: BOM does not exist\n\n" + line, "Error");
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("Delete BOM Instruction Failed: Client does not exist\n\n" + line, "Error");
                                }
                                break;
                            case "CUPE":
                                if (GetClient(lineArray[2].Replace('~', ' '), out client))
                                {
                                    ClearCUPE(client);
                                }
                                else
                                {
                                    MessageBox.Show("Delete CUPE Instruction Failed: Client does not exist\n\n" + line, "Error");
                                }
                                break;
                            case "CONTACTS":
                                List<CONTACT> contactsToDelete;
                                List<CUPERESPONSE> responsesToDelete;
                                if (GetClient(lineArray[2].Replace('~', ' '), out client))
                                {
                                    foreach (GROUP grpToClear in client.GROUP)
                                    {
                                        contactsToDelete = grpToClear.CONTACT.ToList();
                                        foreach (CONTACT contactToDelete in contactsToDelete)
                                        {
                                            responsesToDelete = contactToDelete.CUPERESPONSE.ToList();
                                            foreach (CUPERESPONSE responseToDelete in responsesToDelete)
                                            {
                                                dbo.DeleteObject(responseToDelete);
                                            }
                                            dbo.DeleteObject(contactToDelete);
                                        }
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("Delete CUPEResponse Instruction Failed: Client does not exist\n\n" + line, "Error");
                                }
                                break;
                            case "ITCAP":
                                if (GetClient(lineArray[2].Replace('~', ' '), out client))
                                {
                                    if (GetITCAP(lineArray[3].Replace('~', ' '), client, out itcap))
                                    {
                                        dbo.DeleteObject(itcap);
                                    }
                                    else
                                    {
                                        MessageBox.Show("Delete ITCAP Instruction Failed: ITCAP does not exist\n\n" + line, "Error");
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("Delete ITCAP Instruction Failed: Client does not exist\n\n" + line, "Error");
                                }
                                break;
                            default:
                                MessageBox.Show("Invalid instruction detected\n\n" + line, "Error");
                                break;
                        }
                    }

                    else if (lineArray[0] == "CLEAR")
                    {
                        switch (lineArray[1])
                        {
                            case "ITCAP":
                                if (GetClient(lineArray[2].Replace('~', ' '), out client))
                                {
                                    List<ITCAP> itcapsToDelete = client.ITCAP.ToList();
                                    foreach (ITCAP itcapToDelete in itcapsToDelete)
                                    {
                                        dbo.DeleteObject(itcapToDelete);
                                    }

                                    List<CAPABILITYGAPINFO> capGapInfosToDelete = client.CAPABILITYGAPINFO.ToList();
                                    foreach (CAPABILITYGAPINFO capGapInfoToDelete in capGapInfosToDelete)
                                    {
                                        dbo.DeleteObject(capGapInfoToDelete);
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("Delete ITCAP Instruction Failed: Client does not exist\n\n" + line, "Error");
                                }
                                break;
                            default:
                                MessageBox.Show("Invalid instruction detected\n\n" + line, "Error");
                                break;
                        }

                    }

                    else
                    {
                        MessageBox.Show("Invalid instruction detected:\n\n" + line, "Error");
                    }

                    if (!SaveChanges())
                    {
                        if (MessageBox.Show("Instruction failed to execute: \n" + line +
                                           "\n\nKeep change in log?", "Error", MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            failedChanges.Add(line);
                        }
                        break;
                    }

                    if (loadingScreen != null)
                    {
                        loadingScreen.LoadingTextLabel.Text = "Applying offline changes to database... " + (int)((linesComplete+=100)/totalLines) + "%";
                        loadingScreen.LoadingTextLabel.Update();
                    }
                }
            }

            File.WriteAllText(@"Resources\Changes.log", string.Empty);
            File.WriteAllLines(@"Resources\Changes.log", failedChanges);
        }
예제 #23
0
        public override List<CupeQuestionData> GetCUPEQuestionData()
        {
            List<XElement> cupeQuestionEntList = (from ent in dbo.Element("CUPEQUESTIONS").Elements("CUPEQUESTION")
                                                  select ent).ToList();

            List<CupeQuestionData> cupeQuestionDataList = new List<CupeQuestionData>();
            CupeQuestionData cupeQuestionData;
            CupeQuestionStringData cupeQuestionStringData;
            foreach (XElement cupeQuestionEnt in cupeQuestionEntList)
            {
                cupeQuestionStringData = new CupeQuestionStringData();
                cupeQuestionStringData.OriginalQuestionText = cupeQuestionStringData.QuestionText = cupeQuestionEnt.Element("NAME").Value;
                cupeQuestionStringData.ChoiceA = cupeQuestionEnt.Element("COMMODITY").Value;
                cupeQuestionStringData.ChoiceB = cupeQuestionEnt.Element("UTILITY").Value;
                cupeQuestionStringData.ChoiceC = cupeQuestionEnt.Element("PARTNER").Value;
                cupeQuestionStringData.ChoiceD = cupeQuestionEnt.Element("ENABLER").Value;
                cupeQuestionData = new CupeQuestionData();
                cupeQuestionData.StringData = cupeQuestionStringData;
                cupeQuestionData.InDefault20 = cupeQuestionEnt.Element("INTWENTY").Value == "Y";
                cupeQuestionData.InDefault10 = cupeQuestionEnt.Element("INTEN").Value == "Y";
                cupeQuestionDataList.Add(cupeQuestionData);
            }

            return cupeQuestionDataList;
        }