Exemplo n.º 1
0
        private void NewBOMCreateBOMButton_Click(object sender, EventArgs e)
        {
            List<int> idList;

            CLIENT newClient = new CLIENT();
            idList = (from cnt in mainForm.dbo.CLIENT
                     select cnt.CLIENTID).ToList();
            newClient.CLIENTID = mainForm.GetUniqueID(idList);
            newClient.NAME = NewClientTextBox.Text;

            mainForm.dbo.AddToCLIENT(newClient);
            mainForm.dbo.SaveChanges();

            mainForm.currentClient = newClient;
            mainForm.BOMTable.Rows.Clear();
            Close();
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        public bool AddGroup(string grpName, CLIENT client)
        {
            if ((from ent in client.GROUP
                 where ent.NAME.TrimEnd() == grpName
                 select ent).Count() != 0)
            {
                return false;
            }

            GROUP grp = new GROUP();
            grp.NAME = grpName;
            grp.CLIENT = client;

            dbo.AddToGROUP(grp);

            return true;
        }
Exemplo n.º 4
0
        public bool GetITCAP(string itcqName, CLIENT client, out ITCAP itcap)
        {
            try
            {
                itcap = (from ent in client.ITCAP
                         where ent.ITCAPQUESTION.NAME.TrimEnd() == itcqName
                         select ent).Single();
            }

            catch
            {
                itcap = null;
                return false;
            }

            return true;
        }
Exemplo n.º 5
0
        public bool GetGroup(string grpName, CLIENT client, out GROUP grp)
        {
            try
            {
                grp = (from ent in client.GROUP
                       where ent.NAME.TrimEnd() == grpName
                       select ent).Single();
            }

            catch
            {
                grp = null;
                return false;
            }

            return true;
        }
Exemplo n.º 6
0
        public bool GetCUPE(string name, CLIENT client, out CUPE cupe)
        {
            try
            {
                cupe = (from ent in client.CUPE
                        where ent.NAME.TrimEnd() == name
                        select ent).Single();

                return true;
            }

            catch
            {
                cupe = null;
                return false;
            }
        }
Exemplo n.º 7
0
        public bool GetClient(string cntName, out CLIENT client)
        {
            try
            {
                client = (from ent in dbo.CLIENT
                          where ent.NAME.TrimEnd() == cntName
                          select ent).Single();
            }

            catch
            {
                client = null;
                return false;
            }

            return true;
        }
Exemplo n.º 8
0
        public bool GetCapabilityGapInfo(string capName, CLIENT client, out CAPABILITYGAPINFO capGapInfo)
        {
            try
            {
                capGapInfo = (from ent in client.CAPABILITYGAPINFO
                              where ent.CAPABILITY.NAME.TrimEnd() == capName
                              select ent).Single();

                return true;
            }

            catch
            {
                capGapInfo = null;
                return false;
            }
        }
Exemplo n.º 9
0
        public bool GetBOM(string iniName, CLIENT client, out BOM bom)
        {
            try
            {
                bom = (from ent in client.BOM
                       where ent.IMPERATIVE.NAME.TrimEnd() == iniName
                       select ent).Single();
            }

            catch
            {
                bom = null;
                return false;
            }

            return true;
        }
Exemplo n.º 10
0
        //Used by ClientDataControl
        public override Client AddClient(Client client)
        {
            CLIENT clientEnt = new CLIENT();

            clientEnt.NAME = client.Name.TrimEnd();

            string regionName = client.Region;
            REGION region;
            try
            {
                region = (from ent in dbo.REGION
                          where ent.NAME.TrimEnd() == regionName
                          select ent).Single();
            }
            catch
            {
                region = new REGION();
                region.NAME = client.Region;
                dbo.AddToREGION(region);
            }

            string countryName = client.Country;
            COUNTRY country;
            try
            {
                country = (from ent in region.COUNTRY
                          where ent.NAME.TrimEnd() == countryName
                          select ent).Single();
            }
            catch
            {
                country = new COUNTRY();
                country.NAME = client.Country;
                country.REGION = region;
                dbo.AddToCOUNTRY(country);
            }

            clientEnt.COUNTRY = country;

            string busTypeName = client.BusinessType;
            BUSINESSTYPE busType;
            try
            {
                busType = (from ent in dbo.BUSINESSTYPE
                          where ent.NAME.TrimEnd() == busTypeName
                          select ent).Single();
            }
            catch
            {
                busType = new BUSINESSTYPE();
                busType.NAME = client.BusinessType;
                dbo.AddToBUSINESSTYPE(busType);
            }
            clientEnt.BUSINESSTYPE = busType;

            clientEnt.STARTDATE = client.StartDate;
            clientEnt.BOMCOMPLETE = clientEnt.CUPECOMPLETE = clientEnt.ITCAPCOMPLETE = "N";

            if (!AddClient(clientEnt))
            {
                return null;
            }

            client.EntityObject = clientEnt;
            return client;
        }
Exemplo n.º 11
0
        public bool AddClient(CLIENT client)
        {
            string clientName = client.NAME.TrimEnd();
            //If already in DB, return false
            if ((from ent in dbo.CLIENT
                 where ent.NAME.TrimEnd() == clientName
                 select ent).Count() != 0)
            {
                dbo.Detach(client);
                return false;
            }

            dbo.AddToCLIENT(client);

            AddGroup("Business", client);
            AddGroup("IT", client);
            AddGroup("ITCAP", client);

            File.Create(@"Resources\Clients\" + clientName + ".xml").Close();

            return true;
        }
Exemplo n.º 12
0
 /// <summary>
 /// Create a new CLIENT object.
 /// </summary>
 /// <param name="cLIENTID">Initial value of the CLIENTID property.</param>
 /// <param name="nAME">Initial value of the NAME property.</param>
 public static CLIENT CreateCLIENT(global::System.Int32 cLIENTID, global::System.String nAME)
 {
     CLIENT cLIENT = new CLIENT();
     cLIENT.CLIENTID = cLIENTID;
     cLIENT.NAME = nAME;
     return cLIENT;
 }
Exemplo n.º 13
0
 /// <summary>
 /// Deprecated Method for adding a new object to the CLIENT EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToCLIENT(CLIENT cLIENT)
 {
     base.AddObject("CLIENT", cLIENT);
 }
Exemplo n.º 14
0
 /// <summary>
 /// Create a new CLIENT object.
 /// </summary>
 /// <param name="cLIENTID">Initial value of the CLIENTID property.</param>
 /// <param name="nAME">Initial value of the NAME property.</param>
 /// <param name="sTARTDATE">Initial value of the STARTDATE property.</param>
 /// <param name="bOMCOMPLETE">Initial value of the BOMCOMPLETE property.</param>
 /// <param name="cUPECOMPLETE">Initial value of the CUPECOMPLETE property.</param>
 /// <param name="iTCAPCOMPLETE">Initial value of the ITCAPCOMPLETE property.</param>
 public static CLIENT CreateCLIENT(global::System.Int32 cLIENTID, global::System.String nAME, global::System.DateTime sTARTDATE, global::System.String bOMCOMPLETE, global::System.String cUPECOMPLETE, global::System.String iTCAPCOMPLETE)
 {
     CLIENT cLIENT = new CLIENT();
     cLIENT.CLIENTID = cLIENTID;
     cLIENT.NAME = nAME;
     cLIENT.STARTDATE = sTARTDATE;
     cLIENT.BOMCOMPLETE = bOMCOMPLETE;
     cLIENT.CUPECOMPLETE = cUPECOMPLETE;
     cLIENT.ITCAPCOMPLETE = iTCAPCOMPLETE;
     return cLIENT;
 }