HOME > .NET Framework > Forum > หลังจากกดสมัครโครงการถ้าใส่ข้อมูลไม่ครบให้ฟ้องว่าช่องไหนขาดบ้าง และเช็คว่าถ้าใช้รหัสเดิมสมัครอีกรอบให้ขึ่นคำว่าเคยสมัครไปแล้ว
Imports System.Data
Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.IO
'Imports Cls_Student
Partial Class project
Inherits System.Web.UI.Page
Private gMode As EnumMode
Private Property Mode() As EnumMode
Get
Return gMode
End Get
Set(ByVal value As EnumMode)
gMode = value
End Set
End Property
Enum EnumMode
Add
Edit
View
End Enum
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim dt As New DataTable
Dim db As New Cls_DbAccess(Cls_DbAccess.pConnectionString)
Dim sb As New StringBuilder
sb.Append(String.Format(" select * from Tb_News where News_id ='{0}' ", Request.QueryString("newsid")))
dt = db.GetDataTable(db.OpenDataBase, sb.ToString)
' If dt.Rows.Count > 0 Then
'newsname.Text = dt.Rows(0).Item("News_Topic_Th")
' newsdetail.Text = dt.Rows(0).Item("News_Detail_Th")
' End If
'Response.Write(al.Count)
End Sub
Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click
Dim cs As New Cls_Student(Cls_DbAccess.pConnectionString)
Dim sb As New StringBuilder
sb.Append(String.Format(" where Std_Code ='{0}' ", txtStdCode.Text.Trim))
Dim al As DataTable = cs.GetOfTableStudent(sb.ToString) '5511280001
If al.Rows.Count > 0 Then
txtStdFNameTH.Text = al.Rows(0).Item("Std_FName_Th")
txtStdLNameTH.Text = al.Rows(0).Item("Std_LName_Th")
txtStdFNameEN.Text = al.Rows(0).Item("Std_FName_En")
txtStdLNameEN.Text = al.Rows(0).Item("Std_LName_En")
If Not (IsDBNull(al.Rows(0).Item("Std_Mobile"))) Then txtStdMobile.Text = al.Rows(0).Item("Std_Mobile")
If Not (IsDBNull(al.Rows(0).Item("Std_Email"))) Then txtStdEmail.Text = al.Rows(0).Item("Std_Email")
If Not (IsDBNull(al.Rows(0).Item("Std_Id"))) Then txtStdId.Text = al.Rows(0).Item("Std_Id")
If Not (IsDBNull(al.Rows(0).Item("CompanyName_Th"))) Then txtCompanyName_Th.Text = al.Rows(0).Item("CompanyName_Th")
If Not (IsDBNull(al.Rows(0).Item("Posjob"))) Then txtPosjob.Text = al.Rows(0).Item("Posjob")
If Not (IsDBNull(al.Rows(0).Item("youraddress"))) Then txtyouraddress.Text = al.Rows(0).Item("youraddress")
' Response.Write(al.Rows(0).Item("Std_Code"))
Else
Page.ClientScript.RegisterStartupScript(Page.GetType(), "แจ้งเตือน", "window.alert('ไม่มีข้อมูลของรหัสนี้'); ", True)
End If
End Sub
Protected Sub ImgRegister_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImgRegister.Click
Dim db As New Cls_DbAccess(Cls_DbAccess.pConnectionString)
Dim sb As New StringBuilder
sb.Append("UPDATE Tb_Student SET ")
sb.Append(String.Format("Std_FName_Th='{0}',", txtStdFNameTH.Text.Trim))
sb.Append(String.Format("Std_LName_Th='{0}',", txtStdLNameTH.Text.Trim))
sb.Append(String.Format("Std_FName_En='{0}',", txtStdFNameEN.Text.Trim))
sb.Append(String.Format("Std_LName_En='{0}',", txtStdLNameEN.Text.Trim))
sb.Append(String.Format("Std_Email='{0}',", txtStdEmail.Text.Trim))
sb.Append(String.Format("CompanyName_Th='{0}',", txtCompanyName_Th.Text.Trim))
sb.Append(String.Format("Std_Mobile='{0}' ,", txtStdMobile.Text.Trim))
sb.Append(String.Format("Posjob='{0}',", txtPosjob.Text.Trim))
sb.Append(String.Format("youraddress='{0}'", txtyouraddress.Text.Trim))
sb.Append(String.Format(" WHERE Std_Code='{0}'", txtStdCode.Text.Trim))
' Response.Write(sb.ToString)
db.ExecuteCommandWithTransaction(db.OpenDataBase, sb.ToString)
sb.Clear()
sb.Append("insert into Tb_Project (Std_Code, newsid ) values (")
sb.Append(String.Format("'{0}',", txtStdCode.Text.Trim))
'sb.Append(String.Format("'{0}'", Request.QueryString("newsid")))
sb.Append(String.Format("'{0}'", ("1")))
sb.Append(" ) ")
db.ExecuteCommandWithTransaction(db.OpenDataBase, sb.ToString)
Page.ClientScript.RegisterStartupScript(Page.GetType(), "แจ้งเตือน", "window.alert('บันทึกข้อมูลเรียบร้อยแล้ว'); document.location ='index.htm';", True)
End Sub
End Class
Tag : .NET, Web (ASP.NET), VB.NET, VS 2010 (.NET 4.x)