|
 |
|
ASP.Net สอบถาม การเพิ่มข้อมูล แบบฟอร์มบันทึก แบบเลือกอย่างใดอย่างนึง |
|
 |
|
|
 |
 |
|
อยากสอบถาม การเพิ่มข้อมูล แบบเลือกอย่างใดอย่างนึง
อย่างตัวอย่างในรูปอ่ะค่ะ
ที่เป็นประเภทอุปกรณ์ ถ้าไม่มีให้เลือก ใน dropdownlist ก็พิมพ์ใน textbox ในส่วนของอื่นๆ
ต้องเขียนโค้ดอย่างไงอ่ะค่ะ

อันนี้ในส่วนของโค้ดน่ะค่ะ
Code (VB.NET)
Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click
tmpPictureName = FileUpload1.FileName
tmpPathFilePicture = "~/Mypic/" & tmpPictureName
Dim CurrenPath As String = Server.MapPath("~/Mypic/")
Dim CurrentPath As String = Server.MapPath("~/Mypic/")
If FileUpload1.HasFile Then
CurrentPath += tmpPictureName
FileUpload1.SaveAs(CurrentPath)
tmpPathFilePicture = "~/Mypic/" & tmpPictureName
End If
Try
GenerateID()
sb = New StringBuilder
sb.Remove(0, sb.Length())
sb.Append(" INSERT INTO tblTool(ToolID,ToolName,CategoryID,Brand,Qty,ReceiveDate,InsuranceDate,DepartmentID,CompanyID,ToolPic)")
sb.Append(" VALUES (@ToolID,@ToolName,@CategoryID,@Brand,@Qty,@ReceiveDate,@InsuranceDate,@DepartmentID,@CompanyID,@ToolPic)")
Com = New SqlCommand
With Com
.CommandType = CommandType.Text
.CommandText = sb.ToString
.Connection = Conn
.Parameters.Clear()
.Parameters.Add("@ToolID", SqlDbType.VarChar).Value = LastID
.Parameters.Add("@ToolName", SqlDbType.VarChar).Value = txtToolName.Text
.Parameters.Add("@CategoryID", SqlDbType.Int).Value = CInt(ddlCategory.SelectedValue)
.Parameters.Add("@Brand", SqlDbType.VarChar).Value = txtBrand.Text
.Parameters.Add("@Qty", SqlDbType.Int).Value = CInt(txtQtyTool.Text)
.Parameters.Add("@ReceiveDate", SqlDbType.VarChar).Value = CStr(txtReceiveDate.Text)
.Parameters.Add("@InsuranceDate", SqlDbType.VarChar).Value = CStr(txtInsuranceDate.Text)
.Parameters.Add("@DepartmentID", SqlDbType.Int).Value = CInt(ddlDepartment.SelectedValue)
.Parameters.Add("@CompanyID", SqlDbType.Int).Value = CInt(ddlCompany.SelectedValue)
.Parameters.Add("@ToolPic", SqlDbType.VarChar).Value = tmpPathFilePicture
.ExecuteNonQuery()
End With
Response.Write("<script language=javascript>")
Response.Write("alert('คุณต้องการบันทึกข้อมูล');")
Response.Write("</script>")
Catch ex As Exception
MsgBox(ex.Message)
End Try
ClearData()
End Sub
รบกวนหน่อยน่ะค่ะ
Tag : ASP.NET Web (ASP.NET), VB.NET

|
|
 |
 |
 |
 |
Date :
2014-05-29 11:00:12 |
By :
MINA_MP |
View :
854 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (VB.NET)
if Other ="" Or Null then
.Parameters.Add("@other", SqlDbType.VarChar).Value =Other << parameter ที่จะใส่เข้าไป
Else
.Parameters.Add("@Dropdown", SqlDbType.VarChar).Value = Dropdown <<<< << parameter ที่จะใส่เข้าไป
ประมาณนี้ไหมครับ 
|
 |
 |
 |
 |
Date :
2014-05-29 12:12:52 |
By :
nongpaoza |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตามหลักการของผมนะ
อื่นๆ จะต้องไม่มีให้ user เลือก จะต้องเตรียมข้อมูล ประเภทของอุปกรณ์ให้ครบถ้วน เพื่อให้ user เลือกให้จบในทีเดียว
ไม่งั้น user จะขี้เกียจเปิด dropdown อะไรๆ ก็จะลงอื่นๆ ท่าเดียว
ถ้าเป็นอุปกรณ์ใหม่จริงๆ ต้องมี form สำหรับให้ admin หรือ super user เป็นคน add ประเภทอุปกรณ์ใหม่ให้
|
 |
 |
 |
 |
Date :
2014-06-03 08:02:46 |
By :
Aod47 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณมากค่ะ สำหรับคำแนะนำ เด๋วจะลองกลับไปคิดดูน่ะค่ะ   
|
 |
 |
 |
 |
Date :
2014-06-03 12:52:24 |
By :
MINA_MP |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|