private void SpecializationsView_Load(object sender, EventArgs e)
        {
            check = new DataGridViewCheckBoxColumn();
            check.Name = "checkCol";
            check.HeaderText = "Zaznacz";
            check.IndeterminateValue = false;
            check.ReadOnly = false;
            check.IndeterminateValue = false;
            DG_specs.Columns.Add(check);

            DataClassesDataContext dcdc = new DataClassesDataContext();
            var dSource = (from spec in dcdc.przedmiots select spec);
            DG_specs.DataSource = dSource;

            foreach (DataGridViewColumn col in DG_specs.Columns)
                if (col.Equals(check))
                    continue;
                else col.ReadOnly = true;

            for (int i = 0; i < DG_specs.Rows.Count; i++)
                ((DataGridViewCheckBoxCell)DG_specs.Rows[i].Cells[check.Name]).Value = false;
        }
        private void rButtons_CheckedChanged(object sender, EventArgs e)
        {
            checkedRB = rButtons.Where(rb => rb.Checked == true).First();

            IQueryable<object> context;

            var dcdc = new DataClassesDataContext(Form1.connectionString);
            if (checkedRB == RB_klasa)
            {
                context = from element in dcdc.klasas
                          select element;
                contextLocal = new List<object>(context);
                template = SScheduler.Properties.Resources.tabela_klasy;
            }
            else
                if (checkedRB == RB_nauczyciel)
                {
                    context = from element in dcdc.nauczyciels
                              select element;
                    contextLocal = new List<object>(context);
                    template = SScheduler.Properties.Resources.tabela_nauczyciel;
                }
                else
                    if (checkedRB == RB_sala)
                    {
                        context = from element in dcdc.salas
                                  select element;
                        contextLocal = new List<object>(context);
                        template = SScheduler.Properties.Resources.tabela_sala;
                    }
                    else context = null;

            DG_elements.DataSource = context;

            foreach (var col in DG_elements.Columns)
                if (((DataGridViewColumn)col).Name == "checkCol")
                    continue;
                else
                    ((DataGridViewColumn)col).ReadOnly = true;

            webBrowser1.SendToBack();
        }
        private void dodajAct()
        {
            if (this.Width < 350)
                for (int i = 0; i < 230; i++)
                {
                    this.Width += 1;
                    Thread.Sleep(1);
                }

            if ((atomy)CB_menu2.SelectedItem == atomy.Klasa)
            {
                grupery_input.ForEach(gb => gb.Visible = false);
                GB_Klasa.Visible = true;
            }
            else
                if ((atomy)CB_menu2.SelectedItem == atomy.Sala)
                {
                    grupery_input.ForEach(gb => gb.Visible = false);
                    GB_Sala.Visible = true;
                }
                else
                    if ((atomy)CB_menu2.SelectedItem == atomy.Nauczyciel)
                    {
                        grupery_input.ForEach(gb => gb.Visible = false);
                        GB_Nauczyciel.Visible = true;
                        dcdc = new DataClassesDataContext(connectionString);
                        dcdc.przedmiots.ToList<object>();
                    }
                    else
                        if ((atomy)CB_menu2.SelectedItem == atomy.Przedmiot)
                        {
                            grupery_input.ForEach(gb => gb.Visible = false);
                            GB_Przedmiot.Visible = true;
                        }

            BT_dodaj_dane.Visible = true;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            dcdc = new DataClassesDataContext(connectionString);

            try
            {
                if ((atomy)CB_menu2.SelectedItem == atomy.Klasa)
                {
                    klasa nowa_klasa = new klasa();
                    nowa_klasa.identyfikator = TB_K_identyfikator_klasy.Text[0];
                    nowa_klasa.liczebnosc = short.Parse(TB_K_liczebnosc_klasy.Text);
                    nowa_klasa.rok = byte.Parse(TB_K_rok_klasy.Text);
                    nowa_klasa.id_klasa = Guid.NewGuid();
                    dcdc.klasas.InsertOnSubmit(nowa_klasa);
                    TB_K_identyfikator_klasy.Text = string.Empty;
                    TB_K_liczebnosc_klasy.Text = string.Empty;
                    TB_K_rok_klasy.Text = string.Empty;
                }
                else
                    if ((atomy)CB_menu2.SelectedItem == atomy.Sala)
                    {
                        sala nowa_sala = new sala();
                        nowa_sala.id_sala = Guid.NewGuid();
                        nowa_sala.numer = short.Parse(TB_S_numer.Text);
                        nowa_sala.pojemnosc = byte.Parse(TB_S_pojemnosc.Text);
                        dcdc.salas.InsertOnSubmit(nowa_sala);
                        TB_S_numer.Text = string.Empty;
                        TB_S_pojemnosc.Text = string.Empty;
                    }
                    else
                        if ((atomy)CB_menu2.SelectedItem == atomy.Nauczyciel)
                        {
                            nauczyciel nowy_nauczyciel = new nauczyciel();
                            nowy_nauczyciel.id_nauczyciel = Guid.NewGuid();
                            nowy_nauczyciel.imie = TB_N_imie.Text;
                            nowy_nauczyciel.nazwisko = TB_N_nazwisko.Text;
                            //nowy_nauczyciel.id_specjalizacja =  ((przedmiot)dcdc.przedmiots.Where(przdmt => przdmt.nazwa == CB_spec_nauczyciel.SelectedText)).id_przedmiot;
                            dcdc.nauczyciels.InsertOnSubmit(nowy_nauczyciel);
                            foreach (Guid specID in checkedSpecs)
                            {
                                nauczyciel_przedmiot naucz_przdmt = new nauczyciel_przedmiot();
                                naucz_przdmt.id_nauczyciel_przedmiot = Guid.NewGuid();
                                naucz_przdmt.id_nauczyciel = nowy_nauczyciel.id_nauczyciel;
                                naucz_przdmt.id_przedmiot = specID;
                                dcdc.nauczyciel_przedmiots.InsertOnSubmit(naucz_przdmt);
                            }
                            TB_N_imie.Text = string.Empty;
                            TB_N_nazwisko.Text = string.Empty;
                            CB_spec_nauczyciel.Text = "Wybierz przedmiot";
                        }
                        else
                            if ((atomy)CB_menu2.SelectedItem == atomy.Przedmiot)
                            {
                                przedmiot nowy_przedmiot = new przedmiot();
                                nowy_przedmiot.id_przedmiot = Guid.NewGuid();
                                nowy_przedmiot.nazwa = TB_P_nazwa.Text;
                                dcdc.przedmiots.InsertOnSubmit(nowy_przedmiot);
                                TB_P_nazwa.Text = string.Empty;
                            }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Wprowadzono niepoprawne dane !","", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }

            dcdc.SubmitChanges();
        }
 private void CB_spec_nauczyciel_Click(object sender, EventArgs e)
 {
     dcdc =  new DataClassesDataContext(connectionString);
     List<object> nazwy_przedmiotow = new List<object>();
     dcdc.przedmiots.ToList().ForEach( przdmt => nazwy_przedmiotow.Add(przdmt.nazwa));
     if (!nazwy_przedmiotow.All(przdmt => CB_spec_nauczyciel.Items.Contains(przdmt)))
     {
         CB_spec_nauczyciel.Items.Clear();
         CB_spec_nauczyciel.Items.AddRange(nazwy_przedmiotow.ToArray());
     }
 }