 |
|
เมื่อบันทึกการจองแล้ว ให้เปลี่ยนสถานะเป็นหมายเลข 3 ระบบการจองแผงตลาด ช่วยทีนั่งงงมานานมาก |
|
 |
|
|
 |
 |
|
Code (VB.NET)
Private Sub BtnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSave.Click
If txtidres.Text.Trim() = "" Then
MessageBox.Show("กรุณากดเพิ่มใบจองก่อน!!", "ตรวจสอบข้อผิดพลาด", MessageBoxButtons.OK, MessageBoxIcon.Information)
Exit Sub
End If
If MessageBox.Show("คุณต้องการเพิ่มใบจองใช่หรือไม่", "ตรวจสอบ", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.No Then
Exit Sub
End If
With cn
If .State = ConnectionState.Open Then .Close()
.ConnectionString = strConn
.Open()
End With
Dim sqlSave As String
sqlSave = "Insert Into Reservation(res_ID,panel_Id,res_Date,cus_id,emp_id,Deposit)"
sqlSave &= "values(@id,@panel,@date,@cus,@emp,@deposit)"
Dim cm As New SqlCommand
With cm
.CommandType = CommandType.Text
.CommandText = sqlSave
.Connection = cn
.Parameters.Clear()
.Parameters.AddWithValue("@id", txtidres.Text)
.Parameters.AddWithValue("@panel", txtidpanel.Text)
.Parameters.AddWithValue("@date", DateTimePicker1.Value)
.Parameters.AddWithValue("@cus", txtidcus.Text)
.Parameters.AddWithValue("@emp", txtempid.Text)
.Parameters.AddWithValue("@deposit", txtmoney.Text)
.ExecuteNonQuery()
sqlSave = "SELECT * from Rent R,panel P"
sqlSave &= " WHERE R.panel_id ='" & txtidpanel.Text & "'"
sqlSave &= " AND P.status_panel= 3 "
End With
showData()
MessageBox.Show("บันทึกข้อมูลเรียบร้อยแล้ว")
Clear()
End Sub
Tag : Ms SQL Server 2008, VB.NET, VS 2008 (.NET 3.x)
|
|
 |
 |
 |
 |
Date :
2012-05-28 16:51:09 |
By :
PhungBee |
View :
1059 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
สถานะ แผงมี ว่าง เช่า จอง หากเลือกจองแล้วบันทึก ให้เปลี่ยนสถานะของแผงจากว่าง คือ 1 เป็น จอง คือ 3
ต้องเขียนโค้ด แบบไหน หรือขอแนวทางด้วยจ้า
|
 |
 |
 |
 |
Date :
2012-05-28 16:54:33 |
By :
PhungBee |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
INSERT / UPDATE ?
|
 |
 |
 |
 |
Date :
2012-05-29 06:20:11 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (VB.NET)
Private Sub BtnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSave.Click
If txtidres.Text.Trim() = "" Then
MessageBox.Show("กรุณากดเพิ่มใบจองก่อน!!", "ตรวจสอบข้อผิดพลาด", MessageBoxButtons.OK, MessageBoxIcon.Information)
Exit Sub
End If
If MessageBox.Show("คุณต้องการเพิ่มใบจองใช่หรือไม่", "ตรวจสอบ", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.No Then
Exit Sub
End If
With cn
If .State = ConnectionState.Open Then .Close()
.ConnectionString = strConn
.Open()
End With
Dim sqlSave As String
sqlSave = "Insert Into Reservation(res_ID,panel_Id,res_Date,cus_id,emp_id,Deposit)"
sqlSave &= "values(@id,@panel,@date,@cus,@emp,@deposit)"
sqlSave = "update Panel Set status_panel ='3' Where status_panel = 'txtidpanel.Text '" 'แก้ไขตรงส่วนโค้ดนี้
Dim cm As New SqlCommand
With cm
.CommandType = CommandType.Text
.CommandText = sqlSave
.Connection = cn
.Parameters.Clear()
.Parameters.AddWithValue("@id", txtidres.Text)
.Parameters.AddWithValue("@panel", txtidpanel.Text)
.Parameters.AddWithValue("@date", DateTimePicker1.Value)
.Parameters.AddWithValue("@cus", txtidcus.Text)
.Parameters.AddWithValue("@emp", txtempid.Text)
.Parameters.AddWithValue("@deposit", txtmoney.Text)
.ExecuteNonQuery()
End With
showData()
MessageBox.Show("บันทึกข้อมูลเรียบร้อยแล้ว")
Clear()
End Sub
แก้ไขตางส่วน update แต่ไม่มีอะไรเปลี่ยนแปลงในตาราง panel เลยค่ะ
|
 |
 |
 |
 |
Date :
2012-05-29 10:46:48 |
By :
PhungBee |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|