DEVELOPING YOUR TECHNICAL CAREER

Hi developers or do i say hi programmers….., anyway hi all. One thing we have to know is that its not all about writing codes, testing application or doing the technical stuff that will help us improve our career. A lot is needed alongside;knowing how to mingle with your team, marketing your products; why don’t you stop reading those technical books this holidays and try your hands on any of these books from the pragmatic bookshelf and I bet you will never regret it

Just ebay for these books.

1. practices-of-an-agile-developer-working-in-the-real-world-pragmatic-programmers.

2.the-passionate-programmer-creating-a-remarkable-career-in-software-development-pragmatic-life

3.agile-coaching

4.land-the-tech-job-you-love-pragmatic-life

5.The Pragmatic Programmer, From Journeyman To Master

Happy happy Xmas and prosperous new year. May the Lord Almighty help us to be wise, fair, and kind in all our affairs. Stay blessed

Advertisements

CRYSTAL REPORT USING DATABASE TABLES AS DATASOURCE

Crystal reports can be created in .Net applications with different data sources including using database tables, stored procedures, typed datasets and also without a data source.

In this article we are going through how to create a crystal report for the first time using database tables as the datasource.

1. You have to create your windows project in using VS 2005. After creating the project, right on then project name in the solution explorer, select “add” and then “add new” as shown below.

image

2. In the add new dialog box, select “crystal Report” and name it, and then click on the add button.

image

3. You will be presented with the “crystal report gallery” dialog, choose “using the report wizard” and click on ok

image 

4.In the choose data source dialog, go to the “ Create New Connection” node and then select the “OLE DB(ADO)” sub node.

image

4. You will then be required to provide the database connection information. Slect the “Microsoft OLE DB provider for SQL server” and click on the next button

image

5. Here you provide the database logon parameters

image

6. After successfully connecting to the database, you then select the table (s) you want to display its content on your report

image

6. After selecting the table(s) you select the actual columns you want to displayimage

7. After choosing the columns you will display, you can click on next to choose the columns for grouping and then for filtering, and then finally you choose the format to display your report.

image

8. After you have finished designing your report, you then drag a “crystal reports viewer” onto your form.

image

Then create a code under the form load event to show your report on for load

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ‘create a new report document 
        ‘and load the report from its source
        ‘use Application.StartupPath to get the address of your report fro deployment issues
        Dim rpd As New ReportDocument
        rpd.Load("C:\Gilbert\Personal\Projects\BlogPosts\BlogPosts\tableDS.rpt")
        Me.CrystalReportViewer1.ReportSource = rpd
        SetDBLogonForReport(rpd)

    End Sub

    ‘for deployment issues make sure the database paramaters are encrypted
    ‘and saved in the mysettings class

Private Sub SetDBLogonForReport(ByVal myReportDocument As ReportDocument)
       Dim myConnectionInfo As ConnectionInfo = New   ConnectionInfo()
       myConnectionInfo.DatabaseName = "datalinkDB"
       myConnectionInfo.UserID = "sa"
       myConnectionInfo.Password = "qwerty"
       myConnectionInfo.ServerName = "localhost"
       myConnectionInfo.IntegratedSecurity = "false"
       Dim myTables As Tables = myReportDocument.Database.Tables
       For Each myTable As  CrystalDecisions.CrystalReports.Engine.Table In myTables
           Dim myTableLogonInfo As TableLogOnInfo = myTable.LogOnInfo
           myTableLogonInfo.ConnectionInfo = myConnectionInfo
           myTable.ApplyLogOnInfo(myTableLogonInfo)
       Next
   End Sub

Below is a picture when the application is run

image

HIDING CONTROLS WHEN PRINTING WITH WINDOW.PRINT()

Sometimes in web applications (ASP.NET) we prefer printing a window without some controls that appear on the interface. For example, printing a window by clicking on a print button without showing the print button on the printed document. In this example we are printing a student’s results without showing the Print and the close buttons.

To start, we place the two control in a DIV control.Drag the “DIV” control from the HTML controls section. Name the DIV control by giving a value to ID property as shown below. Place the print and close button in the DIV control.

clip_image002

Note that in creating ASP.NET applications, there are two types of source codes, the VB/C# source code and the HTML code. First we create a script to hide the DIV control as shown below. In the script below the “dv1” is the ID value of the DIV control

Add this script to the HTML source

   1: <script language="javascript" type="text/javascript">

   2:    function hidePrint(){

   3:     document.getElementById("dv1").style.display='none';

   4:     window.print();

   5:     window.close();

   6:             }

   7: </script>

Note that the script should be in between the <head></head> tag of the html source code

Select the print button and go to the html source code and add the onclick property . The value of the onclick property should be the created javascript function (named hidePrint()). The button’s html code should look like the one below after the addition of the onclick property

   1: <input type="button" id="Button1" runat="server" 

   2: value="Print" class="fltbutton"  style="width:60px" 

   3: onclick="javascript:hidePrint();" />

This is all you have to do and you are good to go.

Below is a window showing the student’s results and the Print and the Close Button

clip_image004

What is printed after clicking on the “print” button

clip_image006

Cheers!!!!