retro code...

Necuno

Court Jester
Joined
Sep 27, 2005
Messages
58,567
...going through roughly 4 years back of how i coded its scary to say the least lol

ex
Code:
    /// <summary>
    /// setup all the controls on the page.
    /// </summary>
    private void SetupControls()
    {
        string PageName = Request["PageName"];
        string[] sButtons;
       

        switch (PageName)
        {
            case "Current Service Providers":
            case "View Projects":
                {
                    string PageLocation = GetLocation(PageName);

                    //create string array with the buttons names in the order that they should appear on the bottom bar
                    sButtons = new string[4] { "First", "Last", "Next", "Previous" };
                    SetupNavButtons(sButtons);
                    SetupPageName(PageName); 
                    SetupBusyWith(null);
                    SetupOnclicks(sButtons, "GridViewNavEvent('" + PageLocation + "',this.value);return false");
                    break;
                }
            case "Update User":
            case "New User":
            case "Update Project":
            case "New Project":
                {
                    string PageLocation = GetLocation(PageName);
                    //create string array with the buttons names in the order that they should appear on the bottom bar
                    if (PageName.IndexOf("New") > -1) { sButtons = new string[3] { "Previous", "Next", "Cancel" }; }
                    else { sButtons = new string[2] { "Update", "Return" }; }

                    SetupNavButtons(sButtons);
                    SetupPageName(PageName);
                    SetupBusyWith("");
                    SetupOnclicks(sButtons, "MultiViewNavEvent('" + PageLocation + "',this.value);return false");
                    
                    if (PageName.IndexOf("New") > -1) { SetupCCS("Cancel", "ButtonCancel"); }
                    break;
                }
            case "Test":
                {
                    //create string array with the buttons names in the order that they should appear on the bottom bar
                    sButtons = new string[4] { "Next", "Previous", "First", "Last" };
                    SetupNavButtons(sButtons);
                    SetupPageName(PageName);
                    SetupBusyWith("");
                    SetupOnclicks(sButtons, "MultiViewNavEvent(this.value);return false");
                    break;
                }
            case "Project":
            case "Report Viewer":
            case "Report Viewer SEP":
            case "Reports New":
            case "Report Viewer MPR":
            case "Outstanding MPR":
            case "User Details":
            case "Current Users":
            case "Reports":
            case "Project Personnel":
            case "Cashflow":
            case "Claims":
            case "Add/Edit Claim":
            case "Claim Budget":
            case "Consultant Claim":
            case "Contractor Claim":
            case "Cheque Request":
            case "Report Project":
            case "Project KPI":
            case "Project Service Provider":
                {
                    SetupPageName(PageName);
                    SetupBusyWith(null);
                    break;
                }
            case "Add Service Provider":
            case "Edit Service Provider":
            case "Service Provider Owner":
            case "Service Provider Person":
            //case "Add/Edit Claim":
                {
                    string PageLocation = GetLocation(PageName);
                    //create string array with the buttons names in the order that they should appear on the bottom bar
                    sButtons = new string[2] { "Save", "Cancel" };
                    SetupNavButtons(sButtons);
                    SetupPageName(PageName);
                    SetupBusyWith(null);
                    SetupOnclicks(sButtons, "BtnEvent('" + PageLocation + "',this.value);return false");
                    SetupCCS("Cancel", "ButtonCancel");
                    break;
                }
            //case "Project":
            //    {
            //        string PageLocation = GetLocation(PageName);
            //        //create string array with the buttons names in the order that they should appear on the bottom bar
            //        sButtons = new string[1] { "KPI" };
            //        SetupNavButtons(sButtons);
            //        SetupPageName(PageName);
            //        SetupBusyWith(null);
            //        SetupOnclicks(sButtons, "BtnEvent('" + PageLocation + "',this.value);return false");
            //        //SetupCCS("Cancel", "ButtonCancel");
            //        break;
            //    }
               
            default:
                {
                    //null
                    break;
                }
        }
    }

or

Code:
       /// <summary>
        /// builds all the sub navigational links
        /// </summary>
        /// <param name="PageName">name of the page to get links for</param>
        //private void BuildSubNavLinks(string PageName)
        //private void BuildSubNavLinks(string PageName, string ID)
        private void BuildSubNavLinks(string PageName, string ID, string ID2, string ID3)
        {
            //genTopNavBar NewSubNavLinks = new genTopNavBar();
            genTopNavBar NewSubNavLinks;

            //if (ID == "undefined")
            ////use normal constructor without ID
            //{
            //    NewSubNavLinks = new genTopNavBar();
            //}
            ////else use constructor with ID
            //else if (ID2 == "undefined")
            //{
            //    NewSubNavLinks = new genTopNavBar(ID);
            //}
            //else if (ID3 == "undefined")
            //{
            //    NewSubNavLinks = new genTopNavBar(ID, ID2);
            //}
            //else
            //{
            //    NewSubNavLinks = new genTopNavBar(ID, ID2, ID3);
            //}

            if (ID == null)
            //use normal constructor without ID
            {
                NewSubNavLinks = new genTopNavBar();
            }
            //else use constructor with ID
            else if (ID2 == null)
            {
                NewSubNavLinks = new genTopNavBar(ID);
            }
            else if (ID3 == null)
            {
                NewSubNavLinks = new genTopNavBar(ID, ID2);
            }
            else
            {
                NewSubNavLinks = new genTopNavBar(ID, ID2, ID3);
            }

            //use if to check if ID is null - if not then pass to the constructor
            //if null then use normal constructor

            string[,] SubNavLinks = NewSubNavLinks.SubNavLinks(PageName);

            if (SubNavLinks != null)
            {
                int TotalLinks = SubNavLinks.Length / 3; // 2d, 3part string array. Name, Url, Position

                for (int i = 0; i < TotalLinks; i++)
                {
                    string hlnkID = "hlnkSub" + SubNavLinks[i, 2]; //gets the position, makes up control ID
                    HyperLink CurrentHyperLink = (HyperLink)Page.FindControl(hlnkID);

                    CurrentHyperLink.Text = SubNavLinks[i, 0];          //NAME
                    CurrentHyperLink.NavigateUrl = SubNavLinks[i, 1];   //URL, //add any ID here if needed !
                    
                    // We want documentation to open in a new window, so if
                    // this is the docs link, we give it a special target
                    if (CurrentHyperLink.Text != "Documentation")
                        CurrentHyperLink.Target = "frmBody";
                    else
                        CurrentHyperLink.Target = "_new";

                    CurrentHyperLink.Visible = true;
                }
            }
        }
 
Last edited:

Necuno

Court Jester
Joined
Sep 27, 2005
Messages
58,567
roflol i would love to some of your guy's retro code- i had to dig deep to find some of mine still alive somewhere.
 

dequadin

Expert Member
Joined
May 9, 2008
Messages
1,434
Here some .NET 1.0 stuff from varsity.

Code:
private void bindMembers(string fileNum)
{
	string strSQL = "select Medical_Aid_Code, Medical_Aid_Membership_no from patient where File_no = '" + fileNum + "';";
	bindDataset(strSQL, "patient");
	dtaRow = ds.Tables["patient"].Copy().Select();
	string code = dtaRow[0].ItemArray[0].ToString(), membership = dtaRow[0].ItemArray[1].ToString();
	strSQL = "select First_Name as 'First Name', Surname, ID_no as 'ID#' from patient where Medical_Aid_Code = '" + code + "' and Medical_Aid_Membership_no = '" + membership + "';";
	bindDataset(strSQL, "patient");
	dgMembers.DataSource=ds.Tables["patient"];				
}

it gets worse
Code:
if (dtaRow.Length > 0)
{
	intArray[i][j] = getFileNum(txtArray[i][j].Text);
	txtArray[i][j].Text = dtaRow[0].ItemArray[0] + " " + dtaRow[0].ItemArray[1];					
	strSQL = "insert into appointments values('" + dateTimePicker1.Value.GetDateTimeFormats()[2] + "','" + dtaRow[0].ItemArray[0] + " " + dtaRow[0].ItemArray[1] + "','" + dateTimePicker1.Value.GetDateTimeFormats()[2] + " " +lblArray[j].Text.Substring(0,5) +  "','" + intArray[i][j] + "','" + docArray[cmbDoctor.SelectedIndex] + "');";					
}
else
{
	strSQL = "insert into appointments values('" + dateTimePicker1.Value.GetDateTimeFormats()[2] + "','" + txtArray[i][j].Text + "','" + dateTimePicker1.Value.GetDateTimeFormats()[2] + " " +lblArray[j].Text.Substring(0,5) +  "','" + intArray[i][j] + "','" + docArray[cmbDoctor.SelectedIndex] + "');";										
}

if (intArray[i][j] != -2)
{
	doDatabase("OPEN");
	OdbcCommand myOdbcCommand = new OdbcCommand(strSQL);
	myOdbcCommand.Connection = oODBCConnection;
	try
	{
		myOdbcCommand.ExecuteNonQuery();
	}
	catch (Exception ex)
	{
		strSQL = "update appointments set name = '" + txtArray[i][j].Text + "', file_no = '" + intArray[i][j] + "' where Time = '" + dateTimePicker1.Value.GetDateTimeFormats()[2] + " " +lblArray[j].Text.Substring(0,5) + "' AND Employee_ID = '" + docArray[cmbDoctor.SelectedIndex] + "';";
		myOdbcCommand = new OdbcCommand(strSQL);
		myOdbcCommand.Connection = oODBCConnection;
		try
		{
			myOdbcCommand.ExecuteNonQuery();
		}
		catch (Exception ex2)
		{
			MessageBox.Show(ex.Message + " " + ex2.Message);
		}						
	}
	doDatabase("CLOSE");					
	MessageBox.Show("Appointment added.");							
	txtArray_Click(sender, e);
	if (intArray[i][j] == -1) intArray[i][j] = -2;
}

In my defense I don't believe we had parametrised sql queries back then
 
Last edited:

guest2013-1

guest
Joined
Aug 22, 2003
Messages
19,800
Most of my code has been "adopted" by others so if I state that "this is my code" I'm sure I'll have some of those programmers jump on saying how they wrote the **** :rolleyes:

Anyway... my earlier stuff was scary to say the least...
 
Top