Exemplo n.º 1
0
        private void Entrance(string cardId)
        {
            if (allCards.Contains(cardId))
            {
                var db1    = new CarCheckerContext();
                var userId = db1.Cards.FirstOrDefault(c => c.CardId == cardId).UserId;
                var user   = db1.Users.FirstOrDefault(u => u.Id == userId);
                KnownUser(cardId);

                if (!user.InGarage)
                {
                    if (CheckACar.GetCarSratus(cardId) >= 0)
                    {
                        OpenGate.Open(cardId);
                    }
                    else
                    {
                        errorLabel.Text = "Не уплачено!";
                    }
                }
                else
                {
                    errorLabel.Text = "Пользователь не выехал из гаража, но пытается вьехать";
                }
            }
            else
            {
                UnknownPerson();
            }
            RemoveAndFocus();
        }
Exemplo n.º 2
0
 private void Open(string cardId)
 {
     allCards = db.Cards.Select(c => c.CardId).ToList();
     UnknownPerson();
     if (allCards.Contains(cardId))
     {
         var db1    = new CarCheckerContext();
         var userId = db1.Cards.FirstOrDefault(c => c.CardId == cardId).UserId;
         var user   = db1.Users.FirstOrDefault(u => u.Id == userId);
         KnownUser(cardId);
         if (CheckACar.GetCarSratus(cardId) >= 0)
         {
             OpenGate.Open(cardId);
             UserEntrances.Add(cardId);
         }
         else
         {
             errorLabel.Text = "Не уплачено!";
         }
         //if (user.InGarage)
         //    OpenGate.Open(cardId);
         //else if (CheckACar.GetCarSratus(cardId) >= 0)
         //        OpenGate.Open(cardId);
         //    else
         //        errorLabel.Text = "Не уплачено!";
     }
     RemoveAndFocus();
 }
Exemplo n.º 3
0
        private void GetUserInfo()
        {
            var user = AllUserData.GetSelectedUser(garageComboBox.SelectedItem.ToString());

            nameLabel.Text    = user.Name;
            surnameLabel.Text = user.Surname;
            moneyLabel.Text   = CheckACar.GetCarStatus(Convert.ToInt32(garageComboBox.SelectedItem)).ToString();
        }
Exemplo n.º 4
0
        private void GetUserInfo()
        {
            var user = AllUserData.GetSelectedUser(garageComboBox.SelectedItem.ToString());

            nameTextBox.Text     = user.Name;
            surnameTextBox.Text  = user.Surname;
            balanceTextBox.Text  = CheckACar.GetCarStatus(Convert.ToInt32(garageComboBox.SelectedItem)).ToString();
            phoneTextBox.Text    = user.Phone;
            birthdayTextBox.Text = user.Birthday.ToShortDateString();

            string userStatus;

            if (user.InGarage)
            {
                userStatus = "В гараже";
            }
            else
            {
                userStatus = "Вне гаража";
            }
            statusTextBox.Text = userStatus;

            paymentsGridView.Rows.Clear();
            int i = 0;

            foreach (var payment in user.Payments)
            {
                paymentsGridView.Rows.Add();
                paymentsGridView.Rows[i].Cells[0].Value = payment.DateTime.Date.ToShortDateString();
                paymentsGridView.Rows[i].Cells[1].Value = payment.Sum;
                i++;
            }

            i = 0;
            cardsGridView.Rows.Clear();
            foreach (var card in user.Cards)
            {
                cardsGridView.Rows.Add();
                cardsGridView.Rows[i].Cells[0].Value = card.CardId;
                i++;
            }

            var dates = user.Entrances
                        .Select(en => en.EntranceDate)
                        .GroupBy(dt => dt)
                        .ToList()
            ;

            entrancesDataGrid.Rows.Clear();
            i = 0;
            foreach (var entrance in dates)
            {
                entrancesDataGrid.Rows.Add();
                entrancesDataGrid.Rows[i].Cells[0].Value = entrance.Key.Date.ToShortDateString();
                entrancesDataGrid.Rows[i].Cells[1].Value = entrance.Count();
                i++;
            }
        }