Imports CrystalDecisions.CrystalReports.Engine
Imports System.Data.SqlClient
Imports System.Data
Imports System.IO
Imports System.Text
Public Class frm_bill_repair
Friend repair_id As String
Friend emp As String
Friend cus_name As String
Friend cus_address As String
Friend cus_tel As String
Friend car_lince As String
Friend car_brand As String
Friend car_version As String
Friend car_type As String
Friend car_color As String
Friend emp_technician As String
Friend service_chang As Double
Friend total_repair As Double
Friend cus As String
Friend monney As String
Friend u_name As String
Friend p_word As String
Private Sub frm_bill_repair_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.WindowState = FormWindowState.Maximized
Dim objConn As New SqlConnection
Dim objCmd As New SqlCommand
Dim dtAdapter As New SqlDataAdapter
Dim ds As New DataSet
Dim dt As DataTable
Dim strConnString, strSQL As String
strConnString = "Data Source=CHAREXTERNB\SQLEXPRESS;Initial Catalog=Amarin_db;Integrated Security=True"
strSQL = "select spa_name ,repair_detail_amount,unit_name ,spa_sellprice,repair_detail_total from repair_detail inner join spares on repair_detail .repair_spares = spares.spa_id inner join unit on spares.spa_unit = unit.unit_id where repair_detail_id ='" & repair_id & "'"
objConn.ConnectionString = strConnString
With objCmd
.Connection = objConn
.CommandText = strSQL
.CommandType = CommandType.Text
End With
dtAdapter.SelectCommand = objCmd
dtAdapter.Fill(ds, "myDataTable")
dt = ds.Tables(0)
Dim dt2 As DataTable
Dim ds2 As New DataSet
strSQL = "select service_name,service_price from expenses inner join service_charge on expenses.expenses_service = service_charge.service_id where expenses_id ='" & repair_id & "'"
objConn.ConnectionString = strConnString
With objCmd
.Connection = objConn
.CommandText = strSQL
.CommandType = CommandType.Text
End With
dtAdapter.SelectCommand = objCmd
dtAdapter.Fill(ds2)
dt2 = ds.Tables(0)
Dim rpt As New ReportDocument()
Dim directory As String = My.Application.Info.DirectoryPath
rpt.Load("C:\Users\Charaxter\Documents\Visual Studio 2012\Projects\Amarin_Garege\Amarin_Garege\Report\rpt_bill_repair.rpt")
rpt.SetDataSource(dt)
rpt.SetParameterValue("pr_repair_id", repair_id)
rpt.SetParameterValue("pr_cus_name", cus_name)
rpt.SetParameterValue("pr_cus_address", cus_address)
rpt.SetParameterValue("pr_cus_tel", cus_tel)
rpt.SetParameterValue("pr_car_lince", car_lince)
rpt.SetParameterValue("pr_car_brand", car_brand)
rpt.SetParameterValue("pr_car_version", car_version)
rpt.SetParameterValue("pr_car_type", car_type)
rpt.SetParameterValue("pr_car_color", car_color)
rpt.SetParameterValue("pr_technician", emp_technician)
rpt.SetParameterValue("pr_emp", emp)
rpt.SetParameterValue("pr_total", total_repair)
rpt.SetParameterValue("pr_service_chang", service_chang)
rpt.SetParameterValue("pr_cus", cus)
rpt.SetParameterValue("pr_monney", monney)
rpt.SetParameterValue("pr_username", u_name)
rpt.SetParameterValue("pr_password", p_word)
Me.CrystalReportViewer1.ReportSource = rpt
Me.CrystalReportViewer1.Refresh()
dtAdapter = Nothing
objConn.Close()
objConn = Nothing
End Sub
End Class