Sunday, April 17, 2022

Use Session For List 2

  var Center_List = string.Format("CenterList_{0}", (int)LoggedInOrganizationID);

                var centerList = new List<DBCenterDetailModel>();

                if (Session[Center_List] != null)

                    centerList = Session[Center_List] as List<DBCenterDetailModel>;

                else

                {

                    var param = new { OrgId = (int)LoggedInOrganizationID, OfficeId =                                                                                         SessionHelper.LoginUserOfficeID};

                    var alldata = ultimateReportService.GetDataWithParameter(param, "GetCenterData");

                     centerList = alldata.Tables[0].AsEnumerable()

                    .Select(row => new DBCenterDetailModel

                    {

                        CenterID = row.Field<int>("CenterID"),

                        CenterCode = row.Field<string>("CenterCode"),

                        OfficeID = row.Field<int>("OfficeID"), 

                        OfficeCode = row.Field<string>("OfficeCode"),

                        OfficeName = row.Field<string>("OfficeName")

                    }).ToList();

                     Session[Center_List] = centerList;

                }

Get Maximum value from a ROW Data

 










-- one time table create

--CREATE TABLE InitialData (    

--    RowNum   int  IDENTITY(1,1) NOT NULL , 

-- loan  decimal (17, 2)

       

--  )    







declare @sql varchar(max);

DECLARE @paramDefinition nvarchar(500);


DECLARE @sid int = 1;



  DECLARE @RowSl INT    

     ,@Count INT    

   

 

SET @RowSl = 0    

SET @Count = 6 -- (SELECT COUNT(*) FROM Tables)    

 




WHILE @RowSl <= @Count    

BEGIN 


Set @sql = 'INSERT INTO  InitialData SELECT ';


declare @ColName varchar(28);

Set @ColName=  'loan_' + Cast( format (@RowSl, '0#')  as varchar(5)) +' ' ; 

SET @sql =  @sql + @ColName ;


SET @sql = @sql + ' FROM PRA_MN_RPT_TAB_XL_PD_Test WHERE RowNum =' + CAST( @sid AS nvarchar(2));


EXECUTE(@sql)

 

SET @RowSl += 1    

END -- End While    


SELECT MAX(loan) FROM  InitialData;

Screen Record

 Windows Screen Record WindowsKey+ Alt + R Recording Starts.