Example #1
0
 /// <summary>
 /// Calls the changes show information.
 /// </summary>
 /// <param name="info">The information.</param>
 public void CallChangesShowInfo(ChargesInfo info)
 {
     Dispatcher.Invoke(new Action(delegate
     {
         this.ChangeShowInfo(info);
     }));
 }
Example #2
0
        /// <summary>
        /// Changes the show information.
        /// </summary>
        /// <param name="info">The information.</param>
        public void ChangeShowInfo(ChargesInfo info)
        {
            if (info != null)
            {
                labTime.FontWeight        = FontWeights.Normal;
                labTime.Foreground        = new SolidColorBrush(Colors.Black);
                txtTrainedTime.Foreground = new SolidColorBrush(Colors.Black);
                switch (info.Mode)
                {
                case "Time":
                {
                    labTime.FontWeight        = FontWeights.Bold;
                    labTime.Foreground        = _brush;
                    txtTrainedTime.Foreground = _brush;
                    int hour = (int)info.CurrentMinutes / 1;
                    int min  = (int)((info.CurrentMinutes - hour) * 60.0 / 1.0);
                    int sec  = (int)(Math.Round((info.CurrentMinutes - hour) * 60.0 - min, 3) * 60.0);
                    txtTrainedMileage.Text = Math.Round(Math.Abs(info.CurrentMileage * 1000.0), 2) + "米";
                    txtTrainedTime.Text    = string.Concat(hour, ":", min, ":", sec);
                    txtTrainedTimes.Text   = Math.Abs(info.SurplusTimes) + "次";
                    break;
                }

                case "Mileage":
                {
                    labMileage.FontWeight        = FontWeights.Bold;
                    labMileage.Foreground        = _brush;
                    txtTrainedMileage.Foreground = _brush;
                    txtTrainedMileage.Text       = Math.Round(info.CurrentMileage * 1000.0, 2) + "米";
                    txtTrainedTimes.Text         = Math.Abs(info.SurplusTimes) + "次";
                    double cmin = Math.Abs(info.CurrentMinutes);
                    int    hour = (int)cmin / 1;
                    int    min  = (int)((cmin - hour) * 60.0 / 1.0);
                    int    sec  = (int)(Math.Round((cmin - hour) * 60.0 - min, 3) * 60.0);
                    txtTrainedTime.Text = string.Concat(hour, ":", min, ":", sec);
                    break;
                }

                case "Tries":
                {
                    labTries.FontWeight        = FontWeights.Bold;
                    labTries.Foreground        = _brush;
                    txtTrainedTimes.Foreground = _brush;
                    txtTrainedMileage.Text     = Math.Round(Math.Abs(info.CurrentMileage * 1000.0), 2) + "米";
                    txtTrainedTimes.Text       = info.SurplusTimes + "次";
                    double cmin = Math.Abs(info.CurrentMinutes);
                    int    hour = (int)cmin / 1;
                    int    min  = (int)((cmin - hour) * 60.0 / 1.0);
                    int    sec  = (int)(Math.Round((cmin - hour) * 60.0 - min, 3) * 60.0);
                    txtTrainedTime.Text = string.Concat(hour, ":", min, ":", sec);
                    break;
                }
                }
            }
        }
Example #3
0
 public bool StartCharge(string autoType)
 {
     _sw.WriteLine(DateTime.Now.ToLocalTime() + ":" + "准备开始计费,开始检测许可信息……");
     _lincenseState = _trnLicense.CheckLicense(autoType);
     SqlLiteHelper.SaveTranineesInfo(_trnLicense);
     if (_lincenseState == LicenseState.Normal)
     {
         _sw.WriteLine(DateTime.Now.ToLocalTime() + ":" + "该许可信息有效……");
         if (_currentInfoControl == null)
         {
             _currentInfoControl = new ChargingControl();
             _currentInfoControl.Show();
         }
         else
         {
             _currentInfoControl.Show();
         }
         IsChargerControlHide = false;
         _chargesDisplayInfo  = new ChargesInfo
         {
             PidNo          = _trnLicense.PidNo,
             Mode           = _trnLicense.ChargeMode,
             SeqNo          = Guid.NewGuid().ToString("N").ToUpper(),
             CurrentMileage = _trnLicense.MileageLmt,
             CurrentMinutes = _trnLicense.TimeLmt,
             SurplusTimes   = _trnLicense.TriesLmt
         };
         _currentInfoControl.CallShowTrainerName(_trnLicense.Name);
         _currentInfoControl.CallShowTrainerPhoto(_trnLicense.Photo);
         _currentInfoControl.CallChangesShowInfo(_chargesDisplayInfo);
         IsChargingThread = true;
         Thread chargingThread = new Thread(ChargingThread);
         chargingThread.Start();
         return(true);
     }
     else
     {
         IsChargingThread = false;
         IsCharging       = false;
         _sw.WriteLine(DateTime.Now.ToLocalTime() + ":" + "许可信息无效,失效类型:" + _lincenseState);
         return(false);
     }
 }
Example #4
0
 /// <summary>
 /// Saves the charges information.
 /// </summary>
 /// <param name="info">The information.</param>
 /// <returns></returns>
 public static int SaveChargesInfo(ChargesInfo info)
 {
     if (info != null)
     {
         List <SQLiteParameter> cmdparams = new List <SQLiteParameter>
         {
             new SQLiteParameter("sfzmhm", info.PidNo),
             new SQLiteParameter("autoid", info.AutoId),
             new SQLiteParameter("starttime", info.StartTime),
             new SQLiteParameter("endtime", info.EndTime),
             new SQLiteParameter("mode", info.Mode),
             new SQLiteParameter("currentmileage", info.CurrentMileage),
             new SQLiteParameter("currentminutes", info.CurrentMinutes),
             new SQLiteParameter("surplustimes", info.SurplusTimes)
         };
         return(SqlLiteHelper.ExecuteNonQuery("insert into ChargeProcInfo (sfzmhm,autoid,starttime,endtime,mode,currentmileage,currentminutes,surplustimes) values (@sfzmhm,@autoid,@starttime,@endtime,@mode,@currentmileage,@currentminutes,@surplustimes)", cmdparams));
     }
     return(0);
 }