Search

Thursday, March 19, 2009

Case Statement in Ms-SQL Server

SELECT Partys.PartyId, Partys.PartyName, GRN.ChallanNo, GRNDetail.GrnId, GRNDetail.ChallanQty,
GRNDetail.AcceptQty,
CASE
WHEN challanqty = Acceptqty THEN '55%'
WHEN ((Acceptqty / challanqty) * 100) > 90 THEN '50%'
WHEN ((Acceptqty / challanqty) * 100) > 90 AND ((Acceptqty / challanqty) * 100) < 70 THEN '40%'
WHEN ((Acceptqty / challanqty) * 100) > 70 AND ((Acceptqty / challanqty) * 100) < 50 THEN '25%'
ELSE '0%'
END AS 'Quality',

GRN.PoNo,

Convert(nvarchar,PurchaseOrders.DeliverbyDate,103) as DeliverbyDate,convert(nvarchar,grn.GrnDate,103)AS GrnDate,
Case

when (datediff(day,DeliverbyDate,GrnDate))<= 3 then '45%'
when (datediff(day,DeliverbyDate,GrnDate))> 3 and (datediff(day,DeliverbyDate,GrnDate)) <= 7 then '35%'
when (datediff(day,DeliverbyDate,GrnDate))> 7 and (datediff(day,DeliverbyDate,GrnDate)) <= 10 then '20%'
else
'0%'

end as 'delivery'
FROM GRNDetail

Thursday, March 5, 2009

Monday, March 2, 2009

Print Crystal Report Programatically with Parameter




Print Report On Click Button Or Programatically with Parameter using Below Code

CrystalReportViewer1_Load
{
'Define Report Document

crReportDocument = New ReportDocument()

'Find Current Printer in Local Machine

Dim printDocument As New System.Drawing.Printing.PrintDocument()
crReportDocument.PrintOptions.PrinterName = printDocument.PrinterSettings.PrinterName

'find path of report

Path = Application.StartupPath
Path = Mid(Path, 1, Len(Path) - 9)


'load printer

crReportDocument.Load(Path & "\test2.rpt")

'pass Peramter

crReportDocument.SetParameterValue("@invoiceid", invoiceno)
CrystalReportViewer1.ReportSource = crReportDocument

'Assign User name and database name for avoid error Answer
'Incorrect Log on Parameters

crReportDocument.SetDatabaseLogon("sa", "pass#word1", ".\sqlexpress","TATA")

'Print report using Printer

crReportDocument.PrintToPrinter(1, True, 1, 1)

}
End Sub

Blog Archive

Contributors