Click here to Skip to main content
12,693,013 members (33,230 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: VB VB.NET
Public Class fmrRegistroEvaluaciones

    Dim clsmateria As New RegistroNotas

    Private dt As New DataTable
    Private dt2 As New DataTable
    Private dtDetalle As New DataTable("Detalle")
    Private Dtn As New DataTable
    Dim tp1, tp2, tp3, tp4 As New Integer
    Private Eva1 As New DataTable
    Private Eva2 As New DataTable
    Private Eva3 As New DataTable
    Private Eva4 As New DataTable
    Private dr1 As DataRow
    Private dr2 As DataRow





    Private Sub CrearTablasNotas()

        'Id Producto - 0
        Dim MiColumnaId As DataColumn = New DataColumn()
        With MiColumnaId
            .DataType = System.Type.GetType("System.Int32")
            .AllowDBNull = False
            .ColumnName = "ColGrupoClase"

        End With

        Dim MiColumnaCod As DataColumn = New DataColumn()
        With MiColumnaCod
            .DataType = System.Type.GetType("System.String")
            .AllowDBNull = False
            .ColumnName = "colCodAlumno"
        End With

        Dim MiColumnaNombre As DataColumn = New DataColumn()
        With MiColumnaNombre
            .DataType = System.Type.GetType("System.String")
            .AllowDBNull = False
            .ColumnName = "ColNombre"
        End With

        Dim MicolumnaAct1 As DataColumn = New DataColumn()
        With MicolumnaAct1
            .DataType = System.Type.GetType("System.Decimal")
            .AllowDBNull = False
            .DefaultValue = 0.0
            .ColumnName = "colAct1"
        End With

        Dim MiColumnaAct2 As DataColumn = New DataColumn
        With MiColumnaAct2
            .DataType = System.Type.GetType("System.Decimal")
            .AllowDBNull = False
            .DefaultValue = 0.0
            .ColumnName = "colAct2"
        End With

        Dim MiColumnaAct3 As DataColumn = New DataColumn
        With MiColumnaAct3
            .DataType = System.Type.GetType("System.Decimal")
            .AllowDBNull = False
            .DefaultValue = 0.0
            .ColumnName = "colAct3"

        End With

        Dim MiColumnaAct4 As DataColumn = New DataColumn
        With MiColumnaAct4
            .DataType = System.Type.GetType("System.Decimal")
            .AllowDBNull = False
            .DefaultValue = 0.0
            .ColumnName = "colAct4"
        End With

        With dtDetalle.Columns

.Add(MiColumnaId)  A column named 'MiColumnaId' already belongs to this DataTable
            .Add(MiColumnaCod)
            .Add(MiColumnaNombre)
            .Add(MicolumnaAct1)
            .Add(MiColumnaAct2)
            .Add(MiColumnaAct3)
            .Add(MiColumnaAct4)
        End With


        dgvRegistro.DataSource = dtDetalle
        dgvRegistro.Columns(0).Visible = False
        dgvRegistro.Columns(0).HeaderText = "Codigo Grupo Clase"
        dgvRegistro.Columns(0).ReadOnly = True

        dgvRegistro.Columns(1).HeaderText = "Cod. Alumno"
        dgvRegistro.Columns(1).Width = 110
        dgvRegistro.Columns(1).ReadOnly = True

        dgvRegistro.Columns(2).HeaderText = "Nombre Alumno"
        dgvRegistro.Columns(2).Width = 450
        dgvRegistro.Columns(2).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
        dgvRegistro.Columns(2).HeaderCell.Style.Alignment = DataGridViewContentAlignment.TopCenter
        dgvRegistro.Columns(2).DefaultCellStyle.Format = "n2"
        dgvRegistro.Columns(2).ReadOnly = True

        dgvRegistro.Columns(3).HeaderText = "Actividad 1"
        dgvRegistro.Columns(3).Width = 90
        dgvRegistro.Columns(3).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
        dgvRegistro.Columns(3).HeaderCell.Style.Alignment = DataGridViewContentAlignment.TopCenter
        dgvRegistro.Columns(3).DefaultCellStyle.Format = "n2"
        dgvRegistro.Columns(3).ReadOnly = True

        dgvRegistro.Columns(4).HeaderText = "Actividad 2"
        dgvRegistro.Columns(4).Width = 90
        dgvRegistro.Columns(4).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
        dgvRegistro.Columns(4).HeaderCell.Style.Alignment = DataGridViewContentAlignment.TopCenter
        dgvRegistro.Columns(4).DefaultCellStyle.Format = "n2"
        dgvRegistro.Columns(4).ReadOnly = True

        dgvRegistro.Columns(5).HeaderText = "Actividad 3"
        dgvRegistro.Columns(5).Width = 90
        dgvRegistro.Columns(5).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
        dgvRegistro.Columns(5).HeaderCell.Style.Alignment = DataGridViewContentAlignment.TopCenter
        dgvRegistro.Columns(5).DefaultCellStyle.Format = "n2"
        dgvRegistro.Columns(5).ReadOnly = True



        dgvRegistro.Columns(6).HeaderText = "Actividad 4"
        dgvRegistro.Columns(6).Width = 90
        dgvRegistro.Columns(6).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
        dgvRegistro.Columns(6).HeaderCell.Style.Alignment = DataGridViewContentAlignment.TopCenter
        dgvRegistro.Columns(6).DefaultCellStyle.Format = "n2"
        dgvRegistro.Columns(6).ReadOnly = True
    End Sub




    

    Private Sub fmrRegistroEvaluaciones_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


        dt = clsmateria.ListarGrado
        cmbGrado.DataSource = dt
        cmbGrado.ValueMember = dt.Columns(0).ToString()
        cmbGrado.DisplayMember = dt.Columns(1).ToString()


        CrearTablasNotas()
    End Sub

    
    Private Sub Buscar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Buscar.Click




        dt2 = clsmateria.Grados_SelectAlumnosGrados(cmbmaterias.SelectedValue, cmbGrado.SelectedValue, dtpFecha.Value.Year)

        dgvRegistro.DataSource = dt2


        Dim dt1 As DataTable

        dt1 = clsmateria.TipoEvaluacionesYearMes(dtpFecha.Value.Year, dtpFecha.Value.Month)

        If (dt1.Rows.Count = 0) Then

            MessageBox.Show("No Existen Actividades en este Periodo")
            Return
        Else


            tp1 = dt1.Rows(0).Item(0)
            tp2 = dt1.Rows(1).Item(0)
            tp3 = dt1.Rows(2).Item(0)
            tp4 = dt1.Rows(3).Item(0)


            'txt1.Text = tp1
            'txt2.Text = tp2
            'txt3.Text = tp3
            'txt4.Text = tp4

        End If



        dtDetalle.Clear()
        Dtn = clsmateria.Grados_SelectAlumnosGrados(cmbGrado.SelectedValue, cmbmaterias.SelectedValue, dtpFecha.Value.Year)
        Eva1 = clsmateria.NotasAlumnosGradoMateria(cmbGrado.SelectedValue, cmbmaterias.SelectedValue, dtpFecha.Value.Month, dtpFecha.Value.Year, tp1)
        Eva2 = clsmateria.NotasAlumnosGradoMateria(cmbGrado.SelectedValue, cmbmaterias.SelectedValue, dtpFecha.Value.Month, dtpFecha.Value.Year, tp2)
        Eva3 = clsmateria.NotasAlumnosGradoMateria(cmbGrado.SelectedValue, cmbmaterias.SelectedValue, dtpFecha.Value.Month, dtpFecha.Value.Year, tp3)
        Eva4 = clsmateria.NotasAlumnosGradoMateria(cmbGrado.SelectedValue, cmbmaterias.SelectedValue, dtpFecha.Value.Month, dtpFecha.Value.Year, tp4)


        If Eva1.Rows.Count = 0 And Eva2.Rows.Count = 0 And Eva3.Rows.Count = 0 And Eva4.Rows.Count = 0 Then
            Dim y As Integer
            For y = 0 To Dtn.Rows.Count - 1
                dr1 = dtDetalle.NewRow()
                dr1(0) = Dtn.Rows(y).Item(0)
                dr1(1) = Dtn.Rows(y).Item(1)
                dr1(2) = Dtn.Rows(y).Item(2)
                dtDetalle.Rows.Add(dr1)

            Next

        Else

            Dim x As Integer

            For x = 0 To Dtn.Rows.Count - 1
                dr1 = dtDetalle.NewRow()
                dr1(0) = Dtn.Rows(x).Item(0)
                dr1(1) = Dtn.Rows(x).Item(1)
                dr1(2) = Dtn.Rows(x).Item(2)
                dr1(3) = Eva1.Rows(x).Item(5)
                dr1(4) = Eva2.Rows(x).Item(5)
                dr1(5) = Eva3.Rows(x).Item(5)
                dr1(6) = Eva4.Rows(x).Item(5)



              

                dtDetalle.Rows.Add(dr1)
                dgvRegistro.DataSource = dtDetalle
                CrearTablasNotas()


            Next

        End If

    End Sub
Posted 24-Nov-12 7:32am
idoug12383
Updated 24-Nov-12 8:34am
v2
Comments
Pablo Aliskevicius 25-Nov-12 8:01am
   
Did you mean to call dtDetalle.Columns.Clear() sometime?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.170118.1 | Last Updated 24 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100