Exemple #1
0
        public void EditAWorkshop()
        {
            personlogic.AddPerson(new Teacher("John", "Teacher", "159357"));
            OnlineWks owks  = new OnlineWks("An Online Workshop", "How to give online workshops", DateTime.Now, 5, (Teacher)personlogic.GetPerson("159357"), "somelink");
            OnlineWks owks2 = new OnlineWks("An Online Workshop", "test", DateTime.Now, 5, (Teacher)personlogic.GetPerson("159357"), "test");

            wkscrud.AddWorkshop(owks);
            wkscrud.EditWorkshop(owks, owks2);
            Assert.AreEqual("test", wkscrud.GetWorkshop(1).Topic);
        }
Exemple #2
0
        private void btnSaveWs_Click(object sender, EventArgs e)
        {
            Workshop oldws = (Workshop)listBoxWorkshops.SelectedItem;
            Workshop newws;
            string   title   = tbTitleWsMan.Text;
            string   topic   = tbTopicWsMan.Text;
            int      cap     = Convert.ToInt32(numericUpDownCapacity.Value);
            Teacher  teacher = (Teacher)comboBoxteacherWsMan.SelectedItem;
            DateTime date    = dateTimePicker1.Value;
            string   address = tbAddressWsMan.Text;
            int      room    = Convert.ToInt32(numericUpDownRoomNumber.Value);
            string   link    = tbLinkWsMan.Text;

            try
            {
                if (comboBoxTypeWsMan.SelectedIndex == 0)
                {
                    newws = new InBuildingWks(title, topic, date, cap, teacher, address, room);
                }
                else
                {
                    newws = new OnlineWks(title, topic, date, cap, teacher, link);
                }

                wscrudlogic.EditWorkshop(oldws, newws);
                UpdateWSListbox();
                ClearTextboxes();
                listBoxWorkshops.Enabled = true;
                btnSaveWs.Visible        = false;
                btnAddWs.Visible         = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }