Esempio n. 1
0
        protected void LoadGVDDLExistingSubject(object o, EventArgs e)
        {
            if (ddlSection.Items.Count > 0)
            {
                var YCSId = new YearClassSectionTable(db).GetYearClassSectionId(ddlYear.SelectedValue, ddlClass.SelectedValue, ddlSection.SelectedValue);
                gvSubject.Columns[0].Visible = true;
                var res = new TeacherSubjectTable(db).GetTeacherSubject(YCSId);
                gvSubject.DataSource = res.Select(x => new {
                    Teacher     = x.Teacher.FullName,
                    SubjectId   = x.SubjectCode,
                    SubjectName = x.Name,
                    TotalMark   = x.TotalMark,
                    TSId        = x.TeacherSubjectId
                }).ToList();
                gvSubject.DataBind();

                ddlExistingSubject.DataSource = res.Select(x => new TextValuePair {
                    Text = x.Name, Value = x.TeacherSubjectId
                }).ToList();
                ddlExistingSubject.DataBind();
                gvSubject.Columns[0].Visible = false;
            }
            else
            {
                gvSubject.Columns[0].Visible = true;
                gvSubject.DataSource         = new DataTable();
                gvSubject.DataBind();
                ddlExistingSubject.Items.Clear();
                gvSubject.Columns[0].Visible = true;
            }
            LoadGVExistingMarkPortion(null, null);
        }
Esempio n. 2
0
        protected void btnAssign_Click(object sender, EventArgs e)
        {
            var YCSId = new YearClassSectionTable(db).GetYearClassSectionId(ddlYear.SelectedValue, ddlClass.SelectedValue, ddlSection.SelectedValue);

            TeacherSubjectTable TSTable = new TeacherSubjectTable(db);

            TSTable.RemoveTeacherSubject(ddlTeacher.SelectedValue, ddlSubject.SelectedValue, YCSId);
            var teacherSubjectId = TSTable.AddTeacherSubject(ddlTeacher.SelectedValue, ddlSubject.SelectedValue, YCSId);

            foreach (GridViewRow row in gvMarkPortions.Rows)
            {
                if ((row.FindControl("cbInclude") as CheckBox).Checked)
                {
                    string strPerrcent;
                    if (string.IsNullOrEmpty(strPerrcent = (row.FindControl("txtPercentage") as TextBox).Text))
                    {
                        continue;
                    }
                    var portionId  = Convert.ToInt32((row.FindControl("hfPortionId") as HiddenField).Value);
                    var percentage = Convert.ToInt32(strPerrcent);

                    db.Execute("addMarkPortion", new Dictionary <string, object>()
                    {
                        { "@TSId", teacherSubjectId },
                        { "@PId", portionId },
                        { "@Percentage", percentage }
                    }, true);
                }
            }

            LoadGVDDLExistingSubject(null, null);
        }
Esempio n. 3
0
        protected void gvSubject_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            var teacherSubjectId        = gvSubject.Rows[e.RowIndex].Cells[0].Text;
            TeacherSubjectTable TSTable = new TeacherSubjectTable(db);

            TSTable.RemoveTeacherSubject(teacherSubjectId);
            LoadGVDDLExistingSubject(null, null);
        }
        protected void LoadDDLSubject(object obj, EventArgs e)
        {
            //var studentId = new UserTable<ApplicationUser>(db).GetUserId(User.Identity.Name);
            //var res = db.Query("getSubjectBySYCSRIdTId",
            //		new Dictionary<string, object>() { { "@SYCSRId", ddlYear.SelectedValue }, { "@TId", ddlTerm.SelectedValue } },
            //		true);
            var res = new TeacherSubjectTable(db).GetTeacherSubject(ddlYear.SelectedValue);

            ddlSubject.Items.Clear();
            foreach (var item in res)
            {
                ddlSubject.Items.Add(new ListItem(item.SubjectCode + " - " + item.Name, item.TeacherSubjectId));
            }
            ddlSubject.Items.Insert(0, new ListItem("All", "all"));
            LoadGridView(null, null);
        }
Esempio n. 5
0
        protected void LoadGV(object e, EventArgs o)
        {
            var YCSId = new YearClassSectionTable(db).GetYearClassSectionId(
                new YearTable(db).GetYearId(DateTime.Now.Year),
                ddlClass.SelectedValue,
                ddlSecion.SelectedValue);

            var students = new TeacherSubjectTable(db).GetStudent(ddlSubject.SelectedValue);
            var portions = new MarkPortionTable(db).GetMarkPortion(ddlSubject.SelectedValue);

            DataTable table = new DataTable();

            table.Columns.Add("Student");
            table.Columns.Add("StudentId");
            foreach (var portion in portions)
            {
                table.Columns.Add(portion.Text);
                table.Columns.Add(portion.Value);
            }
            MarkTable markTable = new MarkTable(db);

            foreach (var student in students)
            {
                var row = table.Rows.Add();
                foreach (var portion in portions)
                {
                    var mark = markTable.GetMark(student.RollYearClassSectionId, ddlTerm.SelectedValue, portion.Value);
                    if (mark == null)
                    {
                        row[portion.Text]  = "NULL";
                        row[portion.Value] = portion.Value;
                    }
                    else
                    {
                        row[portion.Text]  = mark.Text;
                        row[portion.Value] = mark.Value;
                    }
                }
            }
        }
        protected void LoadGV(object p1, EventArgs p2)
        {
            var res = new MarkTable(db).GetTermTabulation(ddlTerm.SelectedValue);

            DataTable pivotTable = new DataTable();

            pivotTable.Columns.Add("Position");
            pivotTable.Columns.Add("Roll");
            //roll.AutoIncrement = true;
            //roll.AutoIncrementStep = 1;
            //roll.AutoIncrementSeed = 1;
            pivotTable.Columns.Add("First Name");
            pivotTable.Columns.Add("Last Name");

            Dictionary <string, List <TextValuePair> > subjectMarkPortions = new Dictionary <string, List <TextValuePair> >();

            var teacherSubjects = new TeacherSubjectTable(db).GetTeacherSubject(
                new YearClassSectionTable(db).GetYearClassSectionId(ddlYear.SelectedValue, ddlClass.SelectedValue, ddlSection.SelectedValue));

            foreach (var teacherSubject in teacherSubjects)
            {
                var portions = new MarkPortionTable(db).GetMarkPortion(teacherSubject.TeacherSubjectId);
                subjectMarkPortions.Add(teacherSubject.TeacherSubjectId, portions);
                headerLength.Add(teacherSubject.Name, portions.Count + 1);
                foreach (var portion in portions)
                {
                    pivotTable.Columns.Add(portion.Text + "|" + teacherSubject.TeacherSubjectId);
                }
                pivotTable.Columns.Add("Total|" + teacherSubject.TeacherSubjectId);
            }
            pivotTable.Columns.Add("Grand Total");

            var students     = new StudentTable(db).GetStudents(ddlYear.SelectedValue, ddlClass.SelectedValue, ddlSection.SelectedValue);
            var studentMarks = res.GroupBy(x => x.Student.ID).ToList();

            foreach (var student in students)
            {
                var studentMark = studentMarks.Find(x => x.Key == student.ID);
                var newRow      = pivotTable.Rows.Add();
                newRow["Roll"]       = student.Roll;
                newRow["First Name"] = student.FirstName;
                newRow["Last Name"]  = student.LastName;
                int  grandTotal = 0;
                bool termAbsent = true;
                if (studentMark == null)
                {
                    for (int i = 0; i < newRow.ItemArray.Length; i++)
                    {
                        newRow.ItemArray[i] = "A";
                    }
                }
                else
                {
                    foreach (var subjectMarkPortion in subjectMarkPortions)
                    {
                        int  subjectTotal  = 0;
                        bool subjectAbsent = true;
                        foreach (var portion in subjectMarkPortion.Value)
                        {
                            try {
                                int mark;
                                if (int.TryParse(studentMark.Where(x => x.PortionId == portion.Value).First().Mark, out mark) && mark >= 0)
                                {
                                    newRow[portion.Text + "|" + subjectMarkPortion.Key] = mark;
                                    subjectTotal += mark;
                                    subjectAbsent = false;
                                }
                                else
                                {
                                    newRow[portion.Text + "|" + subjectMarkPortion.Key] = "A";
                                }
                            } catch (Exception ex) {
                                newRow[portion.Text + "|" + subjectMarkPortion.Key] = "A";
                                Global.LogError(ex);
                            }
                        }
                        if (subjectAbsent)
                        {
                            newRow["Total|" + subjectMarkPortion.Key] = "A";
                        }
                        else
                        {
                            newRow["Total|" + subjectMarkPortion.Key] = subjectTotal;
                            termAbsent = false;
                        }
                        grandTotal += subjectTotal;
                    }
                }
                if (termAbsent)
                {
                    newRow["Grand Total"] = "A";
                }
                else
                {
                    newRow["Grand Total"] = grandTotal;
                }
            }

            pivotTable.DefaultView.Sort = "Grand Total DESC";

            gv.DataSource = pivotTable;
            gv.DataBind();
        }