private void buttonClearInEnUitTeken_Click(object sender, EventArgs e) { if (!_NoConnectionMode) { DialogResult dialogResult = MessageBox.Show("Verwijder In En Uit Tijden", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); if (dialogResult == DialogResult.Yes) { NetCom.ServerRequestChangeRegistratieTable request = new NetCom.ServerRequestChangeRegistratieTable(); request.isNieuwEntry = false; request.deEntry = _CurrentlySelectedUser.RegE; request.deEntry.HeeftIngetekend = false; request.deEntry.IsAanwezig = false; request.deEntry.TimeInteken = new TimeSpan(); request.deEntry.TimeUitteken = new TimeSpan(); NetCom.ServerResponse response; try { response = webbbbrrrrrry(request); } catch { //if (MessageBox.Show("Kan Niet Verbinden Met Server", "Ga Naar Alarm Modus?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { enableNoConnectionMode(); // } return; } if (response.IsErrorOccurred) { MessageBox.Show(response.ErrorInfo.ErrorMessage); } ReloadOverzight(); } else if (dialogResult == DialogResult.No) { } } }
private void buttonSave_Click(object sender, EventArgs e) { if (_CurrentlySelectedUser.UsE == null) { return; } if (!_NoConnectionMode) { NetCom.ServerRequestChangeRegistratieTable request = new NetCom.ServerRequestChangeRegistratieTable(); //set all control values back in errr object if (_CurrentlySelectedUser.HasTodayRegEntry) { request.isNieuwEntry = false; request.deEntry = _CurrentlySelectedUser.RegE; } else { request.isNieuwEntry = true; request.deEntry = new DBDingus.RegistratieTableTableEntry(); request.deEntry.IDOfUserRelated = _CurrentlySelectedUser.UsE.ID; request.newEntryDateIsToday = checkBoxSeUserTodayAsDate.Checked; if (!checkBoxSeUserTodayAsDate.Checked) { request.deEntry.Date = dateTimePickerSeDateToListTo.Value.Date; } } request.deEntry.Opmerking = textBoxOpmerking.Text; if (dateTimePickerTijdIn.Enabled) { request.deEntry.TimeInteken = dateTimePickerTijdIn.Value.TimeOfDay; } if (dateTimePickerTimeUit.Enabled) { request.deEntry.TimeUitteken = dateTimePickerTimeUit.Value.TimeOfDay; } request.deEntry.IsLaat = false; request.deEntry.IsZiek = false; request.deEntry.IsStudieverlof = false; request.deEntry.IsFlexiebelverlof = false; request.deEntry.IsExcurtie = false; request.deEntry.IsToegestaalAfwezig = false; if (checkBoxHeefAfwezigReden.Checked) { switch (comboBoxRedenAfwezig.SelectedItem.ToString()) { case "Laat": request.deEntry.IsLaat = true; request.deEntry.Verwachtetijdvanaanwezighijd = dateTimePickerVerwachteTijdVanAankomst.Value.TimeOfDay; break; case "Ziek": request.deEntry.IsZiek = true; break; case "StudieVerlof": request.deEntry.IsStudieverlof = true; break; case "FlexibelVerlof": request.deEntry.IsFlexiebelverlof = true; break; case "Excursie": request.deEntry.IsExcurtie = true; break; case "Toegestaan Afwezig": request.deEntry.IsToegestaalAfwezig = true; break; } } //put in trycatch for noodmodus NetCom.ServerResponse response; try { response = webbbbrrrrrry(request); } catch { // if (MessageBox.Show("Kan Niet Verbinden Met Server", "Ga Naar Alarm Modus?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { enableNoConnectionMode(); // } return; } if (response.IsErrorOccurred) { MessageBox.Show(response.ErrorInfo.ErrorMessage); } ReloadOverzight(); } }
public static NetCom.ServerResponseChangeRegistratieTable ChangeRegistatieTable(DBDingus.AcountTableEntry _MasterRightsEntry, NetCom.ServerRequestChangeRegistratieTable _Request) { NetCom.ServerResponseChangeRegistratieTable _toReturn = new NetCom.ServerResponseChangeRegistratieTable(); SqlCommand _commamd = new SqlCommand(); _commamd.Parameters.AddWithValue("@andered", _Request.deEntry.Opmerking); _commamd.Parameters.AddWithValue("@verwachtetijdvana", _Request.deEntry.Verwachtetijdvanaanwezighijd); if (_Request.isNieuwEntry) { if (_Request.newEntryDateIsToday) { _commamd.CommandText = $"insert into {DBDingus.RegistratieTableNames.RegistratieTableName}( {DBDingus.RegistratieTableNames.IDOfUserRelated}, {DBDingus.RegistratieTableNames.Date}, {DBDingus.RegistratieTableNames.TimeInteken}, {DBDingus.RegistratieTableNames.TimeUitteken}, {DBDingus.RegistratieTableNames.HeeftIngetekend}, {DBDingus.RegistratieTableNames.IsAanwezig}, {DBDingus.RegistratieTableNames.IsZiek}, {DBDingus.RegistratieTableNames.IsFlexibelverlof}, {DBDingus.RegistratieTableNames.IsStudieverlof}, {DBDingus.RegistratieTableNames.IsExcursie}, {DBDingus.RegistratieTableNames.IsLaat}, {DBDingus.RegistratieTableNames.IsToegestaanAfwezig}, {DBDingus.RegistratieTableNames.Opmerking}, {DBDingus.RegistratieTableNames.Verwachtetijdvanaanwezighijd}) values ( {_Request.deEntry.IDOfUserRelated}, cast(getdate() as date), cast('{_Request.deEntry.TimeInteken}' as time), cast('{_Request.deEntry.TimeUitteken}' as time), cast('{_Request.deEntry.HeeftIngetekend}' as bit), cast('{_Request.deEntry.IsAanwezig}' as bit), cast('{_Request.deEntry.IsZiek}' as bit), cast('{_Request.deEntry.IsFlexiebelverlof}' as bit), cast('{_Request.deEntry.IsStudieverlof}' as bit), cast('{_Request.deEntry.IsExcurtie}' as bit), cast('{_Request.deEntry.IsLaat}' as bit), cast('{_Request.deEntry.IsToegestaalAfwezig}' as bit), @andered,cast(@verwachtetijdvana as time) )"; } else { _commamd.CommandText = $"insert into {DBDingus.RegistratieTableNames.RegistratieTableName}( {DBDingus.RegistratieTableNames.IDOfUserRelated}, {DBDingus.RegistratieTableNames.Date}, {DBDingus.RegistratieTableNames.TimeInteken}, {DBDingus.RegistratieTableNames.TimeUitteken}, {DBDingus.RegistratieTableNames.HeeftIngetekend}, {DBDingus.RegistratieTableNames.IsAanwezig}, {DBDingus.RegistratieTableNames.IsZiek}, {DBDingus.RegistratieTableNames.IsFlexibelverlof}, {DBDingus.RegistratieTableNames.IsStudieverlof}, {DBDingus.RegistratieTableNames.IsExcursie}, {DBDingus.RegistratieTableNames.IsLaat}, {DBDingus.RegistratieTableNames.IsToegestaanAfwezig}, {DBDingus.RegistratieTableNames.Opmerking}, {DBDingus.RegistratieTableNames.Verwachtetijdvanaanwezighijd}) values ( {_Request.deEntry.IDOfUserRelated}, cast('{_Request.deEntry.Date.ToString("yyyy\\/MM\\/dd")}' as date), cast('{_Request.deEntry.TimeInteken}' as time), cast('{_Request.deEntry.TimeUitteken}' as time), cast('{_Request.deEntry.HeeftIngetekend}' as bit), cast('{_Request.deEntry.IsAanwezig}' as bit), cast('{_Request.deEntry.IsZiek}' as bit), cast('{_Request.deEntry.IsFlexiebelverlof}' as bit), cast('{_Request.deEntry.IsStudieverlof}' as bit), cast('{_Request.deEntry.IsExcurtie}' as bit), cast('{_Request.deEntry.IsLaat}' as bit), cast('{_Request.deEntry.IsToegestaalAfwezig}' as bit), @andered, cast(@verwachtetijdvana as time) )"; } if (FuncsVSQL.SQLNonQuery(_commamd) > 0) { //_toReturn.deEntry=_Request.deEntry; // _toReturn.deEntry.ID=(int)SqlDingusEnUserRechten.SQLQuery("select SCOPE_IDENTITY() as [yui]").Rows[0]["yui"]; } else { throw new Exception("SQL CHANGED_0 ERROR AT: " + _commamd.CommandText); } } else { if (_Request.newEntryDateIsToday) { _commamd.CommandText = $@"update {DBDingus.RegistratieTableNames.RegistratieTableName} set {DBDingus.RegistratieTableNames.IDOfUserRelated} = {_Request.deEntry.IDOfUserRelated}, {DBDingus.RegistratieTableNames.Date} = cast(getdate() as date), {DBDingus.RegistratieTableNames.TimeInteken} = cast('{_Request.deEntry.TimeInteken}' as time), {DBDingus.RegistratieTableNames.TimeUitteken} = cast('{_Request.deEntry.TimeUitteken}' as time), {DBDingus.RegistratieTableNames.IsAanwezig} = cast('{_Request.deEntry.IsAanwezig}' as bit), {DBDingus.RegistratieTableNames.HeeftIngetekend} = cast('{_Request.deEntry.HeeftIngetekend}' as bit), {DBDingus.RegistratieTableNames.IsZiek} = cast('{_Request.deEntry.IsZiek}' as bit), {DBDingus.RegistratieTableNames.IsFlexibelverlof} = cast('{_Request.deEntry.IsFlexiebelverlof}' as bit), {DBDingus.RegistratieTableNames.IsStudieverlof} = cast('{_Request.deEntry.IsStudieverlof}' as bit), {DBDingus.RegistratieTableNames.IsExcursie} = cast('{_Request.deEntry.IsExcurtie}' as bit), {DBDingus.RegistratieTableNames.IsLaat} = cast('{_Request.deEntry.IsLaat}' as bit), {DBDingus.RegistratieTableNames.IsToegestaanAfwezig} = cast('{_Request.deEntry.IsToegestaalAfwezig}' as bit), {DBDingus.RegistratieTableNames.Opmerking} = @andered, {DBDingus.RegistratieTableNames.Verwachtetijdvanaanwezighijd} = cast(@verwachtetijdvana as time) where {DBDingus.RegistratieTableNames.ID} = {_Request.deEntry.ID}"; } else { _commamd.CommandText = $@"update {DBDingus.RegistratieTableNames.RegistratieTableName} set {DBDingus.RegistratieTableNames.IDOfUserRelated} = {_Request.deEntry.IDOfUserRelated}, {DBDingus.RegistratieTableNames.Date} = cast('{_Request.deEntry.Date.ToString("yyyy\\/MM\\/dd")}' as date), {DBDingus.RegistratieTableNames.TimeInteken} = cast('{_Request.deEntry.TimeInteken}' as time), {DBDingus.RegistratieTableNames.TimeUitteken} = cast('{_Request.deEntry.TimeUitteken}' as time), {DBDingus.RegistratieTableNames.IsAanwezig} = cast('{_Request.deEntry.IsAanwezig}' as bit), {DBDingus.RegistratieTableNames.HeeftIngetekend} = cast('{_Request.deEntry.HeeftIngetekend}' as bit), {DBDingus.RegistratieTableNames.IsZiek} = cast('{_Request.deEntry.IsZiek}' as bit), {DBDingus.RegistratieTableNames.IsFlexibelverlof} = cast('{_Request.deEntry.IsFlexiebelverlof}' as bit), {DBDingus.RegistratieTableNames.IsStudieverlof} = cast('{_Request.deEntry.IsStudieverlof}' as bit), {DBDingus.RegistratieTableNames.IsExcursie} = cast('{_Request.deEntry.IsExcurtie}' as bit), {DBDingus.RegistratieTableNames.IsLaat} = cast('{_Request.deEntry.IsLaat}' as bit), {DBDingus.RegistratieTableNames.IsToegestaanAfwezig} = cast('{_Request.deEntry.IsToegestaalAfwezig}' as bit), {DBDingus.RegistratieTableNames.Opmerking} = @andered, {DBDingus.RegistratieTableNames.Verwachtetijdvanaanwezighijd} = cast(@verwachtetijdvana as time) where {DBDingus.RegistratieTableNames.ID} = {_Request.deEntry.ID}"; } if (FuncsVSQL.SQLNonQuery(_commamd) > 0) { //_toReturn.deEntry=_Request.deEntry; } else { throw new Exception("SQL CHANGED_0 ERROR AT: " + _commamd.CommandText); } } return(_toReturn); }