Tag : .NET, VB.NET, VS 2003 (.NET 1.1), VS 2005 (.NET 2.x), VS 2008 (.NET 3.x), VS 2010 (.NET 4.x)
ประวัติการแก้ไข 2018-08-07 17:04:54
Date :
2018-08-07 17:03:24
By :
futurezax
View :
905
Reply :
8
No. 1
Guest
Code
If DataGridView1.RowCount > 1 Then
Dim iTax As Integer = 0
For index As Integer = 0 To DataGridView1.RowCount - 1
iTax += Convert.ToInt32(DataGridView1.Rows(index).Cells(0).Value)
Next
Label2.Text = iTax
End If
Imports System.Data.SqlClient
Imports System.Threading
Imports System.Globalization
Public Class Form1
Dim resp As MsgBoxResult
Dim a1 As Integer = "10000"
Dim a2 As Integer = "3000"
Dim a3 As Integer = "13000"
Dim a4 As Integer = "50000"
Dim b1 As Integer = "11250"
Dim b2 As Integer = "3250"
Dim b3 As Integer = "14000"
Dim b4 As Integer = "56000"
Dim c1 As Integer = "12500"
Dim c2 As Integer = "3500"
Dim c3 As Integer = "16000"
Dim c4 As Integer = "63000"
Dim d1 As Integer = "13250"
Dim d2 As Integer = "3750"
Dim d3 As Integer = "17000"
Dim d4 As Integer = "66000"
Dim e1 As Integer = "14000"
Dim e2 As Integer = "4000"
Dim e3 As Integer = "18000"
Dim e4 As Integer = "70000"
Dim f1 As Integer = "15000"
Dim f2 As Integer = "4000"
Dim f3 As Integer = "19000"
Dim f4 As Integer = "75000"
Dim g1 As Integer = "16000"
Dim g2 As Integer = "4500"
Dim g3 As Integer = "20500"
Dim g4 As Integer = "80000"
Dim h1 As Integer = "20000"
Dim h2 As Integer = "5000"
Dim h3 As Integer = "25000"
Dim h4 As Integer = "100000"
Dim i1 As Integer = "22500"
Dim i2 As Integer = "6000"
Dim i3 As Integer = "28500"
Dim i4 As Integer = "110000"
Dim j1 As Integer = "25000"
Dim j2 As Integer = "7000"
Dim j3 As Integer = "32000"
Dim j4 As Integer = "125000"
Dim com As String = "Completed"
Dim wai As String = "Waiting"
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim casee As String = ""
If RB1.Checked Then
txt1.Text = a1
txt2.Text = a2
txt3.Text = a3
txt4.Text = a4
ElseIf RB2.Checked Then
txt1.Text = b1
txt2.Text = b2
txt3.Text = b3
txt4.Text = b4
ElseIf RB3.Checked Then
txt1.Text = c1
txt2.Text = c2
txt3.Text = c3
txt4.Text = c4
ElseIf RB4.Checked Then
txt1.Text = d1
txt2.Text = d2
txt3.Text = d3
txt4.Text = d4
ElseIf RB5.Checked Then
txt1.Text = e1
txt2.Text = e2
txt3.Text = e3
txt4.Text = e4
ElseIf RB6.Checked Then
txt1.Text = f1
txt2.Text = f2
txt3.Text = f3
txt4.Text = f4
ElseIf RB7.Checked Then
txt1.Text = g1
txt2.Text = g2
txt3.Text = g3
txt4.Text = g4
ElseIf RB8.Checked Then
txt1.Text = h1
txt2.Text = h2
txt3.Text = h3
txt4.Text = h4
ElseIf RB9.Checked Then
txt1.Text = i1
txt2.Text = i2
txt3.Text = i3
txt4.Text = i4
ElseIf RB10.Checked Then
txt1.Text = j1
txt2.Text = j2
txt3.Text = j3
txt4.Text = j4
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
nameasset()
statussalary()
change_all_column()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Me.Close()
End Sub
Private Sub change_all_column()
Dim header() As String = {"รหัสงาน", "ชื่อ", "ค่าบริการ"}
change_column_datagrid(DGV1, header)
End Sub
Private Sub nameasset()
If cn.State = ConnectionState.Open Then cn.Close()
'cn.ConnectionString = sql
connect_open()
Dim sql1 As String = "SELECT CUSTID,USER_ASSess FROM TBL_POLICY_SUCCESS"
'Dim sql1 As String = "SELECT OFFICER_ID,FNAME_THAI FROM TBL_OFFICER"
Dim da As New SqlDataAdapter(sql1, cn)
Dim dt As New DataTable
da.Fill(dt)
With cbb1
.DataSource = dt
.DisplayMember = dt.Columns.Item("USER_ASSess").ColumnName
.ValueMember = dt.Columns.Item("CUSTID").ColumnName
End With
End Sub
Private Sub statussalary()
If cn.State = ConnectionState.Open Then cn.Close()
'cn.ConnectionString = sql
connect_open()
Dim sql1 As String = "SELECT cus,status FROM Status_Salary"
'Dim sql1 As String = "SELECT OFFICER_ID,FNAME_THAI FROM TBL_OFFICER"
Dim da As New SqlDataAdapter(sql1, cn)
Dim dt As New DataTable
da.Fill(dt)
With cbb2
.DataSource = dt
.DisplayMember = dt.Columns.Item("status").ColumnName
.ValueMember = dt.Columns.Item("cus").ColumnName
End With
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
names.Text = cbb1.Text
sql = "select CERTIFICATE,NAME,TOTALPRICE from TBL_POLICY_SUCCESS where STATUS_REPORT1 = '" & cbb2.Text & "' AND TBL_POLICY_SUCCESS.USER_ASSess = '" & cbb1.Text & "' "
DGV1.DataSource = cmd_dataTable()
' AND TBL_POLICY_SUCCESS.SENT_REPORT_DATE like '" & dtp_1.Value.ToString("yyyy-MM-dd HH:mm:ss.ttt") & "'
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
GirdToExcel(DGV1)
End Sub
Private Sub GirdToExcel(ByRef dgvw As DataGridView)
Dim Appli As New Microsoft.Office.Interop.Excel.Application
Dim Libro As Microsoft.Office.Interop.Excel.Workbook
Dim Hoja As Microsoft.Office.Interop.Excel.Worksheet
Dim col As Integer = DGV1.ColumnCount
Dim row As Integer = DGV1.RowCount
Libro = Appli.Workbooks.Add
Hoja = Appli.Worksheets.Add()
For i As Integer = 1 To col
Hoja.Cells.Item(1, i) = DGV1.Columns(i - 1).Name.ToString
Next
For fila As Integer = 0 To row - 1
For e As Integer = 0 To col - 1
Hoja.Cells.Item(fila + 2, e + 1) = DGV1.Rows(fila).Cells(e).Value
Next
Next
Hoja.Rows.Item(1).font.bold = 1
Hoja.Rows.Item(1).horizontalAlignment = 3
Hoja.Columns.AutoFit()
Appli.Application.Visible = True
Appli.Application.WindowState = Microsoft.Office.Interop.Excel.XlWindowState.xlMaximized
Hoja = Nothing
Libro = Nothing
Appli = Nothing
End Sub
Private Sub DGV1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGV1.CellContentClick
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
If DGV1.RowCount > 1 Then
Dim iTax As Integer = 0
For index As Integer = 0 To DGV1.RowCount - 1
iTax += Convert.ToInt32(DGV1.Rows(index).Cells(0).Value)
Next
Label5.Text = iTax
End If
End Sub
End Class