Exemple #1
0
        //**********************************************************************************
        // Definition of function updateDate()                                             *
        // If all user fields are filled, then data is extracted and populated accordingly *
        // inside the dataGrid.                                                            *
        //**********************************************************************************
        private void updateData()
        {
            try
            {
                dt.Clear();

                if (txtNumAssign.Text != "" && txtStartDate.Text.Length == 5 && Subject != "" &&
                    txtStartPage.Text != "" && txtNumAssign.Text != "" && Pattern != "")
                {
                    KumonLevel level      = new KumonLevel(cbxSubject.Text, txtLevel.Text);
                    DateTime   assignDate = DateTime.Now;
                    int        sheet      = int.Parse(txtStartPage.Text);
                    int        nextSheet  = 0;
                    bool       flag       = false;


                    for (int i = 0; i < int.Parse(txtNumAssign.Text); i++)
                    {
                        DataRow  myRow     = dt.NewRow();
                        TimeSpan increment = new TimeSpan(i, 0, 0, 0);
                        assignDate = (DateTime.Parse(txtStartDate.Text + "/" + DateTime.Now.Year.ToString())
                                      + increment);

                        if (flag || assignDate.DayOfWeek.ToString() == DayOff)
                        {
                            assignDate += new TimeSpan(1, 0, 0, 0);
                            flag        = true;
                        }

                        myRow["#"]        = i + 1;
                        myRow["Assigned"] = assignDate.ToString("MM/dd");

                        if (sheet > 200)
                        {
                            sheet = 1;
                            level++;
                        }

                        myRow["Level"] = level.Level;

                        nextSheet = calculateNextSheet(Pattern, sheet);

                        myRow["Sheet#"] = sheet.ToString() + "-" + (nextSheet - 1).ToString();

                        sheet = nextSheet;
                        dgdFormat.ItemsSource = dt.DefaultView;

                        dt.Rows.Add(myRow);
                    }

                    lblDateRange.Content = txtStartDate.Text + "-" + assignDate.ToString("MM/dd");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #2
0
        public static KumonLevel operator++(KumonLevel currentLevel)
        {
            KumonLevel nextLevel = new KumonLevel(currentLevel);

            if (currentLevel.Subject == "Math")
            {
                nextLevel.Subject = "Math";
                string[] mathLevels = new string[] { "7A", "6A", "5A", "4A", "3A", "2A", "A"
                                                     , "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "W" };
                for (int i = 0; i < mathLevels.Count(); i++)
                {
                    if (currentLevel.Level == mathLevels[i])
                    {
                        nextLevel.Level = mathLevels[i + 1];
                        return(nextLevel);
                    }
                }
            }
            else if (currentLevel.Subject == "Reading")
            {
                nextLevel.Subject = "Reading";
                string[] readingLevels = new string[] { "7A", "6A", "5A", "4A", "3A", "2A", "AI"
                                                        , "AII", "BI", "BII", "CI", "CII", "DI", "DII", "EI", "EII", "FI", "FII"
                                                        , "GI", "GII", "HI", "HII", "I", "J", "K", "L", "M", "N", "O", "W" };
                for (int i = 0; i < readingLevels.Count(); i++)
                {
                    if (currentLevel.Level == readingLevels[i])
                    {
                        nextLevel.Level = readingLevels[i + 1];
                        return(nextLevel);
                    }
                }
            }

            return(nextLevel);
        }
Exemple #3
0
 public KumonLevel(KumonLevel level)
 {
     Subject = level.Subject;
     Level   = level.Level;
 }
Exemple #4
0
        //************************************************************************************
        // Definition of event handler dgdFormat_CellEditEnding()                            *
        // This handles when the level or pages are changed inside the view. If the level is *
        // changed, that level is continued on for the remainder of the rows. If the pages   *
        // are changed, then the same pattern is continued on with the pages picking up from *
        // what was left off. The underlying datatable itself is updated upon change. If     *
        // the student has corrections only (C), pages pick up at the next row               *
        //************************************************************************************
        private void dgdFormat_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
        {
            int    rowIndex = ((DataGrid)sender).ItemContainerGenerator.IndexFromContainer(e.Row);
            string text     = ((TextBox)e.EditingElement).Text;

            if (e.Column.SortMemberPath.Equals("Level"))
            {
                // enter this level++ for subsequent rows
                KumonLevel nextLevel = new KumonLevel(Subject, text);

                for (int i = rowIndex; i < dt.Rows.Count; i++)
                {
                    dt.Rows[i]["Level"] = nextLevel.Level;
                }
                dgdFormat.ItemsSource = dt.DefaultView;
            }
            else if (e.Column.SortMemberPath.Equals("Sheet#"))
            {
                string[] pages;
                int      startPage;
                int      endPage;
                int      currentSheet;
                string   newPattern;

                try
                {
                    pages = text.Split('-');

                    if (text.ToUpper() == "C")
                    {
                        pages     = dt.Rows[rowIndex]["Sheet#"].ToString().Split('-');
                        startPage = int.Parse(pages[0]);
                        endPage   = int.Parse(pages[1]);

                        currentSheet = int.Parse(pages[0]);
                        dt.Rows[rowIndex]["Level"]  = "";
                        dt.Rows[rowIndex]["Sheet#"] = "Corr. Only";
                        rowIndex++;
                    }
                    else if (text.ToUpper() == "T")
                    {
                        pages     = dt.Rows[rowIndex]["Sheet#"].ToString().Split('-');
                        startPage = int.Parse(pages[0]);
                        endPage   = int.Parse(pages[1]);

                        currentSheet = int.Parse(pages[0]);
                        dt.Rows[rowIndex]["Level"]  = "";
                        dt.Rows[rowIndex]["Sheet#"] = "Test Only";
                        rowIndex++;
                    }
                    else if (text.ToUpper() == "H")
                    {
                        pages     = dt.Rows[rowIndex]["Sheet#"].ToString().Split('-');
                        startPage = int.Parse(pages[0]);
                        endPage   = int.Parse(pages[1]);

                        currentSheet = int.Parse(pages[0]);
                        dt.Rows[rowIndex]["Level"]  = "";
                        dt.Rows[rowIndex]["Sheet#"] = "Holiday";
                        rowIndex++;
                    }
                    else
                    {
                        startPage    = int.Parse(pages[0]);
                        endPage      = int.Parse(pages[1]);
                        currentSheet = startPage;
                    }

                    newPattern = getNewPattern(startPage, endPage);



                    for (int i = rowIndex; i < dt.Rows.Count; i++)
                    {
                        int nextSheet;

                        if (currentSheet > 200)
                        {
                            currentSheet -= 200;
                        }

                        nextSheet = calculateNextSheet(newPattern, currentSheet);

                        dt.Rows[i]["Sheet#"] = currentSheet.ToString() + "-"
                                               + (nextSheet - 1).ToString();

                        currentSheet = nextSheet;
                    }
                    dgdFormat.ItemsSource = dt.DefaultView;
                }
                catch (FormatException fEx)
                {
                    MessageBox.Show("Make sure to assign some pages for the student");
                }
            }
        }