private void btnAccess_Click(object sender, EventArgs e)
        {
            string errMsg = "";

            if (dataGridView1.SelectedCells.Count == 0)
            {
                errMsg = "Select topic to be accessed";
            }
            else
            {
                int    selectedTopicId   = Convert.ToInt32(dataGridView1.SelectedCells[0].Value.ToString());
                string selectedTopicName = dataGridView1.SelectedCells[1].Value.ToString();
                Topic  selectedTopic     = new Topic(selectedTopicId, selectedTopicName);
                mainForm.setCurrentTopic(selectedTopic);

                MessageBox.Show(this, "Access to " + selectedTopicName, "Access Topic", MessageBoxButtons.OK, MessageBoxIcon.Information);
                mainForm.Text = "Analytic Hierarchy Process: " + selectedTopicName;
                mainForm.refreshAllChildrenForm();
                this.Close();

                int countAlternative = alternativeListController.getAlternativeList(selectedTopicId.ToString()).Count;
                if (countAlternative >= 2)
                {
                    mainForm.openResultForm();
                }
            }

            if (errMsg != "")
            {
                MessageBox.Show(this, errMsg, "Access Topic", MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
        }
Beispiel #2
0
        public DataGridView getDGV()
        {
            dataGridView1.DataSource = null;
            DataTable dt = new DataTable();

            int criteriaCount = 0;

            // DYNAMIC COLUMN
            dt.Columns.Add(new DataColumn("Alternative Name", typeof(string)));
            foreach (Criteria criteria in criteriaController.getCriteriaList(currentTopicId))
            {
                criteriaCount++;
                string columnName = criteria.criteriaName;
                if (criteria.criteriaUnit != "")
                {
                    columnName += " (" + criteria.criteriaUnit + ")";
                }

                if (criteria.isBoolean)
                {
                    dt.Columns.Add(new DataColumn(columnName, typeof(Boolean)));
                }
                else
                {
                    dt.Columns.Add(new DataColumn(columnName, typeof(double)));
                }
            }

            // DYNAMIC ROW
            foreach (string alternativeName in alternativeListController.getAlternativeList(currentTopicId))
            {
                DataRow row = dt.NewRow();

                row["Alternative Name"] = alternativeName;

                foreach (Criteria criteria in criteriaController.getCriteriaList(currentTopicId))
                {
                    string columnName = criteria.criteriaName;
                    if (criteria.criteriaUnit != "")
                    {
                        columnName += " (" + criteria.criteriaUnit + ")";
                    }

                    row[columnName] = alternativeListController.valueLookup(criteria.criteriaId, alternativeName);
                }

                dt.Rows.Add(row);
            }

            dataGridView1.DataSource = dt;
            dataGridView1.ClearSelection();
            dataGridView1.ReadOnly = true;
            return(dataGridView1);
        }
        public double[][] concatenateAllPriorityVector(string topicId)
        {
            List <string>         criteriaNameList    = new List <string>();
            List <string>         alternativeNameList = alternativeListController.getAlternativeList(topicId);
            List <List <double> > combinedPriorityVec = new List <List <double> >();

            foreach (Criteria criteria in criteriaController.getCriteriaList(topicId))
            {
                criteriaNameList.Add(criteria.criteriaName);
                List <double> oneRow = new List <double>();
                foreach (double val in pairwiseComparisonPerCriteria(topicId, criteria.criteriaId.ToString()))
                {
                    oneRow.Add(val);
                }
                combinedPriorityVec.Add(oneRow);
            }

            double[][] combinedMat           = combinedPriorityVec.Select(x => x.ToArray()).ToArray();
            double[][] transposedCombinedMat = transposeMatrix(combinedMat);

            return(transposedCombinedMat);
        }
        // BUTTON EVENT
        private void btnAdd_Click(object sender, EventArgs e)
        {
            string criteriaName  = txtCriteriaName.Text;
            string criteriaUnit  = txtCriteriaUnit.Text;
            bool   isFewerBetter = cbIsFewerBetter.Checked;
            bool   isBoolean     = cbIsBoolean.Checked;
            string errMsg        = "";
            int    countCriteria = criteriaController.getCriteriaList(currentTopicId).Count;

            if (countCriteria >= 6)
            {
                errMsg = "Maximum number of criteria reached";
            }
            else if (criteriaName == "")
            {
                errMsg = "Criteria Name must be filled";
            }
            else if (criteriaName.Length < 3 || criteriaName.Length > 30)
            {
                errMsg = "Criteria Name length must be between 3 and 30";
            }
            else if (!criteriaController.isCriteriaUnique(currentTopicId, criteriaName))
            {
                errMsg = "Criteria Name must be unique";
            }
            else
            {
                int criteriaId = criteriaController.addCriteria(currentTopicId, criteriaName, criteriaUnit, isFewerBetter, isBoolean, currentUserName);

                foreach (string alternativeName in alternativeListController.getAlternativeList(currentTopicId))
                {
                    alternativeListController.addOneDetailAlternative(criteriaId, alternativeName, 0, currentUserName);
                }

                refreshForm();

                string msg = "Add Success";

                if (countCriteria == 2)
                {
                    msg += ". Now you can determine\nCriteria Weight and add Alternative List.";
                }

                MessageBox.Show(this, msg, "Add Criteria", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            if (errMsg != "")
            {
                MessageBox.Show(this, errMsg, "Add Criteria", MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            string errMsg = "";
            string inputtedAlternativeName = txtAlternativeName.Text;

            if (inputtedAlternativeName == "")
            {
                errMsg = "Alternative Name must be filled";
            }
            else if (alternativeListController.countCertainAlternativeName(currentTopicId, inputtedAlternativeName) > 0)
            {
                errMsg = "Alternative Name must be unique";
            }
            else
            {
                foreach (AddAlternativeUserControl addAlternativeUserControl in flowLayoutPanel1.Controls)
                {
                    int    criteriaId = addAlternativeUserControl.getCriteria().criteriaId;
                    double value      = addAlternativeUserControl.getValue();

                    alternativeListController.addOneDetailAlternative(criteriaId, inputtedAlternativeName, value, currentUserName);
                }

                resetForm();
                alternativeListForm.Refresh();
                mainForm.refreshAllChildrenForm();

                int    countAlternative = alternativeListController.getAlternativeList(currentTopicId).Count;
                string msg = "Add Success";

                if (countAlternative == 2)
                {
                    msg += ". Now you can see the final result.";
                }

                mainForm.updateTooltipVisibility();
                MessageBox.Show(this, msg, "Add Alternative", MessageBoxButtons.OK, MessageBoxIcon.Information);

                if (countAlternative == 11)
                {
                    MessageBox.Show(this, "Maximum number of alternative reached", "Add New Row", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    this.Close();
                }
            }

            if (errMsg != "")
            {
                MessageBox.Show(this, errMsg, "Add Alternative", MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
        }
Beispiel #6
0
        private void AlternativeListForm_Load(object sender, EventArgs e)
        {
            mainForm = (MainForm)this.MdiParent;
            alternativeListController = new AlternativeListController();
            criteriaController        = new CriteriaController();
            currentTopicId            = mainForm.getCurrentTopic().topicId.ToString();
            currentUserName           = mainForm.getCurrentUser().userName;
            isFormEdited = false;

            refreshTable();

            if (alternativeListController.getAlternativeList(currentTopicId).Count < 1)
            {
                MessageBox.Show(this, "Please input 2-11 alternatives", "Alternative List", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Beispiel #7
0
        private void ResultForm_Load(object sender, EventArgs e)
        {
            mainForm                  = (MainForm)this.MdiParent;
            criteriaController        = new CriteriaController();
            alternativeListController = new AlternativeListController();
            resultController          = new ResultController();
            currentTopicId            = mainForm.getCurrentTopic().topicId.ToString();

            this.Text = "Result for " + mainForm.getCurrentTopic().topicName;

            if (alternativeListController.getAlternativeList(currentTopicId).Count < 2)
            {
                this.Close();
            }
            else
            {
                loadDynamicUI();
            }
        }
        public void updateTooltipVisibility()
        {
            // FIRST PAGE, BEFORE LOGIN
            fileToolStripMenuItem.Visible = false;

            //lblUser.Visible = false;
            userToolStripMenuItem1.Visible     = false;
            loginToolStripMenuItem1.Visible    = true;
            registerToolStripMenuItem2.Visible = true;

            viewUserToolStripMenuItem1.Visible = false;
            viewTopicToolStripMenuItem.Visible = false;
            helpToolStripMenuItem.Visible      = false;

            backToolStripMenuItem.Visible             = false;
            criteriaListToolStripMenuItem1.Visible    = false;
            criteriaWeightToolStripMenuItem1.Visible  = false;
            alternativeListToolStripMenuItem1.Visible = false;
            openAllFormToolStripMenuItem1.Visible     = false;
            closeAllFormToolStripMenuItem1.Visible    = false;
            resultToolStripMenuItem1.Visible          = false;

            topicCountToolStripMenuItem.Visible       = false;
            criteriaCountToolStripMenuItem.Visible    = false;
            alternativeCountToolStripMenuItem.Visible = false;

            if (currentUser != null)
            {
                // SECOND PAGE, AFTER LOGIN
                //lblUser.Visible = true;
                //lblUser.Text = "Hi, " + currentUser.userName + "!";
                //lblUser.Parent = this;
                userToolStripMenuItem1.Visible = true;
                userToolStripMenuItem1.Text    = "Hi, " + currentUser.userName + "!";

                loginToolStripMenuItem1.Visible    = false;
                registerToolStripMenuItem2.Visible = false;

                if (currentUser.isAdmin)
                {
                    viewUserToolStripMenuItem1.Visible = true;
                }
                else
                {
                    viewUserToolStripMenuItem1.Visible = false;
                }
                viewTopicToolStripMenuItem.Visible = true;
                helpToolStripMenuItem.Visible      = true;

                backToolStripMenuItem.Visible             = false;
                criteriaListToolStripMenuItem1.Visible    = false;
                criteriaWeightToolStripMenuItem1.Visible  = false;
                alternativeListToolStripMenuItem1.Visible = false;
                openAllFormToolStripMenuItem1.Visible     = false;
                closeAllFormToolStripMenuItem1.Visible    = false;
                resultToolStripMenuItem1.Visible          = false;

                topicCountToolStripMenuItem.Visible = true;

                if (currentUser.isAdmin)
                {
                    topicCountToolStripMenuItem.Text = "Topic(s): " + topicController.getTopicData("").Count;
                }
                else
                {
                    topicCountToolStripMenuItem.Text = "Topic(s): " + topicController.getTopicData(currentUser.userName).Count;
                }

                criteriaCountToolStripMenuItem.Visible    = false;
                alternativeCountToolStripMenuItem.Visible = false;

                if (currentTopic != null)
                {
                    // THIRD PAGE, AFTER ACCESS TOPIC

                    loginToolStripMenuItem1.Visible    = false;
                    registerToolStripMenuItem2.Visible = false;

                    viewUserToolStripMenuItem1.Visible = false;
                    viewTopicToolStripMenuItem.Visible = false;
                    helpToolStripMenuItem.Visible      = true;

                    backToolStripMenuItem.Visible          = true;
                    criteriaListToolStripMenuItem1.Visible = true;
                    closeAllFormToolStripMenuItem1.Visible = true;
                    resultToolStripMenuItem1.Visible       = false;

                    string topicId          = currentTopic.topicId.ToString();
                    int    countCriteria    = mainController.countCriteria(topicId);
                    int    countAlternative = alternativeListController.getAlternativeList(topicId).Count;

                    topicCountToolStripMenuItem.Visible       = false;
                    criteriaCountToolStripMenuItem.Visible    = true;
                    criteriaCountToolStripMenuItem.Text       = "Criteria(s): " + countCriteria.ToString();
                    alternativeCountToolStripMenuItem.Visible = true;
                    alternativeCountToolStripMenuItem.Text    = "Alternative(s): " + countAlternative.ToString();

                    if (countCriteria < 3 || countCriteria > 11)
                    {
                        criteriaWeightToolStripMenuItem1.Visible  = false;
                        alternativeListToolStripMenuItem1.Visible = false;
                        openAllFormToolStripMenuItem1.Visible     = false;
                        resultToolStripMenuItem1.Visible          = false;
                    }
                    else
                    {
                        criteriaWeightToolStripMenuItem1.Visible  = true;
                        alternativeListToolStripMenuItem1.Visible = true;
                        openAllFormToolStripMenuItem1.Visible     = true;
                        resultToolStripMenuItem1.Visible          = false;

                        if (countAlternative >= 2)
                        {
                            resultToolStripMenuItem1.Visible = true;
                        }
                    }
                }
            }
        }
Beispiel #9
0
        private void HelpDialog_Load(object sender, EventArgs e)
        {
            mainForm                  = (MainForm)this.MdiParent;
            mainController            = new MainController();
            alternativeListController = new AlternativeListController();
            Topic  currentTopic   = mainForm.getCurrentTopic();
            string currentTopicId = "";

            if (currentTopic != null)
            {
                cbStep1.Checked = true;
                lblStep1.Text   = status.ElementAt(1);

                currentTopicId = currentTopic.topicId.ToString();
                int countCriteria = mainController.countCriteria(currentTopicId);

                if (countCriteria >= 3 && countCriteria <= 11)
                {
                    cbStep2.Checked = true;
                    lblStep2.Text   = status.ElementAt(1);
                }
                else
                {
                    cbStep2.Checked = false;
                    cbStep3.Checked = true;

                    lblStep2.Text = status.ElementAt(0);
                    lblStep3.Text = status.ElementAt(0);
                }

                if (!mainController.isAllCriteriaWeightDefault(currentTopicId))
                {
                    cbStep3.Checked = true;
                    lblStep3.Text   = status.ElementAt(1);
                }
                else
                {
                    cbStep3.Checked = false;
                    lblStep3.Text   = status.ElementAt(0);
                }

                if (alternativeListController.getAlternativeList(currentTopicId).Count >= 2)
                {
                    cbStep4.Checked = true;
                    cbStep5.Checked = true;

                    lblStep4.Text = status.ElementAt(1);
                    lblStep5.Text = status.ElementAt(1);
                }
                else
                {
                    cbStep4.Checked = false;
                    cbStep5.Checked = false;

                    lblStep4.Text = status.ElementAt(0);
                    lblStep5.Text = status.ElementAt(0);
                }
            }
            else
            {
                cbStep1.Checked = false;
                cbStep2.Checked = false;
                cbStep3.Checked = false;
                cbStep4.Checked = false;
                cbStep5.Checked = false;

                lblStep1.Text = status.ElementAt(0);
                lblStep2.Text = status.ElementAt(0);
                lblStep3.Text = status.ElementAt(0);
                lblStep4.Text = status.ElementAt(0);
                lblStep5.Text = status.ElementAt(0);
            }
        }