Exemple #1
0
        private List <clsSTConstractRule> LoadConnstractRules(XmlNode xmlElement)
        {
            List <clsSTConstractRule> lstRules = new List <clsSTConstractRule>();

            foreach (XmlNode xn in xmlElement.ChildNodes)
            {
                if (xn.Name == "Rule")
                {
                    if (xn.Attributes["Used"].Value == "1")
                    {
                        clsSTConstractRule rule = new clsSTConstractRule();
                        if (xn.Attributes["type"].Value == "P")
                        {
                            rule.Positive = true;
                        }
                        else
                        {
                            rule.Positive = false;
                        }

                        if (xn.Attributes["BigerThan"].Value == "1")
                        {
                            rule.BiggerThan = true;
                        }
                        else
                        {
                            rule.BiggerThan = false;
                        }

                        if (xn.Attributes["Reference"].Value == "1")
                        {
                            rule.BiggerThan = true;
                        }
                        else
                        {
                            rule.BiggerThan = false;
                        }


                        float referenceValue = 0;
                        try { referenceValue = float.Parse(xn.Attributes["Reference"].Value); }
                        catch { referenceValue = float.MinValue; }

                        float actualValue = 0;
                        try { actualValue = float.Parse(xn.Attributes["actual"].Value); }
                        catch { actualValue = float.MinValue; }

                        if (referenceValue != float.MinValue && actualValue != float.MinValue)
                        {
                            rule.ReferenceValue = referenceValue;
                            rule.ActualValue    = actualValue;
                            lstRules.Add(rule);
                        }
                    }
                }
            }

            return(lstRules);
        }
Exemple #2
0
        private void m_cmdProjectSave_Click(object sender, EventArgs e)
        {
            if (this.m_lsvProject.FocusedItem == null &&
                !this.m_blnProject)
            {
                return;
            }
            Cursor.Current = Cursors.WaitCursor;
            this.m_cmdProjectSave.Enabled = false;

            if (this.m_blnProject)
            {//新增的保存
                clsSTCheckProject objProject = new clsSTCheckProject();

                objProject.BoardFrequence = this.m_txtBoardFrequency.Text;
                objProject.BoardTime      = this.m_txtBoardTime.Text;
                objProject.BoardWay       = this.m_txtBoardWay.Text;
                objProject.EnglishName    = this.m_txtEnglishName.Text;
                objProject.RefWaveLength  = this.m_txtRefWaveLength.Text;
                objProject.TestWaveLength = this.m_txtTestWaveLength.Text;
                objProject.Name           = this.m_txtProjectName.Text;

                List <clsSTConstractRule> lstRules = new List <clsSTConstractRule>();
                if (m_chkSmallN.Checked)
                {
                    clsSTConstractRule ruleSmallN = new clsSTConstractRule();
                    ruleSmallN.Positive       = false;
                    ruleSmallN.BiggerThan     = false;
                    ruleSmallN.ReferenceValue = float.Parse(this.m_txtSmallRefN.Text);
                    ruleSmallN.ActualValue    = float.Parse(this.m_txtSmallActualN.Text);
                    lstRules.Add(ruleSmallN);
                }
                if (m_chkBigN.Checked)
                {
                    clsSTConstractRule ruleBigN = new clsSTConstractRule();
                    ruleBigN.Positive       = false;
                    ruleBigN.BiggerThan     = true;
                    ruleBigN.ReferenceValue = float.Parse(this.m_txtBigRefN.Text);
                    ruleBigN.ActualValue    = float.Parse(this.m_txtBigActualN.Text);
                    lstRules.Add(ruleBigN);
                }

                if (m_chkSmallP.Checked)
                {
                    clsSTConstractRule ruleSmallP = new clsSTConstractRule();
                    ruleSmallP.Positive       = false;
                    ruleSmallP.BiggerThan     = false;
                    ruleSmallP.ReferenceValue = float.Parse(this.m_txtSmallRefP.Text);
                    ruleSmallP.ActualValue    = float.Parse(this.m_txtSmallActualP.Text);
                    lstRules.Add(ruleSmallP);
                }
                if (m_chkBigP.Checked)
                {
                    clsSTConstractRule ruleBigP = new clsSTConstractRule();
                    ruleBigP.Positive       = false;
                    ruleBigP.BiggerThan     = true;
                    ruleBigP.ReferenceValue = float.Parse(this.m_txtBigRefP.Text);
                    ruleBigP.ActualValue    = float.Parse(this.m_txtBigActualP.Text);
                    lstRules.Add(ruleBigP);
                }


                //if (lngRes > 0)
                //{//成功
                //    //更新状态标志

                //    this.m_blnProject = false;
                //    //加入到集合

                //    clsSTCheckProject[] objProjects = (clsSTCheckProject[])this.m_lsvProject.Tag;
                //    clsSTCheckProject[] objProjectsNewArr = new clsSTCheckProject[objProjects.Length + 1];
                //    objProjects.CopyTo(objProjectsNewArr, 0);
                //    objProjectsNewArr[objProjectsNewArr.Length - 1] = objProject;
                //    this.m_lsvProject.Tag = objProjectsNewArr;
                //    //添加新项
                //    ListViewItem item = new ListViewItem(objProject.m_strName);

                //    item.SubItems.Add(objProject.m_strPycode);
                //    item.SubItems.Add(objProject.m_strWbcode);

                //    item.Tag = objProject;
                //    this.m_lsvProject.Items.Add(item);
                //    item.Selected = true;
                //    item.Focused = true;
                //    this.m_lsvProject_Click(null, null);

                //}
                //else
                //{//失败
                //    clsCommonDialog.m_mthShowDBError();
                //}
            }
            else
            {//修改的保存
             //clsSTCheckProject objProject = (clsSTCheckProject)this.m_lsvProject.FocusedItem.Tag;

                //clsSTCheckProject objNewProject = new clsSTCheckProject();
                //objProject.m_mthCopyTo(objNewProject);
                //objNewProject.m_strName = this.m_txtProjectName.Text.Trim();
                //objNewProject.m_strPycode = this.m_txtProjectPYCode.Text.Trim();
                //objNewProject.m_strWbcode = this.m_txtProjectWBCode.Text.Trim();

                //long lngRes = clsTmdProjectSmp.s_object.m_lngUpdate(objNewProject);

                //if (lngRes > 0)
                //{//成功
                //    objNewProject.m_mthCopyTo(objProject);

                //    this.m_lsvProject.FocusedItem.Text = objProject.m_strName;
                //    this.m_lsvProject.FocusedItem.SubItems[1].Text = objProject.m_strPycode;
                //    this.m_lsvProject.FocusedItem.SubItems[2].Text = objProject.m_strWbcode;
                //}
                //else
                //{//失败
                //    clsCommonDialog.m_mthShowDBError();
                //}
            }
            //this.m_ProjectdProjectSave.Enabled = true;
            Cursor.Current = Cursors.Default;
        }
Exemple #3
0
        private bool LoadConstractRules(out string message)
        {
            message = string.Empty;
            if (!System.IO.File.Exists(ItemPath))
            {
                message = "未找到配置文件.";
                return(false);
            }

            System.Xml.XmlDocument xmlConfig = new System.Xml.XmlDocument();
            try
            {
                xmlConfig.Load(ItemPath);
                XmlNodeList nodeList = xmlConfig["Configs"]["ConstractValue"].SelectNodes("N");
                foreach (XmlNode node in nodeList)
                {
                    foreach (XmlNode xn in node.ChildNodes)
                    {
                        if (xn.Name == "Rule" && xn.Attributes["Used"].Value == "1")
                        {
                            clsSTConstractRule constractRule = new clsSTConstractRule();

                            if (xn.Attributes["BigerThan"].Value == "1")
                            {
                                constractRule.BiggerThan = true;
                            }
                            else
                            {
                                constractRule.BiggerThan = false;
                            }


                            float referenceValue = 0;
                            try { referenceValue = float.Parse(xn.Attributes["Reference"].Value); }
                            catch { referenceValue = float.MinValue; }

                            float actualValue = 0;
                            try { actualValue = float.Parse(xn.Attributes["actual"].Value); }
                            catch { actualValue = float.MinValue; }

                            if (referenceValue != float.MinValue && actualValue != float.MinValue)
                            {
                                constractRule.ReferenceValue = referenceValue;
                                constractRule.ActualValue    = actualValue;
                                m_lstNegativeRules.Add(constractRule);
                            }
                        }
                    }
                }


                XmlNodeList nodePositiveList = xmlConfig["Configs"]["ConstractValue"].SelectNodes("P");
                foreach (XmlNode node in nodeList)
                {
                    foreach (XmlNode xn in node.ChildNodes)
                    {
                        if (xn.Name == "Rule" && xn.Attributes["Used"].Value == "1")
                        {
                            clsSTConstractRule constractRule = new clsSTConstractRule();

                            if (xn.Attributes["BigerThan"].Value == "1")
                            {
                                constractRule.BiggerThan = true;
                            }
                            else
                            {
                                constractRule.BiggerThan = false;
                            }


                            float referenceValue = 0;
                            try { referenceValue = float.Parse(xn.Attributes["Reference"].Value); }
                            catch { referenceValue = float.MinValue; }

                            float actualValue = 0;
                            try { actualValue = float.Parse(xn.Attributes["actual"].Value); }
                            catch { actualValue = float.MinValue; }

                            if (referenceValue != float.MinValue && actualValue != float.MinValue)
                            {
                                constractRule.ReferenceValue = referenceValue;
                                constractRule.ActualValue    = actualValue;
                                m_lstPositiveRules.Add(constractRule);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                message = ex.Message;
                return(false);
            }
            return(true);
        }