Imports System.Data
Imports System.Data.SqlClient
Partial Class FormEditAppointment
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack() Then
Dim ConnString = "Server=localhost;Initial Catalog=SaleMarketing;Integrated Security=True"
Dim Conn = New SqlConnection(ConnString)
Conn.Open()
Dim SQLstr = "SELECT * FROM APPOINTMENT where APPOINTMENT_ID='" & Request.QueryString("APPOINTMENT_ID") & "'"
Dim com = New SqlCommand(SQLstr, Conn)
Dim da = New SqlDataAdapter(com)
Dim dt = New DataTable()
da.Fill(dt)
TextBox1.Text = dt.Rows(0)("APPOINTMENT_NAME")
TextBox2.Text = dt.Rows(0)("APPOINTMENT_DESC")
txtDate.Text = dt.Rows(0)("APPOINTMENT_START_TIME")
txtDate1.Text = dt.Rows(0)("APPOINTMENT_NOTICE_DATE")
DropDownList1.Text = dt.Rows(0)("APPOINTMENT_STATUS")
DropDownList3.Text = dt.Rows(0)("APPOINTMENT_ASSIGN")
End If
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ConnString = "Server=localhost;Initial Catalog=SaleMarketing;Integrated Security=True"
Dim Conn = New SqlConnection(ConnString)
Conn.Open()
Dim sqlstr = "update APPOINTMENT set APPOINTMENT_NAME='" & TextBox1.Text & "',APPOINTMENT_DESC='" & TextBox2.Text & "',APPOINTMENT_START_TIME='" & txtDate.Text & "',APPOINTMENT_NOTICE_DATE='" & txtDate1.Text & "',APPOINTMENT_STATUS='" & DropDownList1.Text & "',APPOINTMENT_ASSIGN='" & DropDownList3.Text & "' where APPOINTMENT_ID='" & Request.QueryString("APPOINTMENT_ID") & "'"
Dim com = New SqlCommand(sqlstr, Conn)
com.ExecuteNonQuery()
MsgBox("บันทึกข้อมูล 'เรียบร้อย'", MsgBoxStyle.Information, "เรียบร้อย")
Response.Redirect("Appointment.aspx")
End Sub
End Class