Generating pdf using itextsharp in asp.net c# - c#

I want to generate pdf file as attached in the picture. i want to harcode the contents shown in the picture into a pdf file on button click.
How do i proceed, using table structure will work?I am unable to form the table stucture here.
Please help me to sort out my problem.i want the output as shown in below image.

Here you have a good tutorial about using iTextSharp
http://www.mikesdotnetting.com/Category/20

First create one table with two columns like below
_______________________________________________
| | |
| | |
| | |
| COL.0.1 | COL.0.2 |
| | |
| | |
-----------------------------------------------
keep reference to its columns, then create table for left side content and insert it as child content of left column COL.0.1
------------------------------
| designation: xxxxxxx | <---- colspan = 2
------------------------------
| Audit No. | xxxx |
------------------------------
| Received on ....... |
-------------------------------
and you can continue for the rest of content similar to this.
The idea is to split content to smaller tables and nest them.

Related

Creating a Pivot table in C#

In my c# program I have someone input production for the whole day and I calculate machine usage (MU) like so:
Date | Part Number | Mold Num | Machine Num | MU
2/12/2016 | 1185-5B8 | 6580 | 12 | .428
2/12/2016 | 2249300 | 7797 | 36 | .271
2/12/2016 | 146865 | 5096789 | 12 | .260
2/16/2016 | 123456 | 7787 | 56 | .354
2/16/2016 | 123456 | 787 | 54 | .45
2/16/2016 | 123456 | 777 | 56 | .799
2/16/2016 | 123456 | 87 | 54 | .611
All of this data is in my SQL server and what I want to do is to make something like a pivot table and it takes all similar dates/Mold Numbers/Machine Numbers and makes an average the MU and display it in any way that the user wants. Example:
Date | MU
2/12/2016 | 32.0%
2/16/2016 | 55.4%
or
Machine Num. | MU
12 | 34.4%
36 | 27.1%
54 | 53.0%
56 | 57.6%
etc. Basically I want it to be variable and to show whatever the person that is looking at it needs. I want to keep it in my c# program but I can use LINQ to SQL. Please keep in mind that I am very new to c# and LINQ to SQL.
I did try to do this but it was not exactly what I wanted to do. I also could not figure out how I was going to display it on the windows form nor how to change what was in each column.
It seems you need to build pivot table with row dimension (Date, Machine Num), without column dimension and with average by MU.
You can easily do that with help of NReco PivotData library:
var pivotData = new PivotData(
new string[] {"Date","Machine Num"},
new AverageAggregatorFactory("MU"),
new DataTableReader(t) ); // just a sample - you can use DB data reader
var pivotTable = new PivotTable(
new []{"Date"}, // row dimension(s)
new [0], // column dimension(s)
pivotData );
// use pivotTable.RowKeys and indexer for accessing pivot table values
PivotData library can be used for free (I'm an author), and you can download examples package on the component's page. Also you may check advanced PivotData Toolkit components (for rendering pivot table to HTML/CSV/Excel/PDF, aggregating data on DB level with GROUP BY and many others), but they are not free.
According to your description, what you want isn't a pivot table, as already mentioned by #juharr.
For sqlite, this sould be accomplished with the following statement. (I assume the table name is tmp, and what you want is the sum of MU with each MachineNUm, naming it with SMU).
SELECT MachineNum,SUM(MU) AS SMU From tmp GROUP BY MachineNum ORDER BY MachineNum;
Hope it helps.

Fitnesse - method name starting with unwanted "set" prefix

I have trouble with fitnesse adding a prefix "set" to names of my methods and therefore not finding any. It does not do the same thing with a different method from same, which I figured is because said method starts with "get" so I guess there is something I am missing in the syntax since this keyword makes it act differently.
Fitnesse code:
!define COMMAND_PATTERN {%m -r fitSharp.Slim.Service.Runner,C:\Users\Kain\Source\repos\mc\build\Tools\fitnesse\fitSharp.dll %p}
!define TEST_RUNNER {C:\Users\Kain\Source\repos\mc\build\Tools\fitnesse\RunnerW.exe}
!define TEST_SYSTEM {slim}
!path ..\..\results\WindowsHost\Acceptance.Tests.dll
!|Namespace.ConnectorClass|
| get connector schemas |
| ensure | has input schema defined |
| ensure | has output schema defined |
!|Namespace.ConnectorClass|
| send valid query |
| ensure | is valid input |
| ensure | is valid response |
| reject | is error response |
| show | error |
Output:
It looks like you are trying to use the Slim script table. So you need to put script in the first cell of your table:
!|script|Namespace.ConnectorClass|
| get connector schemas |
| ensure | has input schema defined |
| ensure | has output schema defined |
See http://fitnesse.org/FitNesse.UserGuide.WritingAcceptanceTests.SliM.ScriptTable
Without the script cell, Slim is treating your table as a Slim decision table.

Comparing Multiple Tables

There is a horrible legacy tool at my workplace that has been updated/patched to output information to an SQLite database. No one wants to touch the back end of the system, and I don't know enough to dig into it - not my problem. Here is my problem however:
I have an SQLite database, with a number of tables in it. Each table represents a day and contains all of the bus runs, listed such as such:
| Direction | Time | RunNumber | StopIndex |
----------------------------------------------
| In | 6:30 | 1 | 1 |
| In | 6:35 | 1 | 2 |
| In | 6:40 | 1 | 3 |
| In | 6:45 | 1 | 4 |
| In | 7:30 | 2 | 1 |
| In | 7:35 | 2 | 2 |
| In | 7:40 | 2 | 3 |
| In | 7:45 | 2 | 4 |
| Out | 6:40 | 1 | 1 |
| Out | 6:45 | 1 | 2 |
| Out | 6:50 | 1 | 3 |
| Out | 6:55 | 1 | 4 |
Some days can have more run's than others. The numbers of stops will be the same across all tables.
The definition of equal is that both direction and time are the same. Each run is treated as a set - if one of the times for a stop differs, then the entire run needs to be merged into a table.
My question is:
What would be the easiest way, given a list of tables, to generate another table that contains values that were not present on all the given tables? This can be done on the SQLite side, or by C# .NET 4.0.
In reality, I only need to know the run number that differs, so I can later extract it and put it into an Excel Spreadsheet, if that makes it any easier.
Try using EXCEPT. For example, the following query will list all rows that exist in Table1 but do not exist in Table2:
SELECT Direction, Time, RunNumber, StopIndex
FROM Table1
EXCEPT
SELECT Direction, Time, RunNumber, StopIndex
FROM Table2

how to show values in database to be column header in reportviewer c#

I want the data in the database to become the column header names by retrieving data from a table. This table has two fields, TimingID and Timing, I want to display the Timing as Column header in the reportviewer. Actually I am creating a schedule which shows the timing as the column so as to slot employees inside their respective timing. I want all the Timing to be displayed as a header. I wanted the Report to look like this.
LocationStation | 0000 | 0100 | 0200 | 0300 | 0400 | 0500 | 0600 | 0700 | 0800 | 0900 | 1000 | 1100 | 1200
T5-PML | John | John | John | John | John | John | John | John | John | John | John | John
So it means that the employee, 'John' works from 00:00 to 12:00. The Timing stores all the time slot as shown at the column header. I want to show it like that.
Please give me some ideas of how to write in SQL statement?
Thanks in advance.

Nested table in Telerik reporting?

I couldn't find any solution regarding this matter. If anyone use Telerik and have any idea about this please post. :)
Currently I have an ojbect:
Absence
-> List<Available> Available
I was successfully pass the List object to the main table and list out the Absence object. However when i try to do something like the ff, I have a mental block and I could not find anyway either on google or on their documentation
------------------------------------------------------------
| ABSENCE |
------------------------------------------------------------
| Field1 | Field2 |
| |
| ----------------------------------------------------- |
| | Available | |
| ----------------------------------------------------- |
| | Available Field1 | Available Field2 | |
| ----------------------------------------------------- |
| |
|----------------------------------------------------------|
|----------------------------------------------------------|
| Field1 | Field2 |
| |
| ----------------------------------------------------- |
| | Available | |
| ----------------------------------------------------- |
| | Available Field1 | Available Field2 | |
| ----------------------------------------------------- |
| |
------------------------------------------------------------
I cannot find anyway to bind or change the datasource of the subTable to the corresponding sub object
How can I archive this kind of result?
Thank you
You'll want to use SubReports for this. You can read about them in Telerik's documenation or even read this help page that is specifically about master-detail reports which is like what you are doing.
Basically, you'll create two reports. The Master report will display all the Absence objects. As part of the 'detail' section of that report, you'll place a SubReport. The SubReport will show the second report which will list all the Available objects. Then you can pass a parameter from the master report to the sub report and use a filter so you only see the Availables that correspond to the passed in Absence.
Then remember that the outer report's Data Source should be all the Absences and the inner report's Data Source should be all the Availables.
I have had same problem a while ago.
I figured out that Telerik Reporting has some kind of bug with nested tables. If I put Table2 (child) as cell content of Table1 (parent) and try to bind data sources (via bindings or in code, no matter) than my child Table2 will always show the same item in all rows.
I try to ask in official Telerik forum about that but they just tell me to use SubReport (which, by the way, did not resolve my problem).
So I was forced to use List (Telerik Reporting control) as parent content holder. And as you understand it was hard to implement such markup as in Table control.
We have just done something slimier to this in a report today.
You can add a list control into the cell of the table. Using binding on the list, bind the dataSource to the property that contains the list. You can then Add Columns in you listbox to display the data.
We are doing this by assigning the table data source as an Object in C#. I assume you could do something similar if using SQL/other datasources by attaching the relevant datasource to the list box and applying a filter with a parameter.

Categories

Resources