Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > .NET Framework > Forum > ถ้าเราเลือกวันที่ใน datetimepicker มันจะ error ค่ะ แต่ถ้าเราไม่เลือกวันที่ มันก็ให้บันทึกข้อมูลได้ ทำไงดีค่ะ



 

ถ้าเราเลือกวันที่ใน datetimepicker มันจะ error ค่ะ แต่ถ้าเราไม่เลือกวันที่ มันก็ให้บันทึกข้อมูลได้ ทำไงดีค่ะ

 



Topic : 029038

Guest




ถ้าเราเลือกวันที่ใน datetimepicker มันจะ error ค่ะ แต่ถ้าเราไม่เลือกวันที่ มันก็ให้บันทึกข้อมูลได้ ทำไงดีค่ะ


Code (VB.NET)
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
        Dim conn As New SqlClient.SqlConnection()
        Dim cmd As New SqlClient.SqlCommand()
        Dim a As String
        Dim cmdtxt As String
        a = ("รหัสสินค้า : " & txtserialno.Text & "") & vbNewLine
        a &= ("ชื่อสินค้า : " & txtname.Text & "") & vbNewLine
        a &= ("หน่วยสินค้า : " & cmbunit.Text & "") & vbNewLine
        a &= ("ราคาขาย/หน่วย : " & txtsaleprice.Text & "") & vbNewLine
        a &= ("ราคาทุน/หน่วย : " & txtbaseprice.Text & "") & vbNewLine
        a &= ("จำนวนสินค้าถึงจุดสั่งซื้อ : " & txtbaypoint.Text & "") & vbNewLine
        a &= ("คำแนะนำการใช้งาน : " & txtintroduction.Text & "") & vbNewLine
        a &= ("สรรพคุณ : " & txtindication.Text & "") & vbNewLine
        a &= ("คำเตือน : " & txtwarning.Text & "") & vbNewLine
        a &= ("ปริมาณสินค้าคงคลัง : " & txttotalstock.Text & "") & vbNewLine
        a &= ("ประเภทสินค้า : " & cmbtype.Text & "") & vbNewLine
        a &= ("วันที่ผลิต : " & dtpmfd.Text & "") & vbNewLine
        a &= ("วันหมดอายุ : " & dtpexp.Text & "")
        MessageBox.Show(a, "แสดงผล", MessageBoxButtons.OK, MessageBoxIcon.Information)
        conn.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename='C:\Documents and Settings\User\My Documents\PROJECT MORYA.mdf';Integrated Security=True;Connect Timeout=30;User Instance=True"
        conn.Open()
        If Adddata = 1 Then
            cmdtxt = "insert into product (serialno,name,unit,saleprice,baseprice,baypoint,introduction,indication,warning,totalstock,type,mfd,exp) Values ('" & txtserialno.Text & "','" & txtname.Text & "','" & cmbunit.Text & "','" & txtsaleprice.Text & "','" & txtbaseprice.Text & "','" & txtbaypoint.Text & "','" & txtintroduction.Text & "','" & txtindication.Text & "','" & txtwarning.Text & "','" & txttotalstock.Text & "','" & cmbtype.SelectedIndex & "','" & dtpmfd.Value & "','" & dtpexp.Value & "')"
        Else
            cmdtxt = "update product set serialno = ('" & txtserialno.Text & "'),name = ('" & txtname.Text & "'),unit = ('" & cmbunit.Text & "'),saleprice = ('" & txtsaleprice.Text & "'),baseprice = ('" & txtbaseprice.Text & "'),baypoint = ('" & txtbaypoint.Text & "'),introduction = ('" & txtintroduction.Text & "'),indication = ('" & txtindication.Text & "'),warning = ('" & txtwarning.Text & "'),totalstock = ('" & txttotalstock.Text & "'),type = ('" & cmbtype.SelectedIndex & "'),mfd = ('" & dtpmfd.Value & "'),exp = ('" & dtpexp.Value & "') where serialno = '" & txtserialno.Text & "'"
        End If
        'MessageBox.Show("'" & txtid.Text & "','" & txtname.Text & "','" & txtaddress.Text & "', '" & txttel.Text & "','" & txtfax.Text & "','" & txtcomment.Text & "'", "ตรวจสอบ", MessageBoxButtons.OK, MessageBoxIcon.Question)
        cmd.Connection = conn
        cmd.CommandText = cmdTXT
        cmd.ExecuteNonQuery()
        conn.Close()
        MessageBox.Show("บันทึกข้อมูลเรียบร้อยแล้ว ", "บันทึกข้อมูล", MessageBoxButtons.OK, MessageBoxIcon.Information)
        btnAdd.Enabled = True
        btnSave.Enabled = False
        btnDelete.Enabled = True
        btnExit.Enabled = True
        btnEdit.Enabled = True

        txtserialno.Text = ""
        txtname.Text = ""
        cmbunit.Text = ""
        txtsaleprice.Text = ""
        txtbaseprice.Text = ""
        txtbaypoint.Text = ""
        txtintroduction.Text = ""
        txtindication.Text = ""
        txtwarning.Text = ""
        txttotalstock.Text = ""
        cmbtype.Text = ""
        dtpmfd.Text = ""
        dtpexp.Text = ""

        txtserialno.Text = ""
        txtname.Text = ""
        cmbunit.Text = ""
        txtsaleprice.Text = ""
        txtbaseprice.Text = ""
        txtbaypoint.Text = ""
        txtintroduction.Text = ""
        txtindication.Text = ""
        txtwarning.Text = ""
        txttotalstock.Text = ""
        cmbtype.Text = ""
        dtpmfd.Text = ""
        dtpexp.Text = ""

        txtserialno.Enabled = True
        txtname.Enabled = True
        cmbunit.Enabled = True
        txtsaleprice.Enabled = True
        txtbaseprice.Enabled = True
        txtbaypoint.Enabled = True
        txtintroduction.Enabled = True
        txtindication.Enabled = True
        txtwarning.Enabled = True
        txttotalstock.Enabled = True
        cmbtype.Enabled = True
        dtpmfd.Enabled = True
        dtpexp.Enabled = True

        txtserialno.Focus()
    End Sub




Tag : - - - -







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2009-07-09 17:07:10 By : ss View : 1406 Reply : 2
 

 

No. 1



โพสกระทู้ ( 26 )
บทความ ( 0 )



สถานะออฟไลน์


'" & dtpexp.Value & "'

เปลี่ยนเป็น

" & dtpexp.Value & "






Date : 2009-07-17 09:28:08 By : saesee1125
 


 

No. 2

Guest


ได้แล้วค่ะ ขอบคุณค่ะ
Date : 2009-07-17 13:32:16 By : ss
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ถ้าเราเลือกวันที่ใน datetimepicker มันจะ error ค่ะ แต่ถ้าเราไม่เลือกวันที่ มันก็ให้บันทึกข้อมูลได้ ทำไงดีค่ะ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 05
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่