Option Strict On
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.Configuration
Partial Public Class FormDictionary_Core
Inherits System.Web.UI.Page
Dim dr As SqlDataReader
Dim strConn As String = WebConfigurationManager.ConnectionStrings("EvaluationConnectionString").ConnectionString
Dim conn As New SqlConnection(strConn)
Dim cmd As New SqlCommand
Dim dt As New DataTable
Dim mycomm As SqlCommand
Dim datestert As Date
Dim dateend As Date
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
TextBox1.Text = iddetailCore
Dim crsState As String = ""
Dim sqlAddCrs As String = ""
Dim sqlAddDtl As String = ""
Dim sql2 As String = ""
Dim sql3 As String = ""
Dim sql4 As String = ""
Dim sql5 As String = ""
Dim cmd As New SqlCommand
Dim daChk As SqlDataAdapter
Dim dsChk As New DataSet
Dim addChk As Boolean = True
Dim sqlselect As String = ""
Dim unitid As String = ""
Dim countt As Double = 0
conn.Close()
conn.Open()
Try
sqlselect = "Select core,Detail,D1,D2,D3,D4,D5 from Core_Competency where id_core ='" & TextBox1.Text & "'"
cmd = New SqlCommand()
dsChk.Clear()
daChk = New SqlDataAdapter(sqlselect, conn)
daChk.Fill(dsChk, " Core_Competency")
With cmd
.CommandType = CommandType.Text
.CommandText = sqlselect
.Connection = conn
dr = .ExecuteReader()
End With
dr.Read()
If dr.HasRows Then
Label3.Text = CStr(dr(0))
Label15.Text = CStr(dr(1))
Label9.Text = CStr(dr(2))
Label10.Text = CStr(dr(3))
Label12.Text = CStr(dr(4))
Label13.Text = CStr(dr(5))
Label14.Text = CStr(dr(6))
End If
dr.Close()
Catch ex As Exception
End Try
End Sub
Sub Page_UnLoad()
conn.Close()
conn = Nothing
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
Try
If TextBox2.Text <> " " Then
If IsNumeric(TextBox2.Text) Then
Dim c1 As Double
Dim c2 As Double
Dim c3 As Double
Dim c4 As Double
Dim c5 As Double
Dim sum As Double
Dim avg1 As Double
Dim avg2 As Double
'Dim summ As Double
c1 = CDbl(Double.Parse(TextBox2.Text).ToString)
c2 = CDbl(Double.Parse(TextBox3.Text).ToString)
c3 = CDbl(Double.Parse(TextBox4.Text).ToString)
c4 = CDbl(Double.Parse(TextBox5.Text).ToString)
c5 = CDbl(Double.Parse(TextBox6.Text).ToString)
sum = c1 + c2 + c3 + c4 + c5
avg1 = (c1 * 1) + (c2 * 2) + (c3 * 3) + (c4 * 4) + (c5 * 5)
avg2 = avg1 / 100
If sum <> 100 Then
Label30.Text = "คุณกรอกคะแนนไม่เท่า 100% กรุณาแก้ไขคะแนนค่ะ"
lblavg.Text = "0.0"
Label31.Text = Format(sum, "#,###.00")
Else
Label31.Text = Format(sum, "#,###.00")
lblavg.Text = Format(avg2, "#,###.00")
Label30.Text = " "
End If
End If
End If
Catch ex As Exception
'MessageBox.Show("กรุณากรอกจำนวนที่ต้องการแก้ไขให้ถูกต้องให้ถูกต้อง ", "เตือน", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End Try
End Sub
หน้าที่จะรับค่าไปใส่ใน gridview ปัจจุบันเราจะคลิกที่เรดิโอ แต่เจ้านายให้เปลี่ยน เป็นคำนวนจากหน้าบนแล้วให้มาใส่เป็นคะแนนช่องนึง แทน radio button นะค่ะ
ยังเริ่มไม่ถูกว่าจะเอาช่องมาไว้รอรับในกริดอย่างไรค่ะ