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 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 Извините за неудобства"); } }
private void UpdateIDs() { id_bk_or = DB.GetId("select top 1 * from OrdersBooks order by id desc"); }
private void UpdateIDs() { id_pr_or = DB.GetId("select top 1 * from OrdersProducts order by id desc"); }