private void push(bool isNew, bool delete) { try { NetCom.ServerRequestChangeAcountTable request = new NetCom.ServerRequestChangeAcountTable(); DBDingus.AcountTableEntry deEntry = new DBDingus.AcountTableEntry(); if (delete) { deEntry.ID = deEntry.ID = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells[0].Value.ToString()); request.DeleteEntry = true; } else { request.IsNewEntry = isNew; if (isNew) { deEntry.Naam = textBoxNewNaam.Text; deEntry.inlogNaam = textBoxNewInlogNaam.Text; deEntry.inlogWachtwoord = textBoxNewInlogWachtwoord.Text; deEntry.aanspreekpuntBevoegdhijd = Convert.ToInt32(textBoxNewaansprelvl.Text); deEntry.adminBevoegdhijd = Convert.ToInt32(textBoxNewAdminlbvl.Text); } else { deEntry.ID = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells[0].Value.ToString()); deEntry.Naam = textBoxUpdateNaam.Text; deEntry.inlogNaam = textBoxUpdateInlogNaam.Text; if (textBoxUpdateInlogWachtwoord.Text != "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx") { deEntry.inlogWachtwoord = textBoxUpdateInlogWachtwoord.Text; } else { deEntry.inlogWachtwoord = alleDeEntrys.First(x => x.ID == deEntry.ID).inlogWachtwoord; // not changed moet een bool zijn en pw moet niet gestuurd worden.... } deEntry.aanspreekpuntBevoegdhijd = Convert.ToInt32(textBoxUpdateAnsprlvl.Text); deEntry.adminBevoegdhijd = Convert.ToInt32(textBoxUpdateAdminlvl.Text); } } request.deEntry = deEntry; NetCom.ServerResponseChangeAcountTable response = webr <NetCom.ServerResponseChangeAcountTable>(request); if (response.OK == false) { if (isNew) { throw new Exception("buttonNew~~ response !OK"); } else { throw new Exception("buttonUpdate~~ response !OK"); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } refreshList(); }
public static NetCom.ServerResponseChangeAcountTable ChangeAcountTable(DBDingus.AcountTableEntry _MasterRightsEnty, NetCom.ServerRequestChangeAcountTable _request) { NetCom.ServerResponseChangeAcountTable toReturn = new NetCom.ServerResponseChangeAcountTable(); SqlCommand command = new SqlCommand(); if (!_request.IsNewEntry || _request.DeleteEntry) { command.Parameters.AddWithValue("@ID", _request.deEntry.ID); } if (_request.DeleteEntry) { command.CommandText = $"delete from {DBDingus.AcountsTableNames.AcountsTableName} where {DBDingus.AcountsTableNames.ID} = @ID"; } else { command.Parameters.AddWithValue("@aansprBevoeg", _request.deEntry.aanspreekpuntBevoegdhijd); command.Parameters.AddWithValue("@adminBevoeg", _request.deEntry.adminBevoegdhijd); command.Parameters.AddWithValue("@inlogNaam", _request.deEntry.inlogNaam); command.Parameters.AddWithValue("@pw", _request.deEntry.inlogWachtwoord); command.Parameters.AddWithValue("@naam", _request.deEntry.Naam); if (_request.IsNewEntry) { command.CommandText = $"insert into {DBDingus.AcountsTableNames.AcountsTableName} ({DBDingus.AcountsTableNames.Naam}, {DBDingus.AcountsTableNames.inlogNaam}, {DBDingus.AcountsTableNames.inlogWachtwoord}, {DBDingus.AcountsTableNames.aanspreekpuntBevoegthijdLvl}, {DBDingus.AcountsTableNames.adminBevoegdhijd}) values (@naam, @inlogNaam, @pw, @aansprBevoeg, @adminBevoeg)"; } else { command.CommandText = $"update {DBDingus.AcountsTableNames.AcountsTableName} set {DBDingus.AcountsTableNames.Naam}= @naam, {DBDingus.AcountsTableNames.inlogNaam} = @inlogNaam, {DBDingus.AcountsTableNames.inlogWachtwoord} = @pw, {DBDingus.AcountsTableNames.aanspreekpuntBevoegthijdLvl} = @aansprBevoeg, {DBDingus.AcountsTableNames.adminBevoegdhijd} = @adminBevoeg where {DBDingus.AcountsTableNames.ID} = @ID"; } } if (FuncsVSQL.SQLNonQuery(command) != 1) { toReturn.OK = false; } return(toReturn); }