Monday 14 November 2016

Handle dopostback in i.e.

put this code in master page
 protected override void OnInit(EventArgs e)
        {
            Page.ClientTarget = "uplevel";
            base.OnInit(e);

        }

Thursday 3 March 2016

custom paging with searching

//Pass FirstRec ,CurrentPage ,PageSize ,LastRec,OrderBy,OrderByType   parameter through .Net

declare @total int  //count total row
Declare @FirstRec int
 declare @CurrentPage int
declare  @PageSize int
Declare @LastRec int

Set @FirstRec = (@CurrentPage - 1) * @PageSize
Set @LastRec = (@CurrentPage * @PageSize + 1)


IF(@OrderBy = '' or @OrderBy = 'Default')  
BEGIN  
 set @OrderBy = 'mpv.VisitDate '  
 set @OrderByType='desc'
 END

exec ( '
SELECT * FROM
(


SELECT  ROW_NUMBER() OVER (ORDER BY ' +  @OrderBy + ' ' + @OrderByType + ') AS RowNum,
               mp.PatientID,mp.FirstName+'' '' +mp.LastName + case when mp.MobileNumber <>''''  then  ''/ '' + mp.mobilenumber else ''''  END Name , convert(varchar(10),mpv.VisitDate,103)VisitDate,mpv.PatientVisitID,(select count(*) from     MDTM_Patient mp left JOIN MDTM_Patient_VisitDetail mpv on mp.PatientID=mpv.PatientID
                where  mp.IsDeleted=0 and mp.CreatedBy='+@LoginUserId +')as totalpatient,mc.ConsultationType,convert(varchar(10),mc.SentForReviewOn,103)SentForReviewOn,mu.FirstName +'' ''+ mu.LastName as Referto,mc.CaseStatus
             
            FROM MDTM_Patient mp left JOIN MDTM_Patient_VisitDetail mpv on mp.PatientID=mpv.PatientID left join MDTM_Patient_Consultation mc  on mpv.PatientID=mc.PatientID and mc.isdeleted=0 left join MDTM_Users mu on mc.ReferredToDoctor=mu.UserID and mu.IsDeleted=0
                where  mp.IsDeleted=0 and mp.CreatedBy='+@LoginUserId +'   and
(
             mp.FirstName like  '''+ @search+ '%'' or mp.LastName like  '''+ @search+ '%'' or
             mp.FirstName+'' ''+mp.LastName LIKE '''+ @search+ '%'' OR
             mu.FirstName like  '''+ @search+ '%'' or mu.LastName like  '''+ @search+ '%'' OR
             mu.FirstName+'' ''+mu.LastName LIKE '''+ @search+ '%'' OR
             mc.CaseStatus LIKE  '''+ @search+ '%'' OR
             CONVERT(varchar,mpv.VisitDate,105)= '''+ @search+ ''' OR
             CONVERT(varchar,mc.SentForReviewOn,105)= '''+ @search+ '''
             )
) records
where records.RowNum>' + @FirstRec  + ' and records.RowNum<  '+@LastRec )

Monday 9 November 2015

how to create and use table variable

create User Defined Table type in Programmability in sql
my table type is 


1)    CREATE TYPE [dbo].[sitenamelist] AS TABLE(
[siteid] [int] NULL,
[Userid] [int] NULL,
[isdeleted] [bit] NULL,
[createdby] [int] NULL,
[modifiedby] [int] NULL
)

2) calll table type in storedprocedure
 @sitelist as sitenamelist READONLY

INSERT INTO MDTM_AdminSiteLink (SiteID,UserId,IsDeleted,[DateCreated], [CreatedBy]) select SiteID,Userid,isdeleted,GETDATE(),CreatedBy from sitenamelist


3)pass parameter in data layer
 comd.Parameters.AddWithValue("@sitelist", sitelist);

create get set DataTable Type in business entity
private DataTable _sitelist;
        public DataTable sitelist
        {
            get { return _sitelist; }
            set { _sitelist = value; }
        }

dynamic sub query with stuff


  1.  Here MDTM_Site  and MDTM_Hierarchy  is a table
  2. create #temphierachy   temporary table
  3. stuff use for comma seprated value in one row sitename wise




select ms.SiteID ,ms.sitename, mh.LinkedToSite as linksite,
(select SiteName from MDTM_Site where siteid=mh.linkedtosite) as LinkedSiteName
into #temphierachy
from MDTM_Hierarchy mh join MDTM_Site ms on mh.SiteID=ms.SiteID
where mh.NetworkID=@NetworkId and mh.IsDeleted=0

      select distinct sitename, siteid ,
        STUFF((SELECT distinct ', ' + LinkedSiteName
         FROM #temphierachy where sitename = t.sitename
       
            FOR XML PATH(''), TYPE
            ).value('.', 'NVARCHAR(255)')
        ,1,1,'')  AS LinkSiteName
       
      from #temphierachy t order by t.sitename DESC

Writting common Dataaccess layer for MYSQL, Oracle and SQL server by using enterprise library

Wednesday 21 October 2015

Encrypt Decrypt ConnectionString in Web.Config

http://www.codeproject.com/Tips/795135/Encrypt-ConnectionString-in-Web-Config?loginkey=false

cd C:\Windows\Microsoft.NET\Framework\v4.0.30319
ASPNET_REGIIS -pef "connectionStrings" "D:\Articles\EncryptWebConfig" use this command
here EncryptWebConfig is project name
for decrypt 
ASPNET_REGIIS -pdf "connectionStrings" "D:\Articles\EncryptWebConfig" use this command