private void WeightEstimateForm_Load(object sender, EventArgs e)
        {
            for (int i = 0; i < 11; ++i)
            {
                tabControl1.TabPages.Add(WeightParameter.ParaTypeList[i]);
            }


            if (curWa == null)
            {
                lstWeightSort = WeightSortManageForm.GetListWeightSortData();

                if (lstWeightSort.Count > 0)
                {
                    foreach (WeightSortData wsd in lstWeightSort)
                    {
                        cmbWeightClass.Items.Add(wsd);
                    }
                    cmbWeightClass.DisplayMember = "sortName";

                    waItems = WeightArithmeticManageForm.GetArithmeticItems();
                }
            }
            else
            {
                bEditProject          = true;
                txtWeightEstName.Text = curWa.DataName;
                lstWeightSort         = new List <WeightSortData>();
                lstWeightSort.Add(curWa.MakeNewWeightSort());
                cmbWeightClass.Items.Add(curWa.SortName);
                cmbWeightClass.SelectedIndex = 0;
                txtWeightEstName.Enabled     = false;
                cmbWeightClass.Enabled       = false;
                cmbWeightMethod.Enabled      = false;
            }
        }
Exemple #2
0
        private bool QueryWeightSort(WeightArithmetic wa)
        {
            List <WeightSortData> wsDataList = WeightSortManageForm.GetListWeightSortData(false);

            int nindex = -1;

            for (nindex = wsDataList.Count - 1; nindex >= 0; --nindex)
            {
                if (wsDataList[nindex].sortName == wa.SortName)
                {
                    break;
                }
            }

            bool bHasSort = false;
            int  nfit     = 0;

            if (nindex != -1)
            {
                bHasSort = true;

                if (wa.MatchWeightSort(wsDataList[nindex], false))
                {
                    nfit = 1;
                }
            }
            if (nfit == 0)
            {
                for (int i = 0; i < wsDataList.Count; ++i)
                {
                    if (i == nindex)
                    {
                        continue;
                    }

                    if (wa.MatchWeightSort(wsDataList[i], false))
                    {
                        string       Message = bHasSort ? ("算法文件未能和分类\"" + wa.SortName + "\"匹配,但和分类\"") : ("分类\"" + wa.SortName + "\"不存在,但算法文件和分类\"");
                        DialogResult dr      = MessageBox.Show(Message + wsDataList[i].sortName + "\"匹配。是否导入到分类\"" + wsDataList[i].sortName + "\"?", "分类不匹配", MessageBoxButtons.YesNoCancel);
                        if (dr == DialogResult.Cancel)
                        {
                            return(false);
                        }
                        else if (dr == DialogResult.Yes)
                        {
                            wa.SortName = wsDataList[i].sortName;
                            nindex      = i;
                            nfit        = 2;
                            break;
                        }
                        else
                        {
                            nfit = 0;
                        }
                    }
                }

                // 0 建分类
                // 1 符合
                // 2 在其它分类找到

                if (nfit == 0)
                {
                    DialogResult dr = MessageBox.Show("算法未找到匹配分类,是否新建分类?", "是否建分类", MessageBoxButtons.YesNo);
                    if (dr != DialogResult.Yes)
                    {
                        return(false);
                    }
                    // 建分类

                    if (bHasSort)
                    {
                        string strmsg    = "请输入分类名称";
                        bool   bcontinue = true;
                        while (bcontinue)
                        {
                            string sortname = Microsoft.VisualBasic.Interaction.InputBox(strmsg, "输入名称", wa.SortName, -1, -1);
                            sortname = sortname.Trim();
                            if (sortname == "")
                            {
                                return(false);
                            }
                            bcontinue = false;
                            foreach (WeightSortData wsditem in wsDataList)
                            {
                                if (wsditem.sortName == sortname)
                                {
                                    bcontinue = true;
                                    strmsg    = "分类\"" + sortname + "\"已存在!\r\n请重新输入分类名称";
                                }
                            }
                            if (!bcontinue)
                            {
                                wa.SortName = sortname;
                            }
                        }
                    }

                    WeightSortData wsd = wa.MakeNewWeightSort();
                    if (!WeightSortManageForm.SaveHccFile(wsd, false))
                    {
                        return(false);
                    }
                    wsDataList.Add(wsd);

                    treeViewArithmeticList.Nodes[0].Nodes.Add("weightCategory\\" + wa.SortName, wa.SortName, 2, 3);
                }
            }

            return(true);
        }
        private bool QueryWeightSort(WeightArithmetic wa)
        {
            List<WeightSortData> wsDataList = WeightSortManageForm.GetListWeightSortData(false);

            int nindex = -1;
            for (nindex = wsDataList.Count - 1; nindex >= 0; --nindex)
            {
                if (wsDataList[nindex].sortName == wa.SortName)
                {
                    break;
                }
            }

            bool bHasSort = false;
            int nfit = 0;
            if (nindex != -1)
            {
                bHasSort = true;

                if (wa.MatchWeightSort(wsDataList[nindex], false))
                {
                    nfit = 1;
                }
            }
            if (nfit == 0)
            {
                for (int i = 0; i < wsDataList.Count; ++i)
                {
                    if (i == nindex)
                    {
                        continue;
                    }

                    if (wa.MatchWeightSort(wsDataList[i], false))
                    {
                        string Message = bHasSort ? ("算法文件未能和分类\"" + wa.SortName + "\"匹配,但和分类\"") : ("分类\"" + wa.SortName + "\"不存在,但算法文件和分类\"");
                        DialogResult dr = MessageBox.Show(Message + wsDataList[i].sortName + "\"匹配。是否导入到分类\"" + wsDataList[i].sortName + "\"?", "分类不匹配", MessageBoxButtons.YesNoCancel);
                        if (dr == DialogResult.Cancel)
                        {
                            return false;
                        }
                        else if (dr == DialogResult.Yes)
                        {
                            wa.SortName = wsDataList[i].sortName;
                            nindex = i;
                            nfit = 2;
                            break;
                        }
                        else
                        {
                            nfit = 0;
                        }
                    }
                }

                // 0 建分类
                // 1 符合
                // 2 在其它分类找到

                if (nfit == 0)
                {
                    DialogResult dr = MessageBox.Show("算法未找到匹配分类,是否新建分类?", "是否建分类", MessageBoxButtons.YesNo);
                    if (dr != DialogResult.Yes)
                    {
                        return false;
                    }
                    // 建分类

                    if (bHasSort)
                    {
                        string strmsg = "请输入分类名称";
                        bool bcontinue = true;
                        while (bcontinue)
                        {
                            string sortname = Microsoft.VisualBasic.Interaction.InputBox(strmsg, "输入名称", wa.SortName, -1, -1);
                            sortname = sortname.Trim();
                            if (sortname == "")
                            {
                                return false;
                            }
                            bcontinue = false;
                            foreach (WeightSortData wsditem in wsDataList)
                            {
                                if (wsditem.sortName == sortname)
                                {
                                    bcontinue = true;
                                    strmsg = "分类\"" + sortname + "\"已存在!\r\n请重新输入分类名称";
                                }
                            }
                            if (!bcontinue)
                            {
                                wa.SortName = sortname;
                            }
                        }
                    }

                    WeightSortData wsd = wa.MakeNewWeightSort();
                    if (!WeightSortManageForm.SaveHccFile(wsd, false))
                    {
                        return false;
                    }
                    wsDataList.Add(wsd);

                    treeViewArithmeticList.Nodes[0].Nodes.Add("weightCategory\\" + wa.SortName, wa.SortName, 2, 3);
                }
            }

            return true;
        }