|
|
|
ทำอย่างไรให้เพิ่มข้อมูลได้หลายครั้งค่ะ เมื่อกดเพิ่มแล้วก็สามารถเพิ่มข้อมูลได้ แต่เมื่อต้องการเพิ่มซักรอบที่ 3 มันจะขึ้น error ตามรูปอ่ะค่ะ |
|
|
|
|
|
|
|
Code (VB.NET)
If stout.Text <= stqty1.Text Then
If stqty1.Text < stout.Text Then
MessageBox.Show("ยอดคงเหลือน้อยกว่ายอดที่ต้องการเบิกกรุณาเบิกสินค้า Lot แรกให้หมดก่อน", "ผลการตรวจสอบ", MessageBoxButtons.OK, MessageBoxIcon.Warning)
stout.Focus()
Exit Sub
End If
sql = "Insert Into outdetail (outcode,stcode,stout,cost,outfordept,outfordocno,stat) "
sql &= " Values ('" & outcode.Text & "',"
sql &= "'" & Stname.SelectedValue & "',"
sql &= "'" & stout.Text & "',"
sql &= "'" & Cost.Text & "',"
sql &= "'" & outdept.SelectedValue & "',"
sql &= "'" & outfordocno.Text & "',"
sql &= "1)"
sql &= " Insert Into stdetail (stcode,stdate,stout,cost,cmname,cmdept,remark,ststat)"
sql &= " Values ('" & Stname.SelectedValue & "',"
sql &= "'" & outdate.Value.ToString("s") & "',"
sql &= "'" & stout.Text & "',"
sql &= "'" & Cost.Text & "',"
sql &= "'" & outname.Text & "',"
sql &= "'" & outdept.SelectedValue & "',"
sql &= "'" & outfordocno.Text & "',"
sql &= "1)"
sql &= " Update stock"
sql &= " Set stqty=stqty-'" & stout.Text & "',"
sql &= " stqty1=stqty1-'" & stout.Text & "'"
sql &= " Where (stcode='" & Stname.SelectedValue & "')"
sql &= " Update stdetail "
sql &= " Set stbal='" & stqty.Text - stout.Text & "'"
sql &= " Where (stcode='" & Stname.SelectedValue & "')"
sql &= " And (stdate='" & outdate.Value.ToString("s") & "')"
Else
sql = " Insert Into outdetail (outcode,stcode,stout,cost,outfordept,outfordocno,stat)"
sql &= " Values ('" & outcode.Text & "',"
sql &= "'" & Stname.SelectedValue & "',"
sql &= "'" & stout.Text & "',"
sql &= "'" & Cost.Text & "',"
sql &= "'" & outdept.SelectedValue & "',"
sql &= "'" & outfordocno.Text & "',"
sql &= "1)"
sql &= " Insert Into stdetail (stcode,stdate,stout,cost,cmname,cmdept,remark,ststat)"
sql &= " Values ('" & Stname.SelectedValue & "',"
sql &= "'" & outdate.Value.ToString("s") & "',"
sql &= "'" & stout.Text & "',"
sql &= "'" & Cost.Text & "',"
sql &= "'" & outname.Text & "',"
sql &= "'" & outdept.SelectedValue & "',"
sql &= "'" & outfordocno.Text & "',"
sql &= "1)"
sql &= " Update stock"
sql &= " Set stqty=stqty-'" & stout.Text & "',"
sql &= " stqty2=stqty2-'" & stout.Text & "'"
sql &= " Where (stcode='" & Stname.SelectedValue & "')"
sql &= " Update stdetail"
sql &= " Set stbal='" & stqty.Text - stout.Text & "'"
sql &= " Where (stcode='" & Stname.SelectedValue & "')"
sql &= " And (stdate='" & outdate.Value.ToString("s") & "')"
End If
Try
With comAdd
.CommandType = CommandType.Text
.CommandText = sql
.Connection = mySQLConn
.ExecuteNonQuery()
End With
Catch ex As Exception
MessageBox.Show(ex.Message, "ข้อผิดพลาด", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End Try
MsgBox("บันทึกข้อมูลเรียบร้อยแล้ว")
เมื่อกดเพิ่มแล้วก็สามารถเพิ่มข้อมูลได้ แต่เมื่อต้องการเพิ่มซักรอบที่ 3 มันจะขึ้น error ตามรูปอ่ะค่ะ
ช่วยดูให้หน่อยนะค่ะ
Tag : - - - -
|
|
|
|
|
|
Date :
2009-08-31 08:17:16 |
By :
Nicorobin |
View :
1336 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ทำไมคุณไม่ใช้ Loop แทนน่ะครับ
|
|
|
|
|
Date :
2009-08-31 18:40:52 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|