Esempio n. 1
0
 public TotalColumn(string columnname, totalMode totalmode, bool showtotal, TotalAlign totalAlign)
 {
     _ColumnName = columnname;
     _TotalMode = totalmode;
     _ShowTotal = showtotal;
     _TotalAlignment = totalAlign;
 }
Esempio n. 2
0
        public string GetTotalValue(string FieldName, totalMode mode, string format)
        {
            string strValue = "";
            object obj = this.GetObjByID(this.DataSourceID);
            if (obj != null && obj is WebDataSource)
            {

                DataTable dt = (obj as WebDataSource).View.Table;
                decimal total = 0;
                decimal max = decimal.MinValue;
                decimal min = decimal.MaxValue;
                decimal average = new decimal();

                if (dt.Columns[FieldName].DataType.ToString().ToLower() == "system.uint")
                {
                    switch (mode)
                    {
                        case totalMode.count:
                            strValue = dt.Rows.Count.ToString();
                            break;
                        case totalMode.sum:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row.RowState != DataRowState.Deleted
                                    && row[FieldName] != null
                                    && row[FieldName].ToString() != "")
                                {
                                    total += (uint)row[FieldName];
                                }
                            }
                            strValue = total.ToString();
                            break;
                        case totalMode.average:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row.RowState != DataRowState.Deleted
                                    && row[FieldName] != null
                                    && row[FieldName].ToString() != "")
                                {
                                    total += (uint)row[FieldName];
                                }
                            }
                            int count = dt.Rows.Count;
                            average = total / count;
                            strValue = average.ToString();
                            break;
                        case totalMode.max:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row[FieldName] != null
                                    && row[FieldName].ToString() != ""
                                    && row.RowState != DataRowState.Deleted)
                                {
                                    max = Math.Max((uint)row[FieldName], max);
                                }
                            }
                            if (max != decimal.MinValue)
                            {
                                strValue = max.ToString();
                            }
                            break;
                        case totalMode.min:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row[FieldName] != null
                                    && row[FieldName].ToString() != ""
                                    && row.RowState != DataRowState.Deleted)
                                {
                                    min = Math.Min((uint)row[FieldName], min);
                                }
                            }
                            if (min != decimal.MinValue)
                            {
                                strValue = min.ToString();
                            }
                            break;
                    }
                }
                else if (dt.Columns[FieldName].DataType.ToString().ToLower() == "system.uint16")
                {
                    switch (mode)
                    {
                        case totalMode.count:
                            strValue = dt.Rows.Count.ToString();
                            break;
                        case totalMode.sum:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row.RowState != DataRowState.Deleted
                                    && row[FieldName] != null
                                    && row[FieldName].ToString() != "")
                                {
                                    total += (UInt16)row[FieldName];
                                }
                            }
                            strValue = total.ToString();
                            break;
                        case totalMode.average:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row.RowState != DataRowState.Deleted
                                    && row[FieldName] != null
                                    && row[FieldName].ToString() != "")
                                {
                                    total += (UInt16)row[FieldName];
                                }
                            }
                            int count = dt.Rows.Count;
                            average = total / count;
                            strValue = average.ToString();
                            break;
                        case totalMode.max:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row[FieldName] != null
                                    && row[FieldName].ToString() != ""
                                    && row.RowState != DataRowState.Deleted)
                                {
                                    max = Math.Max((UInt16)row[FieldName], max);
                                }
                            }
                            if (max != decimal.MinValue)
                            {
                                strValue = max.ToString();
                            }
                            break;
                        case totalMode.min:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row[FieldName] != null
                                    && row[FieldName].ToString() != ""
                                    && row.RowState != DataRowState.Deleted)
                                {
                                    min = Math.Min((UInt16)row[FieldName], min);
                                }
                            }
                            if (min != decimal.MinValue)
                            {
                                strValue = min.ToString();
                            }
                            break;
                    }
                }
                else if (dt.Columns[FieldName].DataType.ToString().ToLower() == "system.uint32")
                {
                    switch (mode)
                    {
                        case totalMode.count:
                            strValue = dt.Rows.Count.ToString();
                            break;
                        case totalMode.sum:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row.RowState != DataRowState.Deleted
                                    && row[FieldName] != null
                                    && row[FieldName].ToString() != "")
                                {
                                    total += (UInt32)row[FieldName];
                                }
                            }
                            strValue = total.ToString();
                            break;
                        case totalMode.average:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row.RowState != DataRowState.Deleted
                                    && row[FieldName] != null
                                    && row[FieldName].ToString() != "")
                                {
                                    total += (UInt32)row[FieldName];
                                }
                            }
                            int count = dt.Rows.Count;
                            average = total / count;
                            strValue = average.ToString();
                            break;
                        case totalMode.max:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row[FieldName] != null
                                    && row[FieldName].ToString() != ""
                                    && row.RowState != DataRowState.Deleted)
                                {
                                    max = Math.Max((UInt32)row[FieldName], max);
                                }
                            }
                            if (max != decimal.MinValue)
                            {
                                strValue = max.ToString();
                            }
                            break;
                        case totalMode.min:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row[FieldName] != null
                                    && row[FieldName].ToString() != ""
                                    && row.RowState != DataRowState.Deleted)
                                {
                                    min = Math.Min((UInt32)row[FieldName], min);
                                }
                            }
                            if (min != decimal.MinValue)
                            {
                                strValue = min.ToString();
                            }
                            break;
                    }
                }
                else if (dt.Columns[FieldName].DataType.ToString().ToLower() == "system.uint64")
                {
                    switch (mode)
                    {
                        case totalMode.count:
                            strValue = dt.Rows.Count.ToString();
                            break;
                        case totalMode.sum:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row.RowState != DataRowState.Deleted
                                    && row[FieldName] != null
                                    && row[FieldName].ToString() != "")
                                {
                                    total += (UInt64)row[FieldName];
                                }
                            }
                            strValue = total.ToString();
                            break;
                        case totalMode.average:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row.RowState != DataRowState.Deleted
                                    && row[FieldName] != null
                                    && row[FieldName].ToString() != "")
                                {
                                    total += (UInt64)row[FieldName];
                                }
                            }
                            int count = dt.Rows.Count;
                            average = total / count;
                            strValue = average.ToString();
                            break;
                        case totalMode.max:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row[FieldName] != null
                                    && row[FieldName].ToString() != ""
                                    && row.RowState != DataRowState.Deleted)
                                {
                                    max = Math.Max((UInt64)row[FieldName], max);
                                }
                            }
                            if (max != decimal.MinValue)
                            {
                                strValue = max.ToString();
                            }
                            break;
                        case totalMode.min:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row[FieldName] != null
                                    && row[FieldName].ToString() != ""
                                    && row.RowState != DataRowState.Deleted)
                                {
                                    min = Math.Min((UInt64)row[FieldName], min);
                                }
                            }
                            if (min != decimal.MinValue)
                            {
                                strValue = min.ToString();
                            }
                            break;
                    }
                }
                else if (dt.Columns[FieldName].DataType.ToString().ToLower() == "system.int")
                {
                    switch (mode)
                    {
                        case totalMode.count:
                            strValue = dt.Rows.Count.ToString();
                            break;
                        case totalMode.sum:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row.RowState != DataRowState.Deleted
                                    && row[FieldName] != null
                                    && row[FieldName].ToString() != "")
                                {
                                    total += (int)row[FieldName];
                                }
                            }
                            strValue = total.ToString();
                            break;
                        case totalMode.average:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row.RowState != DataRowState.Deleted
                                    && row[FieldName] != null
                                    && row[FieldName].ToString() != "")
                                {
                                    total += (int)row[FieldName];
                                }
                            }
                            int count = dt.Rows.Count;
                            average = total / count;
                            strValue = average.ToString();
                            break;
                        case totalMode.max:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row[FieldName] != null
                                    && row[FieldName].ToString() != ""
                                    && row.RowState != DataRowState.Deleted)
                                {
                                    max = Math.Max((int)row[FieldName], max);
                                }
                            }
                            if (max != decimal.MinValue)
                            {
                                strValue = max.ToString();
                            }
                            break;
                        case totalMode.min:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row[FieldName] != null
                                    && row[FieldName].ToString() != ""
                                    && row.RowState != DataRowState.Deleted)
                                {
                                    min = Math.Min((int)row[FieldName], min);
                                }
                            }
                            if (min != decimal.MinValue)
                            {
                                strValue = min.ToString();
                            }
                            break;
                    }
                }
                else if (dt.Columns[FieldName].DataType.ToString().ToLower() == "system.int16")
                {
                    switch (mode)
                    {
                        case totalMode.count:
                            strValue = dt.Rows.Count.ToString();
                            break;
                        case totalMode.sum:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row.RowState != DataRowState.Deleted
                                    && row[FieldName] != null
                                    && row[FieldName].ToString() != "")
                                {
                                    total += (Int16)row[FieldName];
                                }
                            }
                            strValue = total.ToString();
                            break;
                        case totalMode.average:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row.RowState != DataRowState.Deleted
                                    && row[FieldName] != null
                                    && row[FieldName].ToString() != "")
                                {
                                    total += (Int16)row[FieldName];
                                }
                            }
                            int count = dt.Rows.Count;
                            average = total / count;
                            strValue = average.ToString();
                            break;
                        case totalMode.max:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row[FieldName] != null
                                    && row[FieldName].ToString() != ""
                                    && row.RowState != DataRowState.Deleted)
                                {
                                    max = Math.Max((Int16)row[FieldName], max);
                                }
                            }
                            if (max != decimal.MinValue)
                            {
                                strValue = max.ToString();
                            }
                            break;
                        case totalMode.min:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row[FieldName] != null
                                    && row[FieldName].ToString() != ""
                                    && row.RowState != DataRowState.Deleted)
                                {
                                    min = Math.Min((Int16)row[FieldName], min);
                                }
                            }
                            if (min != decimal.MinValue)
                            {
                                strValue = min.ToString();
                            }
                            break;
                    }
                }
                else if (dt.Columns[FieldName].DataType.ToString().ToLower() == "system.int32")
                {
                    switch (mode)
                    {
                        case totalMode.count:
                            strValue = dt.Rows.Count.ToString();
                            break;
                        case totalMode.sum:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row.RowState != DataRowState.Deleted
                                    && row[FieldName] != null
                                    && row[FieldName].ToString() != "")
                                {
                                    total += (Int32)row[FieldName];
                                }
                            }
                            strValue = total.ToString();
                            break;
                        case totalMode.average:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row.RowState != DataRowState.Deleted
                                    && row[FieldName] != null
                                    && row[FieldName].ToString() != "")
                                {
                                    total += (Int32)row[FieldName];
                                }
                            }
                            int count = dt.Rows.Count;
                            average = total / count;
                            strValue = average.ToString();
                            break;
                        case totalMode.max:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row[FieldName] != null
                                    && row[FieldName].ToString() != ""
                                    && row.RowState != DataRowState.Deleted)
                                {
                                    max = Math.Max((Int32)row[FieldName], max);
                                }
                            }
                            if (max != decimal.MinValue)
                            {
                                strValue = max.ToString();
                            }
                            break;
                        case totalMode.min:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row[FieldName] != null
                                    && row[FieldName].ToString() != ""
                                    && row.RowState != DataRowState.Deleted)
                                {
                                    min = Math.Min((Int32)row[FieldName], min);
                                }
                            }
                            if (min != decimal.MinValue)
                            {
                                strValue = min.ToString();
                            }
                            break;
                    }
                }
                else if (dt.Columns[FieldName].DataType.ToString().ToLower() == "system.int64")
                {
                    switch (mode)
                    {
                        case totalMode.count:
                            strValue = dt.Rows.Count.ToString();
                            break;
                        case totalMode.sum:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row.RowState != DataRowState.Deleted
                                    && row[FieldName] != null
                                    && row[FieldName].ToString() != "")
                                {
                                    total += (Int64)row[FieldName];
                                }
                            }
                            strValue = total.ToString();
                            break;
                        case totalMode.average:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row.RowState != DataRowState.Deleted
                                    && row[FieldName] != null
                                    && row[FieldName].ToString() != "")
                                {
                                    total += (Int64)row[FieldName];
                                }
                            }
                            int count = dt.Rows.Count;
                            average = total / count;
                            strValue = average.ToString();
                            break;
                        case totalMode.max:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row[FieldName] != null
                                    && row[FieldName].ToString() != ""
                                    && row.RowState != DataRowState.Deleted)
                                {
                                    max = Math.Max((Int64)row[FieldName], max);
                                }
                            }
                            if (max != decimal.MinValue)
                            {
                                strValue = max.ToString();
                            }
                            break;
                        case totalMode.min:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row[FieldName] != null
                                    && row[FieldName].ToString() != ""
                                    && row.RowState != DataRowState.Deleted)
                                {
                                    min = Math.Min((Int64)row[FieldName], min);
                                }
                            }
                            if (min != decimal.MinValue)
                            {
                                strValue = min.ToString();
                            }
                            break;
                    }
                }
                else if (dt.Columns[FieldName].DataType.ToString().ToLower() == "system.single")
                {
                    Single stotal = 0;
                    Single smax = Single.MinValue;
                    Single smin = Single.MaxValue;
                    Single saverage = new Single();

                    switch (mode)
                    {
                        case totalMode.count:
                            strValue = dt.Rows.Count.ToString();
                            break;
                        case totalMode.sum:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row.RowState != DataRowState.Deleted
                                    && row[FieldName] != null
                                    && row[FieldName].ToString() != "")
                                {
                                    stotal += (Single)row[FieldName];
                                }
                            }
                            strValue = stotal.ToString();
                            break;
                        case totalMode.average:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row.RowState != DataRowState.Deleted
                                    && row[FieldName] != null
                                    && row[FieldName].ToString() != "")
                                {
                                    stotal += (Single)row[FieldName];
                                }
                            }
                            int count = dt.Rows.Count;
                            saverage = stotal / count;
                            strValue = saverage.ToString();
                            break;
                        case totalMode.max:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row[FieldName] != null
                                    && row[FieldName].ToString() != ""
                                    && row.RowState != DataRowState.Deleted)
                                {
                                    smax = Math.Max((Single)row[FieldName], smax);
                                }
                            }
                            if (smax != Single.MinValue)
                            {
                                strValue = smax.ToString();
                            }
                            break;
                        case totalMode.min:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row[FieldName] != null
                                    && row[FieldName].ToString() != ""
                                    && row.RowState != DataRowState.Deleted)
                                {
                                    smin = Math.Min((Single)row[FieldName], smin);
                                }
                            }
                            if (smin != Single.MinValue)
                            {
                                strValue = smin.ToString();
                            }
                            break;
                    }
                }
                else if (dt.Columns[FieldName].DataType.ToString().ToLower() == "system.float")
                {
                    float ftotal = 0;
                    float fmax = float.MinValue;
                    float fmin = float.MaxValue;
                    float faverage = new float();

                    switch (mode)
                    {
                        case totalMode.count:
                            strValue = dt.Rows.Count.ToString();
                            break;
                        case totalMode.sum:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row.RowState != DataRowState.Deleted
                                    && row[FieldName] != null
                                    && row[FieldName].ToString() != "")
                                {
                                    ftotal += (float)row[FieldName];
                                }
                            }
                            strValue = ftotal.ToString();
                            break;
                        case totalMode.average:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row.RowState != DataRowState.Deleted
                                    && row[FieldName] != null
                                    && row[FieldName].ToString() != "")
                                {
                                    ftotal += (float)row[FieldName];
                                }
                            }
                            int count = dt.Rows.Count;
                            faverage = ftotal / count;
                            strValue = faverage.ToString();
                            break;
                        case totalMode.max:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row[FieldName] != null
                                    && row[FieldName].ToString() != ""
                                    && row.RowState != DataRowState.Deleted)
                                {
                                    fmax = Math.Max((float)row[FieldName], fmax);
                                }
                            }
                            if (fmax != float.MinValue)
                            {
                                strValue = fmax.ToString();
                            }
                            break;
                        case totalMode.min:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row[FieldName] != null
                                    && row[FieldName].ToString() != ""
                                    && row.RowState != DataRowState.Deleted)
                                {
                                    fmin = Math.Min((float)row[FieldName], fmin);
                                }
                            }
                            if (fmin != float.MinValue)
                            {
                                strValue = fmin.ToString();
                            }
                            break;
                    }
                }
                else if (dt.Columns[FieldName].DataType.ToString().ToLower() == "system.double")
                {
                    double dtotal = 0;
                    double dmax = double.MinValue;
                    double dmin = double.MaxValue;
                    double daverage = new double();
                    switch (mode)
                    {
                        case totalMode.count:
                            strValue = dt.Rows.Count.ToString();
                            break;
                        case totalMode.sum:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row.RowState != DataRowState.Deleted
                                    && row[FieldName] != null
                                    && row[FieldName].ToString() != "")
                                {
                                    dtotal += (double)row[FieldName];
                                }
                            }
                            strValue = dtotal.ToString();
                            break;
                        case totalMode.average:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row.RowState != DataRowState.Deleted
                                    && row[FieldName] != null
                                    && row[FieldName].ToString() != "")
                                {
                                    dtotal += (double)row[FieldName];
                                }
                            }
                            int count = dt.Rows.Count;
                            daverage = dtotal / count;
                            strValue = daverage.ToString();
                            break;
                        case totalMode.max:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row[FieldName] != null
                                    && row[FieldName].ToString() != ""
                                    && row.RowState != DataRowState.Deleted)
                                {
                                    dmax = Math.Max((double)row[FieldName], dmax);
                                }
                            }
                            if (dmax != double.MinValue)
                            {
                                strValue = dmax.ToString();
                            }
                            break;
                        case totalMode.min:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row[FieldName] != null
                                    && row[FieldName].ToString() != ""
                                    && row.RowState != DataRowState.Deleted)
                                {
                                    dmin = Math.Min((double)row[FieldName], dmin);
                                }
                            }
                            if (dmin != double.MinValue)
                            {
                                strValue = dmin.ToString();
                            }
                            break;
                    }
                }
                else if (dt.Columns[FieldName].DataType.ToString().ToLower() == "system.decimal"
                    || !string.IsNullOrEmpty(dt.Columns[FieldName].Expression))
                {
                    switch (mode)
                    {
                        case totalMode.count:
                            strValue = dt.Rows.Count.ToString();
                            break;
                        case totalMode.sum:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row.RowState != DataRowState.Deleted
                                    && row[FieldName] != null
                                    && row[FieldName].ToString() != "")
                                {
                                    total += Convert.ToDecimal(row[FieldName]);
                                }
                            }
                            strValue = total.ToString();
                            break;
                        case totalMode.average:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row.RowState != DataRowState.Deleted
                                    && row[FieldName] != null
                                    && row[FieldName].ToString() != "")
                                {
                                    total += Convert.ToDecimal(row[FieldName]);
                                }
                            }
                            int count = dt.Rows.Count;
                            average = total / count;
                            strValue = average.ToString();
                            break;
                        case totalMode.max:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row[FieldName] != null
                                    && row[FieldName].ToString() != ""
                                    && row.RowState != DataRowState.Deleted)
                                {
                                    max = Math.Max(Convert.ToDecimal(row[FieldName]), max);
                                }
                            }
                            if (max != decimal.MinValue)
                            {
                                strValue = max.ToString();
                            }
                            break;
                        case totalMode.min:
                            foreach (DataRow row in dt.Rows)
                            {
                                if (row[FieldName] != null
                                    && row[FieldName].ToString() != ""
                                    && row.RowState != DataRowState.Deleted)
                                {
                                    min = Math.Min(Convert.ToDecimal(row[FieldName]), min);
                                }
                            }
                            if (min != decimal.MinValue)
                            {
                                strValue = min.ToString();
                            }
                            break;
                    }
                }
                else
                {
                    if (mode == totalMode.count)
                    {
                        strValue = dt.Rows.Count.ToString();
                    }
                }
                if (!string.IsNullOrEmpty(format))
                {
                    //format
                    switch (mode)
                    {
                        case totalMode.sum:
                            {
                                strValue = total.ToString(format);
                                break;
                            }
                        case totalMode.average:
                            {
                                strValue = average.ToString(format);
                                break;
                            }
                        case totalMode.max:
                            {
                                if (max != decimal.MinValue)
                                {
                                    strValue = max.ToString(format);
                                }
                                break;
                            }
                        case totalMode.min:
                            {
                                if (min != decimal.MinValue)
                                {
                                    strValue = min.ToString(format);
                                }
                                break;
                            }

                    }
                }
            }
            return strValue;
        }
Esempio n. 3
0
        /*private class User32
        {
            [StructLayout(LayoutKind.Sequential)]
            public struct RECT
            {
                public int left;
                public int top;
                public int right;
                public int bottom;
            }

            [DllImport("user32.dll")]
            public static extern IntPtr GetDesktopWindow();
            [DllImport("user32.dll")]
            public static extern IntPtr GetWindowDC(IntPtr hWnd);
            [DllImport("user32.dll")]
            public static extern IntPtr ReleaseDC(IntPtr hWnd, IntPtr hDC);
            [DllImport("user32.dll")]
            public static extern IntPtr GetWindowRect(IntPtr hWnd, ref RECT rect);
            [DllImport("user32.dll")]
            public static extern void InvalidateRect(IntPtr hWnd, RECT rect, bool b);
        }*/
        public string DoSum(int colIndex, totalMode showMode)
        {
            decimal total = 0;
            decimal max = decimal.MinValue;
            decimal min = decimal.MaxValue;
            decimal average = new decimal();
            int i = -1;
            if (this.AllowUserToAddRows)
                i = this.Rows.Count - 1;
            else
                i = this.Rows.Count;
            string strValue = "";
            if (this.Columns[colIndex].ValueType == typeof(Int16))
            {
                switch (showMode)
                {
                    case totalMode.count:
                        strValue = i.ToString();
                        break;
                    case totalMode.sum:
                        for (int j = 0; j < i; j++)
                        {
                            if (this[colIndex, j].Value != null && this[colIndex, j].Value.ToString() != "")
                                total += (Int16)this[colIndex, j].Value;
                        }
                        strValue = total.ToString();
                        break;
                    case totalMode.max:
                        for (int j = 0; j < i; j++)
                        {
                            if (this[colIndex, j].Value != null && this[colIndex, j].Value.ToString() != "")
                                max = Math.Max((Int16)this[colIndex, j].Value, max);
                        }
                        if (max != decimal.MinValue)
                            strValue = max.ToString();
                        break;
                    case totalMode.min:
                        for (int j = 0; j < i; j++)
                        {
                            if (this[colIndex, j].Value != null && this[colIndex, j].Value.ToString() != "")
                                min = Math.Min((Int16)this[colIndex, j].Value, min);
                        }
                        if (min != decimal.MaxValue)
                            strValue = min.ToString();
                        break;
                    case totalMode.average:
                        if (i != 0)
                        {
                            for (int j = 0; j < i; j++)
                            {
                                if (this[colIndex, j].Value != null && this[colIndex, j].Value.ToString() != "")
                                    total += (Int16)this[colIndex, j].Value;
                            }
                            average = total / i;
                            strValue = average.ToString();
                        }
                        break;
                }
            }
            else if (this.Columns[colIndex].ValueType == typeof(Int32))
            {
                switch (showMode)
                {
                    case totalMode.count:
                        strValue = i.ToString();
                        break;
                    case totalMode.sum:
                        for (int j = 0; j < i; j++)
                        {
                            if (this[colIndex, j].Value != null && this[colIndex, j].Value.ToString() != "")
                                total += (Int32)this[colIndex, j].Value;
                        }
                        strValue = total.ToString();
                        break;
                    case totalMode.max:
                        for (int j = 0; j < i; j++)
                        {
                            if (this[colIndex, j].Value != null && this[colIndex, j].Value.ToString() != "")
                                max = Math.Max((Int32)this[colIndex, j].Value, max);
                        }
                        if (max != decimal.MinValue)
                            strValue = max.ToString();
                        break;
                    case totalMode.min:
                        for (int j = 0; j < i; j++)
                        {
                            if (this[colIndex, j].Value != null && this[colIndex, j].Value.ToString() != "")
                                min = Math.Min((Int32)this[colIndex, j].Value, min);
                        }
                        if (min != decimal.MaxValue)
                            strValue = min.ToString();
                        break;
                    case totalMode.average:
                        if (i != 0)
                        {
                            for (int j = 0; j < i; j++)
                            {
                                if (this[colIndex, j].Value != null && this[colIndex, j].Value.ToString() != "")
                                    total += (Int32)this[colIndex, j].Value;
                            }
                            average = total / i;
                            strValue = average.ToString();
                        }
                        break;
                }
            }
            else if (this.Columns[colIndex].ValueType == typeof(Int64))
            {
                switch (showMode)
                {
                    case totalMode.count:
                        strValue = i.ToString();
                        break;
                    case totalMode.sum:
                        for (int j = 0; j < i; j++)
                        {
                            if (this[colIndex, j].Value != null && this[colIndex, j].Value.ToString() != "")
                                total += (Int64)this[colIndex, j].Value;
                        }
                        strValue = total.ToString();
                        break;
                    case totalMode.max:
                        for (int j = 0; j < i; j++)
                        {
                            if (this[colIndex, j].Value != null && this[colIndex, j].Value.ToString() != "")
                                max = Math.Max((Int64)this[colIndex, j].Value, max);
                        }
                        if (max != decimal.MinValue)
                            strValue = max.ToString();
                        break;
                    case totalMode.min:
                        for (int j = 0; j < i; j++)
                        {
                            if (this[colIndex, j].Value != null && this[colIndex, j].Value.ToString() != "")
                                min = Math.Min((Int64)this[colIndex, j].Value, min);
                        }
                        if (min != decimal.MaxValue)
                            strValue = min.ToString();
                        break;
                    case totalMode.average:
                        if (i != 0)
                        {
                            for (int j = 0; j < i; j++)
                            {
                                if (this[colIndex, j].Value != null && this[colIndex, j].Value.ToString() != "")
                                    total += (Int64)this[colIndex, j].Value;
                            }
                            average = total / i;
                            strValue = average.ToString();
                        }
                        break;
                }
            }
            else if (this.Columns[colIndex].ValueType == typeof(decimal))
            {
                switch (showMode)
                {
                    case totalMode.count:
                        strValue = i.ToString();
                        break;
                    case totalMode.sum:
                        for (int j = 0; j < i; j++)
                        {
                            if (this[colIndex, j].Value != null && this[colIndex, j].Value.ToString() != "")
                                total += (decimal)this[colIndex, j].Value;
                        }
                        strValue = total.ToString();
                        break;
                    case totalMode.max:
                        for (int j = 0; j < i; j++)
                        {
                            if (this[colIndex, j].Value != null && this[colIndex, j].Value.ToString() != "")
                                max = Math.Max((decimal)this[colIndex, j].Value, max);
                        }
                        if (max != decimal.MinValue)
                            strValue = max.ToString();
                        break;
                    case totalMode.min:
                        for (int j = 0; j < i; j++)
                        {
                            if (this[colIndex, j].Value != null && this[colIndex, j].Value.ToString() != "")
                                min = Math.Min((decimal)this[colIndex, j].Value, min);
                        }
                        if (min != decimal.MaxValue)
                            strValue = min.ToString();
                        break;
                    case totalMode.average:
                        if (i != 0)
                        {
                            for (int j = 0; j < i; j++)
                            {
                                if (this[colIndex, j].Value != null && this[colIndex, j].Value.ToString() != "")
                                    total += (decimal)this[colIndex, j].Value;
                            }
                            average = total / i;
                            strValue = average.ToString();
                        }
                        break;
                }
            }
            else if (this.Columns[colIndex].ValueType == typeof(double))
            {
                double dtotal = 0;
                double dmax = double.MinValue;
                double dmin = double.MaxValue;
                double daverage = new double();
                switch (showMode)
                {
                    case totalMode.count:
                        strValue = i.ToString();
                        break;
                    case totalMode.sum:
                        for (int j = 0; j < i; j++)
                        {
                            if (this[colIndex, j].Value != null && this[colIndex, j].Value.ToString() != "")
                                dtotal += (double)this[colIndex, j].Value;
                        }
                        strValue = dtotal.ToString();
                        break;
                    case totalMode.max:
                        for (int j = 0; j < i; j++)
                        {
                            if (this[colIndex, j].Value != null && this[colIndex, j].Value.ToString() != "")
                                dmax = Math.Max((double)this[colIndex, j].Value, dmax);
                        }
                        if (dmax != double.MinValue)
                            strValue = dmax.ToString();
                        break;
                    case totalMode.min:
                        for (int j = 0; j < i; j++)
                        {
                            if (this[colIndex, j].Value != null && this[colIndex, j].Value.ToString() != "")
                                dmin = Math.Min((double)this[colIndex, j].Value, dmin);
                        }
                        if (dmin != double.MaxValue)
                            strValue = dmin.ToString();
                        break;
                    case totalMode.average:
                        if (i != 0)
                        {
                            for (int j = 0; j < i; j++)
                            {
                                if (this[colIndex, j].Value != null && this[colIndex, j].Value.ToString() != "")
                                    dtotal += (double)this[colIndex, j].Value;
                            }
                            daverage = dtotal / i;
                            strValue = daverage.ToString();
                        }
                        break;
                }
            }
            else
            {
                switch (showMode)
                {
                    case totalMode.count:
                        strValue = i.ToString();
                        break;
                    case totalMode.sum:
                        for (int j = 0; j < i; j++)
                        {
                            object value = this.Columns[colIndex] is InfoDataGridViewExpressionColumn
                                ? ((InfoDataGridViewExpressionColumn)this.Columns[colIndex]).GetExpression(j) : this[colIndex, j].Value;
                            if (value != null && value.ToString().Length > 0)
                            {
                                total += decimal.Parse(value.ToString());
                            }
                        }
                        strValue = total.ToString();
                        break;
                    case totalMode.max:
                        for (int j = 0; j < i; j++)
                        {
                          object value = this.Columns[colIndex] is InfoDataGridViewExpressionColumn
                                ? ((InfoDataGridViewExpressionColumn)this.Columns[colIndex]).GetExpression(j) : this[colIndex, j].Value;
                             if (value != null && value.ToString().Length > 0)
                             {
                                 max = Math.Max(decimal.Parse(value.ToString()), max);
                             }
                        }
                        if (max != decimal.MinValue)
                            strValue = max.ToString();
                        break;
                    case totalMode.min:
                        for (int j = 0; j < i; j++)
                        {
                            object value = this.Columns[colIndex] is InfoDataGridViewExpressionColumn
                                ? ((InfoDataGridViewExpressionColumn)this.Columns[colIndex]).GetExpression(j) : this[colIndex, j].Value;
                            if (value != null && value.ToString().Length > 0)
                            {
                                min = Math.Min(decimal.Parse(value.ToString()), min);
                            }
                        }
                        if (min != decimal.MaxValue)
                            strValue = min.ToString();
                        break;
                    case totalMode.average:
                        if (i != 0)
                        {
                            for (int j = 0; j < i; j++)
                            {
                                 object value = this.Columns[colIndex] is InfoDataGridViewExpressionColumn
                                ? ((InfoDataGridViewExpressionColumn)this.Columns[colIndex]).GetExpression(j) : this[colIndex, j].Value;
                                if (value != null && value.ToString().Length > 0)
                                {
                                    total += decimal.Parse(value.ToString());
                                }
                            }
                            average = total / i;
                            strValue = average.ToString();
                        }
                        break;
                }
            }
            return strValue;
        }