Private Sub number_goods_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles number_goods.ValueChanged
If cost_goods.Text <> "" Then If number_goods.Value <= NumGood.Text Then
Total.Text = String.Format("{0:#,###.00}", number_goods.Value * Convert.ToDecimal(cost_goods.Text))
Else
MessageBox.Show("จำนวนสินค้ามีไม่เพียงพอต่อความต้องการโปรดตรวจสอบ", "ข้อความ", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End If
End If
End Sub
Private Sub CalculatePriceInGrid() Dim Sum As Decimal = 0.0
For i = 0 To gridData.RowCount - 1
gridData(7, i).Value = String.Format("{0:#,###.00}", Convert.ToInt32(gridData(4, i).Value) * Convert.ToDecimal(gridData(6, i).Value))
gridData(1, i).Value = i + 1
Sum = Sum + gridData(7, i).Value
Next
total_order.Text = String.Format("{0:#,###.00}", Sum)
End Sub
Private Sub SetLoadData()
Td_saleTableAdapter.FillSaleID(Myset.td_sale, SaleID)
Td_sale_detailTableAdapter.FillBy(Myset.td_sale_detail, SaleID)
For Each myRow In Myset.td_sale.Rows
sale_id.Text = "SAL-" & String.Format("{0:D3}", Convert.ToInt32(myRow("sale_id")))
sale_date.Value = myRow("sale_date")
note_order.Text = myRow("note_order")
Next
gridData.Rows.Clear()
For Each myRow In Myset.td_sale_detail.Rows
gridData.Rows.Add(App.My.Resources.PicDelete, gridData.RowCount + 1, String.Format("{0:D5}", myRow("code_goods")), _
myRow("name_goods"), myRow("number"), myRow("name_unit"), String.Format("{0:#,###.00}", myRow("sale_price")), _
String.Format("{0:#,###.00}", myRow("sale_total_price")))
Next
CalculatePriceInGrid()
End Sub
Private Sub BtnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnDelete.Click
If SaleID <> Nothing Then
If MessageBox.Show("คุณต้องการลบเอกสารนี้จริงหรือไม่", "ข้อความ", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = MsgBoxResult.Yes Then Td_saleTableAdapter.DeleteQuery(SaleID)
ClearData()
sale_id.Text = "SAL-" & String.Format("{0:D3}", CalID)
End If
End If
End Sub
นี่มาจากฟร์อมสั่งซื้อนะค่ะ
Private Sub CalPrice() If IsNumeric(cost_goods.Text) And num_s.Value > 0 Then
order_total_price.Text = String.Format("{0:#,###.00}", Convert.ToDecimal(cost_goods.Text) * Convert.ToDecimal(num_s.Value))
End If
End Sub
rivate Sub BtnAddList_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnAddList.Click If code_goods.Text <> "" And num_s.Value <> 0 Then
gridData.Rows.Add(App.My.Resources.PicDelete, gridData.RowCount + 1, code_goods.Text, name_goods.Text, num_s.Value, String.Format("{0:#,###.00}", cost_goods.Text), _
String.Format("{0:#,###.00}", order_total_price.Text))
CalculateAllPrice()
ClearItemData()
Else
MessageBox.Show("กรุณาตรวจสอบรายละเอียดรายการก่อนการบันทึก", "ข้อความ", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End If
End Sub
Private Sub CalculateAllPrice() Dim sum As Decimal = 0
For i = 0 To gridData.Rows.Count - 1
gridData(1, i).Value = i + 1
gridData(6, i).Value = String.Format("{0:#,###.00}", Convert.ToDecimal(gridData(5, i).Value) * Convert.ToInt32(gridData(4, i).Value))
sum = sum + Convert.ToDecimal(gridData(6, i).Value)
Next
TotalAll.Text = String.Format("{0:#,###.00}", sum)
End Sub
Private Sub getOrderID() New_Order_IDTableAdapter.Fill(Myset1.New_Order_ID)
If Myset1.New_Order_ID.Rows.Count > 0 Then
For Each myRow In Myset1.New_Order_ID.Rows
Temporder_id.Text = "OR-" + String.Format("{0:D5}", Convert.ToInt32(myRow("order_id")) + 1)
order_id.Text = Convert.ToInt32(myRow("order_id")) + 1
Next
Else
Temporder_id.Text = "OR-00001"
order_id.Text = "1"
End If
End Sub
Private Sub InsertItemData()
Try Td_order_detailTableAdapter.DeleteQuery(order_id.Text)
For i = 0 To gridData.Rows.Count - 1
Td_order_detailTableAdapter.InsertQuery(order_id.Text, Convert.ToInt32(gridData(2, i).Value), Convert.ToInt32(gridData(4, i).Value), Convert.ToDecimal(gridData(5, i).Value), Convert.ToDecimal(gridData(6, i).Value))
Next
Catch ex As Exception
MessageBox.Show("เกิดข้อผิดพลาด" & ex.Message, "ข้อความ", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End Try
End Sub
For Each myRow In Myset.tb_order.Rows
order_date.Value = Convert.ToDateTime(myRow("order_date")).ToString("s")
status_order.Text = myRow("status_order")
note_order.Text = myRow("note_order")
Next
gridData.Rows.Clear()
For Each myRow In Myset.td_order_detail.Rows
gridData.Rows.Add(App.My.Resources.PicDelete, gridData.RowCount + 1, String.Format("{0:D5}", myRow("code_goods")), myRow("name_goods"), _
Convert.ToInt32(myRow("num_s")), String.Format("{0:#,###.00}", myRow("order_price")), _
String.Format("{0:#,###.00}", myRow("order_total_price")))
Next
CalculateAllPrice()
End Sub
นี่มาจากฟอร์มรับสินค้านะค่ะ
Private Sub CalculateAllPrice() Dim sum As Decimal = 0
For i = 0 To gridData.Rows.Count - 1
gridData(1, i).Value = i + 1
gridData(6, i).Value = String.Format("{0:#,###.00}", Convert.ToDecimal(gridData(5, i).Value) * Convert.ToInt32(gridData(4, i).Value))
sum = sum + Convert.ToDecimal(gridData(6, i).Value)
Next
TotalAll.Text = String.Format("{0:#,###.00}", sum)
End Sub
Private Sub getOrderID() New_Recive_IDTableAdapter.Fill(Myset.New_Recive_ID)
If Myset.New_Recive_ID.Rows.Count > 0 Then
For Each myRow In Myset.New_Recive_ID.Rows
Temporder_receive_code.Text = "RE-" + String.Format("{0:D5}", Convert.ToInt32(myRow("receive_code")) + 1)
order_id.Text = Convert.ToInt32(myRow("receive_code")) + 1
Next
Else
Temporder_receive_code.Text = "RE-00001"
receive_code.Text = "1"
End If
End Sub
For Each myRow In Myset.tb_order.Rows
order_date.Value = Convert.ToDateTime(myRow("order_date")).ToString("s")
Next
gridData.Rows.Clear()
For Each myRow In Myset.td_order_detail.Rows
gridData.Rows.Add(App.My.Resources.PicDelete, gridData.RowCount + 1, String.Format("{0:D5}", myRow("code_goods")), myRow("name_goods"), _
Convert.ToInt32(myRow("num_s")), String.Format("{0:#,###.00}", myRow("order_price")), _
String.Format("{0:#,###.00}", myRow("order_total_price")))
Next
CalculateAllPrice()
End Sub
Tag : .NET, Ms SQL Server 2008, Crystal Report, VB.NET