Пример #1
0
 private void buttonEliminar_Click(object sender, EventArgs e)
 {
     eliminar();
     verdadero = true;
     bindingSourceDiesSemana.DataSource = DiesSemanaORM.SelectAllDiesSemana();
 }
Пример #2
0
        private void FormDemanda_Load(object sender, EventArgs e)
        {
            bindingSourceInstalacions.DataSource = InstalacionsORM.selectInstalacions();
            listBoxEspai.DataSource    = EspaisORM.selectEspaisInstalacio((INSTALACIONS)comboBoxInst.SelectedItem);
            listBoxEspai.DisplayMember = "nom";
            listBoxEspai.ValueMember   = "id";
            textBoxId.Text             = demanda.id.ToString();
            textBoxNom.Text            = demanda.nom;
            textBoxDuracio.Text        = demanda.duracio.ToString();
            if (demanda.es_asignada == true)
            {
                radioButtonSi.Checked = true;
            }
            else
            {
                radioButtonNo.Checked = true;
            }
            EQUIPS equip = EquipsORM.SelectAllEquipByid(demanda.id_equip).First();
            string nom   = equip.nom;

            textBoxEquip.Text = nom;
            HORES hores = HoresORM.SelectHoresByid(demanda.HORES.id).First();

            textBoxHinici.Text        = hores.inici.ToString();
            textBoxHfi.Text           = hores.fi.ToString();
            listBoxDies.DataSource    = DiesSemanaORM.SelectAllDiesSemana();
            listBoxDies.DisplayMember = "nom";
            listBoxDies.ValueMember   = "id";
            foreach (DIA_SEMANA dia in demanda.DIA_SEMANA)
            {
                listBoxDies.SelectedItems.Add(dia);
            }
            dataGridViewHorari.Rows.Clear();
            //-------------CALENDARI----------------------
            List <HORES> horari = HoresORM.SelectHoresPrimaries(111);

            string[,] rows = new string[Utilitats.intervalsHores, 9];
            for (int i = 0; i < Utilitats.intervalsHores; i++)
            {
                rows[i, 0] = horari[i].inici.ToString();
                rows[i, 1] = horari[i].fi.ToString();
            }

            List <DEMANDA_ACT> demandesAssignades = DemandaActORM.SelectAllDemandaActAssignades();

            for (int k = 0; k < demandesAssignades.Count; k++)
            {
                ESPAIS espai = (ESPAIS)listBoxEspai.SelectedItem;
                if (demandesAssignades[k].id_espai == espai.id)
                {
                    EQUIPS equipDemanda = EquipsORM.SelectAllEquipByid(demandesAssignades[k].id_equip).First();
                    foreach (DIA_SEMANA dia in demandesAssignades[k].DIA_SEMANA)
                    {
                        List <int> intervals = Utilitats.comparaHores(demandesAssignades[k].id_interval_hores);
                        for (int m = 0; m < intervals.Count; m++)
                        {
                            rows[intervals[m], dia.id + 1] = equipDemanda.nom;
                        }
                    }
                }
            }
            //---------OMPLIR CALENDARI--------------------
            dataGridViewHorari.Rows.Clear();
            List <EQUIPS>            equips     = EquipsORM.SelectAllEquips();
            INSTALACIONS             instalacio = (INSTALACIONS)comboBoxInst.SelectedItem;
            List <HORARI_INSTALACIO> horariInst = new List <HORARI_INSTALACIO>();

            horariInst.AddRange(instalacio.HORARI_INSTALACIO);



            for (int i = 0; i < rows.GetLength(0); i++)
            {
                string[] row = new string[rows.GetLength(1)];

                for (int j = 0; j < rows.GetLength(1); j++)
                {
                    row[j] = rows[i, j];
                }

                dataGridViewHorari.Rows.Add(row);
                foreach (DataGridViewRow fila in dataGridViewHorari.Rows)
                {
                    foreach (DataGridViewCell cela in fila.Cells)
                    {
                        if (cela.Value != null)
                        {
                            for (int j = 0; j < equips.Count; j++)
                            {
                                if (cela.Value.ToString() == equips[j].nom)
                                {
                                    cela.Style.BackColor = System.Drawing.Color.Red;
                                }
                            }
                        }
                    }
                }
            }
            //------------PINTAR EN GRIS HORES FORA D'HORARI INSTALACIO----------------

            List <int> diesObert = new List <int>();

            foreach (HORARI_INSTALACIO h in horariInst)
            {
                diesObert.Add(h.id_dia);
            }
            int contador = 0;

            for (int i = 1; i < 8; i++)
            {
                if (diesObert.Contains(i))
                {
                    List <int> intervals = Utilitats.comparaHoresExcluides(horariInst[contador].id_hores);
                    for (int j = 0; j < intervals.Count; j++)
                    {
                        dataGridViewHorari.Rows[intervals[j]].Cells[horariInst[contador].id_dia + 1].Style.BackColor = System.Drawing.Color.LightGray;
                    }
                    contador++;
                }
                else
                {
                    for (int j = 0; j < Utilitats.intervalsHores; j++)
                    {
                        dataGridViewHorari.Rows[j].Cells[i + 1].Style.BackColor = System.Drawing.Color.LightGray;
                    }
                }
            }
        }
Пример #3
0
 private void FormDiesSemana_Activated(object sender, EventArgs e)
 {
     bindingSourceDiesSemana.DataSource = DiesSemanaORM.SelectAllDiesSemana();
 }