private void Delete_Click(object sender, RoutedEventArgs e)
 {
     if (DB.Command($"delete from Authors where [full_name]='{Name.Text}'"))
     {
         SetAuthors();
     }
 }
Exemplo n.º 2
0
 private void Delete_Click(object sender, RoutedEventArgs e)
 {
     if (DB.Command($"delete from BookCategories where [name]='{Name.Text}'"))
     {
         SetCategories();
     }
 }
 private void Add_Click(object sender, RoutedEventArgs e)
 {
     if (DB.Command($"insert into Authors values('{Name.Text}')"))
     {
         SetAuthors();
     }
 }
Exemplo n.º 4
0
 private void Add_Click(object sender, RoutedEventArgs e)
 {
     if (DB.Command($"insert into BookCategories values('{Name.Text}')"))
     {
         SetCategories();
     }
 }
Exemplo n.º 5
0
 private void Delete_Click(object sender, RoutedEventArgs e)
 {
     if (DB.Command($"delete from Products where [name]='{Name.Text}'"))
     {
         SetProducts();
     }
 }
Exemplo n.º 6
0
        private void Add_Click(object sender, RoutedEventArgs e)
        {
            int category_id = DB.GetId($"select id from Categories where [name] = '{Categories.SelectedItem}'");

            if (DB.Command($"insert into Products values({category_id}, '{Name.Text}', '{Description.Text}', {Price.Text}, {Amount.Text})"))
            {
                SetProducts();
            }
        }
        private void Add_Click(object sender, RoutedEventArgs e)
        {
            int category_id = DB.GetId($"select id from BookCategories where [name] = '{Categories.SelectedItem}'");
            int author_id   = DB.GetId($"select id from Authors where [full_name]='{Author.SelectedItem}'");

            if (DB.Command($"insert into Books values({category_id}, {author_id}, '{Name.Text}', '{Description.Text}', {Price.Text}, {Amount.Text})"))
            {
                SetBooks();
            }
        }
        private void Exit_Click(object sender, RoutedEventArgs e)
        {
            foreach (OrderProduct product in cart_items)
            {
                DB.Command($"Update Books set amount=amount+1 where id = {product.BookId}");
            }
            LoginWindow login = new LoginWindow();

            login.Show();
            Close();
        }
 private void Confirm_Click(object sender, RoutedEventArgs e)
 {
     if (ID.Text.Length > 0 && NewPrice.Text.Length > 0)
     {
         if (DB.Command($"Update Books set price={NewPrice.Text} where id={ID.Text}"))
         {
             MessageBox.Show("Успешно обновалено");
             SetBooks();
         }
     }
 }
        private void Delete_Click(object sender, RoutedEventArgs e)
        {
            string        id   = IDDelete.Text;
            List <string> dt   = DB.GetDataOneAttribute($"select id_book from OrdersBooks where number={id}", "id_book");
            List <string> book = DB.GetDataOneAttribute($"select price from Books where id = {dt[0]}", "price");

            if (DB.Command($"delete from OrdersBooks where number = {id}"))
            {
                SetAllInOrder();
                DB.Command($"update Orders set result-={ChangeComa(book[0])} where id = {id_order}");
            }
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            DataTable find = DB.Select($"select * from [Users] where login='******' and password='******'");

            if (find.Rows.Count > 0)
            {
                MessageBox.Show("Пользователь с таким именем уже существует");
            }
            else
            {
                if (RegexLogin(LoginBox.Text))
                {
                    if (RegexPassword(Password.Password))
                    {
                        if (RepeatPassword.Password.Equals(Password.Password))
                        {
                            try
                            {
                                DB.Command($"insert into [Users] values('{LoginBox.Text}', '{Password.Password}')");
                                MessageBox.Show("Успешно создан");
                                UserWindow uw = new UserWindow();
                                uw.Show();
                                Close();
                            }
                            catch (Exception error)
                            {
                                MessageBox.Show(error.Message);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Пароли не совпадают");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Пароль обязан быть 8-20 символовв");
                    }
                }
                else
                {
                    MessageBox.Show("Логин обязан быть 4-15 символов");
                }
            }
        }
        private void AddBook_Click(object sender, RoutedEventArgs e)
        {
            Book      selected = (Book)AllBooks.SelectedItem;
            DataTable dt       = DB.Select($"select amount from Books where id={selected.ID}");
            int       amount   = Convert.ToInt32(dt.Rows[0]["amount"]);

            if (amount - 1 > 0)
            {
                if (first)
                {
                    if (DB.Command($"insert into Orders values({DB.UserID}, (select convert(varchar(10),(select getdate()), 120)), 0)"))
                    {
                        first    = false;
                        id_order = DB.GetId($"select top 1 * from Orders where id_user = {DB.UserID} order by id desc");
                    }
                    else
                    {
                        MessageBox.Show("У нас неполадки в системе попробуйте позже");
                        return;
                    }
                }
                if (DB.Command($"insert into OrdersBooks values({id_bk_or + 1}, {id_order}, {selected.ID})"))
                {
                    DB.Command($"Update Books set amount=amount-1 where id={selected.ID}");
                    SetAllInOrder();
                    UpdateIDs();
                    DB.Command($"update Orders set result+={ChangeComa(selected.Price)} where id = {id_order}");
                }
                else
                {
                    MessageBox.Show("Что-то пошло не так попробуйте позже");
                }
            }
            else
            {
                MessageBox.Show("Этой книги на складе больше не осталось \n Извините за неудобства");
            }
        }