コード例 #1
0
        private void txtUserStride_TextChanged(object sender, EventArgs e)
        {
            Int32 _defaultInt = 2000;

            if (!Int32.TryParse(txtUserStride.Text, out _defaultInt))
            {
                ActivityData.UserStride = _defaultInt;
                MessageBox.Show(Constants.ErrorEnterValidInteger, Constants.GeneralError, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
            }
            else
            {
                ActivityData.UserStride = Convert.ToInt32(txtUserStride.Text, IefAppSettings.CurCulture());
            }
        }
コード例 #2
0
        public static System.Data.DataTable addCalcTableCols(System.Data.DataTable importData)
        {
            System.Data.DataTable _returnTable = new System.Data.DataTable();
            //_returnTable = importData;

            _returnTable.Columns.Add("Month", typeof(string));
            _returnTable.Columns.Add("Weekday", typeof(string));
            _returnTable.Columns.Add("Date", typeof(string));
            _returnTable.Columns.Add("Day_Of_Week", typeof(Int32));
            _returnTable.Columns.Add("Week_NUM", typeof(Int32));
            _returnTable.Columns.Add("Date_Text", typeof(string));
            _returnTable.Columns.Add("Day_of_Month", typeof(Int32));
            _returnTable.Columns.Add("Run_Miles", typeof(decimal));
            _returnTable.Columns.Add("Bike_Miles", typeof(decimal));
            _returnTable.Columns.Add("Walk_Miles", typeof(decimal));
            _returnTable.Columns.Add("Words", typeof(Int32));
            _returnTable.Columns.Add("Steps", typeof(decimal));
            _returnTable.Columns.Add("Miles_Calc", typeof(decimal));
            _returnTable.Columns.Add("Race_Dates", typeof(string));
            _returnTable.Columns.Add("Race_Type", typeof(string));
            _returnTable.Columns.Add("Race_Times", typeof(string));
            _returnTable.Columns.Add("Official_RT", typeof(string));
            _returnTable.Columns.Add("Run_Times", typeof(string));
            _returnTable.Columns.Add("Run_Min", typeof(Int32));
            _returnTable.Columns.Add("Run_Sec", typeof(Int32));
            _returnTable.Columns.Add("Bike_Time", typeof(string));
            _returnTable.Columns.Add("Bike_Min", typeof(Int32));
            _returnTable.Columns.Add("Bike_Sec", typeof(Int32));
            _returnTable.Columns.Add("Walk_Time", typeof(string));
            _returnTable.Columns.Add("Walk_Min", typeof(Int32));
            _returnTable.Columns.Add("Walk_Sec", typeof(Int32));
            //_returnTable.Columns.Add("Colon_Col", typeof(string));
            //_returnTable.Columns.Add("Walk flag", typeof(string));


            foreach (DataRow row in importData.Rows)
            {
                Char charRange     = ':';
                int  startIndexMin = 0;
                int  endIndexMin   = 0;
                int  lengthMin     = 0;
                int  startIndexSec = 0;
                int  endIndexSec   = 0;
                int  lengthSec     = 0;

                //startIndex = _runTime.IndexOf(charRange);
                //endIndex = _runTime.LastIndexOf(charRange);
                //length = endIndex - startIndex + 1;

                string   _month            = Convert.ToDateTime(row["Date"]).ToString("MMMM");
                string   _weekday          = Convert.ToDateTime(row["Date"]).ToString("dddd");
                DateTime _dt               = Convert.ToDateTime(row["Date"]);
                Int32    _dow              = Convert.ToInt32(Convert.ToDateTime(row["Date"]).DayOfWeek);
                Int32    _wkNum            = IefAppSettings.WeekOfYear(IefAppSettings.CurCulture(), _dt);
                string   _dtTxt            = Convert.ToDateTime(row["Date"]).ToString();
                Int32    _dayOfMonth       = Convert.ToInt32(_dt.ToString("dd", IefAppSettings.CurCulture()));
                decimal  _runMiles         = Convert.ToDecimal(row["Run_Miles"]);
                decimal  _bikeMiles        = Convert.ToDecimal(row["Bike_Miles"]);
                decimal  _walkMiles        = Convert.ToDecimal(row["Walk_Miles"]);
                Int32    _words            = Convert.ToInt32(row["Words"]);
                decimal  _steps            = Convert.ToDecimal(row["Steps"]);
                decimal  _milesCalc        = (_steps / ActivityData.UserStride);
                string   _raceDates        = Convert.ToString(row["Race_Dates"]);
                string   _raceType         = GetRunType(Convert.ToSingle(_runMiles));
                string   _raceTime         = Convert.ToString(row["Race_Times"]);
                string   _officialRaceTime = Convert.ToString(row["Official_RT"]);

                //runtime
                //string _runTime = Convert.ToString(row["Run_Times"]);
                string _runTime = Convert.ToString(row["Run_Times"], IefAppSettings.CurCulture());

                startIndexMin = 0;
                endIndexMin   = _runTime.IndexOf(charRange);
                lengthMin     = endIndexMin - startIndexMin;
                Int32 _runMin = Convert.ToInt32(_runTime.Substring(startIndexMin, lengthMin));

                startIndexSec = _runTime.IndexOf(charRange) + 1;
                endIndexSec   = _runTime.Length;
                lengthSec     = endIndexSec - startIndexSec;
                Int32 _runSec = Convert.ToInt32(_runTime.Substring(startIndexSec, lengthSec));

                //bike time
                string _bikeTime = Convert.ToString(row["Bike_Time"]);

                startIndexMin = 0;
                endIndexMin   = _bikeTime.IndexOf(charRange);
                lengthMin     = endIndexMin - startIndexMin;
                Int32 _bikeMin = Convert.ToInt32(_bikeTime.Substring(startIndexMin, lengthMin));

                startIndexSec = _bikeTime.IndexOf(charRange) + 1;
                endIndexSec   = _bikeTime.Length;
                lengthSec     = endIndexSec - startIndexSec;
                Int32 _bikeSec = Convert.ToInt32(_bikeTime.Substring(startIndexSec, lengthSec));

                //walktime
                string _walkTime = Convert.ToString(row["Walk_Time"]);

                startIndexMin = 0;
                endIndexMin   = _walkTime.IndexOf(charRange);
                lengthMin     = endIndexMin - startIndexMin;
                Int32 _walkMin = Convert.ToInt32(_walkTime.Substring(startIndexMin, lengthMin));

                startIndexSec = _walkTime.IndexOf(charRange) + 1;
                endIndexSec   = _walkTime.Length;
                lengthSec     = endIndexSec - startIndexSec;
                Int32 _walkSec = Convert.ToInt32(_walkTime.Substring(startIndexSec, lengthSec));



                _returnTable.Rows.Add(_month, _weekday, _dt, _dow, _wkNum, _dtTxt, _dayOfMonth, _runMiles, _bikeMiles, _walkMiles, _words, _steps, _milesCalc, _raceDates, _raceType, _raceTime, _officialRaceTime, _runTime, _runMin, _runSec, _bikeTime, _bikeMin, _bikeSec, _walkTime, _walkMin, _walkSec);
            }



            return(_returnTable);
        }