Crystal Report Tutorials For Beginners Using C#

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what's up YouTube welcome to dotnet mo this is a video tutorial on crystal report from business to address before starting this video I would like to ask you a favor if you found this video helpful please thumbs up this video and for more awesome videos like this please be subscribed to this channel in this part I will show you some basics about reserve rapport and conserve it would be work things like creating a new curser report and getting started with a crystal report first of all castle report is used to design and generate reports from a wide range of data sources like data base text files XML files etc actually there are two types of cursor report one is for visual studio that is for the purpose of developing the project or crystal report and second one is runtime cursor that will be used in client-side where we don't need to design user report only we need to run created crystal report so keep in mind that there are two types of crystal report one is for visual studio and one is for rent time I will be explaining basics of crystal report with windows form application for that go to file then new then project then select windows and efficacy shop then select windows home application then name your project here I will name it s so here we have a brand new windows form application it comes with a default form form one now I want to change this form title for there go to properties here then changing these form title has basics of crystal report contains windows state 2 maximized in order to avoid commonly seen errors in Crystal report we want to do some pre settings for this project right-click on project then go to properties make sure that targeted framework is not a client profile version after that we have to change this app config now we want to add a property into startup tab use legacy v2 and activation policy to true now let me add crystal report viewer into this form for that open your toolbox then go to reporting section reporting then drag custom report viewer into it is for I want to name this crystal report for that right click on it then properties and change this name here see are we viewer I want to hide this left panel tree for that we can take this property to panel view to none that's it open solution explorer now we are going to add crystal report into this project before that I am going to add a folder into this project right click on it then add new photo inside this folder we are going to save our Crystal Reports so I am going to name this folder as Crystal Reports make sure that folder name does not have any space inside this folder I am going to add a custom report right click on it then add new item then from the left panel select reporting then select fiscal reports and I am going to name this report as C opt as the prefix for this crystal report ClpP hello world click on add now we have a dialog box like this now we have to select the template for this crystal report for now I will select this option as a blank report then click on OK so here we have the crystal report it contains report heard of this section will be shown in the top of the report then we have page data this will be shown in the top of every page then we have section for details then we have report footer will be shown at the end of the report finally we have page footer to be shown at the end of each page in the report so I'm going to design this cursor report as simple as possible since is the first part of this tutorial first of all I'm going to add a text box here in order to write my report had the name or with Courtney I can just type it here report name and they want to format this I click on it and format object or - phone tab want to set it as c0u I see GUI unities then font size to 14 then click on ok let me expand this text box so that you can see the complete texting it now I am going to add a hello world in this detail spot here for that right click then insert text box hello world I want to format it I click on it format object go to phone tab then changing this font family to cg.o you I want to increase the font size to tool then click on OK let me expand it now I want to add page number into this report for that right click inside page future then insert then special field then look for page number here it is then paste the field inside page footer right below hello world now I want to add one more special field inside page header for that right click on it then insert special fields then print that's it you know to see the preview of this Cousteau report you can click on this main report preview here you can see the report name then print date that means today's date then hello world string at the end of this page in the footer section page footer here we have page number now I'm going to show discussive report inside this form crystal report viewer in c-sharp for that I am going to use this form load event in order to generate the even double click on this form here for that I am going to create an object of disgust sir report first of all Crystal Reports that will be the name space of this Crystal Reports in cities inside this folder dot C Appetit hello world Jack name will be C opt if equal to new object now we are going to set this crystal report inside this cursor report viewer for that you can do this report viewer name is C of V view bot got report source first of all we will clear the report source by setting it as null and then we will set it with the Creator crystal report filter report source is equal to C opt that's it now let me run this application for that you can click on the start button here that's it guys here we have the crystal report inside cursors report viewer so it is displayed as we expected so in this video tutorial we will be discussing in the three points first one will be how to display c-sharp data table in Crystal report using data set and second one will be how to use formulas in to support finally we will learn how to suppress report elements in Crystal report with and without condition so let's get started this is my Visual Studio 2013 and I have installed crystal report for which is Studio 2030 I will be explaining things using a windows form application so first of all we are going to create a windows form application for that go to file then new that project under we should see shop select windows then windows form application so name your application here so in this case it will be something like crystal data table and select the location where you want to see the application then click on OK so here we have our brand new windows form application and it has a default windows forms so that will be form 1 and so I want to change the form title for there I click on the phone then go to properties then change the test here so I want to change it as that table to crystal report so that's it no we want to include extra report viewer in order to display our crystal report for that open the toolbox then under reporting header you can see the crystal report viewer here dragged into the form so here we have our crystal report viewer so I want to name the we were for that right-click on the people then go to properties then I want to change the name as see how me data tab now I want to hi this tool panel that is displayed here in the left side area for that we want to change the tool panel view into none that's it next we are going to write code inside the load event of the form first of all go to properties of the form by right-click on the form then click on properties then click on lightning symbols here for events then double click on load so here we have our load event of the form let me paste the code for the hard-coded tab here tablet name will be product and it has four columns serial number' name' price and count and five test data are inserted into the product so we want to show this data table in our crystal report so we will be using data set to pass this c-sharp data table into crystal report now I am going to add cross re-put and data set into our project before that we need to make it organized for that I am going to add a folder with name report generator and then inside the folder I'm going to add two folders one for Crystal report and one for that I said first of all we are going to add a data set for this tab for that white click on that asset folder then add new item and select data from the left panel then select that asset name the data set as the yes product I used DSS prefix for that I said we called app now I'm going to add the dabble for product in the data set for that right click on data set then air then data table name here product and then you can add homes like this column name should be matched with the C sharp data table or column let me copy the column names from here and pacing here you can use ctrl L shortcut to add columns so now we have the product abilene set out data set and it has same column names as c-sharp data table and we can change the data column type here for that right click on the column then click on properties then here you can set the data type also and in this case we have in string decimal law in the by default it will be a string so a name will be string then price as decimal and then count has end I think so it's long so here you can set in 64 that's it to say that I set press control s now we can add the cursor report for that right click on cursor report folder then add new item and you need to select reporting from the Left panel then select crystal report you can name the report here C opt product I use CL pretty as prefix for cursor reports click on add now we have our C opt product it's a report here and now it is asking for for the configuration of the crystal report now keep it keep this crystal report gallery as it is click on OK now we need to select the data set that we have just created for that open the folder project data then Honda IDEO dot that data still you can see B data said that we have created here we have the ds4 right data set with its namespace below that you can see our product tab now in order to select the tab you need to click on this button with right arrow click on that now just click on finish now we have our cursor for COPD product in the report you can see to default elements page number and printing let me get rid of that deleting those fields and here you can see the field explorer window suppose in your case you are not seeing this window you can right click on the report then click on field export there you can see that our base fields under that you can see the tablet product from our data set the yes product under that you can see the columns in it suppose you change some of the columns in our table or you added or deleted columns it won't be updated automatically into our crystal report we just need to update it manually right click on the table then click on verify database if there is any change it will be updated now suppose you need to add more tables into the cursor:default you can do that by I click on the database fields here click on database export then select the table then click on the right arrow here click on ok now I am going to design the crystal report with the product table so here we have the columns serial number name price and count I'm going to drag these columns into details section here you can see one field object element and this will be the text object element so this is a plain text showing see lens number and it stands for the column header and in this field object it will show every column values and it is repeated as much as rows person in the table so let me drag other columns also now I want report header for that I can do something like this right click on the report then insert text object place the object in the middle of the report you can enter the report header here so in this case it will be C sharp that table - crystal report I want to add some styles to these text so for then right click on it then format object then go to phone here you can add just phone and phone size and related things in this case I want the head of a sport and I'm gonna increase the font size to 12 from 10 click on OK and I would expand this header to see the complete text in it now I want to format these column headers for that you can individually format them by right-click on each of them other ways you can select all of them once and right-click on one of them and then you can see a format multiple objects option there click on it in the font tab you can add this this style to bold then remove the underline click OK now I want to show this crystal report in our crystal report viewer in form 1 ok before getting into death to avoid unnecessary errors you need to add this tag inside our app config file use legacy v2 runtime activity policy to true ok then inside the form event we need to set the data source for this cursor report so our cursor for name is CRPD product I'm going to create them create an object of the report CRPD equals new crew support CRPD product okay now we can set the data source like this see our PT dot database Don dabbles then we need to give the e double name that we have given in the data set that is the this product let me copy this and paste in here dot set data source inside that we can pass the table product as a parameter now I am going to set their poor viewer sauce as this causal report for that you can do something like this year we data table dot iPod sauce equals null to reset the a cursory put for you after that we will be setting the Excel report see our PT let me run the application so that's it let me maximize the window so this is how we can show c-sharp data table in custom report so this is our current user report we need to show the tabular border and separation line between each column and each row unfortunate the inclusive report we don't have any element to draw such a table we need to show the borders and separation lines manually let's look how we can do that so in order to add a border for this table we can use box element for that right click on the report then inside box insert box then I'm going to draw this box from the top left corner to bottom right corner like this so we have a border here and we are going to add the column separation for that we will be using a line element draw from the top of border to bottom border same for other columns also now we want to add a rope separation for that we can add a horizontal line here now I want to change the line thickness of these lines for that I'll be selecting all of the lines then right click on one of them and click on format multiple objects then you can change the thickness width here click on ok now let me own the application now okay here we can see a gap here to avoid the gap we can all reduce the details extra space here now let's run the application again and that's it now let's check how we can add formulas into crystal report for that in field Explorer you need to right click on this formula of fields then click on new here we need to name our formula I will say sum of price click on OK then we will see a pop-up window for formula workshop this is where we define our formula so in this formula I need to show the sum of price in from the table for some operations we can use sum function then one open parenthesis and then one closing parenthesis and we need to pass the price as a parameter here so for there you can see the table product here we can see all the tables that we have added into a crystal report here so here we have our product table then I want to add this price parameter for the sum function for that you can drag this price into the some function like this now you can save the formula by pressing ctrl s or otherwise you can use any of these button save and save and close okay in order to show the formula we can drag the formula into our report so in this case I will show here right below the price and we'll add a text box saying this is sum of price okay let me run the application now that's it here we can see some of price is equal to 840 finally we are going to discuss how we can suppress or hide elements in Crystal report so suppose we want to hide this report footer for that you can right-click on the report footer then click on suppress now if you run the application you can't see the report photo otherwise if you want to suppress an element in Crystal report using a condition suppose here we have the sum of price as 840 so if I want to suppress this report footer if the sum of price is greater than a 850 for that you can do something like this click on in the element then click on second export here we can see these sections that we have in Crystal report we have reported a page header details page footer and report footer so we need to hide or suppress this report footer conditionally for that check this suppress check box then click on this button this is for to have a define our condition for suppressing click on it now we need to describe our condition here if if our formula sum of price that's here drag this into the if condition then if the condition is greater than 850 then true else false this means if the formula or some of price is greater than 850 then suppress the element else don't suppress the element in order to save the condition you can press ctrl s click on okay now let's run the application here you can see the report photo since the sum of price is 840 suppose I am going to add a fixed value into our sum of price for that you can right click on the formula then we can't edit here I am going to add F 50 into actual sum of price save and close now let me run the application now so here you can't see the report food since the formula value is greater than 850 you can download this sample code from the link given below in video description in this video we will discuss how to use stored procedures in our Crystal Reports so let's take how we can consume stored procedures in Kosovo report for that I will be using a windows form application to show how it works even though you can use the same method in any system application whether it is WPF or asp.net web application in order to create a windows form application go to file then new then project or you can use the shortcut ctrl shift n under we should see sharp select windows then windows form application then name your project here I will name it as stored procedure in Crystal report you can see our PT then select the location where you want to save this application then click on OK so now we have a brand-new windows form application in this video tutorial we are going to deal with two methods to create cursor report from store procedure in the first method we will call stored procedure from our c-sharp code and we will pass the result into our crystal report in the second method we will be calling this tour procedure directly from our crystal report so let get started I am going to design this form with cursor report viewer let me expand this form and from the tool box I am going to drag crystal report viewer and the reporting heading drag into the form then go to properties I want to change name for this viewer CRV report then our tool panel view to none and I want to change this form title has crystal report with stored procedure in order to select the two methods I will drag two buttons let me copy the button that's it I will name this button as BTN method one and text will be method 1 method - BTN method 2 before discussing our first method let me do the DB part for that let me open my management studio here I want to create a new database for that right click on databases then click on new database then name your DB here I will name it as 4 like DB click on OK so here you can see the newly created product DB here I want to add a tab into this DB for that right click on tables then tabal so let's create a table to store details of products starting with product ID column that type will be int then product name as walk 50 then product code as Walker 50 then price has decimal 18 2 then count as in let me save the table you can use the shortcut control s or you can click on the Save button here then name your table here I will name it as product click on OK in order to see the newly created tab explain these tabs here there you can see the product tab I have inserted some test rows into the product table now let me create a stored procedure for that click on new query here make sure that we have selected the proper database product DB here in order to create a new stored procedure you can type like this create pros then procedure name will be product under X price and we have a parameter at price of the type decimal 18 - as begin and so in this store procedure we will retrieve all the product details whose amount is less than this price threshold sequel query will be like this select star from product were price less than given price instead of select star I will specify column names here product name then product core price and count in order to execute this query you can use the shortcut f5 or click on this execute button here so we have created these stored procedure successfully in order to see the newly created stored procedure you can expand program ability then under store procedure it should be there if not click on this refresh button here that's it now back to visual studio before explaining method 1 you need to change your app config file for there let me open my app config file here and you need to add this tag into your startup tag use legacy v2 runtime activation policy to true now back to a form in order to work with crystal report I will add two folders into our project one is for Crystal report so I will name it less crystal report and one is for data set so under data set I am going to create a new data set for product for the mighty Khan data set then add new item this select data from the left panel then select data set here then I will name it as das product I use DSS prefix for data set we can add I'm going to add a data table here for their right click then add data table then you can name your table here I will name it test product then we can add columns from our product table so it will be you don't want Product ID since we have not selected product ID in our stored procedure so starting with product name for that rightly then add column or you can use the shortcut ctrl L product name then product core then price and calm that's it so we have created a data set here this product and we need this data set in method 1 only now let me create a crystal report for that right click on the photo then add new atom then reporting the select crystal report I will name it as C opt method 1 then click on add then it will open a dialog box like this keep the option as it is using the report wizard click on OK then I will select the data set from here so I will select the product tab under this product that I said then click on finish let me design the crystal report before that I will delete the default initial field from our crystal report that is print date and page number I will add a report header here so I want to make this in a same length for that egg salad and right click then align tops let me reduce the detail section height and I will change the column header style for that select all of them then right click for my multiple objects then go to font uncheck underline had a bold style to these corridors click on OK so let's MMN method one further I will use the method one button click event in that I will call the stored procedure product under X price and we will go to the result into NC shop data tab and we will pass the cutter table into our crystal report that's it for that I will use the method 1 button click event double click on the button first of all I will create an object of SQL connection here SQL connection so in this case I need to import the system dot that a dot a scale fine name space then SQL corn equals new SQL constant inside that we need to pass our connection string you so under the folder Chris every poor you can see a cursor report see uppity method and I want to rename that into civt method one but that right click on it then rename I will rename it into CR PT method one click and that's it so we will be creating another crystal report for method two now back to the event first of all we will check whether the SQL connection is open or not if it is closed we will open the SQL connection now we will make use of SQL data adapted to retrieve the yourself from our stored procedure SQL data adapter skew LD a equals new SQL data adapter inside that we need to pass our stored procedure name for that I will copy the stored procedure name from our stored procedure and pacing here and second parameter will be our SQL connection SQL corn and then we will set the data adapter command select command dot command type equals command type dot stored procedure and we will pass the toe procedure parameter select command dot parameters dot had with value parameter name is price copy paste here and in this case I will pass a value 65 now I will create an object of data table here d t VL equals new data table and then we will fill the result into this data table by calling the full function SQL da dot fill DT beer so we have the stored procedure result inside this data table SQL corn door closed and now we need to pass this data table into a stored procedure first of all I will create an object of the stored procedure CRPG method 1 see a free tea method 1 equals new C opt method 1 and we will set the so report data source like this database dot doubles and we'll pass the data table name here that you can see in the data set as product so I will type your product door set data source and we will pass our data table here DT BL and we will set this person report into a crystal report vivo for that first of all I will reset the report source to null and we will set this crystal pour into the crystal report you will see RP team at that one let me run this application for that click on the start button here now click on method one so that's it here you can see the details of products from our product table whose amount is below 65 so in for the last two columns you can see a miss alignment for that you can align these headers to the right part or you can align these Roly tastes to left part for that let me go to my crystal report see a pretty method one and select the column headers and right click format multiple objects and then go to paragraph then alignment to right click on okay say let me run this application again click on my third one now it looks fine so in method one we called store procedure from our c-sharp code and we filled the result in to see some data table and we paused the data table into code see a PT method one through the data set D s product now let's move to method two for that I am going to add new report and new ADA reporting select castle report I will name the castle report as C RPG method to click on add then keep the option as it is using the report wizard click on OK in this case we are going to add new connection into data sources for that let me expand create new connection folder then go to oily DBA do expand the folder then click on make new connection then we need to select the server so in this case I will select Microsoft oil BBB provider for SQL Server then click on next so here we need to pass our connection information in this case I will use Windows authentication mode so I will select integrator security to true so if you are going to use the SQL Server authentication mode you can uncheck this and you need to pass a user ID and password so in this case I will stick with Windows authentication mode then we need to pass server name here local backward slash SQL d 2000 tool then we need to select database from this drop-down I will select product DB then click on finish so here you can see a connection locally backwards flashes QLD 2012 expand this connection expand product DB expand DB o below that you can see store procedures here we have our stored procedure of product and X price select the procedure then click on this button with right arrow so it will pop up another dialog box in bed we need to pass default values for our stored procedure parameters so in this case we have a parameter hat price so whether you can set it as null or you can enter some value here for now I will set it as click on ok then click on finish here so in this case a remove special fields print date and page number and in the file explorer you can see database fields here and then you can see the studio CGA product under X price below that you can see the columns from our store procedure product name product code price and count so if we can make use of these columns in our crystal report instead of data set so we don't need to use that asset in this method now let's design the report for that I will drag text object from the toolbox into report header and I will in the method to here and I am going to format the object let me English the font size to somehow 24 and staff will be pulled click on okay let me expand the object now I'm going to add columns from our stored procedure go to field Explorer then drag these columns product name product core price and count I want to format these tablet this for that select all of them then right click format multiple objects then go to font uncheck underline selecting bolt from style drop-down click on ok let me dig this the size of detail section here and you can see the parameter fees from our stored procedure here as price if you click on main report preview here you can see the preview of our crystal report at the moment we don't have any product details here since we have passed null value to the parameter product now let's consume this crystal report see a pretty method to using the button method to so let me create button click even for this button for that let me double click on it let me create an object of Thea cursor report here so then store procedure in CR PT cursor fourth dot C I pity myself to see our PT method two will be the object name equals new see how pretty method two and we are going to set this cursor report to our crystal report view work for there let me copy these two lines from our method one and facing here and changing CR PT method one to see our PT method two so we are going to pass value into this parameter field from our C sharp so we can create the report dynamically for that you can do something like this our PD method to dot set parameter value then first parameter will be the parameter name itself so it is at price and I will pass a value here as 65 that's it let me run this application click on method - that's it here we have the product details whose price is under 65 in this video I will tell you how to create sub reports in cursory porn so let get started this is my Visual Studio 2013 for the demonstration purpose I have created a Windows Phone application with name sub report before creating crystal report let me create a folder for adding new crystal report with named Crystal report inside that we will add our Crystal Reports first of all I am going to add a main person report for that right-click on the folder and click on add new item select reporting from the left panel then select report name in the report as see a pretty main click on add then from this dialog box I will select as blank report click on OK I will add a report header for that Michael then insert text object I will and the sub report in Crystal report let me format this object for that right click on it then click on format object and go to font style will be bold let me English the phone size to tool click on OK let me expand this so that you can see the complete text in it now let me add a new personal report I click on the folder then add new item select reporting then crystal report and name your report here I will name it as C ability report in project click on add select as blank report click on OK and I will add a header for that right click then insert text object header will be report inside same report let me expand this I'm going to format the object ball style phone will be tool click on OK now let's add one more crystal report right click on the folder click on add new item select reporting and select the circle name your report here I will name it as see a pretty outside project report click on add and I'm going to add I have to here right click insert text object text will be report outside project I click on it format object go to font bold style phone size will be tool click on OK let me expand the text object now I am going to move this cursor report see a pretty outside project report into mine desktop for that right click on the folder then click on open folder in File Explorer and then I'm going to cut these two files from here and pissing in desktop now back to visual studio refresh right click on the report then click on delete click on OK okay the report is deleted now and in this report let me change this title here report inside same project not report now we are going to add sub reports inside our main report so let me add a sub report here for that right click then insert then sub report pace your sub report in detail section and after placing that you will get a pop-up dialog box like this from this dialog box itself you can say that the three different ways to create sub report inside MN report first way is to create sub report using the reports inside the same project and second one is using this option you can create sub reports from the outside report and the last option is to create a new crystal report for this sub report so let me start with the first option choose a cursive report in project so from this drop-down you will get all the crystal report inside this project so I selected see a beauty report in project click on ok so here we have the sub report that is created from this iPod sub reports in main report we take the space as much as much as the sub report will that we have given here if you expand this it will take that much space to display the content inside the sub report you can see the sub report preview if you click on this main report preview so while seeing this preview you can see that there is a border for our sub report and in order to remove that border you can right click on the sub report then click on format object then click on border here you need to select none from the drop down for all these four sides so that it will remove the border from four sides click on OK now if you check the preview you can see the border for sub report now let me add another sub report into this main report using the second method for that I will add a section below this section 3 right-click on this section then click on insert section below so here we have details B section inside that I will add XO report right click on the report then insert then click on subreport and place your report inside the details B section select choose an existing report option then click on browse and select the report that we have just moved from this project click on open click on ok so now we add a report from outside the project into our main report as a sub report back to main report now if you check the preview you can see D sub report one and two now let's add our final sub report using the method three option for that let me add a section below this details B section then I'm gonna add a sub report here right click here then click on insert then click on support place your sub report inside the details C section and select the third option create a sub report with the report wizard name your report here I will maybe as child report you can select data from the Left panel that you need to design the report after that you can click on finish then click on OK if you double-click on this sub report you can view the report let me add a title here in the text object I will enter the title as child report let me format that bold style and size will be true click on OK let me expand the title that's it back to main report so in this main report we have added three sub report using three different ways if you check the main report you can see them report inside same report for outside project then child report that is designed using the report wizard using method 1 & 2 we have created subreport using that is report inside the project and outside the project if you make any changes in this report it won't affect the original report because these reports are created using a copy of them so if you make anything in this report it won't affect the original report that means if you leave this title she'll report inside same report I will edit the title and I'm gonna append a 1 to this title let me expand this and saving these reports and if you check this capt reporting project you can see the modification though because it is different and the sub report inside this main report is a copy of this report in this video I will show you how to display multiple tables in Crystal report using an example so we have to create a product report in that we have two tables first table is for top five costly products and we will display zero stock products in the second table so let get started this is my Visual Studio 2013 first of all let me create a windows form application for that go to file then new then project select windows under viciously sharp then select windows form application then name your application here I will name it as multiple tab in Crystal report then select the location where you want to save this application here then click on ok so here we have our brand new windows form application here in order to avoid possible errors in this application we have to make sure few points for that right click on the project then click on properties from this target framework drop down make sure that you are not selected client profile version of.net framework then check your app config file in app config file we have to set use legacy we to runtime activation policy to true that's it before adding any crucial report or data set it is a best practice to add two separate folder for these two files for that right-click on the project then click on add then new folder I will name it as crystal report try to end a folder name without any space so that you can avoid future errors then we have to add one more folder for that asset that set folder now let me show you my DB part this is my management studio and here I have a table product it's design looks like this product ID product name product called amount and count and it has few rows now we need to add a new store procedure to generate product report for that click on new query here start like this create rows then procedure name will be product report as first of all we have to get top five costly products from our product tab for that select top five star from product then order by amount in descending order in the next query we will select all products which has zero count for that select star from product count equals zero in order to create this stored procedure click on this execute button here newly created stored procedure can be seen under this folder store procedure here product report using this stored procedure a product report we will generate product report now back to visual studio inside this data set folder I am going to add a new data set for product tablets for that right click then click on add new item select data from the left panel then select data set you can name your data CTO I will leave it as D is product click on add so here we have to add two tablets one for costly product and one for zero count product in order to add a new table right click then add data table you can name your table here I will name it as costly product now we need to add the columns for that right click then add column or you can use the shortcut ctrl L then I am going to copy the column name from the management studio and pacing here like this we need four columns product name or a core amount and count with this same structure we need one more table for 0 count products for that right-click on the table and copy then paste it here and rename the table as 0 product save the data set next we are going to create the crystal report for that right click on cursor report folder then add new item then select reporting from the left panel then select crystal report then name your report here I will name it as CL PT product report click on add keep the options as it is click on OK from this dialog box we have to select the data set let me expand the project data folder then expanded your dotnet data sets inside that you can see about data set this product here select the data set then click on this double arrow then click on finish so here we have our newly created crystal report and in this case we don't need these default elements so you can see our data set and its tabs here first of all I am going to add a report Hebda here for that right click then insert text object title will be product report I click on it then form an object and found ball style then font size will be told click on OK let me expand the elements so that can see the complete text in it in order to add multiple tables in a single crystal report you have to use sub reports in the previous video we have discussed how to add sub reports in cursor report if you have not watched that video I have given the link in video description please go through that now I'm going to add a custom report in section 3 for the right-click then insert sub report then pace your sub report then it will open a new dialog box like this name your sub report here I will leave it as ghostly product then click on report wizard then add this costly product double click on finish now click on OK now I'm going to add one more sub report in detail section 1 for that right click insert subreport pace yourself report then every name this sub report has zero product click on report wizard here then select the second tab 0 product then click on finish then click on OK let me arrange them in a same line in this case I don't want this border for these sub reports and we have discussed how we can remove this border from sub report in the previous video for that right-click on sub report then format object go to border select none' from all of these four drop-down then click on OK now you can see there is no border same thing can be applied for second reporter that's it now let's design these sub reports for that double click on them and remove default fields then I'm going to draw a double here with these columns product name product code amount and count let me select all of the column headers right click format multiple object then fold ball style remove underline click on OK let me add a box now we need to add lines to separate these columns one more line to separate rows let me add a header here top five costly products right click on it format object font ball style keep the phone as it is click on OK let me explain the head now that's it now we need to do the same for this zero product subreport double-click on it you that's it we have designed both of these sub reports now let's check the main preview so here we have the two doubles now let's check how we can display this crystal report inside our crystal report video now let me add a crystal report viewer into this form for then go to toolbox then under reporting heading we can see crystal report we were drag them into four then go to properties of this crystal report viewer I will name it as C IV viewer let me remove this tree view from here for that I will change this tool panel view to none now we are going to display this crystal report inside this crystal report viewer during the form load event for that double-click on this phone so we have the form load even here let me create an object of SQL connection object here SQL connection for that we have to import the name space system dot data dot s clear kind object name will be SQL cone equals new SQL connection inside that we have to pass our database connection string for now I will copy/paste the connection string here then after that I will open the connection object SQL corn by calling the function offer then let's declare SQL that adapter object as SQL da equals mini SQL data adapter inside that first of all we have to pass the store procedure name it is product report as a second parameter we will pass our SQL connection object here then we will set the data adapter command type select command dot command type equals command type dot stored procedure I will declare a data set here data set D is product equals new data set and we will fill the data adapter result into this data set D is product now we can cross the SQL connection object here skill cannot cross now we want to pass these datas into our crystal report before that I will create an object of the report see a PT product report crystal report dot C opt product report object will be seen a PT product equals new object and now we can pass our data Co see a PT product dot data base dot apples inside that we will pass our table name from our data set copy and pasting you then we can call set data source function inside that we will pass our first table from our data set let me copy this and pissing below that let me change this dabbling to zero product and for zero product second tablet will be passed and we even said this crystal report into a crystal report Beiber see a V dot report sauce first of all we will set it as null after then we we sit with our crystal report C opt product now let me run this application for that click on the start button here so here we have the form let me maximize this here we have the exact final output and we have to reduce the separation line thickness for that back to application then open our crystal report double click on sub reports then select the separation lines from the you can select all of them by holding ctrl and clicking on them finally click finally right click on it then click on mark format multiple object then select the least thickness width click on OK do the same for zero product sub report you let me expand the subreport width you let me run this application again so here we have the final perfect outboard in this video we will discuss how we can add watermark or background image in Crystal report using C shop in the last part of the video I will show you how to display dynamic image or watermark in christian report in the previous video we have discussed how to show multiple tables in Crystal report you can find the video link in video description this is the final output of previous lesson in this lesson we will add watermark into this cursor report I can give you the brief description of the project but if you want to learn it from scratch please go to be the previous lesson here we have the project in windows form application and it contains a single form with a crystal report viewer and we will be using this report viewer to show the crystal report inside the crystal report folder we have a crystal report and we have a data set based product through this data set we will be passing our data for report generation this is our data base inside that we have a table with column Product ID product name product code amount and count product table is populated with few rows store procedure product report will retrieve the data store report generation in the first select worry it will sell top 5 co-sleep product in the table in the second select query it will select products with 0 count inside the form load even of the form we have generated product report first of all we called stored procedure product report and we fill the result into data set D s product and we have passed data into cursor report using this data set and finally we have displayed the crystal report into our crystal report beaver don't worry you can download this project from the link given below in video description so now let's try to add watermark into this crystal report first of all I will show you how you can add a image into purser report for that I will add a new session below this report header right click on it then click on insert section below then inside this section I am going to add a new image right click then insert picture then select the picture then click on open then place your picture inside this section now if I run this application you can see the newly added image right below the report had the product report and it will take as much as space needed based on its size now I am going to make this picture as a watermark for this report for that right click then section expert now we want to move this section with image or watermark above all of other sections for that here you can see a upward arrow select this section with image or watermark then click on this arrow then click on ok so watermark session is the first section in this crucial report now one more step right click on this section then section export then select this option underlay following sections click on OK now let me run this application so here you can see the image as a watermark for this report in order to fit this watermark into your report you can add just width and height of the report based on the page size or you can edit this image in photo editing software is like Photoshop according to the page size to see the page size right click then go to design then page setup then you can see page options from this drop-down you can select the size of the page in your report if you select therefore you can see width and height of the page and according to these measures you can edit your watermark for now I will select f4 click on OK now I will show you a limitation of crystal report watermark if I add lines into report had a bee section here you can't see these lines in the generated report let me show you that now you can't see the these two lines that I have added in report header B section in generator report that's one of the limitation of crystal report watermark there is a solution for this problem if you want to draw an element with the line you can draw that element in a sub report like I have done in these sub report ghostly product and zero product inside these sub reports I have I have added lines here you can see lines two separate columns and rows and even though you can see these lines in generator report because it is in sub report so a solution to this problem is to add lines in sub report so that you can see those lines about the watermark now let's discuss how we can make this watermark dynamic so that we can change the image during runtime for that I'm going to add a new tab in to this data set right click add data table I will name this table as report details let me add one column watermark path now save this data set then back to the crystal report then expand data phase in field Explorer right click on it then data expert expand project that ato dortmund data sets then include this newly added report it is stable into our report click on OK click on okay so now we have the newly added report details here in order to make this watermark dynamic right click on it then format object then go to Pizza tab then click on this formula button right to graphic location then from here we will select the watermark path column here and drag into this field then click on save and close and we'll click on OK so now we have to pass the image path from our C shaft code let me go to the form load event so here we have to pass a new data table data table the TBL new data table TBL columns dot add first parameter as column name itself so I will copy this from here and paste it the second parameter will be the type of column type of string and let me add a walk into this table ETTL door closed dot and inside this I am going to add image path of a watermark now let me select a watermark image from my desktop this is fine right click on it go to properties then select the path paste it here finally we have to pass the emails name let me copy from here and pasting here and we want to pass this tablet into our data set so that let me copy this line and pasting here let me change the travel name for detail and we will pass the newly created Tab key TBL let me run this application now so here you can see the new image that we have passed during run time so this is how we can add run time watermark into cursor report in this video we are going to discuss how we can group that as a Methuselah report before starting this video I would like to ask you a favor if you found this video helpful please thumbs up this video and for more awesome videos like this please be subscribed to this channel dot that mob without further ado let get started this is my t-shirt studio 2013 here we have a c-sharp windows form application into this application I am going to add a custom report for that right-click on this project then and new item select reporting from the left panel and select restore report then name your report here I will name it as COPD sales report I use COPD as a prefix focus with report then click on that I'm going to create a blank report so I will select this as Bank report then click on OK before designing this report let me show you my database here this is my SQL Server management studio here we have a database dot AdMob inside that we have a table says it contains columns like sales ID date product count price and order now I want to create a new store procedure in order to retrieve all of these data into crystal report for that I'll click on database and click on new query in order to create this tool procedure you can start like this create cross says view or as select star from sales click on this execute button here now I am going to import data from the newly created to procedure for that right-click on this database fees field Explorer and click on database expert expand create new connection then expand oil EDB ato then double click on make new connection then select Microsoft oledb provider for SQL Server and click on next then type your server name your local backward slash SQL e 2012 then select this integrated security to true then select database from this drop-down I will said move then click on finish so here we have the newly created connection expand this expand or net move then expand dbo and expense tour procedures then select the newly created true procedure since vo and click on this right arrow then click on ok so here we can see the newly added store procedure here did this to a procedure we can design this cursor report first of all let me show that as from store procedure inside this report then we will add loop into the report first of all let me add report order sales report all right click on it format object go to font tab want to change the form family to see GUI change in phone size to 14 click on OK let me expand the header you want to see the complete text in it we are going to add these stop passages column into the report first of all date product count price an tot select all of these column headers by click on it then format multiple objects for Co font tab then change the on family to see geo UI then change font size to told and check the sample lines then click on ok let me expand these column headers let me see the preview of this report click on this mean report review now we have to make it as a table then we need to add a box then we need to add lines in order to separate these columns help me let me add a horizontal line for this column header so to preview so here we have a decent-looking table for since we put now I am going to add loop into this report for that click on crystal rapport insert then glue in this we have to select a column for blue P so I will select this product column then you can change the order of sorting I will select it as ascending order then click on OK so here you can see the glue name inside group header section then we have two footer section as well let me arrange it here let me switch to preview here so here you can see the product name as the blue border under that you can see says of the product back not book pencil now I want to style this blue header for that right click on it then format object then go to phone tabs changing color to white and you want to change the background color to black click on OK that means to preview that's it now I want to show some of totals for each group so yes some fold these sales from this back product and there will be some code these sales from this book product for that we can use this blue photo section and for that I am going to add a running total right click on running total fields then new now we are going to create some for total column select the column total then click on this right arrow so here we have the feed then we have the type of summary as sum and you want to evaluate it for each row we want to reset the formula on change of group so he is selected our group click on ok now we have to add this running total field into our report here this total sum should be right below the total column I want to make it a same width I click on it then same width and I want to align them I click on it then align price that's it I want to change the format of this cotton I click on it then format object put a phone then change this color as white change background color to black click on OK that's it let me see the preview so here we have the total of sales from back and here we have says from normal here we have some off sales from pen and pencil here now we want to add horizontal line for these rows for that you can add horizontal line here horizontal line below this photo section lines I click on it then format object I will select the highest fields and then click on ok let me see the preview here yes it looks fine now in this video we will discuss how we can export crystal report into Excel and PDF using C sharp desktop applications like Windows Phone and we will discuss so we can export PDF and Excel in SP web applications also before start in this video I would like to ask you a favor if you found this video helpful please thumbs up this video and for more hours of videos like this please be subscribed to this channel dot that Bob without further ado let's get started first of all I will show you how you can export custom report in desktop applications like windows form application for that here we have one form inside this application form one inside that we have a crystal report viewer and we have a crystal report here crpd product so here you can see the copt product crystal report and said that we are going to bind his symbol that CC shop that a double here first of all we have declared an object of CRPD product crystal report and we have created an object of that a double product here inside the form load event we have created columns for this c-sharp data table here and we have filled some test data into this table here and we have assigned this table as the data source for this crystal report and we have set this crystal report as the report source for this crystal report Bevo let me run this application for that click on the start button here so this is how the cursor report looks like now we are going to export this crystal report using this export button here inside this button export button we have written code inside the button click even here first of all we have created an object of report document as Andy report and then we have Laura this crystal report Capt product into this report document here and then we have said this c-sharp that a double product into this report document this c-sharp data table is populated inside the form load even here in order to work this method you have to change the properties of the crystal report I'll click on it then properties then change this property copy to output directory then set it as copy if newer J we have created an object of export options and disk file destination options then here we have created an objective save file dialog in order to select a file directory to save this PDF or Excel first of all I will show you how we can export this Kasab report into a PDF file for that I have said this save file dialog object filter as PDF files after selecting a file path and filename we will save that file path into this variable after that we will do this first of all we will set the for export format type into PDF and then we will set the destination configuration into this property destination options and we have to set these format options with the corresponding form PDF format options here and finally we will call the report document object dot export function in this tutorial we are going to export this crystal report into PDF and Excel program Italy butt-kisser report viewer provides this export option using this export but click on this button so here you can see the available export options PDF CSV format Microsoft Excel Microsoft Word and much more let me try to export this crystal report into PDF for that you can click on this export button here I want to save this PDF into my desktop and I want to name this PDF has exported PDF click on save let me check my desktop here so here we have exporter PDF let me open that in my foxy trader now it looks fine now I am going to export this same Christian report into Excel for that let me stop this execution here now I want to comment the code for PDF here and I want to uncommon code for excel want to change this export format type don't worry you can download this project from the link given below in video description let me run this application again click on export so here you can see the export extension as Excel extension XLS I want to save this file into desktop I will name this excel as exported excel click on save due to low disk space in my system I have not installed Microsoft Excel in my system so I can't open this XLS file now so I have demonstrated how you can export crucial report into PDF and Excel using a c-sharp windows form application so here we have a symbol SP web application inside that we have a default SPX page inside that we have a button export button inside this button click event I am going to export the same windows form application crystal report into PDF and Excel so here we have the button click event inside the button click event we have a using statement with report document object Rd and we have declared crystal report see our PT and data table product here and we have declared columns for this product table and inserted some that us into this tablet product and then we have loaded description with this crystal report Capt product product that our table has the source for this crystal report so here is the main function report document object dot export to HTTP response first parameter will be the export format type for then we can pass like this export format type dot portable document that is PDF then responds true then attachment name so this crystal report will be downloaded as crystal dot PDF and then finally response load end function let me run this application click on the start button here now click on this export button so here we are going to download this exported crystal report as PDF click on key so it is downloaded let me open that so here is the file in order to export this same report into Excel you have to pass excel format here that we have done here let me come in this line and uncomment this line if you want this application you can expose this crystal report into Excel that's it guys if you found this video helpful please please subscribe to this channel dot AdMob you can download these two projects from the link given below in video description please like and share this video with your friends and colleagues so that they can benefit from this have a nice day bye
Info
Channel: CodAffection
Views: 96,904
Rating: undefined out of 5
Keywords: Crystal Report, Crystal Report Tutorial For Beginners, Crystal Report Using Visual Studio, Sap Crystal Report Tutorial, Crystal Report Using C#, Crystal Report in C# Asp.Net, Crystal Report in Windows Form Application, Crystal Report Tutorial Youtube, Learn Crystal Report, Step By Step Tutorial For Crystal Report, Beginners to advenced, Using SQL Server Database, crystal report in c# windows application, crystal reports for beginners in c#, CodAffection
Id: 3eYPA6-j4vs
Channel Id: undefined
Length: 109min 5sec (6545 seconds)
Published: Mon Jul 24 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.