Click here to Skip to main content
15,900,325 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
QuestionRe: Finding a record by its primary key Pin
developer626-Aug-08 2:07
developer626-Aug-08 2:07 
AnswerRe: Finding a record by its primary key Pin
Dan Neely26-Aug-08 2:19
Dan Neely26-Aug-08 2:19 
GeneralRe: Finding a record by its primary key Pin
Paul Conrad22-Aug-08 9:36
professionalPaul Conrad22-Aug-08 9:36 
GeneralRe: Finding a record by its primary key Pin
SilimSayo25-Aug-08 3:52
SilimSayo25-Aug-08 3:52 
GeneralRe: Finding a record by its primary key Pin
Nathan Tuggy25-Aug-08 8:45
Nathan Tuggy25-Aug-08 8:45 
GeneralRe: Finding a record by its primary key Pin
Nathan Tuggy25-Aug-08 8:46
Nathan Tuggy25-Aug-08 8:46 
GeneralRe: Finding a record by its primary key Pin
CDP180228-Aug-08 4:37
CDP180228-Aug-08 4:37 
Generali cant believe its not butter...or that i wrote this Pin
SomeGuyThatIsMe18-Aug-08 3:42
SomeGuyThatIsMe18-Aug-08 3:42 
the point was to do 2 column reversable order sorting, i wrote this thing as an intern.. have fun guys and gals.

int    t1   = 0;
int    t2   = 0;
string temp = "";
string orig = "";

if (lblSortOrder.Text==e.SortExpression)//if they click the same column reverse order
{
    Trace.Write("asdf","in order switcher");
    lblSortOrder.Text +=" DESC";
}
else if (lblSortOrder.Text.IndexOf(e.SortExpression)== -1)//if they click a different column use both sort terms
{
    Trace.Write("asdf","in column adder");
    temp=e.SortExpression;
    temp+=", "+lblSortOrder.Text;
    lblSortOrder.Text=temp;
}
else if (lblSortOrder.Text.IndexOf(',')!=-1)//if the first two fail and is a multi column search
{
    if (lblSortOrder.Text.IndexOf(e.SortExpression)!=-1)//if expression is in the sort string, make it primary and reverse its order
    {
        orig=lblSortOrder.Text;
        t1=orig.IndexOf(e.SortExpression);
        t2=orig.IndexOf(",",t1)-t1;

        if(t2>=0)
        {
            temp=orig.Substring(t1,t2);
        }
        else
        {
            temp=orig.Substring(t1);
        }
        //Trace.Write("orig after substring",orig);
        //Trace.Write("temp",temp);

        if(temp.IndexOf("DESC")!=-1)
        {
            orig=orig.Remove(t1,temp.Length);
            temp=temp.Remove(temp.IndexOf("DESC"),4);
            temp=temp.Trim();
            //Trace.Write("remove desc",temp);
        }
        else
        {
            orig=orig.Remove(t1,temp.Length);
            temp+=" DESC";
            temp=temp.Trim();
            //Trace.Write("add desc",temp);
        }
        orig=orig.Trim();
        lblSortOrder.Text=temp+","+orig;
    }//end if sort expression contained in sort string
    else
    {
        lblSortOrder.Text=e.SortExpression;
        //Trace.Write("???","you should never see this");
    }
}//end multi column else if
else
{
    lblSortOrder.Text=e.SortExpression;
}//end sort ifs

//remove any messed up commas
lblSortOrder.Text=lblSortOrder.Text.Replace(",," , ",");
lblSortOrder.Text=lblSortOrder.Text.Replace(", ," , ",");

//remove all strings after second column
t1=lblSortOrder.Text.IndexOf(",",lblSortOrder.Text.IndexOf(",")+1);
if(t1>10)
{
    lblSortOrder.Text=lblSortOrder.Text.Remove(t1,(lblSortOrder.Text.Length-t1));
}


Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.

Generalwho wrote wrote this C program? PinPopular
Steven A. Lowe17-Aug-08 18:22
Steven A. Lowe17-Aug-08 18:22 
JokeRe: who wrote wrote this C program? PinPopular
darkelv17-Aug-08 19:47
darkelv17-Aug-08 19:47 
GeneralRe: who wrote wrote this C program? Pin
Vimalsoft(Pty) Ltd24-Aug-08 4:01
professionalVimalsoft(Pty) Ltd24-Aug-08 4:01 
GeneralRe: who wrote wrote this C program? PinPopular
QuiJohn19-Aug-08 3:03
QuiJohn19-Aug-08 3:03 
GeneralRe: who wrote wrote this C program? Pin
Mladen Janković19-Aug-08 3:09
Mladen Janković19-Aug-08 3:09 
GeneralRe: who wrote wrote this C program? Pin
Dan Neely19-Aug-08 7:25
Dan Neely19-Aug-08 7:25 
GeneralRe: who wrote wrote this C program? Pin
Yusuf19-Aug-08 8:48
Yusuf19-Aug-08 8:48 
GeneralRe: who wrote wrote this C program? Pin
mattraffel22-Aug-08 8:36
mattraffel22-Aug-08 8:36 
GeneralRe: who wrote wrote this C program? Pin
BillW333-Sep-08 11:21
professionalBillW333-Sep-08 11:21 
GeneralRe: who wrote wrote this C program? Pin
Paul Conrad21-Aug-08 16:50
professionalPaul Conrad21-Aug-08 16:50 
JokeRan across this sql the other day. PinPopular
Austin Harris15-Aug-08 8:44
Austin Harris15-Aug-08 8:44 
GeneralRe: Ran across this sql the other day. Pin
Pete O'Hanlon15-Aug-08 8:54
mvePete O'Hanlon15-Aug-08 8:54 
GeneralRe: Ran across this sql the other day. Pin
PIEBALDconsult15-Aug-08 12:06
mvePIEBALDconsult15-Aug-08 12:06 
GeneralRe: Ran across this sql the other day. Pin
Brent Lamborn15-Aug-08 9:32
Brent Lamborn15-Aug-08 9:32 
GeneralRe: Ran across this sql the other day. Pin
Paul Conrad16-Aug-08 5:52
professionalPaul Conrad16-Aug-08 5:52 
GeneralRe: Ran across this sql the other day. Pin
Yusuf16-Aug-08 17:27
Yusuf16-Aug-08 17:27 
GeneralRe: Ran across this sql the other day. Pin
Mike Dimmick17-Aug-08 10:17
Mike Dimmick17-Aug-08 10:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.