Thursday, September 25, 2008
C# 101 Samples
C# 101 Samples CS101SamplesBCL.msi CS101SamplesBCL2.msi CS101SamplesDataAccess.msi CS101SamplesVSTO.msi CS101SamplesWebDevelopment.msi CS101SamplesWinForms.msi Labels: C# |
Java Tutorial
A practical guide for programmers with hundreds of complete, working examples. Your First Cup of Java: Detailed instructions to help you run your first program: for Win32, for UNIX, for Mac. Getting Started : Essential Java Classes Learning the Java Language Custom Networking Writing Applets JDKTM 1.1 -- And Beyond Download Labels: Java |
Wednesday, September 24, 2008
A Lot of Crystal Report Sample
vbnet_win_adodotnet.zip This Visual Basic .NET sample Windows application demonstrates how to build and populate an ADO.NET dataset and pass the dataset to a report at runtime. Download vbnet_win_changefont.zip This Visual Basic .NET sample Windows application demonstrates how to change the font of database and text field at runtime. Download Vbnet_win_custompapersource.zip This Visual Basic .NET sample Windows application demonstrates using the new CustomPaperSource property in Crystal Reports 10 to print a report to a different printer tray. Download vbnet_win_customviewer.zip This Visual Basic .NET sample Windows application demonstrates how to create a customized viewer. Download vbnet_win_dbengine.zip This VB .NET Windows application demonstrates how to log onto a secure SQL database using the database table objects of the ReportDocument class. Download vbnet_win_dbviewer.zip This VB .NET Windows application demonstrates how to log onto a secure SQL database using the LogOnInfo object of the Windows Form viewer. Download Vbnet_win_dynamicimage.zip This Visual Basic .NET sample Windows application demonstrates how to create a dataset, add images to the dataset, and pass this dataset to the subreport at runtime. Download vbnet_win_dynamic_report_formula.zip This Visual Basic .NET sample Windows application demonstrates how to create a dynamic report based on user input. This application uses blank formula fields to specify which database fields appear on the report and to specify which field to group on. Download Labels: VB.Net |
How to export to Crystal Reports format from a VS .NET application
How to export to Crystal Reports format from a VS .NET application How do you export a report to Crystal Reports format from a .NET application (Windows or web) using VB .NET or C# code? Resolution To export a report to Crystal Reports format from a .NET application perform the following steps: Read more... ==================== NOTE: The following steps will show both VB .NET and C# code samples. ==================== 1. Add the assemblies. Three assemblies must be added; CrystalDecisions.CrystalReports.Engine.dll, CrystalDecisions.ReportSource.dll and CrystalDecisions.Shared.dll. To add them, place the following code at the top of the code page: VB. NET: Imports CrystalDecisions.CrystalReports.Engine Imports CrystalDecisions.Shared C#: Using CrystalDecisions.CrystalReports.Engine; Using CrystalDecisions.Shared; 2. Define a location to save the file to. Place the following code in the routine that will process the report (For example the Page_Load or Button_Click event): VB. NET: Dim exportFileName As String = "exportedReport.rpt" Dim exportPath As String = Application.StartupPath & "\" & exportFileName C#: string exportFileName = "exportedReport.rpt"; string exportPath = Application.StartupPath + "\\" + exportFileName; 3. Load the report. The following code instantiates a ReportDocument object and loads a report from disk. VB. NET: Dim crReportDocument As New ReportDocument crReportDocument.Load("path_to_your_report_file.rpt") C#: ReportDocument crReportDocument = new ReportDocument(); crReportDocument.Load("path_to_your_report_file.rpt"); 4. Export the report to disk. There are two methods to export a report to disk. The first is to use the 'ExportOptions' class to define the exporting options while the second is to use the 'ReportDocument.ExportToDisk' shortcut method. Both are described below. Method 1 - Using the 'ExportOptions' Class --------------------------------------------------- VB. NET: Dim crExportOptions As ExportOptions Dim crDestOptions As New DiskFileDestinationOptions crDestOptions.DiskFileName = exportPath crExportOptions = crReportDocument.ExportOptions crExportOptions.DestinationOptions = crDestOptions crExportOptions.ExportDestinationType = ExportDestinationType.DiskFile crExportOptions.ExportFormatType = ExportFormatType.CrystalReport crReportDocument.Export() C#: ExportOptions crExportOptions; DiskFileDestinationOptions crDestOptions = new DiskFileDestinationOptions(); crDestOptions.DiskFileName = exportPath; crExportOptions = crReportDocument.ExportOptions; crExportOptions.DestinationOptions = crDestOptions; crExportOptions.ExportDestinationType = ExportDestinationType.DiskFile; crExportOptions.ExportFormatType = ExportFormatType.CrystalReport; crReportDocument.Export(); Method 2 - Using the 'ExportToDisk' Method ---------------------------------------------------- VB.NET: crReportDocument.ExportToDisk(ExportFormatType.CrystalReport, exportPath) C#: crReportDocument.ExportToDisk(ExportFormatType.CrystalReport, exportPath); Once the code is executed successfully, you will find the exported report in Crystal Report (.RPT) format in the folder as specified by the 'exportPath' variable, which in this case is the folder with the running executable (.exe). Labels: Code Snippet |
Active Directory Utility Class
Active Directory Utility Class This static class contains utility methods which are useful as samples of how to access Active Directory information from a .NET application. Note that this class is NOT production-ready; it is for sample use only! A production-ready application would: • Store the credentials used to access AD in a secure location (username and password are embedded in the code which is a big security hole!) • Consider using appropriate “least privilege” account(s) • Have better exception handling Furthermore, this sample class assumes that all users and groups are in the same Active Directory domain; modifications will be required to handle multiple (trusted) domains. The class provides the following. Note that all user and group names are not qualified by their domain name in this version. GetUserCN (username) – Returns the common name (first and list names) of a user given the username GetUserInfo (username) – Returns a UserInfo structure (defined in the same .cs file) containing the first name, last name and login name for the user GetUserInfoEx (username) – Returns a UserInfoEx structure (defined in the same .cs file) containing the user’s first and last name, address, phone number, email and other information UpdateUserProperty (username, propertyName, propertyValue) – Updates a single property of an AD user GetAdGroups (prefix) – Return a string array of Active Directory group names beginning with the specified prefix GetGroupsForUser (username) – Return a string array of Active Directory group names which the specified user is a member of FindUsers (username) – Return a UserInfo array of users matching the specified pattern AddUserToGroup (username, groupname) – Adds the specified user to the specified group RemoveUserFromGroup (username, groupname) – Removes the specified user from the specified group AddNewUser (username, password, firstName, lastName, description) – Creates a new user with the specified information) ChangeUserPassword (username, newPassword) – Changes a user’s password to a new value. Download Labels: C# |