Beispiel #1
0
        private void btnJYNew_Click(object sender, EventArgs e)
        {
            if (treeViewArithmeticList.Nodes.Count > 1 && selNode.Parent == treeViewArithmeticList.Nodes[1])
            {
                WeightArithmetic wa = (WeightArithmetic)selNode.Tag;

                if (!QueryWeightSort(wa))
                {
                    return;
                }
            }

            WeightArithmeticOperForm form = new WeightArithmeticOperForm("jynew", selNode);

            if (form.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            foreach (TreeNode node in treeViewArithmeticList.Nodes[0].Nodes)
            {
                if (node.Text == form.strWeightSortName)
                {
                    node.Nodes.Add(node.Name + "\\" + form.strWeightArithmeticFileName + ".wem", form.strWeightArithmeticFileName, 4, 5);
                    if (node.IsExpanded == false)
                    {
                        node.Expand();
                    }
                    break;
                }
            }
            WeightParameter.GetWeightParameterList()[10].Clear();
        }
        /// <summary>
        /// 导出重量设计结果为对应的SyswareDataObject.xml
        /// </summary>
        /// <param name="result"></param>
        /// <param name="isAddChildren"></param>
        /// <returns></returns>
        public static string saveWeightArithmeticDataObjectToXml(WeightArithmetic result, bool isAddChildren)
        {
            string path = null;

            try
            {
                SyswareDataObject sdo = new SyswareDataObject();
                if (isAddChildren)
                {
                    SyswareDataObject subSdo = new SyswareDataObject();
                    sdo.name = result.DataName;
                    sdo.children.Add(transFormWeightArithmeticToDataObject(-1, result.ExportDataToWeightSort().lstWeightData)[0]);
                }
                else
                {
                    sdo.name = "重量设计结果";
                    SyswareDataObject subSdo = new SyswareDataObject();
                    subSdo.name     = result.DataName;
                    subSdo.children = transFormWeightArithmeticToDataObject(-1, result.ExportDataToWeightSort().lstWeightData);
                    sdo.children.Add(subSdo);
                }
                XmlDocument myXmlDoc = saveSyswareDataObjectToXML(null, null, sdo);
                path = System.IO.Path.GetTempPath() + System.IO.Path.GetRandomFileName() + ".xml";
                //将xml文件保存到临时路径下
                myXmlDoc.Save(path);
            }
            catch
            {
                // XLog.Write("无法保存重量设计XML." + e.Message);

                return(null);
            }

            return(path);
        }
Beispiel #3
0
        /// <summary>
        /// 确认按钮单击
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            if (this.weightResultTree.SelectedNode == null)
            {
                return;
            }
            int i = Convert.ToInt16(this.weightResultTree.SelectedNode.ToolTipText);

            if (flag == 0)
            {
                WeightArithmetic wa = mainForm.designProjectData.lstWeightArithmetic[i];
                ((WeightAssessmentForm)this.Owner).saveWeightDataGridView(wa.ExportDataToWeightSort(), 1);
            }
            else if (flag == 1)
            {
                WeightAdjustmentResultData ward = mainForm.designProjectData.lstAdjustmentResultData[i];
                ((WeightAssessmentForm)this.Owner).saveWeightDataGridView(ward.weightAdjustData, 1);
            }
            else if (flag == 2)
            {
                WeightSortData wsd = WeightSortData.clsStringToWeightSortData(lstTypeWeight[i].MainSystem_Name);
                ((WeightAssessmentForm)this.Owner).saveWeightDataGridView(wsd, 1);
            }
            else if (flag == 3)
            {
                WeightSortData wsd = WeightSortData.clsStringToWeightSortData(lstWeightDesign[i].MainSystem_Name);
                ((WeightAssessmentForm)this.Owner).saveWeightDataGridView(wsd, 1);
            }
            this.Close();
        }
        public WeightEstimateForm(MainForm main_Form, WeightArithmetic weight_Arithmetic)
        {
            InitializeComponent();
            dataGridViewParaInput.Columns[1].ValueType = System.Type.GetType("System.Decimal");

            mainForm = main_Form;
            curWa = weight_Arithmetic;
        }
        public WeightEstimateForm(MainForm main_Form, WeightArithmetic weight_Arithmetic)
        {
            InitializeComponent();
            dataGridViewParaInput.Columns[1].ValueType = System.Type.GetType("System.Decimal");

            mainForm = main_Form;
            curWa    = weight_Arithmetic;
        }
        private void cmbWeightMethod_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!bEditProject)
            {
                string itemvalue = ((KeyValuePair <string, string>)cmbWeightMethod.SelectedItem).Value;
                curWa = WeightArithmetic.ReadArithmeticData(itemvalue);
            }

            OnCurWaChanged();
        }
Beispiel #7
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            try
            {
                System.Windows.Forms.OpenFileDialog dlg = new OpenFileDialog();
                dlg.RestoreDirectory = true;
                dlg.Filter           = "Wem files (*.wem)|*.wem";
                if (dlg.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                List <WeightSortData> wsDataList = WeightSortManageForm.GetListWeightSortData(false);

                WeightArithmetic wa = WeightArithmetic.ReadArithmeticData(dlg.FileName);
                WeightParameter.GetWeightParameterList()[10].Clear();

                if (!QueryWeightSort(wa))
                {
                    return;
                }

                if (!WeightArithmeticOperForm.WriteArithmeticFile(wa, true))
                {
                    return;
                }
                //加节点
                foreach (TreeNode treenode in treeViewArithmeticList.Nodes[0].Nodes)
                {
                    if (treenode.Text == wa.SortName)
                    {
                        string filename = "weightCategory\\" + wa.SortName + "\\" + wa.Name + ".wem";
                        if (!treenode.Nodes.ContainsKey(filename))
                        {
                            treenode.Nodes.Add(filename, wa.Name, 4, 5);
                            if (treenode.IsExpanded == false)
                            {
                                treenode.Expand();
                            }
                        }
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                XCommon.XLog.Write("导入重量算法文件错误");
            }
        }
        private void cmbWeightMethod_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!bEditProject)
            {
                string itemvalue = ((KeyValuePair<string, string>)cmbWeightMethod.SelectedItem).Value;
                curWa = WeightArithmetic.ReadArithmeticData(itemvalue);
            }

            OnCurWaChanged();
        }
Beispiel #9
0
        private void btnExport_Click(object sender, EventArgs e)
        {
            System.Windows.Forms.SaveFileDialog dlg = new SaveFileDialog();
            dlg.FileName = selNode.Text;

            WeightArithmetic wa = null;

            if (selNode.Tag != null)
            {
                wa           = selNode.Tag as WeightArithmetic;
                dlg.FileName = wa.Name;
            }

            dlg.OverwritePrompt = false;
            dlg.DefaultExt      = "wem";
            dlg.Filter          = "Wem files (*.wem)|*.wem";
            if (dlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            if (selNode.Tag == null)
            {
                if (selNode.Name != dlg.FileName)
                {
                    try
                    {
                        if (File.Exists(dlg.FileName))
                        {
                            if (MessageBox.Show("文件\"" + dlg.FileName + "\"已存在,是否覆盖?", "文件已存在", MessageBoxButtons.YesNo) == DialogResult.Yes)
                            {
                                System.IO.File.Copy(selNode.Name, dlg.FileName, true);
                            }
                            else
                            {
                                return;
                            }
                        }
                        else
                        {
                            System.IO.File.Copy(selNode.Name, dlg.FileName, true);
                        }
                    }
                    catch
                    {
                        MessageBox.Show("导出文件失败!");
                        return;
                    }
                }
            }
            else
            {
                wa = selNode.Tag as WeightArithmetic;
                if (!wa.WriteArithmeticFile(dlg.FileName, true))
                {
                    return;
                }
            }

            XCommon.XLog.Write("成功导出算法到文件\"" + dlg.FileName + "\"!");
        }
Beispiel #10
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;
        }
        static public bool WriteArithmeticFile(WeightArithmetic wa, bool bOverWritePrompt)
        {
            string filepath = "weightCategory\\" + wa.SortName + "\\" + wa.Name + ".wem";

            return(wa.WriteArithmeticFile(filepath, bOverWritePrompt));
        }
        public WeightArithmeticOperForm(string str_Type, TreeNode selNode)
        {
            InitializeComponent();
            strType = str_Type;

            List <WeightSortData> wsDataList = WeightSortManageForm.GetListWeightSortData();

            for (int i = 0; i < wsDataList.Count; ++i)
            {
                comboBoxWeightSort.Items.Add(wsDataList[i].sortName);
            }
            string wsortname = null;

            switch (strType)
            {
            case "new":
            {
                wsortname        = selNode.Text;
                txtName.ReadOnly = false;
                txtName.Text     = "新建算法";
                break;
            }

            case "edit":
            {
                waData = WeightArithmetic.ReadArithmeticData(selNode.Name);
                dateTimePickerCreateTime.Text     = waData.CreateTime;
                dateTimePickerLastModifyTime.Text = waData.LastModifyTime;
                txtRemark.Text = waData.Remark;

                comboBoxWeightSort.Enabled = false;
                wsortname        = selNode.Parent.Text;
                txtName.Text     = waData.Name;
                txtName.ReadOnly = true;
                break;
            }

            case "jynew":
            {
                if (selNode.Tag == null)
                {
                    waData    = WeightArithmetic.ReadArithmeticData(selNode.Name);
                    wsortname = selNode.Parent.Text;
                }
                else
                {
                    WeightArithmetic tempwa = selNode.Tag as WeightArithmetic;
                    waData    = (tempwa != null) ? tempwa.Clone() : (new WeightArithmetic());
                    wsortname = waData.SortName;
                }
                dateTimePickerCreateTime.Text     = waData.CreateTime;
                dateTimePickerLastModifyTime.Text = waData.LastModifyTime;
                txtRemark.Text = waData.Remark;

                mapCandidateFormula = new Dictionary <WeightFormula, string>();
                foreach (WeightFormula wf in waData.FormulaList)
                {
                    mapCandidateFormula.Add(wf, wf.NodePath);
                }

                txtName.Text     = waData.Name + " 副本";
                txtName.ReadOnly = false;
                break;
            }
            }
            int nselindex = 0;

            for (int i = 0; i < wsDataList.Count; ++i)
            {
                if (wsDataList[i].sortName == wsortname)
                {
                    nselindex = i;
                    break;
                }
            }
            comboBoxWeightSort.SelectedIndex = nselindex;
        }
        public WeightArithmeticOperForm(string str_Type, TreeNode selNode)
        {
            InitializeComponent();
            strType = str_Type;

            List<WeightSortData> wsDataList = WeightSortManageForm.GetListWeightSortData();

            for (int i = 0; i < wsDataList.Count; ++i)
            {
                comboBoxWeightSort.Items.Add(wsDataList[i].sortName);
            }
            string wsortname = null;

            switch (strType)
            {
                case "new":
                    {
                        wsortname = selNode.Text;
                        txtName.ReadOnly = false;
                        txtName.Text = "新建算法";
                        break;
                    }
                case "edit":
                    {
                        waData = WeightArithmetic.ReadArithmeticData(selNode.Name);
                        dateTimePickerCreateTime.Text = waData.CreateTime;
                        dateTimePickerLastModifyTime.Text = waData.LastModifyTime;
                        txtRemark.Text = waData.Remark;

                        comboBoxWeightSort.Enabled = false;
                        wsortname = selNode.Parent.Text;
                        txtName.Text = waData.Name;
                        txtName.ReadOnly = true;
                        break;
                    }
                case "jynew":
                    {
                        if (selNode.Tag == null)
                        {
                            waData = WeightArithmetic.ReadArithmeticData(selNode.Name);
                            wsortname = selNode.Parent.Text;
                        }
                        else
                        {
                            WeightArithmetic tempwa = selNode.Tag as WeightArithmetic;
                            waData = (tempwa != null) ? tempwa.Clone() : (new WeightArithmetic());
                            wsortname = waData.SortName;
                        }
                        dateTimePickerCreateTime.Text = waData.CreateTime;
                        dateTimePickerLastModifyTime.Text = waData.LastModifyTime;
                        txtRemark.Text = waData.Remark;

                        mapCandidateFormula = new Dictionary<WeightFormula, string>();
                        foreach (WeightFormula wf in waData.FormulaList)
                        {
                            mapCandidateFormula.Add(wf, wf.NodePath);
                        }

                        txtName.Text = waData.Name + " 副本";
                        txtName.ReadOnly = false;
                        break;
                    }
            }
            int nselindex = 0;
            for (int i = 0; i < wsDataList.Count; ++i)
            {
                if (wsDataList[i].sortName == wsortname)
                {
                    nselindex = i;
                    break;
                }
            }
            comboBoxWeightSort.SelectedIndex = nselindex;
        }
        public static bool WriteArithmeticFile(WeightArithmetic wa, bool bOverWritePrompt)
        {
            string filepath = "weightCategory\\" + wa.SortName + "\\" + wa.Name + ".wem";

            return wa.WriteArithmeticFile(filepath, bOverWritePrompt);
        }