Sunday 5 February 2017

Crystal Report... Displaying Serial Number based on the Condition

                                            I was working on a client project in which my part is to design report’s based on crystal report. In this I got a interesting requirement from client side. According to that, I have to insert serial number in the report for particular table row based on some condition, and I want to skip the serial number if that condition is fail’s.












Above image shows the normal report output… but I have to display report like …


Here , my condition is based on ‘Bill No ’ column . If Billno column has any value the serial no column should have the value … otherwise the s.no column should skip the value…
Based on this, I wrote the condition in formula  block..



So, here my condition is , to check whether the column “Bill_no” has any value or null …
If the column “Bill_no” is null or no value , no value taken place in S.no column in report..
Else
It'll display the S.no with increment..


Note: here I used Totext keyword… Because it return only string or char value .. so I used Totext keyword..  
We can use this totext in two format …if I use like  Totext(srno:=srno+1,0) the S.no will display like 1,2,3,4…. Else if use like Totext(srno:=srno+1) the S.no will Display Like 1.00,2.00,3.00,4.00 …….

To Disable that decimal value we have to use “Totext(srno:=srno+1,0)”… 0 indicates number of decimal’s to print after dot…

That’s it..




Wednesday 18 January 2017

Tuples In C#


What is tuple and when it was introduced?
A tuple is a new data type introduced by .NET Framework 4.0. When there is a requirement to store the multiple values of different data types and without having to create a class to store the values, we can go with tuple. Simply “Tuple is a container with the similar or different data type, which supports 7 items (similar/different data types) plus 1 Tuple type”. Point to be noted here is, it is not a collection.
How to declare a tuple?
Tuple will be declared similar to Dictionary<Tkey, TValue>.
Tuple<T1>
Tuple<T1, T2>
Tuple<T1, T2, T3>
Tuple<T1, T2, T3, T4>
Tuple<T1, T2, T3, T4, T5>
Tuple<T1, T2, T3, T4, T5, T6>
Tuple<T1, T2, T3, T4, T5, T6, T7>
Tuple<T1, T2, T3, T4, T5, T6, T7, TRest>
Here, T can be any type and TRest is a Tuple type.
If you have seen it, while declaring a tuple, you will get 8 override functions, as shown below.


In the last override method, we can add 7 types with one Tuple type (I will explain in detail with an example). 



The method given above will return all the arithmetic results of the provided values (a, b).
How to read tuple
Once you have added values into tuple, it is easy to retrieve the data from it. Tuple stores the data in “Item” property. From the example given above, we can get the values, as shown below.

A Tuple with more than 7 arguments.
The 8th type of a tuple is tuple.
Observe the example given below. We have a tuple called dataWithEightarguments with 8 parameters in which 8th one is a tuple. Hence, while adding data to it, we need to pass tuple type data as 8th parameter. 


Monday 16 January 2017

Understanding the memory structure of MIFARE 1k and 4k Classic Smartcards

Understanding the memory structure of MIFARE 1k and 4k Classic Smartcards
This article shows the memory structure which is used in MIFARE 1k and 4k smartcards
Basically the MIFARE Classic card is a memory storage device. The memory is divided into sectors, which are also divided into blocks of 16 bytes.

MIFARE Classic 1K card

The MIFARE Classic 1K card has 16 sectors, each of which are divided into four blocks. If we do the math, we can figure out how the memory structure would be like: 16 bytes (1 block) * 4 blocks * 16 sectors = 1024 bytes.


 MIFARE 1K card memory structure
The above image shows the memory structure of MIFARE 1K card. From this we can clearly understand different blocks which are used for various purpose .
Here, the Block’s shows where we can write data in to the card. you have plenty of location in a card that you can write data. Also there are some restricted blocks you should not write in to.
Restricted blocks
Here the restricted blocks CSN,CIS,Site Key block’s. We cant write data in these blocks.



MIFARE Classic 4K card
The MIFARE Classic 4K card has 40 sectors, 32 of which are divided into four blocks and the remaining 8 are divided into 16 blocks. 16 bytes (1 block) * 4 blocks * 32 sectors + 16 bytes (1 block) * 16 blocks * 8 sectors = 4096 bytes. The memory structure is as follows:



MIFARE 4K card memory structure
The number on the blocks indicates its index. Each sector is protected by the site key written in the last block of the sector. For example, block 3 contains the site key for sector 1 and block 7 for sector 2. The last block in each sector also contains access conditions information such as "write", "read" and "read & write". The following figure demonstrates how the last block consists of:


 

Thursday 12 January 2017

GETDATE() ..Date and Time Functions in SQL Server 2008 R2

This blog will list different ways to use GETDATE() funtion in SQL Server 2008 R2The major changes in new SQL Server 2008 are the DateTime function and the introduction of new data types.

GETDATE()

 
So we all know the Function GETDATE()  returns the current system date and time.
Query:
select GETDATE()
output look like : 2017-02-27 10:53:49.737 
 
the output is only in numeric format.
----------------------------------------------------------------------------------------------------------------------------- 
if we want to convert into character format we can use the following query
 
Query:
select convert(char(20),getdate(),100)
output look like : Feb 27 2017 10:55AM 
here i convert the date to char format.
--------------------------------------------------------------------------------------------
we can use the above query in three format (above query is 1st format) for different use...
format 2:
Query:
select convert(char(20),getdate(),10)
output look like : 02-27-17
here ,if use '10' it returns only date from getdate() function

 
Note::
in the above query..
char(20) means- considering the total length of the output
if i try like ..
select convert(char(10),getdate(),100)
output look like : Feb 27 201    (here it took only 10 character length)
--------------------------------------------------------------------------------------------
Right() Function :
 
query : 
select right(convert(char(20),getdate(),100),8)
 
output look like: 12:33PM
 
Here, the right() function consider only 8 characters from right to left 
 
for example ...
 
query : 
 
select right(convert(char(20),getdate(),100),6)
 
output look like: ':37PM '
 
here, in this query we use 6 (above query we use 8)..... that mean it consider 6 characters from right to left 
--------------------------------------------------------------------------------------------
left() Function :

same as right() function.. here it consider the characters from left side.. 
query : 
select left(convert(char(20),getdate(),100),8)
 
output look like: Feb 27 2 
 
Here, the left() function consider only 8 characters from left to right..