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 > ช่วยด้วยพอดีอยากทราบโค้ดในVBคำนวณราคารวมในColumn DataGridview1 แล้วหาผลรวมของColumnราคารวม แสดงผลที่ยอดการชำระอ่ะคะ



 

ช่วยด้วยพอดีอยากทราบโค้ดในVBคำนวณราคารวมในColumn DataGridview1 แล้วหาผลรวมของColumnราคารวม แสดงผลที่ยอดการชำระอ่ะคะ

 



Topic : 066431



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



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




ช่วยหน่อยนะคะ



Tag : .NET, Ms Access, VB.NET, VS 2008 (.NET 3.x)







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2011-09-12 23:11:45 By : zeezakim View : 3988 Reply : 7
 

 

No. 1



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



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


รบกวนท่านผู้รู้ด้วยนะคะ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-09-13 09:11:24 By : zeezakim
 


 

No. 2



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



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

เอาโค้ดมาดูด้วยครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-09-13 09:25:09 By : lee_latee
 

 

No. 3



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



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


ตอนนี้ยังไม่มีโค้ดเลยคะ หาจากทุกๆที่แล้วยังไม่เจอเลยตั้งกระทู้รบกวนด้วยนะคะ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-09-13 09:27:19 By : zeezakim
 


 

No. 4



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



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


Private Sub dataGridViewData_CellValueChanged(sender As Object, e As DataGridViewCellEventArgs)
Try
If e.RowIndex > -1 AndAlso e.ColumnIndex > -1 Then
Select Case dataGridViewData.Columns(e.ColumnIndex).Name
Case "Qty", "Price"
Dim Price As [Double] = 0
Dim Qty As [Double] = 0
Dim Amount As [Double] = 0
If dataGridViewData.CurrentRow.Cells("Price").Value IsNot Nothing Then
[Double].TryParse(dataGridViewData.CurrentRow.Cells("Price").Value.ToString(), Price)
End If
[Double].TryParse(dataGridViewData.CurrentRow.Cells("Qty").Value.ToString(), Qty)
Amount = Qty * Price
dataGridViewData.CurrentRow.Cells("Amount").Value = Util.ToDecimal(Amount.ToString("#,###.00"))
CalCulate()
Exit Select
Case Else
Exit Select
'CalCulate();
End Select
End If
Catch ex As Exception
Util.MsgError(Util.GetMSGError(ex), "เกิดข้อผิดพลาด")
End Try
End Sub

ดู Concept นะครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-09-13 10:04:25 By : ่ำVC#.Net
 


 

No. 5



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



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


มันออกมาแบบนี้คะ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-09-13 10:47:27 By : zeezakim
 


 

No. 6



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



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

เป็นตัวอย่าง เพื่อศึกษา นะครับ
Code (VB.NET)
 Private dt As New DataTable
    Private dr As DataRow
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        DataGridView1.AutoGenerateColumns = False
        CreateDTProduct()
    End Sub

 Private Sub CreateDTProduct()
        dt.Columns.Add("ProductId", GetType(String))
        dt.Columns.Add("ProductName", GetType(String))
        dt.Columns.Add("Qty", GetType(Integer))
        dt.Columns.Add("Price", GetType(Double))
        dt.Columns.Add("TotalPrice", GetType(Double))
    End Sub

 Private Function ValidationData() As Boolean
        If (txtProductId.Text = "") Then
            MsgBox("ตรวจสอบ รหัสสินค้า")
            Return False
        End If
        If (txtProductName.Text = "") Then
            MsgBox("ตรวจสอบ ชื่อสินค้า")
            Return False
        End If
        If (txtQty.Text = "") Then
            MsgBox("ตรวจสอบ จำนวนสินค้า")
            Return False
        End If
        If (cboPrice.Text = "") Then
            MsgBox("ตรวจสอบ ราคาสินค้า")
            Return False
        End If
        If (Microsoft.VisualBasic.Information.IsNumeric(txtQty.Text) = False) Then
            MsgBox("ตรวจสอบ จำนวนสินค้า")
            Return False
        End If
        If (Microsoft.VisualBasic.Information.IsNumeric(cboPrice.Text) = False) Then
            MsgBox("ตรวจสอบ ราคาสินค้า")
            Return False
        End If
        Return True
    End Function

 Private Sub TotalSumPrice()
        If (dt.Rows.Count <> 0) Then
            Dim _ttSumPrice As Double = 0
            For index As Integer = 0 To dt.Rows.Count - 1
                _ttSumPrice = _ttSumPrice + Double.Parse(dt.Rows(index).Item("TotalPrice").ToString())            
            Next
            txtTotalSumPrice.Text = _ttSumPrice.ToString("#,##0.00")
        End If
    End Sub

Private Sub btnAddProduct_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddProduct.Click
        If (ValidationData()) Then
            If DataGridView1.Rows.Count = 0 Then
                dr = dt.NewRow()
                dr("ProductId") = txtProductId.Text
                dr("ProductName") = txtProductName.Text
                dr("Qty") = txtQty.Text
                dr("Price") = cboPrice.Text
                dr("TotalPrice") = txtTotalPrice.Text

                dt.Rows.Add(dr)
                dr = Nothing
            Else
                Dim _chkAddPrd As Boolean = False
                For index As Integer = 0 To dt.Rows.Count - 1
                    'ตรวจสอบ รหัสสินค้าที่เหมือนกัน
                    If (txtProductId.Text = dt.Rows(index).Item("ProductId").ToString()) Then

                        Dim _qtyGrd As Integer = Integer.Parse(dt.Rows(index).Item("Qty").ToString()) 'จำนวน
                        Dim _ttPrice As Integer = Integer.Parse(dt.Rows(index).Item("Price").ToString()) 'ราคา

                        dt.Rows(index).Item("Qty") = _qtyGrd + Integer.Parse(txtQty.Text) 'บวกจำนวนเพิ่ม
                        dt.Rows(index).Item("TotalPrice") = _ttPrice * Integer.Parse(dt.Rows(index).Item("Qty").ToString()) 'ผล ราคารวมใหม่
                        _chkAddPrd = True
                        Exit For
                    End If
                Next

                If _chkAddPrd = False Then ' ไม่มีสินค้าเหมือนกัน ให้เพิ่มใหม่
                    dr = dt.NewRow()
                    dr("ProductId") = txtProductId.Text
                    dr("ProductName") = txtProductName.Text
                    dr("Qty") = txtQty.Text
                    dr("Price") = cboPrice.Text
                    dr("TotalPrice") = txtTotalPrice.Text

                    dt.Rows.Add(dr)
                    dr = Nothing
                End If

            End If

            TotalSumPrice()
            DataGridView1.DataSource = dt

        End If
    End Sub

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-09-13 11:23:55 By : lee_latee
 


 

No. 7



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



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


ขอบคุณคะ ทุกๆท่าน และพี่บิ๊กด้วยนะคะ ที่กรุณา
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-09-13 12:15:34 By : zeezakim
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ช่วยด้วยพอดีอยากทราบโค้ดในVBคำนวณราคารวมในColumn DataGridview1 แล้วหาผลรวมของColumnราคารวม แสดงผลที่ยอดการชำระอ่ะคะ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ 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 อัตราราคา คลิกที่นี่