示例#1
0
        private void LoadStudentCourseGrid()
        {
            DataTable studentCourseResults = null;

            switch (m_dbLayer)
            {
            case "linq":
                studentCourseResults = LinqLayer.GetAllStudentCourses();
                break;

            case "lightweight":
                studentCourseResults = StudentDAL.SearchStudent();
                break;

            default:
                break;
            }

            grdStudentCourse.DataSource = null;
            grdStudentCourse.DataSource = studentCourseResults;
            grdStudentCourse.Columns["Student Name"].Width      = 200;
            grdStudentCourse.Columns["Course (Level)"].Width    = 200;
            grdStudentCourse.Columns["StudentCourseId"].Visible = false;
            grdStudentCourse.Columns["StudentId"].Visible       = false;
            grdStudentCourse.Columns["CourseId"].Visible        = false;
            grdStudentCourse.Columns["isDeleted"].Visible       = false;
        }
示例#2
0
 private void grdStudent_RowsRemoved(object sender, DataGridViewRowsRemovedEventArgs e)
 {
     if (m_editWithGridView)
     {
         if (m_grdStudent_SelectedRowId >= 0)
         {
             LinqLayer.DeleteStudent(m_grdStudent_SelectedRowId);
             m_grdStudent_SelectedRowId = -1;
         }
     }
 }
示例#3
0
 private void grdStudent_RowEnter(object sender, DataGridViewCellEventArgs e)
 {
     if (m_editWithGridView)
     {
         if (m_NewRowIndex < grdStudent.NewRowIndex)
         {
             LinqLayer.AddStudent(grdStudent["First Name", m_NewRowIndex].Value.ToString(), grdStudent["Last Name", m_NewRowIndex].Value.ToString());
             m_NewRowIndex = grdStudent.NewRowIndex;
         }
     }
 }
示例#4
0
 private void btnStudentCourseDelete_Click(object sender, EventArgs e)
 {
     if (grdStudentCourse.SelectedRows.Count > 0)
     {
         LinqLayer.DeleteStudentCourse(Convert.ToInt32(grdStudentCourse.Rows[grdStudentCourse.SelectedRows[0].Index].Cells["StudentCourseId"].Value));
         LoadStudentCourseGrid();
     }
     else
     {
         MessageBox.Show("You must select a student course record to delete.", "Delete Student Course Record", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
示例#5
0
 private void grdStudent_RowLeave(object sender, DataGridViewCellEventArgs e)
 {
     if (m_editWithGridView)
     {
         if (grdStudent.RowCount > 0)
         {
             if (grdStudent.CurrentRow != null)
             {
                 LinqLayer.UpdateStudentName(Convert.ToInt32(grdStudent.Rows[grdStudent.CurrentRow.Index].Cells["Id"].Value), grdStudent.Rows[grdStudent.CurrentRow.Index].Cells["First Name"].Value.ToString(), grdStudent.Rows[grdStudent.CurrentRow.Index].Cells["Last Name"].Value.ToString());
             }
         }
     }
 }
示例#6
0
        private void LoadStudentGrid()
        {
            DataTable studentResults = null;

            switch (m_dbLayer)
            {
            case "linq":
                studentResults = LinqLayer.GetAllStudents();
                break;

            case "lightweight":
                studentResults = StudentDAL.SearchStudent();
                break;

            default:
                break;
            }

            grdStudent.DataSource                   = null;
            grdStudent.DataSource                   = studentResults;
            grdStudent.Columns["Id"].Visible        = false;
            grdStudent.Columns["isDeleted"].Visible = false;
        }
示例#7
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (txtFirstName.Text.Trim() == "")
            {
                MessageBox.Show("You must enter a first name.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (txtLastName.Text.Trim() == "")
            {
                MessageBox.Show("You must enter a last name.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (m_AddEdit == StudentOperation.Add)
            {
                LinqLayer.AddStudent(txtFirstName.Text, txtLastName.Text);
            }
            else
            {
                LinqLayer.UpdateStudentName(m_Id, txtFirstName.Text, txtLastName.Text);
            }

            this.Close();
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (cboStudentName.Text.Trim() == "-- Select Student Name --")
            {
                MessageBox.Show("You must select a student name.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (cboCourse.Text.Trim() == "-- Select Course Name --")
            {
                MessageBox.Show("You must select a course.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (m_AddEdit == StudentCourseOperation.Add)
            {
                LinqLayer.AddStudentCourse(Convert.ToInt32(cboStudentName.SelectedValue), Convert.ToInt32(cboCourse.SelectedValue), Convert.ToInt32(txtMark.Text));
            }
            else
            {
                LinqLayer.UpdateStudentCourse(m_StudentCourseId, Convert.ToInt32(cboStudentName.SelectedValue), Convert.ToInt32(cboCourse.SelectedValue), Convert.ToInt32(txtMark.Text));
            }

            this.Close();
        }