コード例 #1
0
        // 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);
            }
        }
コード例 #2
0
        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);
            }
        }