예제 #1
0
 private double Evaluated(FColumn fcx, int columnstt, DataTable dt)
 {
     System.Collections.Hashtable h  = new System.Collections.Hashtable();
     Formula.BieuThuc             bt = new Formula.BieuThuc(fcx.FormulaColumn);
     foreach (string str in bt.variables)
     {
         bool kt = true;
         for (int j = 0; j < listFColumn.Count; j++)
         {
             FColumn fc = listFColumn[j];
             if (dt.Rows[fc.Rowstt]["MaSo"].ToString() == str && fc.IsEvaluated == false)
             {
                 dt.Rows[fc.Rowstt][columnstt] = Evaluated(fc, columnstt, dt);
                 kt             = false;
                 fc.IsEvaluated = true;
                 h.Add(str, dt.Rows[fc.Rowstt][columnstt]);
                 break;
             }
         }
         if (kt == true)
         {
             for (int i = 0; i < dt.Rows.Count; i++)
             {
                 string MaSo = dt.Rows[i]["MaSo"].ToString();
                 if (str == MaSo)
                 {
                     h.Add(str, dt.Rows[i][columnstt]);
                     break;
                 }
             }
         }
     }
     return(bt.Evaluate(h));
 }
예제 #2
0
        private void FormReport()
        {
            string query = _drTable["Query"].ToString().ToUpper();

            query = trimSpace(query);
            query = query.Replace("+ @@PS", "+ '" + _psString.Replace("'", "''") + "' ");
            query = query.Replace("+@@PS", "+ '" + _psString.Replace("'", "''") + "' ");
            query = query.Replace("'@@PS'", " '" + _psString.Replace("'", "''") + "' ");
            query = query.Replace("@@PS", _psString);
            query = UpdateSpecialCondition(query);
            query = query.Replace("@@SYSREPORTID", _drTable["sysReportID"].ToString());
            if (_dtData == null)
            {
                _dtData = DbData.GetDataTable(query);
            }
            if (_dtData == null)
            {
                return;
            }

            int n = _dtData.Columns.Count;


            for (int i = 0; i < _dtData.Rows.Count; i++)
            {
                if (_dtData.Rows[i]["CachTinh"].ToString() != string.Empty && _dtData.Rows[i]["CachTinh"].ToString() != "0")
                {
                    FColumn x = new FColumn(i, _dtData.Rows[i]["CachTinh"].ToString(), false);
                    listFColumn.Add(x);
                }
                else
                {
                    continue;
                }
            }
            for (int i = _dtData.Columns.Count - 1; i >= 0; i--)
            {
                if (_dtData.Columns[i].DataType == typeof(System.Decimal))
                {
                    foreach (FColumn fc in listFColumn)
                    {
                        if (fc.IsEvaluated == false)
                        {
                            _dtData.Rows[fc.Rowstt][i] = Evaluated(fc, i, _dtData);
                        }
                    }
                }
                else
                {
                    break;
                }
            }
        }