private void btmSearchVarata_Click(object sender, EventArgs e) // New order { // Check date again, if user change data, and no do search if (!OrderUtils.CheckCottageBookDate(Convert.ToInt32(dgSearchTable.CurrentRow.Cells[0].Value), dtpSearchFROM.Text, dtpSearchTO.Text)) { btnSearchHae_Click(sender, e); return; } ConnectionUtils.OpenConnection(); MySqlCommand command = new MySqlCommand("SELECT toimintaalue_id FROM toimintaalue WHERE nimi Like '" + dgSearchTable.CurrentRow.Cells[1].Value.ToString() + "'", ConnectionUtils.connection); int toimintaalueid = Convert.ToInt32(command.ExecuteScalar().ToString()); // Make object to send on Booking window Cottage cottage = new Cottage(Convert.ToInt32(dgSearchTable.CurrentRow.Cells[0].Value), toimintaalueid, dgSearchTable.CurrentRow.Cells[2].Value.ToString(), dgSearchTable.CurrentRow.Cells[3].Value.ToString(), dgSearchTable.CurrentRow.Cells[4].Value.ToString(), dgSearchTable.CurrentRow.Cells[5].Value.ToString(), Convert.ToInt32(dgSearchTable.CurrentRow.Cells[6].Value.ToString()), dgSearchTable.CurrentRow.Cells[7].Value.ToString(), Convert.ToDouble(dgSearchTable.CurrentRow.Cells[8].Value.ToString())); ConnectionUtils.CloseConnection(); NewBook newbook = new NewBook(cottage, dtpSearchFROM.Value.Date, dtpSearchTO.Value.Date); Booking booking = new Booking(newbook); booking.ShowDialog(); }