Tuesday, October 14, 2014

javascript full screen fullscreen window for internet explorer script

  <meta http-equiv="X-UA-Compatible" content="IE=8" />
<body dir="rtl" onload="FullScreenWindow();">



function FullScreenWindow() {
    //window.moveTo(0,0);
    //resizeTo(screen.availWidth,screen.availHeight);

    window.moveTo(0, 0);
    if (document.layers) // navigator 4+
    {
        var deltaX = screen.availWidth - window.outerWidth;
        var deltaY = screen.availHeight - window.outerHeight;
        window.resizeBy(deltaX, deltaY);
    } else if (document.all) // exploder 4+
    { resizeTo(screen.availWidth, screen.availHeight); }

}



Saturday, August 16, 2014

gridview custom pager user control

http://yugalpandya.wordpress.com/2013/09/30/custom-paging-user-control-for-large-amount-of-data-in-gridview/

Friday, August 15, 2014

Elmah Error Logging Http Handler Links

http://www.hanselman.com/blog/NuGetPackageOfTheWeek7ELMAHErrorLoggingModulesAndHandlersWithSQLServerCompact.aspx

http://docs.nuget.org/docs/start-here/Using-the-Package-Manager-Console

Steps for apply elmah for Project (WebApplication - WebSite)
1- open your solution using visual studio.
2- Open Package Manager Console
3- Install-package elmah
4-install-package elmah.sqlserver
5- go to your solution folder and  find Package Folder then elmah.sqlserver.1.2 you will find sql file
Elmah.SqlServer.sql
run the script to your sql server to create elmah database.
6- after creating elmah script on your sql server Change Connection String in your web.config to be linked to your sql server instance.
7- run your project to open elmah.axd to get errors occured as http errors

8- To Apply Elmah For All Solution to log All Errors you should write this code in your functions exception handling
try
{
// your function code
}
   Catch ex As Exception
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex)
            End Try

9- to enable send Mail Using Elmah to your Mail instead of monitor errors using elmah.axd
you should change mail configuration for elmah in your web.config 

<elmah>
    <security allowRemoteAccess="true" />
    <errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="ELMAH_CONSTR" />
    <errorMail from="portal@mwa.gov.sa" to="msibrahim@mwa.gov.sa" subject="خطأ في البوابة الداخلية تجريبي" async="false">
    </errorMail>
    <errorFilter>
      <test>
        <or>
          <regex binding="Exception.Message" pattern="^The operation has timed out$" />
          <and>
            <equal binding="HttpStatusCode" value="404" type="Int32" />
            <equal binding="HttpStatusCode" value="504" type="Int32" />
            <regex binding="FilterSourceType.Name" pattern="mail" />
          </and>
          <and>
            <regex binding="Exception.Message" pattern="^Logon failure: unknown user name or bad password" />
            <regex binding="Exception.Message" pattern="^Microsoft.Exchange.WebServices.Data.AutodiscoverLocalException: The Autodiscover service couldn't be located." />
            <regex binding="FilterSourceType.Name" pattern="mail" />
          </and>
        </or>
      </test>
    </errorFilter>
  </elmah>

10- you should edit your smtp mail server configuration in IIs Or your Web.config file
<system.net>
    <mailSettings>
      <smtp>
        <network host="your smtp mail server" port="25"  password="****" userName="******" />
      </smtp>
    </mailSettings>
  </system.net>
11- now you will receive automatic mail when any error occurs for your web site.

thanks.






Thursday, August 14, 2014

SQL SERVER LOOP RESULT SET - QUERY BY TEMP TABLE SAMPLE CODE

BEGIN
Drop table #TEMP_STAGES_STAGES
Declare @P_STAGE_ID Varchar(20)
SET ROWCOUNT 0
SELECT STAGE_ID ,STAGE_NAME into #TEMP_STAGES FROM dbo.WORK_FLOWS_LOAD_CURRENT_STAGES_BY_ORDER_FUNCTION(3, 1, 2);
SET ROWCOUNT 1
Select @P_STAGE_ID = STAGE_ID from #TEMP_STAGES
While @@rowcount <> 0
Begin
select * from MEDICAL_REPORTS_APPROVAL_STAGES Where  REQUEST_STAGE_ID = @P_STAGE_ID
PRINT(@P_STAGE_ID);
Delete from #TEMP_STAGES where STAGE_ID = @P_STAGE_ID
Select @P_STAGE_ID = STAGE_ID from #TEMP_STAGES
End
Set Rowcount 0
Drop table #TEMP_STAGES
END

Friday, June 6, 2014

jquery umalqura Calender with Gregorien Date Selector User Control Example

output :
description :
the article source build on ApI related
http://keith-wood.name/datepick.html

the Sample contains user Control with two textboxes the right one to select Umalqura date , the Second to select Gregorien Date .
when you select date (umalqura or gregorien ) the second date captured automatic using conversion method.

public Properties For User Control :
1- getGregorianDateText
return selected Gregorien date for the calender control.

2- getHijriDateText
get Hijri date using Umalqura Calender user selected .

3- SelectedCalendareDate
get or set the selected date for calender ,

4- SetHijriDate
set hijri date for the calender.
-------------------------------------------------------------
you can download Full Sample using this dropbox Link.
https://www.dropbox.com/sh/h840agq0v6xgnix/AAB2uJ-xLstnTQfzOCZTqOrza?dl=0

sql server Cursor template Example

using cursor in sql server :
cursor used to capture collection of result used after for looping or fetching in sub query .
example :

USE yourdbname
GO
declare cur cursor for
select  user_id from USERS
open cur
declare @id int
fetch next from cur into @id
while (@@FETCH_STATUS = 0)
begin
    print(@id)
    fetch next from cur into @id
end
close cur
deallocate cur
GO


------------------------------------------------------------
to get values from cursor should declare variable or scalar table keep cursor values.


SQL SERVER PAGING OUTPUT DATA TO GRIDVIEW SAMPLE CODE

when you create gridview display multiple rows so you can divide rows query for sql server according your paging selection this will demanded to pass page size and page index to get query result .
this is best for performance to get from database rows needed to show not load all rows every postback for gridview paging.

sql server sample  code:

BEGIN
SET NOCOUNT ON
SET XACT_ABORT ON
---------------------------------------------------------------
DECLARE @INTPAGE INT =2 ;
DECLARE @INTPAGESIZE INT =10 ;
DECLARE @REQUEST_REPORT_NO VARCHAR(50) = NULL
   DECLARE @PATIENT_PROFILE_NO VARCHAR(50) = NULL
    DECLARE @REQUEST_STAGE_ID VARCHAR(50) = NULL
    DECLARE @REQUEST_STATUS_ID VARCHAR(50) = NULL
    DECLARE @FROM_DATE DATETIME = NULL
    DECLARE @TO_DATE DATETIME = NULL
   
DECLARE @INTSTARTROW INT;
DECLARE @INTENDROW INT;

SET @INTSTARTROW = (@INTPAGE -1) * @INTPAGESIZE + 1;
SET @INTENDROW = @INTPAGE * @INTPAGESIZE;  
--------------------------------------------------------------

WITH BLOGS AS
(
SELECT VR.*  ,
 ROW_NUMBER() OVER(ORDER BY VR.CREATE_DATE DESC) AS INTROW ,
      COUNT(VR.REQUEST_REPORT_NO) OVER() AS TOTAL_ROWS_COUNT
FROM VACATION_REPORTS_REQUEST VR
RIGHT JOIN WORK_FLOWS_TYPES_STAGES T ON VR.REQUEST_STAGE_ORDER = T.STAGE_ORDER
WHERE
        T.TYPE_ID = [DBO].[WORK_FLOWS_TYPE_GET_BY_USER_ID](6,VR.CREATE_BY_USER_ID)
  AND T.STAGE_ORDER =VR.REQUEST_STAGE_ORDER
  AND ([REQUEST_REPORT_NO] = @REQUEST_REPORT_NO OR @REQUEST_REPORT_NO IS NULL)
  AND  (@PATIENT_PROFILE_NO IS NULL OR VR.PATIENT_PROFILE_NO = @PATIENT_PROFILE_NO)
  AND  (@REQUEST_STAGE_ID IS NULL  OR T.STAGE_ID = @REQUEST_STAGE_ID)
  AND  (@REQUEST_STATUS_ID IS NULL OR VR.REQUEST_STATUS_ID = @REQUEST_STATUS_ID)
  AND (@FROM_DATE IS NULL OR VR.CREATE_DATE > = @FROM_DATE)
  AND (@TO_DATE IS NULL OR VR.CREATE_DATE < = @TO_DATE)
  AND (@FROM_DATE IS NULL OR
(@TO_DATE IS NOT NULL AND @FROM_DATE IS NOT  NULL AND  VR.CREATE_DATE BETWEEN @FROM_DATE AND @TO_DATE)
)
 
  )
 SELECT * FROM BLOGS
WHERE (@INTPAGESIZE =0 OR INTROW BETWEEN @INTSTARTROW AND @INTENDROW)
END