Пример #1
0
        private async void btnRegister_Click(object sender, EventArgs e)
        {
            string name            = txtRgsName.Text.Trim();
            string surname         = txtRgsSurname.Text.Trim();
            string password        = txtRgsPass.Text.Trim();
            string password_repeat = txtRgsRepeatPass.Text.Trim();
            string email           = txtRgsEmail.Text.Trim();

            if (CheckRegisteration(name, surname, password, password_repeat, email))
            {
                string hashPassword = Helpers.HashPassword(password);

                User usr = new User()
                {
                    Name     = name,
                    Surname  = surname,
                    Password = hashPassword,
                    Email    = email
                };

                db.Users.Add(usr);

                await db.SaveChangesAsync();

                MessageBox.Show("Registration is successfully, please wait confirmation", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Пример #2
0
        private async void btnSell_Click(object sender, EventArgs e)
        {
            DateTime date  = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day);
            decimal  total = decimal.Parse(lblTotal.Text);

            Order order = new Order()
            {
                Total = total, OrderTime = date, UserId = _user.Id
            };

            foreach (ListClass book in lbCellBooks.Items)
            {
                order.OrderBooks.Add(new OrderBook {
                    BookId = book.Id, OrdersId = order.Id, Count = book.Count
                });
            }

            db.Orders.Add(order);
            await db.SaveChangesAsync();

            foreach (ListClass book in lbCellBooks.Items)
            {
                DecrimentBookCount(book);
            }

            MessageBox.Show("Order succesfully generated !");

            lbCellBooks.Items.Clear();
            lblTotal.Text = "0";
            CmbAndDgvRefresh();
        }
Пример #3
0
        private async void dgvUsers_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            int id = (int)dgvUsers.Rows[e.RowIndex].Cells[0].Value;

            User usr = db.Users.Find(id);

            DialogResult result = MessageBox.Show($"Are you sure confirm {usr.Name} {usr.Surname} ?", "Information"
                                                  , MessageBoxButtons.YesNo, MessageBoxIcon.Information);

            if (result == DialogResult.Yes)
            {
                usr.Status = true;
            }
            else
            {
                usr.Deleted = true;
            }
            await db.SaveChangesAsync();

            NewUserButtonText();
            DgvNewUser();
        }