protected bool IsAllReserved() { List<DatabaseLibrary.Copy> copies = new DatabaseLibrary.CopyTable().SelectAllPresentByBook((Convert.ToInt32(dropDownList_book_id.SelectedValue))); int count = copies.Count(); if (count == 0) { return true; } else return false; }
protected void Button1_Click(object sender, EventArgs e) { //prida do Borrowing + update copy try { DatabaseLibrary.Borrowing bor = new DatabaseLibrary.Borrowing(); string borrowing_from = TextBox_borrowing_from.Text; string[] items = borrowing_from.Split('/'); DateTime borrowing_from_toDB = new DateTime(Int32.Parse(items[2]), Int32.Parse(items[1]), Int32.Parse(items[0])); string borrowing_to = TextBox_borrowing_to.Text; string[] items2 = borrowing_to.Split('/'); DateTime borrowing_to_toDB = new DateTime(Int32.Parse(items2[2]), Int32.Parse(items2[1]), Int32.Parse(items2[0])); bor.borrowing_from = borrowing_from_toDB; bor.borrowing_to = borrowing_to_toDB; bor.borrowing_is_returned = false; bor.client_id = Convert.ToInt32(DropDownList_borrowing_client_id.SelectedValue); bor.copy_id = Convert.ToInt32(DropDownList_borrowing_copy_id.SelectedValue); new DatabaseLibrary.BorrowingTable().Insert(bor); DatabaseLibrary.CopyTable copyTable = new DatabaseLibrary.CopyTable(); DatabaseLibrary.Copy copy = copyTable.SelectOne(bor.copy_id); copy.copy_is_present = 0; copyTable.Update(copy); //z neznameho duvodu nejde Label1.Text = "Výpůjčka byla zapsána"; Console.WriteLine("oukej"); } catch (Exception ex) { Label1.Text = "chybka"; Console.WriteLine("chybka"); } Response.Redirect(Request.RawUrl); }