Beispiel #1
0
        private void exportTextToolStripMenuItem_Click(object sender, EventArgs e)
        {
            bool GetAnswer =
                MessageBox.Show("Export answer or not? ", "Export type",
                                MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes;
            StringBuilder stringBuilder = new StringBuilder();

            //取每个矩阵出来进行导出
            for (int index = 0; index < listBoxMatrix.Items.Count; index++)
            {
                //取出当前矩阵和层次
                TreeNodeCollection CurrentLayer = ((TreeNodeCollection[])LayerList.ToArray(typeof(TreeNodeCollection)))[index + 1];
                string[,] CurrentMatrix = ((string[][, ])MatrixList.ToArray(typeof(string[, ])))[index + 1];
                if (CurrentMatrix != null)
                {
                    string[] FactorsString = new string[CurrentLayer.Count];
                    int      i             = 0;
                    //取出该层因素
                    foreach (TreeNode node in CurrentLayer)
                    {
                        FactorsString[i] = node.Text;
                        i++;
                    }
                    FormSurvey formSurvey = new FormSurvey(FactorsString, CurrentLayer[0].Parent.Text, CurrentMatrix);
                    formSurvey.Show();
                    stringBuilder.Append("------------------------------------------------\r\n");
                    stringBuilder.Append(formSurvey.getAllQuestionText(needAnswerOrNot: GetAnswer));
                    formSurvey.Close();
                }
            }
            FormText formText = new FormText();

            formText.Show(stringBuilder.ToString(), "SurveyText");
        }
Beispiel #2
0
        private void generateResultToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FormText formText = new FormText();

            formText.Show(GenerateReport(), "AHPCalculatingReport");
        }
Beispiel #3
0
        private bool checkMarix(bool ShowResultOrNot)
        {
            StringBuilder  checkResultStr    = new StringBuilder();
            StringBuilder  MatrixNotOKPrompt = new StringBuilder();
            MatrixOperater matrixOperater    = new MatrixOperater();
            ArrayList      checkResultList;

            string[,] currentMatrix;
            bool matrixComplete = true;
            bool AllPass        = true;

            System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();  //新建计时停表
            stopwatch.Restart();
            for (int MatrixIndex = 1; MatrixIndex < MatrixList.Count; MatrixIndex++)
            {
                //显示正在检查那个数组
                checkResultStr.Append("Checking " +
                                      listBoxMatrix.Items[MatrixIndex - 1].ToString() + "\r\n");
                //将该数组信息输出
                currentMatrix = (string[, ])MatrixList[MatrixIndex];
                for (int i = 0; i < currentMatrix.GetLength(0); i++)
                {
                    for (int j = 0; j < currentMatrix.GetLength(1); j++)
                    {
                        checkResultStr.Append(currentMatrix[i, j]);
                        //检查是否要插入制表符
                        if (j < currentMatrix.GetLength(1) - 1)
                        {
                            checkResultStr.Append("\t");
                        }
                    }
                    checkResultStr.Append("\r\n");
                }
                //再换一行,准备输出计算结果和判断结果
                checkResultStr.Append("\r\n");

                //检查数组是否已经填写完毕
                if (matrixOperater.IsMatrixHasZero(currentMatrix))
                {
                    checkResultStr.Append("This matrix not complete(Zero detected)!\r\n");
                    matrixComplete = false;
                }
                else
                {
                    //输出计算结果
                    checkResultList = matrixOperater.CheckMatrix(
                        matrixOperater.conventStringMatrixIntoNumberArray(
                            currentMatrix
                            )
                        );
                    checkResultStr.Append("CI = " + checkResultList[0] + " CR = " + checkResultList[1] +
                                          " CR < 0.1? " + (((bool)checkResultList[2]) ? "YES" : "NO") + "\r\n");
                    //如果有超限数组,加入提示
                    if ((bool)checkResultList[2] == false)
                    {
                        MatrixNotOKPrompt.Append(listBoxMatrix.Items[MatrixIndex - 1].ToString() + "\r\n");
                    }
                }
                //输出分隔符
                checkResultStr.Append("------------------------------------------------\r\n");
            }

            //检查结束
            stopwatch.Stop();
            checkResultStr.Append("Checking finish in " + stopwatch.Elapsed.TotalMilliseconds.ToString() + "ms.\r\n");
            //输出检查结果
            if (MatrixNotOKPrompt.ToString().Equals("") && matrixComplete)
            {
                //如果没有不OK的矩阵
                checkResultStr.Append("Congratulations, All Matrix pass the test!\r\n");
                AllPass = true;
            }
            else if (matrixComplete)
            {
                checkResultStr.Append("Some matrix given in the following did not pass the test, check and retest.\r\n");
                checkResultStr.Append(MatrixNotOKPrompt.ToString() + "\r\n");
                AllPass = false;
            }
            else
            {
                checkResultStr.Append("Some matrix not complete, check and retest.\r\n");
                AllPass = false;
            }

            if (ShowResultOrNot)
            {
                //显示结果
                FormText formText = new FormText();
                formText.Show(checkResultStr.ToString(), "MatrixCheckResult");
            }

            return(AllPass);
        }