Thursday, September 21, 2017

jQuery actual validation with From date and to date validation


jQuery actual validation with From date and to date validation.
1.  If from date is selected then to date will be >= from date
2.  If to date selected first then from date will be <= to date


$(document).ready(function () {
            $("#<%=txtCreateDtFrom.ClientID %>").prop('readonly', true);
            $("#<%=txtCreateDtTo.ClientID %>").prop('readonly', true);
            $("#<%=txtDeadlineFrom.ClientID %>").prop('readonly', true);
            $("#<%=txtDeadlineTo.ClientID %>").prop('readonly', true);

            $(".calendar-drop").datepicker({
                changeMonth: true,
                changeYear: true
            });

            $("#<%=txtCreateDtFrom.ClientID %>").datepicker({
                changeMonth: true,
                changeYear: true,
                beforeShow: function () {
                    dt = $("#<%=txtCreateDtTo.ClientID %>").datepicker('getDate');
                    return { maxDate: dt };
                }
            });
            $("#<%=txtCreateDtTo.ClientID %>").datepicker({
                changeMonth: true,
                changeYear: true,
                beforeShow: function () {
                    dt = $("#<%=txtCreateDtFrom.ClientID %>").datepicker('getDate');
                    return { minDate: dt };
                }
            });

            $("#<%=txtDeadlineFrom.ClientID %>").datepicker({
                changeMonth: true,
                changeYear: true,
                beforeShow: function () {
                    dt = $("#<%=txtDeadlineTo.ClientID %>").datepicker('getDate');
                    return { maxDate: dt };
                }
            });

            $("#<%=txtDeadlineTo.ClientID %>").datepicker({
                changeMonth: true,
                changeYear: true,
                beforeShow: function () {
                    dt = $("#<%=txtDeadlineFrom.ClientID %>").datepicker('getDate');
                    return { minDate: dt };
                }
            });          

});           

Friday, September 15, 2017

SQL Server loop through all records or loop through a set of records without cursor in Stored Proceure/function.



              SELECT * INTO #TEMPRES
              FROM
              (
                     SELECT ROW_NUMBER() OVER(order by (SELECT 1)) AS SerialNo, RES.Column1, RES.Column2
                     FROM (SELECT DISTINCT Column1, Column2
                           FROM teble1 WHERE Column2= 'test' ) AS RES
              ) AS X


              --SELECT * FROM #TEMPRES
              --//// MAKING LOOP OF RECORDS ////
              DECLARE @RowCnt INT = 1
              SELECT @RowCnt=COUNT(*) FROM #TEMPRES
              IF(@RowCnt > 0)
              BEGIN
                     DECLARE @i INT = 1
                     WHILE(@i <= @RowCnt)
                     BEGIN
                                  SELECT ProjectLPDetailsBatchID FROM #TEMPRES WHERE SerialNo = @i    
                           END
                           SET @i = @i + 1
                     END
              END

              DROP TABLE #TEMPRES