Click here to Skip to main content
15,881,281 members
Articles / Desktop Programming / Windows Forms

Recoding Using the Template Method Design Pattern

Rate me:
Please Sign up or sign in to vote.
1.47/5 (5 votes)
29 May 2007CPOL 20.4K   77   13  
This article shows a recoding sample using the Template Method Design Pattern.
        /// Initialize Current Activity        
        private void InitCommonVariables()
        {
            // Get Selected Activity
            currentActivity = (Progress.Model.ProgressActivity)this.Activity;
            if (currentActivity.BNodeLevel == (int)ActivityNodeLevel.Kojun)
            {
                // Ready to Set ComboBox Items from M_STDLDTM DataTable
                dtMSTDLDTM = ((ProgressGanttModel)(currentActivity.GanttModel)).dtMSTDLDTM;
                if (dtMSTDLDTM.Rows.Count > 0)
                {
                    // Set Primary Key of Table for Row Search
                    System.Data.DataColumn[] primaryKey = new System.Data.DataColumn[1];
                    primaryKey[0] = dtMSTDLDTM.Columns[0];
                    dtMSTDLDTM.PrimaryKey = primaryKey;
                    listWrkID = new ArrayList();
                    listWrkNM = new ArrayList();
                    // Set Filter
		    String filter = "";
                    if (initParams.scheduleType == EnumScheduleType.Mschedule)
                    {
                 	filter = "SCH_TYP<>2";
                    }
                    else if (initParams.scheduleType == EnumScheduleType.Sschedule)
                    {
                 	filter = "SCH_TYP=2";
                    }
                    filter = "(" + filter + ") AND (DEL_FLG<>1)";
      		    // Initialize ArrayList
                    foreach (System.Data.DataRow row in dtMSTDLDTM.Select(filter))
                    {
                        listWrkID.Add(row["WRK_ID"].ToString());
                        listWrkNM.Add(row["WRK_NM"].ToString());
                    }
                }
  		// If DataTable has no Column Add Columns for Error Handling
                if (dtMSTDLDTM.Columns.Count == 0)
                {
                    System.Data.DataColumn wrkIDColumn = new System.Data.DataColumn("WRK_ID");
                    System.Data.DataColumn wrkNMColumn = new System.Data.DataColumn("WRK_NM");
                    dtMSTDLDTM.Columns.Add(wrkIDColumn);
                    dtMSTDLDTM.Columns.Add(wrkNMColumn);
                }
                // Ready to Set ComboBox Items from M_EVENT DataTable
                if (currentActivity.BEventFlg == 1)
                {
                    dtMEVENT = ((ProgressGanttModel)(currentActivity.GanttModel)).dtMEVENT;
                    if (dtMEVENT.Rows.Count > 0)
                    {
                        // Set Primary Key of Table for Row Search
                        primaryKey = new System.Data.DataColumn[1];
                        primaryKey[0] = dtMEVENT.Columns[0];
                        dtMEVENT.PrimaryKey = primaryKey;
                        listEventID = new ArrayList();
                        listEventNM = new ArrayList();
       			// Initialize ArrayList
                        foreach (System.Data.DataRow row in dtMEVENT.Rows)
                        {
                            listEventID.Add(row["EVENT_ID"].ToString());
                            listEventNM.Add(row["EVENT_NM"].ToString());
                        }
                    }
     		    // If DataTable has no Column Add Columns for Error Handling
                    if (dtMEVENT.Columns.Count == 0)
                    {
                        System.Data.DataColumn eventIDColumn = new System.Data.DataColumn("EVENT_ID");
                        System.Data.DataColumn eventNMColumn = new System.Data.DataColumn("EVENT_NM");
                        dtMEVENT.Columns.Add(eventIDColumn);
                        dtMEVENT.Columns.Add(eventNMColumn);
                    }
  		}
     	    }
 	} 

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
Japan Japan
Ph.D(Computer Network)
Project Manger
Developer

Comments and Discussions