Exemple #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            int    calchouer = endH - startH;
            string subHour, subHour2;

            if (comboBox1.Text == null || comboBox1.Text == "")
            {
                MessageBox.Show("You have to fill the Hours");
                return;
            }


            else
            {
                hour = comboBox1.Text;
                int inthourcombo = Int32.Parse(hour.Substring(0, 2));
                int hourlistStart;
                int hourlistEnd;
                date = monthCalendar1.SelectionStart.ToShortDateString();
                day  = monthCalendar1.SelectionStart.DayOfWeek.ToString();



                for (int i = 0; i < counter; i++)
                {
                    if (listView1.Items[i].Text.ToString().Trim() == monthCalendar1.SelectionStart.ToShortDateString().Substring(0, 10))
                    {
                        subHour       = listView1.Items[i].SubItems[2].Text.Substring(0, 5);
                        subHour2      = listView1.Items[i].SubItems[2].Text.Substring(6, 2);
                        hourlistStart = Int32.Parse(subHour.Substring(0, 2));
                        hourlistEnd   = Int32.Parse(subHour2);
                        if (subHour == comboBox1.Text || ((inthourcombo <= hourlistEnd && inthourcombo >= hourlistStart)))
                        {
                            MessageBox.Show("This class is occupied in this hour");
                            return;
                        }
                    }
                }
                AddToSce addSce = new AddToSce(b, day, hour, date, b, null, this, b.Text);
                addSce.Show();
            }
        }
Exemple #2
0
        private void DynamicButton_Click(object sender, EventArgs e)
        {
            Button btn = (Button)sender;
            int    hours_index = 0, days_index = 0;

            for (int i = 0; i < buttons.Length; i++)
            {
                if (buttons[i] == btn)
                {
                    hours_index = i / 7;
                    days_index  = i % 7;
                    hour        = Hours[hours_index - 1];
                    day         = days[days_index - 1];
                }
            }


            string date = buttons[days_index].Text.Substring(day.Length + 1);


            AddToSce s = new AddToSce(btn, day, hour, date, buttons[1], this);

            s.Show();
        }