public Boolean editResidence(Residence r, int residence_id) { //update hq id not implemented yet String query = "UPDATE employee_residence SET country = '" + r.Country + "', city = '" + r.City + "', street = '" + r.Street + "', number = '" + r.Number + "', postal_code = '" + r.Postal_code + "', current_residence = '" + r.Current_residence + "' WHERE id = '" + residence_id + "'"; try { residence.Insert(query); return(true); } catch (Exception e) { Console.WriteLine(e.Message); return(false); } }
public Boolean addResidence(Residence r) { String query = "INSERT INTO employee_residence(employee_id, country, city, street, number, postal_code, current_residence) VALUES('" + r.Employee_id + "', '" + r.Country + "', '" + r.City + "', '" + r.Street + "', '" + r.Number + "', '" + r.Postal_code + "', '" + r.Current_residence + "')"; try { residence.Insert(query); return(true); } catch (Exception e) { Console.WriteLine(e.Message); return(false); } }
private void btnSave_Click(object sender, EventArgs e) { Residence residence = new Residence(); residence.Employee_id = employee_id; residence.City = textBox_city.Text; residence.Street = textBox_street.Text; residence.Country = textBox_city.Text; residence.Postal_code = textBox_postalcode.Text; residence.Number = int.Parse(textBox_housenr.Text); if (residence_id == 0) { db1.addResidence(residence); } else { db1.editResidence(residence, residence_id); } this.Close(); }
private void AddEditEmployee_Activated(object sender, EventArgs e) { var residences = db1.getSingleUserResidence(employee_id); var current_residence = new Residence(); residenceListbox.DataSource = new BindingSource(residences, null); residenceListbox.DisplayMember = "Street"; residenceListbox.ValueMember = "Id"; degreeListBox.DataSource = new BindingSource(db1.getSingleUserDegree(employee_id), null); degreeListBox.DisplayMember = "course"; degreeListBox.ValueMember = "id"; foreach (var residence in residences) { if (residence.Current_residence == true) { current_residence = residence; } } if (employeeBsn != 0) { residenceListbox.SelectedItem = current_residence; } }