示例#1
0
        /// <summary>
        /// 数据绑定
        /// </summary>
        private void BindGrid()
        {
            string sqlEnd = sql;

            //加载查询条件
            string textSubject = ""; //ddlSubject.Text;
            string textExam    = ""; //ddlExam.Text;

            if (!string.IsNullOrEmpty(textSubject))
            {
                sqlEnd = sql + " and es.SubjectName like '" + textSubject + "'";
            }
            if (!string.IsNullOrEmpty(textExam))
            {
                sqlEnd = sql + " and epi.ExamName like '" + textExam + "'";
            }

            //数据量  条数
            //int count = ZAJCZN.MIS.Helpers.DbHelperSQL.Query("select pe.id " + sqlEnd).Tables[0].Rows.Count;

            //排序判断
            //if (Grid1.SortDirection == "ASC")
            //{
            //    sqlEnd += " order by " + Grid1.SortField + " ASC";
            //}
            //else
            //{
            //    sqlEnd += " order by " + Grid1.SortField + " desc";
            //}

            sqlEnd = sqlEnd + "group by SubjectName";

            //数据加载及绑定
            System.Data.DataSet   ds   = ZAJCZN.MIS.Helpers.DbHelperSQL.Query(sqlEnd);
            System.Data.DataTable data = ds.Tables[0];

            System.Data.DataRow dr = data.NewRow();
            dr["SubjectName"] = "合计";
            dr["TotalCount"]  = data.Compute("SUM(TotalCount)", "true");
            dr["PassCount"]   = data.Compute("SUM(PassCount)", "true");
            dr["PassRate"]    = data.Compute("SUM(PassRate)", "true");
            data.Rows.Add(dr);

            Grid1.RecordCount = 0;
            //int pageIndexMax = (Grid1.PageIndex + 1) * Grid1.PageSize;
            //int pageIndexmin = pageIndexMax - Grid1.PageSize;
            Grid1.DataSource = data;//data.Select("" + pageIndexmin + " < RowNum and RowNum <=" + pageIndexMax + "");
            Grid1.DataBind();
        }
    static void Main(string[] args)
    {
        var calc = new System.Data.DataTable();

        Console.WriteLine(calc.Compute("(123/2*15+22)", ""));
        Console.ReadLine();
    }
示例#3
0
        public string Calculate2(string param)
        {
            try
            {
                if (param.Trim() == string.Empty)
                {
                    return("0");
                }

                if (param.Contains("^"))
                {
                    var list = param.Split('^');
                    if (list.Count() == 2)
                    {
                        var num1 = this.Calculate2(list[0]);
                        var num2 = this.Calculate2(list[1]);

                        var result = Math.Pow(Convert.ToDouble(num1), Convert.ToDouble(num2));
                        return(result.ToString());
                    }
                }

                History.Add(param);
                System.Data.DataTable myDT = new System.Data.DataTable();
                return(myDT.Compute(param, null).ToString());
            }
            catch (Exception)
            {
                throw new ArgumentException();
            }
        }
示例#4
0
 public double igual()
 {
     // DataTable es una estructura de datos que nos permite guardar informacion tabulada
     System.Data.DataTable table = new System.Data.DataTable();
     // Este es el quivalente al metodo .Eval() en python
     ultimaRespuesta = Convert.ToDouble(table.Compute(this.expresion.ToString(), String.Empty));
     // Y sirve como que si fueran operaciones en Excel
     return(ultimaRespuesta);
 }
 private void keyboarPresshandler(object sender, System.Windows.Forms.KeyEventArgs e)
 {
     if (e.KeyCode == System.Windows.Forms.Keys.Enter)
     {
         System.Data.DataTable dataTable = new System.Data.DataTable();
         var result = dataTable.Compute(textBox.Text, "");
         textBox.Text = result.ToString();
     }
 }
        void EvaluateExpression()
        {
            string valueToEvaluate = inputDisplay.Replace('X', '*');

            System.Data.DataTable dataTable = new System.Data.DataTable();
            var finalResult = dataTable.Compute(valueToEvaluate, "");

            inputDisplay = finalResult.ToString();
            isResult     = true;
        }
        private void buttonwa_Click(object sender, EventArgs e)
        {
            TextView textview1 = FindViewById <TextView>(Resource.Id.textView1);

            System.Data.DataTable dt = new System.Data.DataTable();
            double result            = double.Parse(dt.Compute(textview1.Text, "").ToString());

            textview1.Text = result.ToString();
            sdisply        = result.ToString();
        }
示例#8
0
        public static List <DTO.EwavFrequencyControlDto> FrequencyOutputList(System.Data.DataTable dt, EwavGadgetParameters ewavGadgetParameters)
        {
            List <EwavFrequencyControlDto> fdsList = new List <EwavFrequencyControlDto>();

            for (int x = 0; x < dt.Rows.Count; x++)
            {
                for (int i = 1; i < dt.Columns.Count; i++)
                {
                    Dictionary <string, double> dic = GetConfLimit((double)dt.Rows[x][i],
                                                                   (double)dt.Compute(string.Format("SUM([{0}])", dt.Columns[i].ColumnName), ""));

                    EwavFrequencyControlDto frequencyItem = new EwavFrequencyControlDto
                    {
                        FrequencyColumn     = dt.Rows[x][i].ToString(),
                        FreqVariable        = dt.Rows[x][ewavGadgetParameters.MainVariableName].ToString(),
                        Perc95ClLowerColumn = dic["lower"].ToString(),  //dtDataSources.Rows[x]["freq"].ToString(),  // dtDataSources.Rows[x][ewavGadgetParameters.MainVariableName].ToString(),
                        Perc95ClUpperColumn = dic["upper"].ToString(),  //dtDataSources.Rows[x]["freq"].ToString(), //dtDataSources.Rows[x][ewavGadgetParameters.MainVariableName].ToString(),
                        PercentColumn       = dt.Rows[x][i].ToString(), //dtDataSources.Rows[x][ewavGadgetParameters.MainVariableName].ToString(),
                        NameOfDtoList       = dt.TableName.ToString()
                    };
                    if (frequencyItem.NameOfDtoList.Trim().IndexOf("=") > 0)
                    {
                        switch (frequencyItem.NameOfDtoList.ToString().Substring(frequencyItem.NameOfDtoList.Trim().IndexOf("=") + 1))
                        {
                        case " 0":
                            frequencyItem.NameOfDtoList = frequencyItem.NameOfDtoList.Replace(frequencyItem.NameOfDtoList.ToString().Substring(frequencyItem.NameOfDtoList.Trim().IndexOf("=") + 1), " No");
                            break;

                        case " false":
                            frequencyItem.NameOfDtoList = frequencyItem.NameOfDtoList.Replace(frequencyItem.NameOfDtoList.ToString().Substring(frequencyItem.NameOfDtoList.Trim().IndexOf("=") + 1), " No");
                            break;

                        case " 1":
                            frequencyItem.NameOfDtoList = frequencyItem.NameOfDtoList.Replace(frequencyItem.NameOfDtoList.ToString().Substring(frequencyItem.NameOfDtoList.Trim().IndexOf("=") + 1), " Yes");
                            break;

                        case " true":
                            frequencyItem.NameOfDtoList = frequencyItem.NameOfDtoList.Replace(frequencyItem.NameOfDtoList.ToString().Substring(frequencyItem.NameOfDtoList.Trim().IndexOf("=") + 1), " Yes");
                            break;

                        case " ":
                            frequencyItem.NameOfDtoList = string.Format("{0}Missing", frequencyItem.NameOfDtoList);
                            break;

                        default:
                            break;
                        }
                    }

                    fdsList.Add(frequencyItem);
                }
            }

            return(fdsList);
        }
示例#9
0
 /// <summary>
 /// 计算表达式的值
 /// </summary>
 /// <param name="EvalExpression">表达式字符串</param>
 /// <returns>返回表达式的布尔类型结果, 任何异常情况都会返回null</returns>
 internal static object Calculate(string EvalExpression)
 {
     try
     {
         return(dtCalculate.Compute(EvalExpression, null));
     }
     catch (Exception)
     {
         return(null);
     }
 }
示例#10
0
 public static double Eval(String expression)
 {
     try
     {
         return(Convert.ToDouble(table.Compute(expression, String.Empty)));
     }
     catch (Exception ex)
     {
         dout(ex.ToString());
         dout("G::Eval failed: '{0}'", expression);
     }
     return(double.NaN);
 }
示例#11
0
        public RptBudget(System.Data.DataTable tbl, int sucursal)
        {
            Thread.CurrentThread.CurrentCulture = new CultureInfo("es-MX");
            InitializeComponent();
            objectDataSource1.DataSource = tbl;
            string folio = tbl.Rows[0][0].ToString();

            textBox5.Value  = folio;
            textBox15.Value = tbl.Rows[0][3].ToString();
            DateTime fecha = new DateTime();

            fecha           = Convert.ToDateTime(tbl.Rows[0][2]);
            txtfecha.Value  = fecha.Day.ToString() + " " + fecha.ToString("MMM").ToUpper() + " ," + fecha.Year.ToString();
            textBox32.Value = tbl.Rows[0][5].ToString();
            textBox13.Value = tbl.Rows[0][4].ToString();
            textBox3.Value  = tbl.Rows[0][6].ToString();
            textBox14.Value = tbl.Rows[0][13].ToString();
            textBox20.Value = tbl.Rows[0][14].ToString();

            object sumObject;

            sumObject = tbl.Compute("Sum(Ptotal)", string.Empty);
            decimal suma = Convert.ToDecimal(sumObject);

            textBox28.Value = "$" + suma.ToString("#,###.00", CultureInfo.InvariantCulture);
            if (sucursal == 11 || sucursal == 12 || sucursal == 13 || sucursal == 15 || sucursal == 17 || sucursal == 18)
            {
                textBox30.Value = "27058 - TORREÓN, COAH.";
            }
            else
            {
                textBox30.Value = "34207 - DURANGO, DGO.";
            }


            textBox18.Value = strTelefonoCorreo(sucursal);
            decimal iva   = suma * Convert.ToDecimal(0.16);
            decimal total = suma + iva;

            textBox27.Value = "$" + iva.ToString("#,###.00", CultureInfo.InvariantCulture);
            textBox16.Value = "$" + total.ToString("#,###.00", CultureInfo.InvariantCulture);
            generarImportes(total);
            //textBox18.Value = tbl.Rows[0][13].ToString();
            // textBox19.Value = tbl.Rows[0][14].ToString();
            textBox12.Value = "$" + total.ToString("#,###.00", CultureInfo.InvariantCulture);
            textBox16.Value = "$" + total.ToString("#,###.00", CultureInfo.InvariantCulture);

            string camino = @"C:\Ektelesis.Net\CFDI\DATOS\PDF\COT_" + folio + "_LRG920502BG7.pdf";

            SaveReport(this.Report, camino);
        }
示例#12
0
 public static bool TryCalculate(this string me, out string result)
 {
     try
     {
         var dt = new System.Data.DataTable();
         result = dt.Compute(me, "").ToString();
         return(true);
     }
     catch
     {
         result = string.Empty;
         return(false);
     }
 }
        public static object Evaluate(string expression)
        {
            if (string.IsNullOrWhiteSpace(expression))
            {
                return(null);
            }

            expression = ReplaceOperators(expression);

            // https://stackoverflow.com/a/25313985/4856020
            var table = new System.Data.DataTable();

            return(table.Compute(expression, string.Empty));
        }
        public void buttonHandler(object sender, System.EventArgs e)
        {
            var button = sender as System.Windows.Forms.Button;

            if (button.Text == "=")
            {
                System.Data.DataTable dataTable = new System.Data.DataTable();
                var result = dataTable.Compute(textBox.Text, "");
                textBox.Text = result.ToString();
            }
            else
            {
                textBox.Text += button.Text;
            }
        }
示例#15
0
        private string ExecutaExpressao(string expressao)
        {
            try
            {
                var expressaoFormatada = expressao.ToLower().Replace("  ", " ");

                var table = new System.Data.DataTable();

                return(table.Compute(expressaoFormatada, string.Empty).ToString());
            }
            catch (Exception exception)
            {
                Log.Application.Error("Erro ao processar regra [" + this.regraId + "]. Expressao: " + expressao, exception);
                throw;
            }
        }
 private void RLVeränderung_TextChanged(object sender, EventArgs e)
 {
     try
     {
         string textBoxText = RLVeränderung.Text;
         int    lastChar    = Convert.ToInt32(textBoxText[textBoxText.Length - 1]);
         if (48 <= lastChar && lastChar <= 57)
         {
             System.Data.DataTable table = new System.Data.DataTable();
             decimal result = (decimal)table.Compute(textBoxText, "");
             Länge2RelativUpDown.Increment = result;
             RLVeränderung.Text            = Convert.ToString(result);
         }
     }
     catch { }
 }
示例#17
0
 public string Calculate(string param)
 {
     try
     {
         if (param.Trim() == string.Empty)
         {
             return("0");
         }
         History.Add(param);
         System.Data.DataTable myDT = new System.Data.DataTable();
         return(myDT.Compute(param, null).ToString());
     }
     catch (Exception)
     {
         throw new ArgumentException();
     }
 }
 protected void GetResult(object sender, DirectEventArgs e)
 {
     if ((First.Text == "0") || (Second.Text == "0") || (Third.Text == "0"))
     {
         X.Msg.Alert("Uwaga!", "Podaj inna wartość niż 0").Show();
     }
     else if (First.Text.IsEmpty() || Second.Text.IsEmpty() || Third.Text.IsEmpty() || Operator1.Text.IsEmpty() || Operator2.Text.IsEmpty())
     {
         X.Msg.Alert("Uwaga!", "Wypełnij wszystkie pola").Show();
     }
     else
     {
         var dt = new System.Data.DataTable();
         wynik.Text = (dt.Compute(First.Text + Operator1.Text + Second.Text + Operator2.Text + Third.Text, "")).ToString();
         Store2.Add(new {First = First.Text, Operator1 = Operator1.Text, Second = Second.Text,Operator2 = Operator2.Text,
                             Third = Third.Text, data = DateTime.Now.ToString("yyyy-MM-dd h:mm"), wynik = wynik.Text });
     }
 }
示例#19
0
        protected override void RefreshView()
        {
            //Number
            string expression = runs[2].Text;
            int    number     = 0;

            try
            {
                System.Data.DataTable eval = new System.Data.DataTable();
                number = (int)eval.Compute(expression, "");
            }
            catch
            {
                number = oneNumberOperationModel.Number;
            }

            oneNumberOperationModel.Number = number;


            UpdateData();
        }
 /// <summary>
 /// If a URL or Parameters need to perform a calculation, extract the values and operators to replace the content with the result
 /// </summary>
 /// <param name="initialString">URL or Parameters containing the calculation(s) to perform</param>
 /// <returns>initialString with all calculations replaced by results</returns>
 private string Calculate(string initialString)
 {
     System.Data.DataTable dt = new System.Data.DataTable();
     while (initialString.IndexOf("Calculate{") > -1 && initialString.IndexOf("}") > initialString.IndexOf("Calculate{"))
     {
         double result            = 0;
         var    rawCalculation    = initialString.Substring(initialString.IndexOf("Calculate{"), 1 + initialString.IndexOf("}") - initialString.IndexOf("Calculate{"));
         var    actualCalculation = rawCalculation.Substring(rawCalculation.IndexOf("{") + 1, rawCalculation.IndexOf("}") - rawCalculation.IndexOf("{") - 1);
         try
         {
             result = double.Parse(dt.Compute(actualCalculation, "").ToString());
         }
         catch (Exception ex)
         {
             // Cannot perform calculation
             WriteLog(string.Format("Unable to perform calculation on: {0}", actualCalculation), ex);
         }
         initialString = initialString.Replace(rawCalculation, result.ToString());
     }
     return(initialString);
 }
示例#21
0
        public bool SaveRighting(System.Data.DataTable dt, string RoleId)
        {
            System.Data.DataRow[] array = dt.Select("TypeId=1");
            System.Data.DataTable dts   = new System.Data.DataTable();
            dts.Columns.AddRange(
                new System.Data.DataColumn[] {
                new System.Data.DataColumn("RoleId"),
                new System.Data.DataColumn("FuncId"),
                new System.Data.DataColumn("OpCode")
            });
            foreach (System.Data.DataRow r in array)
            {
                object OpCode = 0;
                if (int.Parse(r["FuncHandle"].ToString()) > 0)
                {
                    OpCode = dt.Compute("sum(FuncHandle)", "ParentId='" + r["Id"] + "'");
                    OpCode = OpCode.ToString() == "" ? 0 : OpCode;
                }
                dts.Rows.Add(RoleId, r["Id"], OpCode);
            }

            return(Sev.SaveRighting(dts, RoleId));
        }
示例#22
0
        public void DataBind(System.Data.DataTable dt)
        {
            if (UseSum)
            {
                System.Data.DataRow dr = dt.NewRow();
                bool sumStr            = false;
                foreach (ColumnInfo info in this.ArrayColumn)
                {
                    switch (info.ColumnType)
                    {
                    case "Double":
                    case "Int32":
                    case "Decimal":
                        if (info.IsSum)
                        {
                            dr[info.ColumnName] = dt.Compute(string.Format("Sum({0})", info.ColumnName), "true");
                        }
                        break;

                    case "String":
                        if (!sumStr)
                        {
                            dr[info.ColumnName] = "合计";
                            sumStr = true;
                        }
                        break;

                    default:
                        break;
                    }
                }
                dt.Rows.Add(dr);
            }

            this.DataSource = dt;
        }
示例#23
0
        static Double eval(String expression)
        {
            var table = new System.Data.DataTable();

            return(Convert.ToDouble(table.Compute(expression, String.Empty)));
        }
示例#24
0
        private void IvChange_Click(object sender, RoutedEventArgs e)
        {
            SetAttributeOperationModel setAttributeOperationModel = new SetAttributeOperationModel();

            for (int i = 0; i < _UI.Count - 1; i++)
            {
                DockPanel dp   = _UI[i] as DockPanel;
                int       type = (dp.Children[0] as ComboBox).SelectedIndex;
                TextBox   tb   = dp.Children[1] as TextBox;
                if (type == 0)
                {
                    //时间
                    if (!tb.Text.Trim().Equals(String.Empty))
                    {
                        try
                        {
                            String result;
                            if (tb.Text.Trim()[0] == '+' || tb.Text.Trim()[0] == '-')
                            {
                                //计算数学表达式
                                string expression          = tb.Text.Substring(1);
                                System.Data.DataTable eval = new System.Data.DataTable();
                                result = eval.Compute(expression, "").ToString();
                                result = tb.Text.Trim()[0] + result;
                            }
                            else
                            {
                                //计算数学表达式
                                string expression          = tb.Text;
                                System.Data.DataTable eval = new System.Data.DataTable();
                                result = eval.Compute(expression, "").ToString();
                            }
                            setAttributeOperationModel.AttributeOperationModels.Add(new SetAttributeOperationModel.AttributeOperationModel(SetAttributeOperationModel.AttributeOperationModel.AttributeType.TIME, result));
                        }
                        catch
                        {
                            tb.Select(0, tb.Text.Length);
                            tb.Focus();
                            return;
                        }
                    }
                }
                else if (type == 1)
                {
                    //位置
                    if (!tb.Text.Trim().Equals(String.Empty))
                    {
                        String strNumber = tb.Text.Trim();
                        if (strNumber[0] == '+' || strNumber[0] == '-')
                        {
                            if (!System.Text.RegularExpressions.Regex.IsMatch(strNumber.Substring(1), "^\\d+$"))
                            {
                                tb.Select(0, tb.Text.Length);
                                tb.Focus();
                                return;
                            }
                        }
                        else
                        {
                            if (!System.Text.RegularExpressions.Regex.IsMatch(strNumber, "^\\d+$"))
                            {
                                tb.Select(0, tb.Text.Length);
                                tb.Focus();
                                return;
                            }
                        }
                        setAttributeOperationModel.AttributeOperationModels.Add(new SetAttributeOperationModel.AttributeOperationModel(SetAttributeOperationModel.AttributeOperationModel.AttributeType.POSITION, tb.Text.Trim()));
                    }
                }
                else if (type == 2)
                {
                    //颜色
                    if (!tb.Text.Trim().Equals(String.Empty))
                    {
                        String strNumber = tb.Text.Trim();
                        if (strNumber[0] == '+' || strNumber[0] == '-')
                        {
                            if (!System.Text.RegularExpressions.Regex.IsMatch(strNumber.Substring(1), "^\\d+$"))
                            {
                                tb.Select(0, tb.Text.Length);
                                tb.Focus();
                                return;
                            }
                        }
                        else
                        {
                            if (!System.Text.RegularExpressions.Regex.IsMatch(strNumber, "^\\d+$"))
                            {
                                tb.Select(0, tb.Text.Length);
                                tb.Focus();
                                return;
                            }
                        }
                        setAttributeOperationModel.AttributeOperationModels.Add(new SetAttributeOperationModel.AttributeOperationModel(SetAttributeOperationModel.AttributeOperationModel.AttributeType.COLOR, tb.Text.Trim()));
                    }
                }
            }
            this.setAttributeOperationModel.AttributeOperationModels.Clear();
            this.setAttributeOperationModel.AttributeOperationModels.AddRange(setAttributeOperationModel.AttributeOperationModels.ToArray());
            sw.OnRefresh();
        }
示例#25
0
 private static string Eval(string newFunc)
 {
     System.Data.DataTable table = new System.Data.DataTable();
     return(Convert.ToDouble(table.Compute(newFunc, String.Empty)).ToString());
 }
        public static float[,] Formula(string formula)
        {
            string[] formulaPreview = formula.Split('|');
            int _i = Convert.ToInt32(formulaPreview[0]);
            int _j = Convert.ToInt32(formulaPreview[1]);
            var formulaCalculator = new System.Data.DataTable();
            float[,] _matrix = new float[_i, _j];

            for (int i = 0; i < _i; i++) {
                for (int j = 0; j < _j; j++) {
                    string i_formula = formulaPreview[2].Replace("i", (i + 1).ToString());
                    string x_formula = formulaPreview[3].Replace("j", (j + 1).ToString());
                    Console.WriteLine(i_formula);
                    _matrix[i, j] = Convert.ToSingle(formulaCalculator.Compute("(" + i_formula + " + " + x_formula + ")", ""));
                }
            }
            return _matrix;
        }
示例#27
0
 public static double Evaluate(string expression)
 {
     System.Data.DataTable table = new System.Data.DataTable();
     return(Math.Round(Convert.ToDouble(table.Compute(expression, String.Empty)), 6));
 }
 static public UInt64 EvalUInt64(String expression)
 {
     System.Data.DataTable table = new System.Data.DataTable();
     return(Convert.ToUInt64(table.Compute(expression, string.Empty)));
 }
示例#29
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            //try
            //{
            if (Convert.ToInt32(Fee.Text.Trim()) > 0)
            {
                WX.Model.Sell.MODEL sell;
                sell              = WX.Model.Sell.NewDataModel();
                sell.Fee.value    = Fee.Text;
                sell.TypeID.value = DropDownList1.SelectedValue;
                string valuestr1;
                valuestr1 = "<td>" + DropDownList1.SelectedItem.Text + "</td><td>" + sell.Fee.ToString() + "</td>";
                System.Data.DataTable dt      = ULCode.QDA.XSql.GetDataTable("SELECT * FROM [Count_TypeColum] where TypeID=" + sell.TypeID.ToString() + " order by OrderNo asc");
                System.Data.DataTable dataone = new System.Data.DataTable();
                object[] objs = new Object[dt.Rows.Count];
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    dataone.Columns.Add(dt.Rows[i]["Mark"].ToString());
                    objs[i] = "";
                }
                dataone.Rows.Add(objs);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    try
                    {
                        dataone.Rows[0][dt.Rows[i]["Mark"].ToString()] = Convert.ToDouble(dataone.Compute(WX.Model.TypeColum.GetFormula(this, dt.Rows[i]["Formula"].ToString(), dataone), "")).ToString("0.00");
                    }
                    catch { Response.Write(dt.Rows[i]["Formula"].ToString() + "----"); }
                    if (dt.Rows[i]["Visible1"].ToString() == "1")
                    {
                        valuestr1 += "<td>" + dataone.Rows[0][dt.Rows[i]["Mark"].ToString()] + "</td>";
                    }
                }
                Literal1.Text = ULCode.QDA.XSql.GetDataTable("Select ColumStr1 from Count_Type where ID=" + DropDownList1.SelectedValue).Rows[0][0].ToString().Replace("<td>", "<td><div style='width:100px;'>").Replace("</td>", "</div></td>");
                Literal2.Text = valuestr1;

                WX.Main.AddLog(WX.LogType.Default, "计算业务提成!", String.Format("{0}", DropDownList1.SelectedItem.Text + ":" + Fee.Text));
            }
            //}
            //catch { }
        }
示例#30
0
        private void IvChange_Click(object sender, RoutedEventArgs e)
        {
            ConditionJudgmentOperationModel conditionJudgmentOperationModel = new ConditionJudgmentOperationModel();

            if (cbOperator.SelectedIndex == 0)
            {
                conditionJudgmentOperationModel.MyOperator = ConditionJudgmentOperationModel.Operation.REPLACE;
            }
            else
            {
                conditionJudgmentOperationModel.MyOperator = ConditionJudgmentOperationModel.Operation.REMOVE;
            }

            char splitNotation = StaticConstant.mw.projectUserControl.suc.StrInputFormatDelimiter;
            char rangeNotation = StaticConstant.mw.projectUserControl.suc.StrInputFormatRange;

            if (!tbIfTime.Text.Equals(String.Empty))
            {
                try
                {
                    object result              = null;
                    string expression          = tbIfTime.Text;
                    System.Data.DataTable eval = new System.Data.DataTable();
                    result = eval.Compute(expression, "");
                    conditionJudgmentOperationModel.IfTime = (int)result;
                }
                catch
                {
                    tbIfTime.Select(0, tbIfTime.Text.Length);
                    tbIfTime.Focus();
                    return;
                }
            }

            if (!tbIfPosition.Text.Equals(String.Empty))
            {
                StringBuilder fastGenerationrPositionBuilder = new StringBuilder();
                if (suc.rangeDictionary.ContainsKey(tbIfPosition.Text))
                {
                    for (int i = 0; i < suc.rangeDictionary[tbIfPosition.Text].Count; i++)
                    {
                        if (i != suc.rangeDictionary[tbIfPosition.Text].Count - 1)
                        {
                            fastGenerationrPositionBuilder.Append(suc.rangeDictionary[tbIfPosition.Text][i] + splitNotation.ToString());
                        }
                        else
                        {
                            fastGenerationrPositionBuilder.Append(suc.rangeDictionary[tbIfPosition.Text][i]);
                        }
                    }
                }
                else
                {
                    List <int> positions = GetTrueContent(tbIfPosition.Text, splitNotation, rangeNotation);
                    if (positions != null)
                    {
                        fastGenerationrPositionBuilder.Append(tbIfPosition.Text);
                        conditionJudgmentOperationModel.IfPosition = positions;
                    }
                    else
                    {
                        tbIfPosition.Select(0, tbIfPosition.Text.Length);
                        tbIfPosition.Focus();
                        return;
                    }
                }
            }

            if (!tbIfColor.Text.Equals(String.Empty))
            {
                StringBuilder fastGenerationrColorBuilder = new StringBuilder();
                if (suc.rangeDictionary.ContainsKey(tbIfColor.Text))
                {
                    for (int i = 0; i < suc.rangeDictionary[tbIfColor.Text].Count; i++)
                    {
                        if (i != suc.rangeDictionary[tbIfColor.Text].Count - 1)
                        {
                            fastGenerationrColorBuilder.Append(suc.rangeDictionary[tbIfColor.Text][i] + splitNotation.ToString());
                        }
                        else
                        {
                            fastGenerationrColorBuilder.Append(suc.rangeDictionary[tbIfColor.Text][i]);
                        }
                    }
                }
                else
                {
                    List <int> colors = GetTrueContent(tbIfColor.Text, splitNotation, rangeNotation);
                    if (colors != null)
                    {
                        fastGenerationrColorBuilder.Append(tbIfColor.Text);
                        conditionJudgmentOperationModel.IfColor = colors;
                    }
                    else
                    {
                        tbIfColor.Select(0, tbIfColor.Text.Length);
                        tbIfColor.Focus();
                        return;
                    }
                }
            }

            String result2;

            if (!tbThenTime.Text.Equals(String.Empty))
            {
                if (tbThenTime.Text.Trim()[0] == '+' || tbThenTime.Text.Trim()[0] == '-')
                {
                    //计算数学表达式
                    string expression          = tbThenTime.Text.Substring(1);
                    System.Data.DataTable eval = new System.Data.DataTable();
                    result2 = eval.Compute(expression, "").ToString();
                    result2 = tbThenTime.Text.Trim()[0] + result2;
                    conditionJudgmentOperationModel.ThenTime = result2;
                }
                else
                {
                    //计算数学表达式
                    string expression          = tbThenTime.Text;
                    System.Data.DataTable eval = new System.Data.DataTable();
                    result2 = eval.Compute(expression, "").ToString();
                    conditionJudgmentOperationModel.ThenTime = result2;
                }
            }

            if (!tbThenPosition.Text.Equals(String.Empty))
            {
                String strNumber = tbThenPosition.Text.Trim();
                if (strNumber[0] == '+' || strNumber[0] == '-')
                {
                    if (!System.Text.RegularExpressions.Regex.IsMatch(strNumber.Substring(1), "^\\d+$"))
                    {
                        tbThenPosition.Select(0, tbThenPosition.Text.Length);
                        tbThenPosition.Focus();
                        return;
                    }
                }
                else
                {
                    if (!System.Text.RegularExpressions.Regex.IsMatch(strNumber, "^\\d+$"))
                    {
                        tbThenPosition.Select(0, tbThenPosition.Text.Length);
                        tbThenPosition.Focus();
                        return;
                    }
                }
            }
            conditionJudgmentOperationModel.ThenPosition = tbThenPosition.Text;

            if (!tbThenColor.Text.Equals(String.Empty))
            {
                String strNumber = tbThenColor.Text.Trim();
                if (strNumber[0] == '+' || strNumber[0] == '-')
                {
                    if (!System.Text.RegularExpressions.Regex.IsMatch(strNumber.Substring(1), "^\\d+$"))
                    {
                        tbThenColor.Select(0, tbThenColor.Text.Length);
                        tbThenColor.Focus();
                        return;
                    }
                }
                else
                {
                    if (!System.Text.RegularExpressions.Regex.IsMatch(strNumber, "^\\d+$"))
                    {
                        tbThenColor.Select(0, tbThenColor.Text.Length);
                        tbThenColor.Focus();
                        return;
                    }
                }
            }
            conditionJudgmentOperationModel.ThenColor = tbThenColor.Text;
            //this.conditionJudgmentOperationModel = conditionJudgmentOperationModel;
            this.conditionJudgmentOperationModel.MyOperator   = conditionJudgmentOperationModel.MyOperator;
            this.conditionJudgmentOperationModel.IfTime       = conditionJudgmentOperationModel.IfTime;
            this.conditionJudgmentOperationModel.IfAction     = conditionJudgmentOperationModel.IfAction;
            this.conditionJudgmentOperationModel.IfPosition   = conditionJudgmentOperationModel.IfPosition;
            this.conditionJudgmentOperationModel.IfColor      = conditionJudgmentOperationModel.IfColor;
            this.conditionJudgmentOperationModel.ThenTime     = conditionJudgmentOperationModel.ThenTime;
            this.conditionJudgmentOperationModel.ThenPosition = conditionJudgmentOperationModel.ThenPosition;
            this.conditionJudgmentOperationModel.ThenColor    = conditionJudgmentOperationModel.ThenColor;

            suc.Test();
        }
示例#31
0
        /// <summary>
        /// Constrói dados do grupo.
        /// Percorre tabela de dados do relatório, filtrando e distinguindo os dados pela coluna do grupo.
        /// Também calcula os valores de cada grupo, totalizando-os.
        /// </summary>
        /// <param name="p_table">Tabela de dados do relatório.</param>
        /// <param name="p_parentgroupcolumn">Coluna do grupo pai.</param>
        public void BuildCalculate(System.Data.DataTable p_table, string p_parentgroupcolumn)
        {
            System.Collections.Generic.List <string> v_allcolumns_temp;
            string[] v_allcolumns;
            int      i, j, k;

            // PASSO 1: PEGANDO COLUNAS E DADOS DO GRUPO

            // alocando lista de colunas
            v_allcolumns_temp = new System.Collections.Generic.List <string>();

            // adicionando coluna do grupo pai
            if (p_parentgroupcolumn != null && p_parentgroupcolumn != "")
            {
                v_allcolumns_temp.Add(p_parentgroupcolumn);
            }

            // adicionando coluna do grupo
            v_allcolumns_temp.Add(this.v_column);

            // adicionando todas as colunas do cabeçalho do grupo (exceto as colunas de valor)
            for (k = 0; k < this.v_headerfields.Count; k++)
            {
                if (this.v_headerfields[k].v_column != "" &&
                    !this.v_headerfields[k].v_groupedvalue &&
                    !v_allcolumns_temp.Contains(this.v_headerfields[k].v_column))
                {
                    v_allcolumns_temp.Add(this.v_headerfields[k].v_column);
                }
            }

            // adicionando todas as colunas do rodapé do grupo (exceto as colunas de valor)
            for (k = 0; k < this.v_footerfields.Count; k++)
            {
                if (this.v_footerfields[k].v_column != "" &&
                    !this.v_footerfields[k].v_groupedvalue &&
                    !v_allcolumns_temp.Contains(this.v_footerfields[k].v_column))
                {
                    v_allcolumns_temp.Add(this.v_footerfields[k].v_column);
                }
            }

            // alocando vetor de string
            v_allcolumns = new string[v_allcolumns_temp.Count];

            // copiando nomes de colunas para o vetor de string
            for (k = 0; k < v_allcolumns_temp.Count; k++)
            {
                v_allcolumns[k] = v_allcolumns_temp[k];
            }

            // filtrando dados distintos pela lista de colunas, e armazenando em tabela
            if (p_parentgroupcolumn != null && p_parentgroupcolumn != "")
            {
                p_table.DefaultView.Sort = p_parentgroupcolumn + ", " + this.v_column;
            }
            else
            {
                p_table.DefaultView.Sort = this.v_column;
            }
            this.v_table = p_table.DefaultView.ToTable(true, v_allcolumns);

            // PASSO 2: PREENCHENDO VALORES

            // limpando array temporario
            v_allcolumns_temp.Clear();

            // adicionando todas as colunas do cabeçalho do grupo (somente as colunas de valor)
            for (k = 0; k < this.v_headerfields.Count; k++)
            {
                if (this.v_headerfields[k].v_column != "" &&
                    this.v_headerfields[k].v_groupedvalue &&
                    !v_allcolumns_temp.Contains(this.v_headerfields[k].v_column))
                {
                    v_allcolumns_temp.Add(this.v_headerfields[k].v_column);
                }
            }

            // adicionando todas as colunas do rodapé do grupo (somente as colunas de valor)
            for (k = 0; k < this.v_footerfields.Count; k++)
            {
                if (this.v_footerfields[k].v_column != "" &&
                    this.v_footerfields[k].v_groupedvalue &&
                    !v_allcolumns_temp.Contains(this.v_footerfields[k].v_column))
                {
                    v_allcolumns_temp.Add(this.v_footerfields[k].v_column);
                }
            }

            // criando colunas de valor na tabela do grupo
            for (k = 0; k < v_allcolumns_temp.Count; k++)
            {
                this.v_table.Columns.Add(v_allcolumns_temp[k]);
            }

            // preenchendo valores sumarizados
            for (i = 0; i < this.v_table.Rows.Count; i++)
            {
                for (j = 0; j < v_allcolumns_temp.Count; j++)
                {
                    this.v_table.Rows[i][v_allcolumns_temp[j]] = p_table.Compute("Sum(" + v_allcolumns_temp[j] + ")", this.v_column + " = '" + this.v_table.Rows[i][this.v_column].ToString() + "'").ToString();
                }
            }
        }
示例#32
0
        protected override void RefreshView()
        {
            char splitNotation = StaticConstant.mw.projectUserControl.suc.StrInputFormatDelimiter;
            char rangeNotation = StaticConstant.mw.projectUserControl.suc.StrInputFormatRange;

            List <int> positions = null;
            List <int> colors    = null;

            StringBuilder fastGenerationrRangeBuilder = new StringBuilder();
            String        position = runs[5].Text;

            if (suc.rangeDictionary.ContainsKey(position))
            {
                positions = suc.rangeDictionary[position];
                for (int i = 0; i < suc.rangeDictionary[position].Count; i++)
                {
                    if (i != suc.rangeDictionary[position].Count - 1)
                    {
                        fastGenerationrRangeBuilder.Append(suc.rangeDictionary[position][i] + splitNotation.ToString());
                    }
                    else
                    {
                        fastGenerationrRangeBuilder.Append(suc.rangeDictionary[position][i]);
                    }
                }
            }
            else
            {
                positions = GetTrueContent(position, splitNotation, rangeNotation);
                if (positions != null)
                {
                    fastGenerationrRangeBuilder.Append(position);
                }
                else
                {
                    positions = createFromQuickOperationModel.PositionList;
                }
            }

            String        color = runs[14].Text;
            StringBuilder fastGenerationrColorBuilder = new StringBuilder();

            if (suc.rangeDictionary.ContainsKey(color))
            {
                colors = suc.rangeDictionary[color];
                for (int i = 0; i < suc.rangeDictionary[color].Count; i++)
                {
                    if (i != suc.rangeDictionary[color].Count - 1)
                    {
                        fastGenerationrColorBuilder.Append(suc.rangeDictionary[color][i] + splitNotation.ToString());
                    }
                    else
                    {
                        fastGenerationrColorBuilder.Append(suc.rangeDictionary[color][i]);
                    }
                }
            }
            else
            {
                colors = GetTrueContent(color, splitNotation, rangeNotation);
                if (colors != null)
                {
                    fastGenerationrColorBuilder.Append(color);
                }
                else
                {
                    colors = createFromQuickOperationModel.ColorList;
                }
            }

            object result = null;
            String time   = runs[2].Text;

            try
            {
                string expression          = time;
                System.Data.DataTable eval = new System.Data.DataTable();
                result = eval.Compute(expression, "");
            }
            catch
            {
                result = createFromQuickOperationModel.Time;
            }

            String interval = runs[8].Text;

            if (!System.Text.RegularExpressions.Regex.IsMatch(interval, "^\\d+$"))
            {
                interval = createFromQuickOperationModel.Interval.ToString();
            }
            String continued = runs[11].Text;

            if (!System.Text.RegularExpressions.Regex.IsMatch(continued, "^\\d+$"))
            {
                continued = createFromQuickOperationModel.Continued.ToString();
            }

            //Type
            int    type    = 0;
            String strType = runs[17].Text;
            int    _type   = -1;

            for (int i = 0; i < types.Count; i++)
            {
                if (((string)Application.Current.FindResource(types[i])).Equals(strType))
                {
                    _type = i;
                    break;
                }
            }
            switch (_type)
            {
            case -1:
                type = Create.UP;
                break;

            case 0:
                type = Create.UP;
                break;

            case 1:
                type = Create.DOWN;
                break;

            case 2:
                type = Create.UPDOWN;
                break;

            case 3:
                type = Create.DOWNUP;
                break;

            case 4:
                type = Create.UPANDDOWN;
                break;

            case 5:
                type = Create.DOWNANDUP;
                break;

            case 6:
                type = Create.FREEZEFRAME;
                break;
            }

            //Action
            int    action    = 0;
            String strAction = runs[20].Text;
            int    _action   = -1;

            for (int i = 0; i < actions.Count; i++)
            {
                if (((string)Application.Current.FindResource(actions[i])).Equals(strAction))
                {
                    _action = i;
                    break;
                }
            }

            switch (_action)
            {
            case -1:
                action = Create.ALL;
                break;

            case 0:
                action = Create.ALL;
                break;

            case 1:
                action = Create.OPEN;
                break;

            case 2:
                action = Create.CLOSE;
                break;
            }

            createFromQuickOperationModel.Time         = (int)result;
            createFromQuickOperationModel.PositionList = positions;
            createFromQuickOperationModel.Interval     = int.Parse(interval);
            createFromQuickOperationModel.Continued    = int.Parse(continued);
            createFromQuickOperationModel.ColorList    = colors;
            createFromQuickOperationModel.Type         = type;
            createFromQuickOperationModel.Action       = action;

            UpdateData();

            //suc.UpdateStep();
            //RefreshView();
        }