Schedule Scanner and Parser Grammer's: S -> ɛ; S -> FREE; S -> A; B -> & A; B -> ɛ; A -> E { T } B; E -> SUN; E -> MON; E -> THU; E -> WED; E -> THR; E -> FRI; E -> SAT; D -> & T; D -> ɛ; T -> N ~ N D; N -> 8; N -> 9; N -> 10; N -> 11; N -> 12; N -> 13; N -> 14; N -> 15; N -> 16; N -> 17; N -> 18; N -> 19; N -> 20;
        private void dgvProfessor_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.ColumnIndex == 5)
                {
                    if (e.RowIndex < dgvProfessor.Rows.Count - 1 && dgvProfessor.Rows[e.RowIndex].Cells[1].Value != null)
                    {
                        ProfScheduleForm psForm = new ProfScheduleForm();
                        psForm.Text = "Professor " + "(" + dgvProfessor.Rows[e.RowIndex].Cells[1].Value.ToString() + ")" + " Schedule";
                        //
                        // Construct dgvSchedule in ProfScheduleForm psForm ---------------------------------
                        //
                        psForm.dgvSchedule.Rows.Add(12);
                        psForm.dgvSchedule.ForeColor = Color.DarkBlue;
                        psForm.dgvSchedule.Rows[0].Cells[0].Value = "8 ~ 9";
                        psForm.dgvSchedule.Rows[1].Cells[0].Value = "9 ~ 10";
                        psForm.dgvSchedule.Rows[2].Cells[0].Value = "10 ~ 11";
                        psForm.dgvSchedule.Rows[3].Cells[0].Value = "11 ~ 12";
                        psForm.dgvSchedule.Rows[4].Cells[0].Value = "12 ~ 13";
                        psForm.dgvSchedule.Rows[5].Cells[0].Value = "13 ~ 14";
                        psForm.dgvSchedule.Rows[6].Cells[0].Value = "14 ~ 15";
                        psForm.dgvSchedule.Rows[7].Cells[0].Value = "15 ~ 16";
                        psForm.dgvSchedule.Rows[8].Cells[0].Value = "16 ~ 17";
                        psForm.dgvSchedule.Rows[9].Cells[0].Value = "17 ~ 18";
                        psForm.dgvSchedule.Rows[10].Cells[0].Value = "18 ~ 19";
                        psForm.dgvSchedule.Rows[11].Cells[0].Value = "19 ~ 20";
                        // -------------------------------------------------------------------------------------
                        string scheduleData = "";
                        if (dgvProfessor[6, e.RowIndex].Value != null)
                            scheduleData = dgvProfessor[6, e.RowIndex].Value.ToString();

                        ProfessorInfoCompiler compileData = new ProfessorInfoCompiler();
                        if (compileData.StartScanner(scheduleData.ToUpper()))
                        {
                            // [1 ~ Columns.Count, 0 ~ Rows.Count]
                            bool[,] fillByChecker = compileData.CompiledData;

                            // read Rows
                            for (int i = 0; i < 12; i++)
                            {
                                // read Columns
                                for (int j = 1; j < 8; j++)
                                {
                                    if (fillByChecker[i, j])
                                        psForm.dgvSchedule[j, i].Value = true;
                                }
                            }
                        }
                        else
                        {
                            // error massage for dgvProfessor data's
                            MessageBox.Show(scheduleData, "Data is incorrect!", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        }
                        psForm.Interface_TextBox = (DataGridViewTextBoxCell)dgvProfessor.Rows[e.RowIndex].Cells[6];
                        psForm.ShowDialog();
                    }
                }
            }
            catch { }
        }
示例#2
0
        private void dgvProfessor_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.ColumnIndex == 5)
                {
                    if (e.RowIndex < dgvProfessor.Rows.Count - 1 && dgvProfessor.Rows[e.RowIndex].Cells[1].Value != null)
                    {
                        ProfScheduleForm psForm = new ProfScheduleForm();
                        psForm.Text = "Professor " + "(" + dgvProfessor.Rows[e.RowIndex].Cells[1].Value.ToString() + ")" + " Schedule";
                        //
                        // Construct dgvSchedule in ProfScheduleForm psForm ---------------------------------
                        //
                        psForm.dgvSchedule.Rows.Add(12);
                        psForm.dgvSchedule.ForeColor = Color.DarkBlue;
                        psForm.dgvSchedule.Rows[0].Cells[0].Value  = "8 ~ 9";
                        psForm.dgvSchedule.Rows[1].Cells[0].Value  = "9 ~ 10";
                        psForm.dgvSchedule.Rows[2].Cells[0].Value  = "10 ~ 11";
                        psForm.dgvSchedule.Rows[3].Cells[0].Value  = "11 ~ 12";
                        psForm.dgvSchedule.Rows[4].Cells[0].Value  = "12 ~ 13";
                        psForm.dgvSchedule.Rows[5].Cells[0].Value  = "13 ~ 14";
                        psForm.dgvSchedule.Rows[6].Cells[0].Value  = "14 ~ 15";
                        psForm.dgvSchedule.Rows[7].Cells[0].Value  = "15 ~ 16";
                        psForm.dgvSchedule.Rows[8].Cells[0].Value  = "16 ~ 17";
                        psForm.dgvSchedule.Rows[9].Cells[0].Value  = "17 ~ 18";
                        psForm.dgvSchedule.Rows[10].Cells[0].Value = "18 ~ 19";
                        psForm.dgvSchedule.Rows[11].Cells[0].Value = "19 ~ 20";
                        // -------------------------------------------------------------------------------------
                        string scheduleData = "";
                        if (dgvProfessor[6, e.RowIndex].Value != null)
                        {
                            scheduleData = dgvProfessor[6, e.RowIndex].Value.ToString();
                        }

                        ProfessorInfoCompiler compileData = new ProfessorInfoCompiler();
                        if (compileData.StartScanner(scheduleData.ToUpper()))
                        {
                            // [1 ~ Columns.Count, 0 ~ Rows.Count]
                            bool[,] fillByChecker = compileData.CompiledData;

                            // read Rows
                            for (int i = 0; i < 12; i++)
                            {
                                // read Columns
                                for (int j = 1; j < 8; j++)
                                {
                                    if (fillByChecker[i, j])
                                    {
                                        psForm.dgvSchedule[j, i].Value = true;
                                    }
                                }
                            }
                        }
                        else
                        {
                            // error massage for dgvProfessor data's
                            MessageBox.Show(scheduleData, "Data is incorrect!", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        }
                        psForm.Interface_TextBox = (DataGridViewTextBoxCell)dgvProfessor.Rows[e.RowIndex].Cells[6];
                        psForm.ShowDialog();
                    }
                }
            }
            catch { }
        }