protected void btnCalcResult_Click(object sender, EventArgs e)
        {
            var ds = (SQLDataService)DataServiceProvider.DataService;

            if (ctrlBicycle.SelectedMasterPK != "")
            {
                var bicycle = new Bicycle();
                bicycle.SetExistObjectPrimaryKey(ctrlBicycle.SelectedMasterPK);
                ds.LoadObject(bicycle);

                var averageTime = Statistics.GetAverageRentTime(bicycle);
                lblResult.Text =
                    $"Средняя продолжительность проката: {averageTime.ToLongTimeString() }.";
            }
            else
            {
                WebMessageBox.Show("Выберите велосипед.");
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Закрывает сессию.
        /// </summary>
        public static void CloseSession(TransportSession session)
        {
            var ds = (SQLDataService)DataServiceProvider.DataService;

            session.FinishDate = DateTime.Now;
            session.State      = SessionState.Закрыта;
            ds.UpdateObject(session);

            var details = session.TransportSessionString.GetAllObjects();

            foreach (var d in details)
            {
                var bicycle = new Bicycle();
                bicycle.SetExistObjectPrimaryKey(((TransportSessionString)d).Bicycle.__PrimaryKey);
                ds.LoadObject(bicycle);
                bicycle.CurPoint = session.EndPoint;
                bicycle.IsFree   = true;
                ds.UpdateObject(bicycle);
            }
        }