Пример #1
0
 public DaySessionClass AccountDiscountMoney(DaySessionClass dsc)
 {
     List<clients_per_session_t> clientsOnSession = GetListOfClientsPerExactSession(dsc.Сессия);
     //-----------------------------------------------------------------------------------------------------------------------------------------------
     //--------------------------------------------Since client stoped play before timer, algorithm---------------------------------------------------
     //--------------------------------------------find the highest discount size and substract from end sum,-----------------------------------------
     //--------------------------------------------in order client do not get discount as change money------------------------------------------------
     //-----------------------------------------------------------------------------------------------------------------------------------------------
     if (clientsOnSession.Count >= 1)
     {
         double realDiscount = 0; //applied discount
         foreach (clients_per_session_t c in clientsOnSession)
         {
             var clientDiscount = GetClientInfoById(c.client_id).pers_discount;
             if (clientDiscount > realDiscount)
             {
                 realDiscount = (double) clientDiscount;
             }
         }
         double bonusMoney = ((dsc.Оплачено*realDiscount)/(100 + realDiscount));
         dsc.Оплачено = dsc.Оплачено - bonusMoney;
         if ((dsc.Счетчик) > (dsc.Оплачено - bonusMoney)) //if played less than was real paid money
         {
             dsc.Скидка_сессии = dsc.Счетчик - dsc.Оплачено - bonusMoney;
         }
         else if (dsc.Счетчик <= (dsc.Оплачено - bonusMoney))
         {
             dsc.Скидка_сессии = 0;
         }
     }
     return dsc;
     //-----------------------------------------------------------------------------------------------------------------------------------------------
     //-----------------------------------------------------------------------------------------------------------------------------------------------
     //-----------------------------------------------------------------------------------------------------------------------------------------------
 }
Пример #2
0
 public CheckoutPriceAndTime(int sessionId)
 {
     InitializeComponent();
     _sessionId = sessionId;
     _daySessionMyClass = DataBaseClass.Instancedb()
         .GetDaySessionMyClassBySessionId(sessionId, DataBaseClass.Instancedb().GetListOfAllClientsPerSessionT());
 }
 public void ReplaceClient(DaySessionClass sessionToReplace, string newPlaystation, string comments)
 {
     //            if (EndPointsControl.EndPointsControlInstance().SwitchOn(newPlaystation) &&
     //                EndPointsControl.EndPointsControlInstance().SwitchOff(sessionToReplace.Приставка))
     if (ChangePlst(newPlaystation, sessionToReplace.Приставка))
     {
         DataBaseClass.Instancedb().ChangePlaystation(sessionToReplace, newPlaystation, comments);
     }
 }
 //, List<clients_per_session_t> clientsPerSession)
 public void UpdatePrices(DaySessionClass sessionToUpdate)
 {
     //            TimeSpan timeToPlay = new TimeSpan();
     List<clients_per_session_t> clientsPerSession =
         DataBaseClass.Instancedb().GetListOfClientsPerExactSession(sessionToUpdate.Сессия);
     double sumToPlay =
         clientsPerSession.Select(t1 => DataBaseClass.Instancedb().GetClientSavingsById(t1.client_id))
             .Select(moneyOnCard => moneyOnCard.savings)
             .Sum();
     TimeSpan t = AddNewSessionModel.InstanceAddNewSessionModel()
         .GetTimeToPlay(sumToPlay, sessionToUpdate.Приставка, sessionToUpdate.Начало);
     //            MessageBox.Show("new sum to play = " + sumToPlay + "\nnew time to play = " + t);
     DataBaseClass.Instancedb().ExtendGameTimeWithClientWithDiscountCard(sessionToUpdate, t, sumToPlay);
 }
Пример #5
0
        private void CloseClientWithDiscount(DaySessionClass sessionToClose, string comments, DateTime endTime)
        {
            //sessionToClose = DataBaseClass.Instancedb().AccountDiscountMoney(sessionToClose);
            //double changeMoney = Math.Ceiling(GetOddMoney(sessionToClose),0);
            //if (changeMoney > 1)
            //{
            //    DialogResult dresult =
            //        MessageBox.Show(
            //            @" " + changeMoney +
            //            ErrorsAndWarningsMessages.ErrorsAndWarningsInstance().GetWarning(7),
            //            ErrorsAndWarningsMessages.ErrorsAndWarningsInstance().GetCaption(2), MessageBoxButtons.YesNo,
            //            MessageBoxIcon.Warning);
            //    switch (dresult)
            //    {
            //        case DialogResult.Yes:
            //            comments += ". " + changeMoney +
            //                        ErrorsAndWarningsMessages.ErrorsAndWarningsInstance().GetWarning(8);
            //            sessionToClose.Оплачено = sessionToClose.Оплачено - changeMoney;
            //            sessionToClose.Счетчик -= changeMoney;
            //            DataBaseClass.Instancedb().AddMoneyToCash(changeMoney * (-1));

            //            break;
            //        case DialogResult.No:
            //            DataBaseClass.Instancedb().CloseSessionWithCard(sessionToClose, comments, endTime);
            //            break;
            //    }
            //}
            //else */DataBaseClass.Instancedb().CloseSessionWithCard(sessionToClose, comments, endTime);

            DataBaseClass.Instancedb().CloseSessionWithCard(sessionToClose, comments, endTime);
            //---------------------------------------------------------------------------------------------------------------------------
            //---------------------------------------------------------------------------------------------------------------------------
            //--------------------------------------When client will be able to store money on card--------------------------------------
            //---------------------------------------------------------------------------------------------------------------------------
            //---------------------------------------------------------------------------------------------------------------------------
            //---------------------------------------------------------------------------------------------------------------------------
            //DataBaseClass.Instancedb().CloseSessionWithCard(sessionToClose, comments, endTime);
            //---------------------------------------------------------------------------------------------------------------------------
            //---------------------------------------------------------------------------------------------------------------------------
            //---------------------------------------------------------------------------------------------------------------------------
            //---------------------------------------------------------------------------------------------------------------------------
            //---------------------------------------------------------------------------------------------------------------------------
        }
Пример #6
0
        public void CloseClientBeforeTimeOut(DaySessionClass sessionToClose, List<clients_per_session_t> clientOnSession, DateTime closeTime, string comments)
        {
            if (clientOnSession.Count > 0)
            {
                if (EndPointsControl.EndPointsControlInstance().SwitchOff(sessionToClose.Приставка))
                {

                    if (clientOnSession.Count == 1 && clientOnSession[0].client_id.Equals(Options.OptionsInstance().UsualClient))
                    {
                        CloseUsualClient(sessionToClose, comments, closeTime);
                    }
                    else if (clientOnSession.Count >= 1 && !clientOnSession[0].client_id.Equals(Options.OptionsInstance().UsualClient))
                        //with discount card
                    {
                        CloseClientWithDiscount(sessionToClose, comments, closeTime);
                    }
                }
            }
            else
            {
                MessageBox.Show(ErrorsAndWarningsMessages.ErrorsAndWarningsInstance().GetError(14) +
                                sessionToClose.Сессия);
            }
        }
 public void ExtendTimeForSession(DaySessionClass sessionToExtend, int hoursToExtend, int minutesToExtend,
     double moneyToExtend)
 {
     TimeSpan t = TimeSpan.FromHours(hoursToExtend).Add(TimeSpan.FromMinutes(minutesToExtend));
     DataBaseClass.Instancedb().ExtendGameTimeWithUsualClient(sessionToExtend, t, moneyToExtend);
 }
Пример #8
0
 public CloseSessionForm(DaySessionClass sessionToClose)
 {
     _sessionToClose = sessionToClose;
     InitializeComponent();
 }
Пример #9
0
        //substract one hour from game if client was playing lower than one hour
        //private double GetOddMoney(DaySessionClass sessionToCalculate)
        //    //substract one hour from game if client was playing lower than one hour
        //{
        //    double moneyPlayed = sessionToCalculate.Счетчик;
        //    double oneHourPrice = AddNewSessionModel.InstanceAddNewSessionModel()
        //        .GetSumToPay(sessionToCalculate.Приставка, TimeSpan.FromHours(1), sessionToCalculate.Начало);
        //    if (moneyPlayed <= oneHourPrice && (sessionToCalculate.Оплачено - oneHourPrice) <= 0)
        //    {
        //        return 0;
        //    }
        //    if (moneyPlayed <= oneHourPrice && (sessionToCalculate.Оплачено - oneHourPrice) > 1)
        //    {
        //        return sessionToCalculate.Оплачено - oneHourPrice;
        //    }
        //    if (moneyPlayed > oneHourPrice)
        //    {
        //        return sessionToCalculate.Счетчик;
        //            //sessionToCalculate.Оплачено - sessionToCalculate.Счетчик;
        //    }
        //    return 0;
        //}
        private double GetOddMoney(DaySessionClass sessionToCalculate)
        {
            double moneyPlayed = sessionToCalculate.Счетчик;
            //double oneHourPrice = AddNewSessionModel.InstanceAddNewSessionModel()
                //.GetSumToPay(sessionToCalculate.Приставка, TimeSpan.FromHours(1), sessionToCalculate.Начало);
            if (moneyPlayed <= sessionToCalculate.Оплачено)
            {
                if (sessionToCalculate.Оплачено - moneyPlayed <= 0)
                    return 0;

                return sessionToCalculate.Оплачено - moneyPlayed;
            }
            if (moneyPlayed > sessionToCalculate.Оплачено)
            {
                return 0;
            }
            return 0;
        }
Пример #10
0
 private void CloseUsualClientLightCutOff(DaySessionClass sessionToClose, string comments, DateTime endTime)
 {
     double changeMoney = Math.Ceiling(GetOddMoney(sessionToClose));
     if (changeMoney > 1)
     {
         DialogResult dresult =
             MessageBox.Show(
                 @" " + changeMoney +
                 ErrorsAndWarningsMessages.ErrorsAndWarningsInstance().GetWarning(7),
                 ErrorsAndWarningsMessages.ErrorsAndWarningsInstance().GetCaption(2), MessageBoxButtons.YesNo,
                 MessageBoxIcon.Warning);
         switch (dresult)
         {
             case DialogResult.Yes:
                 comments += ". " + changeMoney +
                             ErrorsAndWarningsMessages.ErrorsAndWarningsInstance().GetWarning(8);
                 sessionToClose.Оплачено = sessionToClose.Оплачено - changeMoney;
                 //                        sessionToClose.Счетчик -= changeMoney;
                 DataBaseClass.Instancedb()
                     .AddMoneyToCash(changeMoney*(-1),
                         DataBaseClass.Instancedb().GetOpenedGlobalSession().daily_id);
                 DataBaseClass.Instancedb().CloseSessionWithUsualClient(sessionToClose, comments, endTime);
                 break;
             case DialogResult.No:
                 DataBaseClass.Instancedb().CloseSessionWithUsualClient(sessionToClose, comments, endTime);
                 break;
         }
     }
     else
         DataBaseClass.Instancedb().CloseSessionWithUsualClient(sessionToClose, comments, endTime);
 }
Пример #11
0
 public void ExtendGameTimeWithUsualClient(DaySessionClass sessionToExtend, TimeSpan timeToExtend,
     double moneyToExtend)
 {
     var db = new dbDataContext();
     lock (db)
     {
         var session = (from d in db.GetTable<days_sessions_t>()
             where d.session_id == sessionToExtend.Сессия
             select d).SingleOrDefault();
         if (session != null)
         {
             session.end_game += timeToExtend;
             session.payed_sum += moneyToExtend;
             if (String.IsNullOrWhiteSpace(session.comments))
             {
                 session.comments = "Доплачено на" + timeToExtend + " и " + moneyToExtend + " сом.";
             }
             else
             {
                 session.comments += "\n" + "Доплачено на" + timeToExtend + " " + moneyToExtend + " сом.";
             }
             try
             {
                 db.SubmitChanges();
             }
             catch (Exception)
             {
                 MessageBox.Show(ErrorsAndWarningsMessages.ErrorsAndWarningsInstance().GetError(5));
             }
         }
     }
 }
Пример #12
0
 public ChangePlaystation(DaySessionClass sessionToReplace, double playedMoney)
 {
     InitializeComponent();
     _ds = sessionToReplace;
     _ds.Счетчик = playedMoney;
 }
Пример #13
0
        public List<DaySessionClass> CloseSessionBeforeTimer(DaySessionClass sessionToClose)
        {
            var csf = new CloseSessionForm(sessionToClose);
            csf.ShowDialog();
            return GetAllOpenedDaySessions();
            //            int dailyId = DataBaseClass.Instancedb().GetLastOpenedGlobalSessionDailyId();
            //            var selectedSession = DataBaseClass.Instancedb().GetDaySessionBySessionId(sessionToClose.Сессия, dailyId);
            //            if (selectedSession != null)
            //            {

            //                selectedSession.money_left = (double)dataGridViewDaysSession.CurrentRow.Cells[6].Value;
            //                _db.SubmitChanges();
            //            }
            //            var withDiscountCard = (from w in _db.clients_per_session_ts
            //                                    where w.session_id == selectedSessionId
            //                                    select w.client_id).ToList();
        }
Пример #14
0
        public void CloseSessionWithUsualClient(DaySessionClass dsc, string comments, DateTime endTime)
        {
            var db = new dbDataContext();
            lock (db)
            {
                int dayId = GetOpenedGlobalSession().daily_id;
                var sessionIdtoDelete = (from s in db.GetTable<days_sessions_t>()
                    where s.daily_id == dayId
                    where s.session_id == dsc.Сессия
                    select s).SingleOrDefault();
                if (sessionIdtoDelete == null) return;

                sessionIdtoDelete.end_game = endTime;
                sessionIdtoDelete.session_state = "closed";

            //                if (endTime - dsc.Начало < TimeSpan.FromHours(1))
            //                {
            //                    dsc.Счетчик = dsc.Оплачено - dsc.Счетчик;
            //                }
                sessionIdtoDelete.payed_sum = dsc.Оплачено;
                sessionIdtoDelete.played_money = dsc.Счетчик;
                if (String.IsNullOrWhiteSpace(sessionIdtoDelete.comments))
                {
                    sessionIdtoDelete.comments = comments;
                }
                else
                {
                    sessionIdtoDelete.comments += "\n" + comments;
                }
                UpdatePlaystationState(dsc.Приставка, "free");
                while (true)
                {
                    try
                    {
                        db.SubmitChanges();
                        break;
                    }
                    catch
                    {
                        MessageBox.Show(
                            ErrorsAndWarningsMessages.ErrorsAndWarningsInstance().GetError(3));
                    }
                }
            }
        }
Пример #15
0
        public void ChangePlaystation(DaySessionClass ds, string newPlaystation, string comments)
        {
            var db = new dbDataContext();
            lock (db)
            {
                DateTime curTime = DateTime.Now;
                for (int i = 0; i < 5; i++)
                {
                    try
                    {
                        var matchDs = (from os in db.GetTable<days_sessions_t>()
                            where os.session_id == ds.Сессия
                            select os).SingleOrDefault();
                        if (matchDs != null)
                        {
                            UpdatePlaystationState(matchDs.playstation_id, "free");
                            db.SubmitChanges();
                            matchDs.playstation_id = newPlaystation;
                            decimal moneyLeftFromLastGame = (decimal) (matchDs.payed_sum - ds.Счетчик);
                            TimeSpan paidTime =
                                AddNewSessionController.AddNewSessionControllerInstance()
                                    .UpdateTimeLeft(moneyLeftFromLastGame, newPlaystation, 0, 18900, DateTime.Now);
                            if (matchDs.start_game != null && matchDs.end_game != null)
                                matchDs.end_game = curTime.Add(paidTime);
                            if (String.IsNullOrWhiteSpace(matchDs.comments))
                            {
                                matchDs.comments = "Пересел с " + ds.Приставка + " на " + newPlaystation + " " +
                                                   comments;
                            }
                            else
                            {
                                matchDs.comments += "\n" + "Пересел с " + ds.Приставка + " на " + newPlaystation + " " +
                                                    comments;
                            }
                            UpdatePlaystationState(newPlaystation, "busy");
                            //                    matchDs.session_discount += 5;// Discount because of replacing
                            //                    matchDs.end_game
                            db.SubmitChanges();
                            break;
                        }
                        MessageBox.Show(ErrorsAndWarningsMessages.ErrorsAndWarningsInstance().GetError(39));
                    }
                    catch (Exception)
                    {
                        if (i <= 0)
                        {
                            MessageBox.Show(ErrorsAndWarningsMessages.ErrorsAndWarningsInstance()
                                .GetErrorWithLine(1, 88));
                        }
                    }
                }

            }
        }
Пример #16
0
 public ExtendSessionTime(DaySessionClass sessionToExtend)
 {
     _sessionToExtend = sessionToExtend;
     InitializeComponent();
 }
Пример #17
0
 public void ExtendGameTimeWithClientWithDiscountCard(DaySessionClass sessionToExtend, TimeSpan timeOfgame,
     double moneyOnCard)
 {
     var db = new dbDataContext();
     lock (db)
     {
         var session = (from d in db.GetTable<days_sessions_t>()
             where d.session_id == sessionToExtend.Сессия
             select d).SingleOrDefault();
         if (session != null)
         {
             session.end_game = session.start_game + timeOfgame;
             session.payed_sum = moneyOnCard;
             try
             {
                 db.SubmitChanges();
             }
             catch (Exception)
             {
                 MessageBox.Show(ErrorsAndWarningsMessages.ErrorsAndWarningsInstance().GetError(5));
             }
         }
     }
 }