private void push(bool isNew, bool delete)
        { // push to server
            NetCom.ServerRequestChangeModTable request = new NetCom.ServerRequestChangeModTable();
            DBDingus.ModifierTableEntry        d       = new DBDingus.ModifierTableEntry();
            if (delete)
            {
                request.DeleteEntry = true;
                d.ID = curModEntryID;
            }
            else
            {
                request.DeleteEntry = false;
                if (isNew)
                {
                    request.IsNewEntry = true;
                }
                else
                {
                    d.ID = curModEntryID;
                    request.IsNewEntry = false;
                }
                //fill D
                if (checkBoxIsStudiVerlof.Checked || checkBoxIsFlexiebelverlof.Checked || checkBoxIsExcurtie.Checked)
                {
                    d.HoursToAdd = new TimeSpan();
                }
                else
                {
                    d.HoursToAdd = dateTimePickerHoursToAdd.Value.TimeOfDay;
                }
                d.DateTotEnMet   = dateTimePickerDatumTotEnMet.Value;
                d.DateVanafEnMet = dateTimePickerVanafEnMet.Value;
                d.omschrijveing  = textBoxOpmerking.Text;
                d.isExurtie      = checkBoxIsExcurtie.Checked;
                d.isStudieVerlof = checkBoxIsStudiVerlof.Checked;
                d.isFlexibelverlofoeorfsjklcghiur = checkBoxIsFlexiebelverlof.Checked;
                d.DaysOfEffect[0] = checkBoxMo.Checked;
                d.DaysOfEffect[1] = checkBoxDi.Checked;
                d.DaysOfEffect[2] = checkBoxWo.Checked;
                d.DaysOfEffect[3] = checkBoxDo.Checked;
                d.DaysOfEffect[4] = checkBoxVr.Checked;
                d.DaysOfEffect[5] = checkBoxZa.Checked;
                d.DaysOfEffect[6] = checkBoxZo.Checked;

                d.UserIDs = selectedUsers.Select(i => i.ID).ToList();
            }
            request.deEntry = d; // request.deEntry in the firstplcae
            NetCom.ServerResponseChangeModTable response = webr <NetCom.ServerResponseChangeModTable>(request);
            if (response.OK)
            {
                //niuets
            }
            else
            {
                MessageBox.Show("niet ok");
            }
            ClearInterface();
            LoadAlleDeEntrys();
            LoadDataTablesFromAlleDeEntrys();
        }
 private void dataGridViewModEntrys_SelectionChanged(object sender, EventArgs e)
 {  // update interface
     if (dataGridViewModEntrys.SelectedRows.Count > 0)
     {
         DBDingus.ModifierTableEntry entry = alleDeModifierEntrys.FirstOrDefault(a => a.ID == Convert.ToInt32(dataGridViewModEntrys.SelectedRows[0].Cells[0].Value.ToString()));
         if (entry != null)
         {
             buttonUpdate.Enabled = true;
             curModEntryID        = entry.ID;
             selectedUsers        = alleDeUserEntrys.Where(x => entry.UserIDs.Any(i => i == x.ID)).ToList();
             LoadSelectedUsersFromSelectedUsers();
             dateTimePickerDatumTotEnMet.Value = entry.DateTotEnMet;
             dateTimePickerVanafEnMet.Value    = entry.DateVanafEnMet;
             dateTimePickerHoursToAdd.Value    = Convert.ToDateTime(entry.HoursToAdd.ToString());
             textBoxOpmerking.Text             = entry.omschrijveing;
             checkBoxMo.Checked                = entry.DaysOfEffect[0];
             checkBoxDi.Checked                = entry.DaysOfEffect[1];
             checkBoxWo.Checked                = entry.DaysOfEffect[2];
             checkBoxDo.Checked                = entry.DaysOfEffect[3];
             checkBoxVr.Checked                = entry.DaysOfEffect[4];
             checkBoxZa.Checked                = entry.DaysOfEffect[5];
             checkBoxZo.Checked                = entry.DaysOfEffect[6];
             checkBoxIsExcurtie.Checked        = entry.isExurtie;
             checkBoxIsFlexiebelverlof.Checked = entry.isFlexibelverlofoeorfsjklcghiur;
             checkBoxIsStudiVerlof.Checked     = entry.isStudieVerlof;
         }
     }
 }
Beispiel #3
0
        public static List <DBDingus.ModifierTableEntry> GetListMTFromReader(SqlCommand _command)
        {
            List <DBDingus.ModifierTableEntry> toReturn = new List <DBDingus.ModifierTableEntry>();

            try
            {
                using (SqlConnection connection = new SqlConnection(_ConnectionString))
                {
                    _command.Connection = connection;
                    connection.Open();
                    SqlDataReader _reader = _command.ExecuteReader();

                    List <string> fields = new List <string>();
                    for (int i = 0; i < _reader.FieldCount; i++)
                    {
                        fields.Add(_reader.GetName(i));
                    }
                    while (_reader.Read())
                    {
                        DBDingus.ModifierTableEntry entry = new DBDingus.ModifierTableEntry();
                        if (fields.Contains(DBDingus.ModifierTableNames.ID))
                        {
                            entry.ID = ReadFromReader <Int32>((IDataRecord)_reader, DBDingus.ModifierTableNames.ID);
                        }
                        if (fields.Contains(DBDingus.ModifierTableNames.DateTotEnMet))
                        {
                            entry.DateTotEnMet = ReadDateTimeFromReader((IDataRecord)_reader, DBDingus.ModifierTableNames.DateTotEnMet);
                        }
                        if (fields.Contains(DBDingus.ModifierTableNames.DateVanafEnMet))
                        {
                            entry.DateVanafEnMet = ReadDateTimeFromReader((IDataRecord)_reader, DBDingus.ModifierTableNames.DateVanafEnMet);
                        }
                        if (fields.Contains(DBDingus.ModifierTableNames.UserIDs))
                        {
                            entry.UserIDs = JsonConvert.DeserializeObject <List <int> >(ReadFromReader <string>((IDataRecord)_reader, DBDingus.ModifierTableNames.UserIDs));
                        }
                        if (fields.Contains(DBDingus.ModifierTableNames.DaysOfEffect))
                        {
                            entry.DaysOfEffect = JsonConvert.DeserializeObject <bool[]>(ReadFromReader <string>((IDataRecord)_reader, DBDingus.ModifierTableNames.DaysOfEffect));
                        }
                        if (fields.Contains(DBDingus.ModifierTableNames.HoursToAdd))
                        {
                            entry.HoursToAdd = ReadDateTimeFromReader((IDataRecord)_reader, DBDingus.ModifierTableNames.HoursToAdd).TimeOfDay;
                        }
                        if (fields.Contains(DBDingus.ModifierTableNames.Omschrijving))
                        {
                            entry.omschrijveing = ReadFromReader <string>((IDataRecord)_reader, DBDingus.ModifierTableNames.Omschrijving);
                        }
                        if (fields.Contains(DBDingus.ModifierTableNames.isStudiever))
                        {
                            entry.isStudieVerlof = ReadFromReader <bool>((IDataRecord)_reader, DBDingus.ModifierTableNames.isStudiever);
                        }
                        if (fields.Contains(DBDingus.ModifierTableNames.isExur))
                        {
                            entry.isExurtie = ReadFromReader <bool>((IDataRecord)_reader, DBDingus.ModifierTableNames.isExur);
                        }
                        if (fields.Contains(DBDingus.ModifierTableNames.isflexy))
                        {
                            entry.isFlexibelverlofoeorfsjklcghiur = ReadFromReader <bool>((IDataRecord)_reader, DBDingus.ModifierTableNames.isflexy);
                        }
                        toReturn.Add(entry);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception($"(MTFromReader)ERROR @ SQL Command: {_command.CommandText} | Message: {ex.Message}");
            }
            return(toReturn);
        }