//method to create a new Sag private void btn_OpretSag_Click(object sender, EventArgs e) { //Initializes SagBLL and SagDAL sag = new SagBLL(SagsStatus(), SagsBoligID(), SagsSælgerID(), SagsMæglerID()); try { if (!SagBLL.BoligExistsISag(SagsBoligID())) { //creates a new SagBLL in DB sag.OpretSag(sag); //retrieves Sags ID from DB SagBLL matchingsag = SagBLL.HentSag(sag); //show SagsID in TextBox sagID_txt.Text = matchingsag.SagsID.ToString(); } else { MessageBox.Show("Der findes allerede en sag med denne bolig ID. Vælg venligst en anden bolig."); } } catch (Exception ex) { MessageBox.Show(ex.Message); } //save SagsID in a string string sagsid = null; if (sagID_txt != null) { sagsid = sagID_txt.Text; } //if Sag is beign closed because a house has been sold if (sagStatus_cbox.SelectedItem.ToString() == "Lukket (solgt bolig)") { //user must create a new Handle MenuBarKnapper.HandlenCreate(sagsid); } //Loader data fra databasen ind i datagridview SagUI_Load(sender, e); //disable alle TextBoxes DisableAll(); }