Friday, December 23, 2011

How to validate dates using Javascript


here is the javascript function compare two dates.

        function validatedates() {
            
            var objPEndDate = document.getElementById('<%=txtDate1.ClientID%>').value;
            var objCExpiryDate = document.getElementById('<%=txtDate2.ClientID%>').value;


            var PEndDate = new Date(objPEndDate);
            var CExpiryDate = new Date(objCExpiryDate);


            if (CExpiryDate > PEndDate) {
                alert("Coupon Expiry Date should be less than Promotion End Date.");
                return false;
            }
            return true;
        }




HTML code


<asp:TextBox ID="txtDate2" CssClass="ICStyle ICStyle3Width" onchange="validatedates();" runat="server" />

Thursday, December 22, 2011

How to make any .Net Server Control visible invisible using Javascript

1. This is how you can make ASP.NET Server Control visible.

document.getElementById('<%= YourServerControlID.ClientID %>').style.display = "inline";

2. This is how you can make ASP.NET Server Control invisible.

document.getElementById('<%= YourServerControlID.ClientID %>').style.display = "none";

How to change SelectedIndex of Dropdownlist in Javascript


var oDDL = document.getElementById('<%=YourDropDownListID.ClientID%>');
oDDL.selectedIndex = 0;

Tuesday, February 23, 2010

Optimized Grid Paging

There are 3 things involved in Grid Paging.
1. Stored Procedure
2. Business Class Functionality
3. User Interface and its Code Behind.

1. Stored Procedure

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go


-- =============================================
-- Author:
-- Description:
-- =============================================
ALTER PROCEDURE [dbo].[GRID_PAGING]
-- Add the parameters for the stored procedure here
@PageIndex INT = 0,
@PageSize INT = 10,
@NoOfRows NUMERIC(18,0) OUTPUT,
@NoOfPages INT OUTPUT
-- @Sort VARCHAR(100)=''
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

CREATE TABLE #GridPaging (ItemID Numeric(18,0),
ItemName NVARCHAR(500),
SpecialDescription NVARCHAR(500),
ItemStatus NVARCHAR(255))

INSERT INTO #GridPaging (ItemID,
ItemName,
SpecialDescription,
ItemStatus)
SELECT ItemID,
ItemName,
SpecialDescription,
ItemStatus
FROM Product


DECLARE @PageLowerBound INT
DECLARE @PageUpperBound INT
DECLARE @RowsToReturn INT
--First Set the rowcount
SET @RowsToReturn = @PageSize * (@PageIndex + 1)
SET ROWCOUNT @RowsToReturn
--Set the page bounds
SET @PageLowerBound = @PageSize * @PageIndex
SET @PageUpperBound = @PageLowerBound + @PageSize + 1
--Create a temp table to store the select results
CREATE TABLE #PageIndex
(IndexID INT IDENTITY(1,1) NOT NULL,
ItemID NUMERIC(18,1))

--Insert into the temp table
INSERT INTO #PageIndex ( #PageIndex.ItemID )
SELECT #GridPaging.ItemID FROM #GridPaging ORDER BY #GridPaging.ItemID ASC

--Important SQL Statement
SELECT GP.ItemID,
GP.ItemName,
GP.SpecialDescription,
GP.ItemStatus
FROM #GridPaging GP, #PageIndex PIN
WHERE GP.ItemID = PIN.ItemID
AND ( PIN.IndexID &gt; @PageLowerBound
AND PIN.IndexID &lt; @PageUpperBound )

ORDER BY PIN.IndexID

SET @NoOfRows=(SELECT COUNT(1) FROM #GridPaging)
SET @NoOfPages=@NoOfRows/@PageSize + 1

END

2. Business Class Function

//For Grid Paging
public DataTable GetProducts_PageWise(Int32 PageIndex, Int32 PageSize, out Int64 NoOfRows, out Int32 NoOfPages)
{
try
{
oDal.OpenConnection();
oCon = oDal.GetConnection();

cmd = new SqlCommand("GRID_PAGING", oCon);
cmd.CommandType = CommandType.StoredProcedure;

cmd.Parameters.Add("@PageIndex", SqlDbType.Int).Value = PageIndex;
cmd.Parameters.Add("@PageSize", SqlDbType.Int).Value = PageSize;
SqlParameter oNoOfRows = new SqlParameter();
oNoOfRows.ParameterName = "@NoOfRows";
oNoOfRows.DbType = DbType.Int64;
oNoOfRows.Direction = ParameterDirection.Output;
oNoOfRows.Value = 0;
cmd.Parameters.Add(oNoOfRows);

SqlParameter oNoOfPages = new SqlParameter();
oNoOfPages.ParameterName = "@NoOfPages";
oNoOfPages.DbType = DbType.Int32;
oNoOfPages.Direction = ParameterDirection.Output;
oNoOfPages.Value = 0;
cmd.Parameters.Add(oNoOfPages);

SqlDataReader oSDR;
oSDR = cmd.ExecuteReader();

DataTable oDT = new DataTable();
oDT.Load(oSDR);

NoOfRows = Convert.ToInt64(oNoOfRows.Value);
NoOfPages = Convert.ToInt32(oNoOfPages.Value);


return oDT;
}
catch (Exception ex)
{
ErrorMsg = ex.Message;
NoOfRows = 0;
NoOfPages = 0;
return null;
}
finally
{
oCon.Close();
cmd.Dispose();
oCon.Dispose();
}
}

3. User Interface and its Code Behind
3.1 User Interface:


<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" >
                         <ContentTemplate>
                          
                            <asp:UpdateProgress ID="UpdateProgress1" AssociatedUpdatePanelID="UpdatePanel1" runat="server">
                                <ProgressTemplate>
                                  Populating Grid...
                                </ProgressTemplate>
                            </asp:UpdateProgress>
                          
                            <asp:ListView ID="lvItemsTable" runat="server"  ItemPlaceholderID="layoutTableTemplate"
                            DataKeyNames="ItemID" >
                          
                              <LayoutTemplate>
                                    <table cellpadding="5" style="width:100%" >
                                        <thead style="position:relative;">
                                            <tr style="background-color:#EAF8FF;text-align:left;">
                                                <th style="position:relative;">Item ID</th>
                                                <th style="position:relative">Item Name</th>
                                                <th style="position:relative">Special Desc.</th>
                                                <th style="position:relative">Item Status</th>
                                            </tr>
                                        </thead>
                                        <tbody id="layoutTableTemplate" runat="server" ></tbody>
                                    </table>
                                </LayoutTemplate>
                              
                                <ItemTemplate>
                                   <tr>
                                        <td style="text-align:left;"><%#DataBinder.Eval(Container.DataItem, "ItemID")%></td>
                                        <td style="text-align:left;"><%#DataBinder.Eval(Container.DataItem, "ItemName")%></td>
                                        <td style="text-align:left;"><%#DataBinder.Eval(Container.DataItem, "SpecialDescription")%></td>
                                        <td style="text-align:left;"><%#DataBinder.Eval(Container.DataItem, "ItemStatus")%></td>
                                   </tr>
                                </ItemTemplate>
                                <AlternatingItemTemplate>
                                   <tr style="background-color:#EAF8FF">
                                        <td style="text-align:left;"><%#DataBinder.Eval(Container.DataItem, "ItemID")%></td>
                                        <td style="text-align:left;"><%#DataBinder.Eval(Container.DataItem, "ItemName")%></td>
                                        <td style="text-align:left;"><%#DataBinder.Eval(Container.DataItem, "SpecialDescription")%></td>
                                        <td style="text-align:left;"><%#DataBinder.Eval(Container.DataItem, "ItemStatus")%></td>
                                   </tr>
                              
                                </AlternatingItemTemplate>
                                <EmptyDataTemplate>No Records Found
                                </EmptyDataTemplate>
                                                          
                            </asp:ListView>
                            <br /><br />
                          
                          
                            <div id="divPager" runat="server" style="width:100%;">
                            Go To Page No. <asp:DropDownList ID="ddlPageIndex" AutoPostBack="true"
                                    runat="server" onselectedindexchanged="ddlPageIndex_SelectedIndexChanged"></asp:DropDownList>
                                    Page Size <asp:DropDownList ID="ddlPageSize" AutoPostBack="true"
                                    runat="server" onselectedindexchanged="ddlPageSize_SelectedIndexChanged">
                                    <asp:ListItem Selected="True" Text="10" Value="10" ></asp:ListItem>
                                    <asp:ListItem Text="20" Value="20" ></asp:ListItem>
                                    <asp:ListItem Text="30" Value="30" ></asp:ListItem>
                                    <asp:ListItem Text="40" Value="40" ></asp:ListItem>
                                    </asp:DropDownList>
                            </div>
                         </ContentTemplate>
                        
                         </asp:UpdatePanel>



3.2 Code Behind of User Interface (Page.aspx.cs)




protected void Page_Load(object sender, EventArgs e)
{
if (this.IsPostBack.Equals(false))
{
Boolean blnResult = false;
blnResult= DisplayItems(0,Convert.ToInt32(ddlPageSize.SelectedValue.ToString()));
}
}



private Boolean DisplayItems(Int32 PageIndex, Int32 PageSize)
{
DataTable oDT = new DataTable();
try
{
cProduct oProduct = new cProduct();
Int64 NoOfRows = 0;
Int32 NoOfPages = 0;

oDT = oProduct.GetProducts_PageWise(PageIndex, PageSize, out NoOfRows, out NoOfPages);

lvItemsTable.DataSource = oDT;
lvItemsTable.DataBind();

if (ddlPageIndex.Items.Count.Equals(0))
{
PopulatePageNumbers(NoOfPages);
}
else if (!(ddlPageIndex.Items[ddlPageIndex.Items.Count - 1].Value.ToString().Equals(NoOfPages.ToString())))
{
PopulatePageNumbers(NoOfPages);
}

return true;
}
catch (Exception ex)
{
return false;
}
finally
{
oDT = null;
}
}

private void PopulatePageNumbers(Int32 NoOfPages)
{
ddlPageIndex.Items.Clear();
for (int intCtr = 1; intCtr &lt;= NoOfPages; intCtr++)

{
ListItem oLI = new ListItem();
oLI.Text = intCtr.ToString();
oLI.Value = intCtr.ToString();
ddlPageIndex.Items.Add(oLI);

}

}

protected void ddlPageIndex_SelectedIndexChanged(object sender, EventArgs e)
{
Boolean blnResult = false;
blnResult = DisplayItems(Convert.ToInt32(ddlPageIndex.SelectedValue.ToString()) - 1, Convert.ToInt32(ddlPageSize.SelectedValue.ToString()));

}

protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
{
Boolean blnResult = false;
blnResult = DisplayItems(0, Convert.ToInt32(ddlPageSize.SelectedValue.ToString()));

}

Saturday, February 13, 2010

Work Breakdown Structure

Work Breakdown Structure

Identifier

WBS Element

Include?

Your Label for This

1.0

Acquisition Process

1.1

Initiation

1.1.1

Describe concept or need

1.1.2

Analyze system requirements

1.1.3

Approve system requirements

1.1.4

Define software requirements

1.1.5

Consider acquisition options

1.1.6

Evaluate off-the-shelf products

1.1.7

Document and execute acquisition plan

1.1.8

Document acceptance criteria

1.2

RFP Preparation

1.2.1

Document acquisition requirements (RFP)

1.2.2

Tailor standards

1.2.3

Define contract milestones and audits

1.2.4

Give requirements to performer

1.3

Contract Prep and update

1.3.1

Establish selection procedure

1.3.2

Select supplier based on evaluation

1.3.3

Get inputs on tailoring this Standard

1.3.4

Prepare and negotiate contract

1.3.5

Negotiate changes to contract

1.4

Supplier Monitoring

1.4.1

Monitor supplier activities

1.4.2

Cooperate with timely solutions

1.5

Acceptance and Completion

1.5.1

Define acceptance tests and procedures

1.5.2

Conduct acceptance review and testing

1.5.3

Perform CM after acceptance

2

Supply Process

2.1

Initiation

2.1.1

Review RFP, policies, regulations

2.1.2

Decide to bid, or accept contract

2.2

Preparation of Response

2.2.1

Prepare proposal in response to RFP

2.3

Contract

2.3.1

Negotiate and enter into contract

2.3.2

Mod contract per change mechanism

2.4

Planning

2.4.1

Define management and QA

2.4.2

Select a life cycle model

2.4.3

Plan management, assurance, resources

2.4.4

Evaluate make-buy decisions

2.4.5

Document project management plans

2.5

Execution and Control

2.5.1

Execute project management plans

2.5.2

Develop, operate or maintain per process

2.5.3

Monitor progress, identify problems

2.5.4

Control subcontractors per Acquisition Process

2.5.5

Interface with IV&V and test agent

2.5.6

Interface with others per contract and plans

2.6

Review and Evaluation

2.6.1

Coordinate contract reviews

2.6.2

Support meetings, reviews, tests, audits

2.6.3

Conduct V&V per this process

2.6.4

Report evaluations, audits, tests to acquirer

2.6.5

Provide access to facilities

2.6.6

Perform QA

2.7

Delivery and Completion

2.7.1

Deliver the product per contract

2.7.2

Support acquirer with product per contract

3

Development Process

3.1

Process Implementation

3.1.1

Define software life cycle model

3.1.2

Document and control outputs

3.1.3

Select and use standards, tools and languages

3.1.4

Document development plans

3.1.5

Deliver all needed products

3.2

System Requirements Analysis

3.2.1

Specify system requirements

3.2.2

Evaluate Requirements Against Criteria

3.3

System Architectural Design

3.3.1

Establish top-level architecture

3.3.2

Evaluate architecture against criteria

3.4

Software Requirements Analysis

3.4.1

Document software requirements

3.4.2

Evaluate requirements against criteria

3.4.3

Conduct joint reviews

3.5

Software Architectural Design

3.5.1

Transform requirements into architecture

3.5.2

Document top-level design for interfaces

3.5.3

Document top-level design for database

3.5.4

Document preliminary user documentation

3.5.5

Document preliminary test requirements

3.5.6

Evaluate architecture against criteria

3.5.7

Conduct joint reviews

3.6

Software Detailed Design

3.6.1

Document design for each component

3.6.2

Document design for interfaces

3.6.3

Document design for database

3.6.4

Update user documentation

3.6.5

Document unit test requirements

3.6.6

Update integration test requirements

3.6.7

Evaluate detailed design against criteria

3.6.8

Conduct joint reviews

3.7

Software Coding and Testing

3.7.1

Document each unit, database and tests

3.7.2

Conduct and document unit testing

3.7.3

Update user documentation

3.7.4

Update integration test requirements

3.7.5

Evaluate code and test results

3.8

Software Integration

3.8.1

Document integration plans

3.8.2

Conduct and document integration tests

3.8.3

Update user documentation

3.8.4

Document qualification tests

3.8.5

Evaluate plans and tests against criteria

3.8.6

Conduct joint reviews

3.9

Software Qualification testing

3.9.1

Conduct and document qualification tests

3.9.2

Update user documentation

3.9.3

Evaluate tests against criteria

3.9.4

Support audits

3.9.5

Prepare product for next phase

3.10

System Integration

3.10.1

Integrate software with hardware and others

3.10.2

Document integration tests

3.10.3

Evaluate integrated system against criteria

3.11

System Qualification Testing

3.11.1

Conduct and document qualification tests

3.11.2

Evaluate system against criteria

3.11.3

Support audits

3.11.4

Prepare product for installation

3.12

Software Installation

3.12.1

Plan installation in target environment

3.12.2

Install software per plan

3.13

Software Acceptance Support

3.13.1

Support acquirer's acceptance tests

3.13.2

Deliver product per contract

3.13.3

Provide training per contract

4

Operations Process

4.1

Process Implementation

4.1.1

Document operational activities

4.1.2

Document problem tracking procedures

4.1.3

Document product testing procedures

4.2

Operational Testing

4.2.1

Conduct operational testing

4.2.2

Test software code and databases

4.3

System Operation

4.3.1

Operate per user documentation

4.4

User Support

4.4.1

Assist users as requested

4.4.2

Track user requests

4.4.3

Provide problem work-around solutions

5

Maintenance Process

5.1

Process Implementation

5.1.1

Document maintenance activities

5.1.2

Document problem tracking procedures

5.1.3

Manage modifications to the system

5.2

Problem and Modification Analysis

5.2.1

Analyze problem reports

5.2.2

Replicate or verify problems

5.2.3

Develop modifications

5.2.4

Document problems, analysis, fixes

5.2.5

Get modifications approved per contract

5.3

Modification Implementation

5.3.1

Document where changes are needed

5.3.2

Implement modifications

5.4

Maintenance Review/Acceptance

5.4.1

Review integrity of modified system

5.4.2

Get approval for modifications per contract

5.5

Migration

5.5.1

Ensure products meet this standard

5.5.2

Develop and execute Migration Plan

5.5.3

Notify users of migration

5.5.4

Conduct parallel operations if needed

5.5.5

Notify all concerned, archive all records

5.5.6

Perform post-op review of changes

5.5.7

Keep data from old environment

5.6

Software Retirement

5.6.1

Document plans for retirement

5.6.2

Notify all users of plans and activities

5.6.3

Conduct parallel operations

5.6.4

Notify all concerned, archive all records

5.6.5

Keep data from retired product per contract

6

Documentation

6.1

Process Implementation

6.1.1

Develop a documentation plan

6.2

Design and Development

6.2.1

Use applicable standards for documents

6.2.2

Confirm source of input data

6.2.3

Review and edit documents against standards

6.3

Production

6.3.1

Produce documents per plan

6.3.2

Control per CM Process

6.4

Maintenance

6.4.1

Modify documents per CM Process

7

Configuration Management

7.1

Process Implementation

7.1.1

Develop CM Plan

7.2

Configuration Identification

7.2.1

Establish scheme to identify software items

7.3

Configuration Control

7.3.1

Manage change requests

7.3.1.1

Record change requests

7.3.1.2

Evaluate change requests

7.3.1.3

Approve change requests

7.3.2

Keep audit trail

7.3.3

Control access to items

7.4

Configuration Status Accounting

7.4.1

Maintain records and status reports

7.5

Configuration Evaluation

7.5.1

Ensure functional completeness of products

7.6

Release Management and Delivery

7.6.1

Control release and delivery of products and documentation

8

Quality Assurance

8.1

Process Implementation

8.1.1

Establish QA process

8.1.2

Coordinate with Verification, Validation, Joint Reviews and Audit Processes

8.1.3

Develop QA Plan

8.1.4

Schedule and execute QA tasks

8.1.5

Make QA records available to acquirer

8.1.6

Give QA team organizational freedom

8.2

Product Assurance

8.2.1

Assure plans are executed

8.2.2

Assure products comply with contract

8.2.3

Assure delivered products satisfy requirements

8.3

Process Assurance

8.3.1

Assure processes comply with contract

8.3.2

Assure practices, tests, libraries comply

8.3.3

Assure prime requirements are passed to subs

8.3.4

Assure support provided per contract

8.3.5

Assure measures performed per standards and procedures

8.3.6

Assure staff is trained

8.4

Assurance of Quality Systems

8.4.1

Assure additional quality management activities are performed per ISO 9001, if required

9

Verification

9.1

Process Implementation

9.1.1

Determine if verification effort needed

9.1.2

If so, establish process

9.1.3

Select independent verification organization

9.1.4

Identify activities and products to verify

9.1.5

Develop verification plan and procedures

9.1.6

Implement verification plan

9.2

Verification

9.2.1

Verify contract against criteria

9.2.2

Verify process against criteria

9.2.3

Verify requirements against criteria

9.2.4

Verify design against criteria

9.2.5

Verify code against criteria

9.2.6

Verify integration against criteria

9.2.7

Verify documentation against criteria

10

Validation

10.1

Process Implementation

10.1.1

Determine if validation effort needed

10.1.2

If so, establish process

10.1.3

Select validation organization

10.1.4

Develop validation plan

10.1.5

Implement validation plan

10.2

Validation

10.2.1

Prepare test requirements, cases, specs

10.2.2

Ensure requirements met

10.2.3

Conduct tests

10.2.4

Validate that product satisfies intended use

10.2.5

Test product in target environment

11

Joint Review

11.1

Process Implementation

11.1.1

Hold periodic and ad hoc reviews

11.1.2

Agree to resources needed

11.1.3

Set agenda, products, scope, procedures

11.1.4

Record problems detected

11.1.5

Document and distribute results

11.1.6

Agree on outcome and action items

11.2

Project Management Reviews

11.2.1

Evaluate status against plans, schedules

11.3

Technical Reviews

11.3.1

Evaluate products or services

12

Audit

12.1

Process Implementation

12.1.1

Audit at predetermined milestones per plan

12.1.2

Select independent auditors

12.1.3

Agree to audit resources

12.1.4

Agree on agenda, products, scope

12.1.5

Record problems detected

12.1.6

Document and distribute results

12.1.7

Agree on outcome and action items

12.2

Audit

12.2.1

Conduct audits per criteria

13

Problem Resolution

13.1

Process Implementation

13.1.1

Establish problem resolution process for handling problems in products and activities

13.2

Problem Resolution

13.2.1

Track problems through detection, analysis, and resolution

14

Management

14.1

Initiation and Scope Definition

14.1.1

Establish the requirements for management

14.1.2

Check resources: personnel, materials, etc.

14.1.3

Modify requirements to achieve criteria

14.2

Planning

14.2.1

Plan efforts, schedules, tasks, duties, costs

14.3

Execution and Control

14.3.1

Implement plan to meet objectives

14.3.2

Monitor process

14.3.3

Investigate and resolve problems

14.3.4

Report progress

14.4

Review and Evaluation

14.4.1

Ensure products and plans are evaluated

14.4.2

Assess evaluation results

14.5

Closure

14.5.1

Determine when process is complete

14.5.2

Check results for completeness

15

Infrastructure

15.1

Process Implementation

15.1.1

Define infrastructure needed

15.1.2

Plan and document infrastructure establishment

15.2

Establish Infrastructure

15.2.1

Document configuration of infrastructure

15.2.2

Install infrastructure in time for process

15.3

Maintain Infrastructure

15.3.1

Maintain, monitor, modify infrastructure to satisfy requirements of process

16

Improvement

16.1

Process Establishment

16.1.1

Establish organizational processes for software life cycle

16.2

Process Assessment

16.2.1

Develop process assessment procedure

16.2.2

Review process for effectiveness

16.3

Process Improvement

16.3.1

Improve processes as needed

16.3.2

Collect and analyze process data

16.3.3

Collect and use quality cost data

17

Training

17.1

Process Implementation

17.1.1

Determine training needs, develop plan

17.2

Training Material Development

17.2.1

Develop training presentation materials

17.3

Training Plan Implementation

17.3.1

Provide training to personnel, keep records

18

Tailoring

18.1

Identify Project Environment

18.1.1

Identify model, activities, requirements, policies, strategies, criticality, etc.

18.2

Solicit Input

18.2.1

Solicit input from users, support personnel, bidders, etc.

18.3

Select Processes, Activities and Tasks

18.3.1

Decide on processes, activities and tasks

18.3.2

Specify in contract others not in this Standard

18.4

Document Tailoring Decisions and Rationale

18.4.1

Document decisions and rationale