コード例 #1
0
ファイル: MethodForm.cs プロジェクト: vanloc0301/mychongchong
        /// <summary>
        /// 检查FM_FormulaTemplate中变量是否已经赋值
        /// </summary>
        /// <param name="dicvalue"></param>
        /// <param name="bigclass"></param>
        /// <param name="smallclass"></param>
        /// <returns>true,表示可以继续计算,false表示有些值没有输入,不能继续计算</returns>
        private bool CanEvaluate(Dictionary<string, string> dicvalue, string bigclass, string smallclass)
        {
            Dictionary<string, double> ls = new Dictionary<string, double>();
            Dictionary<string, double> ls1 = new Dictionary<string, double>();
            FormulaEngine fe = new FormulaEngine();
            byte nResult = 0;
            double dValue = 0.0;
            string pErr = "";
            this.fM_FormulaTemplateTableAdapter.FillBy(this.dataSetFMFormulaTemplate.FM_FormulaTemplate, bigclass, smallclass);

            if (this.dataSetFMFormulaTemplate.FM_FormulaTemplate.Count > 0)
            {
                foreach (DataRow dr in this.dataSetFMFormulaTemplate.FM_FormulaTemplate.Rows)
                {
                    FormulaEngine.GetMasterVariables(dr["MethodFormula"].ToString(), ref nResult, ref dValue, ref pErr, ref ls, ref ls1);
                }

                foreach (string tmp in ls1.Keys)
                {
                    if (ls.ContainsKey(tmp))
                    {
                        ls.Remove(tmp);
                    }
                }

                foreach (string tmp in ls.Keys)
                {
                    if (!dicvalue.ContainsKey(tmp))
                    {
                        return false;
                    }
                }
                return true;
            }
            else
            {
                MessageBox.Show(string.Format("CanEvaluate 在FM_FormulaTemplate表中无找到任何记录:{0}-{1}", bigclass, smallclass));
                return false;
            }
        }
コード例 #2
0
ファイル: MethodForm.cs プロジェクト: vanloc0301/mychongchong
        private void simpleButton7_Click(object sender, EventArgs e)
        {
            Dictionary<string, double> ls = new Dictionary<string, double>();
            Dictionary<string, double> ls1 = new Dictionary<string, double>();
            FormulaEngine fe = new FormulaEngine();
            byte nResult = 0;
            double dValue = 0.0;
            string pErr = "";
            //FormulaEngine.ht["a"] = 10;
            //FormulaEngine.ht["b"] = 20;
            //FormulaEngine.ht["d"] = 20;
            this.fM_FormulaTemplateTableAdapter.FillBy(this.dataSetFMFormulaTemplate.FM_FormulaTemplate, "假设开发法", "商品房");

            if (this.dataSetFMFormulaTemplate.FM_FormulaTemplate.Count > 0)
            {
                foreach (DataRow dr in this.dataSetFMFormulaTemplate.FM_FormulaTemplate.Rows)
                {
                    FormulaEngine.GetMasterVariables(dr["MethodFormula"].ToString(), ref nResult, ref dValue, ref pErr, ref ls, ref ls1);
                }

                foreach (string tmp in ls1.Keys)
                {
                    if (ls.ContainsKey(tmp))
                    {
                        ls.Remove(tmp);
                    }
                }
                string masterstr;
                StringBuilder sb = new StringBuilder();
                foreach (string tmp in ls.Keys)
                {
                    sb.AppendFormat("{0}#", tmp);
                }
                masterstr = sb.ToString();

            }
        }