private void BtnAdd_Click(object sender, RoutedEventArgs e) { string msg = string.Empty; if (Equipment.getEquipId == null) { string query = "select top 1 id from as_bodenbelag order by id desc"; DataTable dt = DataConnection.GetData(query); int id = 1; if (dt != null && dt.Rows.Count == 1) { id = Convert.ToInt32(dt.Rows[0][0].ToString()) + 1; query = "insert into as_bodenbelag values('" + Application.Current.Properties["BuildingId"] + "','" + Application.Current.Properties["LevelId"] + "','" + Application.Current.Properties["CadId"] + "'," + id + ",'','" + cbBodenbelagtyp.SelectedValue + "'," + txtFlaeche.Text + ")"; msg = DataConnection.ExecuteQuery(query); } else if (dt != null && dt.Rows.Count >= 1) { int status = 0; for (int i = 0; i < dt.Rows.Count; i++) { if (dt.Rows[i][0].ToString() != "") { id = Convert.ToInt32(dt.Rows[0][0].ToString()) + 1; query = "insert into as_bodenbelag values('" + Application.Current.Properties["BuildingId"] + "','" + Application.Current.Properties["LevelId"] + "','" + Application.Current.Properties["CadId"] + "'," + id + ",'','" + cbBodenbelagtyp.SelectedValue + "'," + txtFlaeche.Text + ")"; msg = DataConnection.ExecuteQuery(query); status = 1; break; } } if (status == 0) { query = "insert into as_bodenbelag values('" + Application.Current.Properties["BuildingId"] + "','" + Application.Current.Properties["LevelId"] + "','" + Application.Current.Properties["CadId"] + "'," + id + ",'','" + cbBodenbelagtyp.SelectedValue + "'," + txtFlaeche.Text + ")"; msg = DataConnection.ExecuteQuery(query); } } else { query = "insert into as_bodenbelag values('" + Application.Current.Properties["BuildingId"] + "','" + Application.Current.Properties["LevelId"] + "','" + Application.Current.Properties["CadId"] + "'," + id + ",'','" + cbBodenbelagtyp.SelectedValue + "'," + txtFlaeche.Text + ")"; msg = DataConnection.ExecuteQuery(query); } //var myWindow = if (msg == "Executed") { query = "select top 1 id from as_bodenbelag order by id desc"; dt = DataConnection.GetData(query); if (dt != null && dt.Rows.Count > 0) { UpdateChildGetSet = true; SelectChildTypeValues = "EquipId " + dt.Rows[0][0].ToString() + ": " + "bodenbelag " + cbBodenbelagtyp.SelectedValue + "," + txtFlaeche.Text; Window.GetWindow(this).Close(); } } else { MessageBox.Show("Please select/enter correct input values"); } } else { string updatedcolumns = "bodenbelagstyp='" + cbBodenbelagtyp.SelectedValue + "' , flaeche='" + txtFlaeche.Text + "'"; msg = EquipmentData.UpdateEquipment("as_bodenbelag", updatedcolumns, Equipment.getEquipId); if (msg == "Executed") { UpdateChildGetSet = true; SelectChildTypeValues = "EquipId " + Equipment.getEquipId + ": " + "bodenbelag " + cbBodenbelagtyp.SelectedValue + "," + txtFlaeche.Text; Window.GetWindow(this).Close(); } else { MessageBox.Show("Please select/enter correct input values"); } } }