Example #1
0
        private void GarageComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            var user = AllUserData.GetSelectedUser(garageComboBox.SelectedItem.ToString());

            nameLabel.Text    = "Name: " + user.Name;
            surnameLabel.Text = "Surname: " + user.Surname;
        }
Example #2
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();
        }
Example #3
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++;
            }
        }
Example #4
0
 private void KnownUser(AllUserData user)
 {
     nameLabel.Text     = user.User.Name;
     surnameLabel.Text  = user.User.Surname;
     garageLabel.Text   = user.User.GarageNumber.ToString();
     phoneLabel.Text    = user.User.Phone;
     ballanceLabel.Text = user.User.Balance.ToString();
     errorLabel.Text    = "";
 }
Example #5
0
 public IHttpActionResult AddUser([FromBody] AllUserData allData)
 {
     if (Users.Add(allData.User, allData.Card.CardId))
     {
         return(Ok());
     }
     else
     {
         return(InternalServerError());
     }
 }
Example #6
0
        public static AllUserData ShowUserByCardId(string card)
        {
            var db    = new CarCheckerContext();
            var users = db.Cards.Include(c => c.User).ToList();

            var user = new AllUserData
            {
                User = GetUserByCard(card),
                Card = db.Cards.FirstOrDefault(c => c.CardId == card)
            };

            return(user);
        }
Example #7
0
        public static string AddCardToUser(User user, string cardId)
        {
            var allAboutUser = new AllUserData()
            {
                Card = new RFIDCard()
                {
                    CardId = cardId
                },
                User = user
            };

            using (var client = new HttpClient())
            {
                var response = client.PostAsJsonAsync($"{APP_PATH}/users/AddCardToUser", allAboutUser).Result;
                return(response.StatusCode.ToString());
            }
        }
Example #8
0
 private void AddCardButton_Click(object sender, EventArgs e)
 {
     try
     {
         var user = AllUserData.GetSelectedUser(garageComboBox.SelectedItem.ToString());
         AddUser.AddCardToUser(user, CardTextBox.Text);
         DialogResult result = MessageBox.Show("Успех!", "Успех!", MessageBoxButtons.OK);
         if (result == DialogResult.OK)
         {
             Close();
         }
     }
     catch (Exception)
     {
         DialogResult result = MessageBox.Show("Ошибка!", "Ошибка!", MessageBoxButtons.OK);
     }
 }
Example #9
0
 private void makePaymentButton_Click(object sender, EventArgs e)
 {
     try
     {
         var user = AllUserData.GetSelectedUser(garageComboBox.SelectedItem.ToString());
         BussinesLogic.Payment.Pay(user, Convert.ToDouble(payTextBox.Text));
         DialogResult result = MessageBox.Show("Успех!", "Успех!", MessageBoxButtons.OK);
         if (result == DialogResult.OK)
         {
             Close();
         }
     }
     catch (Exception)
     {
         DialogResult result = MessageBox.Show("Ошибка!", "Ошибка!", MessageBoxButtons.OK);
     }
     finally
     {
         GetUserInfo();
     }
 }
Example #10
0
        private void garageComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            var user = AllUserData.GetSelectedUser(garageComboBox.SelectedItem.ToString());

            nameLabel.Text    = user.Name;
            surnameLabel.Text = user.Surname;

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

            entrancesDataGrid.Rows.Clear();
            int 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++;
            }
        }
Example #11
0
 public IHttpActionResult AddCardToUser(AllUserData allData)
 {
     Users.AddCardToUser(allData.User, allData.Card.CardId);
     return(Ok());
 }
Example #12
0
 public User GetUserByGarage(string id) => AllUserData.GetSelectedUser(id);
 public ActionResult GetInfo(string cardnumber)
 {
     return(View(AllUserData.GetSelectedUser(cardnumber)));
 }