private void BtnDeleteRoom_Click(object sender, RoutedEventArgs e) { if (lbDisplayRooms.SelectedItem != null) { string msg = " Are you sure want to delete room?"; MessageBoxResult result = MessageBox.Show( msg, "", MessageBoxButton.YesNo, MessageBoxImage.Warning); if (result == MessageBoxResult.Yes) { // If user doesn't want to close, cancel closure string query = "delete from kl_raum where geb_id=" + lbDisplayBuilding.SelectedItem + " and geschoss_id='" + lbDisplayLevels.SelectedValue + "' and cad_id='" + lbDisplayRooms.SelectedItem + "'"; msg = DataConnection.ExecuteQuery(query); if (msg == "Executed") { MessageBox.Show("Successfully deleted"); } FillRoomsByLevelAndBuilding(); } } else { MessageBox.Show("Select room id"); } }
public static string DeleteEquipment(string table, string equipId) { string msg = string.Empty; string query = "delete from " + table + " where id=" + equipId + " and gebaeude_id=" + Application.Current.Properties["BuildingId"] + " and geschoss_id='" + Application.Current.Properties["LevelId"] + "' and raum_id='" + Application.Current.Properties["CadId"] + "'"; msg = DataConnection.ExecuteQuery(query); return(msg); }
private void BtnAdd_Click(object sender, RoutedEventArgs e) { string query = "insert into kl_gebaeude values('" + txtBuildingId.Text + "','')"; DataConnection.ExecuteQuery(query); UpdateGetSet = true; this.Close(); }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { if (RoomAddOrEdit == "NewRoom") { string msg = " Are you sure want to close without saving?"; MessageBoxResult result = MessageBox.Show( msg, "", MessageBoxButton.YesNo, MessageBoxImage.Warning); if (result == MessageBoxResult.No) { // If user doesn't want to close, cancel closure e.Cancel = true; } else { string query = "delete from as_bodenbelag where gebaeude_id=" + Application.Current.Properties["BuildingId"] + " and geschoss_id='" + Application.Current.Properties["LevelId"] + "' and raum_id='" + Application.Current.Properties["RaumId"] + "'"; DataConnection.ExecuteQuery(query); query = "delete from as_fenster where gebaeude_id=" + Application.Current.Properties["BuildingId"] + " and geschoss_id='" + Application.Current.Properties["LevelId"] + "' and raum_id='" + Application.Current.Properties["RaumId"] + "'"; DataConnection.ExecuteQuery(query); query = "delete from as_feuerloescher where gebaeude_id=" + Application.Current.Properties["BuildingId"] + " and geschoss_id='" + Application.Current.Properties["LevelId"] + "' and raum_id='" + Application.Current.Properties["RaumId"] + "'"; DataConnection.ExecuteQuery(query); query = "delete from [as_glasbau-element] where gebaeude_id=" + Application.Current.Properties["BuildingId"] + " and geschoss_id='" + Application.Current.Properties["LevelId"] + "' and raum_id='" + Application.Current.Properties["RaumId"] + "'"; DataConnection.ExecuteQuery(query); query = "delete from as_leuchte where gebaeude_id=" + Application.Current.Properties["BuildingId"] + " and geschoss_id='" + Application.Current.Properties["LevelId"] + "' and raum_id='" + Application.Current.Properties["RaumId"] + "'"; DataConnection.ExecuteQuery(query); query = "delete from as_oberlicht where gebaeude_id=" + Application.Current.Properties["BuildingId"] + " and geschoss_id='" + Application.Current.Properties["LevelId"] + "' and raum_id='" + Application.Current.Properties["RaumId"] + "'"; DataConnection.ExecuteQuery(query); query = "delete from as_sonnenschutz where gebaeude_id=" + Application.Current.Properties["BuildingId"] + " and geschoss_id='" + Application.Current.Properties["LevelId"] + "' and raum_id='" + Application.Current.Properties["RaumId"] + "'"; DataConnection.ExecuteQuery(query); query = "delete from as_tor where gebaeude_id=" + Application.Current.Properties["BuildingId"] + " and geschoss_id='" + Application.Current.Properties["LevelId"] + "' and raum_id='" + Application.Current.Properties["RaumId"] + "'"; DataConnection.ExecuteQuery(query); query = "delete from as_tuer where gebaeude_id=" + Application.Current.Properties["BuildingId"] + " and geschoss_id='" + Application.Current.Properties["LevelId"] + "' and raum_id='" + Application.Current.Properties["RaumId"] + "'"; DataConnection.ExecuteQuery(query); } } }
private void BtnAdd_Click(object sender, RoutedEventArgs e) { string msg = string.Empty; if (Equipment.getEquipId == null) { string query = "select top 1 id from as_sonnenschutz order by id desc"; DataTable dt = DataConnection.GetData(query); int id = 1; if (dt != null && dt.Rows.Count > 0) { if (dt.Rows[0][0].ToString() != "") { id = Convert.ToInt32(dt.Rows[0][0].ToString()) + 1; } query = "insert into as_sonnenschutz values(" + Application.Current.Properties["BuildingId"] + ",'" + Application.Current.Properties["LevelId"] + "','" + Application.Current.Properties["CadId"] + "'," + id + ",'','" + cbtype.SelectedValue + "','" + cbLage.SelectedValue + "')"; 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_sonnenschutz values('" + Application.Current.Properties["BuildingId"] + "','" + Application.Current.Properties["LevelId"] + "','" + Application.Current.Properties["CadId"] + "'," + id + ",'','" + cbtype.SelectedValue + "','" + cbLage.SelectedValue + "')"; msg = DataConnection.ExecuteQuery(query); status = 1; break; } } if (status == 0) { query = "insert into as_sonnenschutz values('" + Application.Current.Properties["BuildingId"] + "','" + Application.Current.Properties["LevelId"] + "','" + Application.Current.Properties["CadId"] + "'," + id + ",'','" + cbtype.SelectedValue + "','" + cbLage.SelectedValue + "')"; msg = DataConnection.ExecuteQuery(query); } } else { query = "insert into as_sonnenschutz values('" + Application.Current.Properties["BuildingId"] + "','" + Application.Current.Properties["LevelId"] + "','" + Application.Current.Properties["CadId"] + "'," + id + ",'','" + cbtype.SelectedValue + "','" + cbLage.SelectedValue + "')"; msg = DataConnection.ExecuteQuery(query); } if (msg == "Executed") { query = "select top 1 id from as_sonnenschutz order by id desc"; dt = DataConnection.GetData(query); if (dt != null && dt.Rows.Count > 0) { UpdateChildGetSet = true; SelectChildTypeValues = "EquipId " + dt.Rows[0][0].ToString() + ": " + "sonnenschutz " + cbtype.SelectedValue + "," + cbLage.SelectedValue; //var myWindow = Window.GetWindow(this).Close(); } } else { MessageBox.Show("Please enter correct input values"); } } else { string updatedcolumns = "sonnenschutztyp='" + cbtype.SelectedValue + "' , lage='" + cbLage.SelectedValue + "'"; msg = EquipmentData.UpdateEquipment("as_sonnenschutz", updatedcolumns, Equipment.getEquipId); if (msg == "Executed") { UpdateChildGetSet = true; SelectChildTypeValues = "EquipId " + Equipment.getEquipId + ": " + "sonnenschutz " + cbtype.SelectedValue + "," + cbLage.SelectedValue; Window.GetWindow(this).Close(); } else { MessageBox.Show("Please enter correct input values"); } } }
private void Btnsaveandclose_Click(object sender, RoutedEventArgs e) { string gasabsperrsch = "N"; string heizungabsperr = "N"; string Hydrant = "N"; string schukostdose = "N"; string sprinkler = "N"; string telnetzdose = "N"; string wasserabsperr = "N"; if (chkgasabsperrsch.IsChecked == true) { gasabsperrsch = "Y"; } if (chkheizungabsperr.IsChecked == true) { heizungabsperr = "Y"; } if (chkHydrant.IsChecked == true) { Hydrant = "Y"; } if (chkschukostdose.IsChecked == true) { schukostdose = "Y"; } if (chksprinkler.IsChecked == true) { sprinkler = "Y"; } if (chktelnetzdose.IsChecked == true) { telnetzdose = "Y"; } if (chkwasserabsperr.IsChecked == true) { wasserabsperr = "Y"; } if (EditRoomId == 0) { int id = 1; string query = "select top 1 id from kl_raum order by id desc"; DataTable dt = DataConnection.GetData(query); if (dt != null && dt.Rows.Count > 0) { if (dt.Rows[0][0].ToString() != "") { id = Int32.Parse(dt.Rows[0][0].ToString()) + 1; } } query = "insert into kl_raum values(" + id + "," + Building + ",'" + Level + "','" + CadId + "','" + txtraum.Text + "','" + Bezeichnug + "','" + Max + "','" + IST + "'," + txtflaeche.Text + "," + txtLichte.Text + "," + txtAnzap.Text + "," + txtAnzma.Text + ",'" + cbzustand.SelectionBoxItem + "','" + txtbemerku.Text + "'," + txtumfang.Text + "," + chkschukostdose.IsChecked + "," + txtanzheizho.Text + "," + chktelnetzdose.IsChecked + "," + txtanzpatchsc.Text + "," + chksprinkler.IsChecked + "," + chkgasabsperrsch.IsChecked + "," + chkwasserabsperr.IsChecked + "," + chkheizungabsperr.IsChecked + "," + chkHydrant.IsChecked + ")"; string msg = DataConnection.ExecuteQuery(query); if (msg == "Executed") { RoomAddOrEdit = ""; saveStatus = "yes"; MessageBox.Show("Saved Successfully"); Info = "Raum-Nr:" + txtraum.Text + "\n" + "Flaeche:" + txtflaeche.Text + " m\u00b2" + "\n" + "Lichte Hohe:" + txtLichte.Text + " m" + "\n" + "Anz. A.P:" + txtAnzap.Text + "\n" + "Anz. M.A:" + txtAnzma.Text + "\n" + "zustand sch:" + cbzustand.SelectedValue + "\n" + "Bemerkung:" + txtbemerku.Text + "\n" + "Umfang [m]:" + txtumfang.Text + " m" + "\n" + "Anz. Heizho:" + txtanzheizho.Text + "\n" + "Anz. Patchsc:" + txtanzpatchsc.Text + "\n" + "Bezeichnug:" + Bezeichnug + "\n" + "MAX:" + Max + "\n" + "IST:" + IST; this.Close(); } else { MessageBox.Show("Please enter correct input fields"); } } else { string query = "update kl_raum set raumnummer='" + txtraum.Text + "' , raumbezeichnung='" + Bezeichnug + "' , DIN277_max='" + Max + "' , DIN277_ist='" + IST + "' , raumflaeche=" + txtflaeche.Text + " , lichte_raumhoehe=" + txtLichte.Text + " , anzahl_arbeitsplaetze=" + txtAnzap.Text + " , anzahl_mitarbeiter=" + txtAnzma.Text + " , bemerkung='" + txtbemerku.Text + "' , umfang=" + txtumfang.Text + " , schukosteckdose=" + chkschukostdose.IsChecked + " , anzahl_heizkoerper=" + txtanzheizho.Text + " , telefon_netzwerkdose=" + chktelnetzdose.IsChecked + " , anzahl_patschraenke=" + txtanzpatchsc.Text + " , sprinkler=" + chksprinkler.IsChecked + " , gasabsperrschieber=" + chkgasabsperrsch.IsChecked + " , wasserabsperrschieber=" + chkwasserabsperr.IsChecked + " , heizungsabsperrschieber=" + chkheizungabsperr.IsChecked + " , hydrant=" + chkHydrant.IsChecked + " where id=" + EditRoomId + ""; string msg = DataConnection.ExecuteQuery(query); if (msg == "Executed") { RoomAddOrEdit = ""; saveStatus = "yes"; MessageBox.Show("Saved Successfully"); Info = "Raum-Nr:" + txtraum.Text + "\n" + "Flaeche:" + txtflaeche.Text + " m\u00b2" + "\n" + "Lichte Hohe:" + txtLichte.Text + " m" + "\n" + "Anz. A.P:" + txtAnzap.Text + "\n" + "Anz. M.A:" + txtAnzma.Text + "\n" + "zustand sch:" + cbzustand.SelectedValue + "\n" + "Bemerkung:" + txtbemerku.Text + "\n" + "Umfang [m]:" + txtumfang.Text + " m" + "\n" + "Anz. Heizho:" + txtanzheizho.Text + "\n" + "Anz. Patchsc:" + txtanzpatchsc.Text + "\n" + "Bezeichnug:" + Bezeichnug + "\n" + "MAX:" + Max + "\n" + "IST:" + IST; this.Close(); } else { MessageBox.Show("Please enter correct input fields"); } } }
private void BtnAdd_Click(object sender, RoutedEventArgs e) { string msg = string.Empty; if (Equipment.getEquipId == null) { string query = "select top 1 id from as_tuer order by id desc"; DataTable dt = DataConnection.GetData(query); int id = 1; if (dt != null && dt.Rows.Count > 0) { id = Convert.ToInt32(dt.Rows[0][0].ToString()) + 1; query = "insert into as_tuer values('" + Application.Current.Properties["BuildingId"] + "','" + Application.Current.Properties["LevelId"] + "','" + Application.Current.Properties["CadId"] + "'," + id + ",'','" + cbTürtyp.SelectedValue + "','" + cbTürblattmaterial.SelectedValue + "','" + txtBreite.Text + "','" + txtHohe.Text + "','" + cbTuerzargenmaterial.SelectedValue + "','" + cbAntrieb.SelectedValue + "')"; 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_tuer values('" + Application.Current.Properties["BuildingId"] + "','" + Application.Current.Properties["LevelId"] + "','" + Application.Current.Properties["CadId"] + "'," + id + ",'','" + cbTürtyp.SelectedValue + "','" + cbTürblattmaterial.SelectedValue + "','" + txtBreite.Text + "','" + txtHohe.Text + "','" + cbTuerzargenmaterial.SelectedValue + "','" + cbAntrieb.SelectedValue + "')"; msg = DataConnection.ExecuteQuery(query); status = 1; break; } } if (status == 0) { query = "insert into as_tuer values('" + Application.Current.Properties["BuildingId"] + "','" + Application.Current.Properties["LevelId"] + "','" + Application.Current.Properties["CadId"] + "'," + id + ",'','" + cbTürtyp.SelectedValue + "','" + cbTürblattmaterial.SelectedValue + "','" + txtBreite.Text + "','" + txtHohe.Text + "','" + cbTuerzargenmaterial.SelectedValue + "','" + cbAntrieb.SelectedValue + "')"; msg = DataConnection.ExecuteQuery(query); } } else { query = "insert into as_tuer values('" + Application.Current.Properties["BuildingId"] + "','" + Application.Current.Properties["LevelId"] + "','" + Application.Current.Properties["CadId"] + "'," + id + ",'','" + cbTürtyp.SelectedValue + "','" + cbTürblattmaterial.SelectedValue + "','" + txtBreite.Text + "','" + txtHohe.Text + "','" + cbTuerzargenmaterial.SelectedValue + "','" + cbAntrieb.SelectedValue + "')"; msg = DataConnection.ExecuteQuery(query); } if (msg == "Executed") { query = "select top 1 id from as_tuer order by id desc"; dt = DataConnection.GetData(query); if (dt != null && dt.Rows.Count > 0) { UpdateChildGetSet = true; SelectChildTypeValues = "EquipId " + dt.Rows[0][0].ToString() + ": " + "tuer" + " (" + txtHohe.Text + "x" + txtBreite.Text + ")," + cbTürtyp.SelectedValue + "," + cbTürblattmaterial.SelectedValue + "," + cbTuerzargenmaterial.SelectedValue + "," + txtGlasflaeche.Text + "," + cbAntrieb.SelectedValue; //var myWindow = Window.GetWindow(this).Close(); } } else { MessageBox.Show("Please enter correct input values"); } } else { string updatedcolumns = "türtyp='" + cbTürtyp.SelectedValue + "' , breite='" + txtBreite.Text + "' , hoehe='" + txtHohe.Text + "' , türblattmaterial='" + cbTürblattmaterial.SelectedValue + "' , [glasflaeche einseitig]='" + txtGlasflaeche.Text + "' , antrieb='" + cbAntrieb.SelectedValue + "'"; msg = EquipmentData.UpdateEquipment("as_tuer", updatedcolumns, Equipment.getEquipId); if (msg == "Executed") { UpdateChildGetSet = true; SelectChildTypeValues = "EquipId " + Equipment.getEquipId + ": " + "tuer" + " (" + txtHohe.Text + "x" + txtBreite.Text + ")," + cbTürtyp.SelectedValue + "," + cbTürblattmaterial.SelectedValue + "," + cbTuerzargenmaterial.SelectedValue + "," + txtGlasflaeche.Text + "," + cbAntrieb.SelectedValue; Window.GetWindow(this).Close(); } else { MessageBox.Show("Please enter correct input values"); } } }