|
Wow! That's something really new here!
A very nice way to obfuscate code.
|
|
|
|
|
I'm always in search for obfuscate code.
|
|
|
|
|
I read it once and was like 'Huh, what's the problem?'. And then I saw it. That's the sign of a true horror.
I don't think this even gives a warning in C# because the if is fully formed and bracing for scope is fine.
|
|
|
|
|
BobJanova wrote: That's the sign of a true horrorprankster. FTFY
Oxfords English < Official CCC Players Dictionary
Excuse me for my improper grammar and typos.
It's because English is my primary language, not my first language.
My first languages are C# and Java.
VB, ASP, JS, PHP and SQL are my second language.
Indonesian came as my third language.
My fourth language? I'm still creating it, I'll let you know when it's done!
|
|
|
|
|
This is one of the reasons why I always brace single line if statements - it is too easy to miss what is happening especially if someone or something (code prettifiers etc) mangle the code like you have found.
|
|
|
|
|
That is a work of art!
|
|
|
|
|
Names changed to protect the innocent....
private void FillGrid()
{
}
private void Case_SelectionChanged(object sender, EventArgs e)
{
FillGrid();
}
private void FillCase(string PatientID)
{
case.ItemIndex = 0;
}
protected void Search()
{
FillCase(PatientID);
case.EditValue = caseNo.Trim();
Case_SelectionChanged(new object(), new EventArgs());
FillGrid();
}
So, in 4 lines of code in Search(), we call a lengthy FillGrid function 4 times....Really?
modified 25-Oct-11 12:06pm.
|
|
|
|
|
That example is not complete, is it? All of the functions you show are private/protected, none is public, and only one gets called by a user interaction. The real fun must be somewhere else. Didn't you see a function like:
private void Button1_Click(object sender, EventArgs e)
{
FillCase("");
Search();
Case_SelectionChanged(new object(), new EventArgs());
FillGrid();
FillCase("some value");
Search();
Case_SelectionChanged(new object(), new EventArgs());
FillGrid();
... and some more lines of code
}
|
|
|
|
|
He just wanted to be on the safe side and assured that the grid is filled, no matter what happens
And from the clouds a mighty voice spoke: "Smile and be happy, for it could come worse!"
And I smiled and was happy And it came worse.
|
|
|
|
|
From what I can see the grid won't actually be filled if the FillGrid throws an Exception. Unless there is a deleted try catch block there that recursively calls the FillGrid Method again in its catch block...
It's an OO world.
public class Naerling : Lazy<Person>{}
|
|
|
|
|
Did you got the guy fired, cause of such guys the software can't cope up even with hardware advancements. Even with a quad core machines and GBs of RAM we still have the same performance issues we used to have in the days of Pentium I and a few MB of RAM.
|
|
|
|
|
AsOfDateBlankLabels();
if (this.g_eFormMode != PortfolioDetailFormMode.Portfolio_Edit)
{
c_boolSetDefaultValues = false;
}
c_boolSetDefaultValues = true;
I need say no more.
And before you ask, AsOfDateBlankLabels doesn't use it. At all.
|
|
|
|
|
Where's the problem ? It compiles... :p
/me running
|
|
|
|
|
Did I read it wrong but it looks the the "c_" variable will always be true
|
|
|
|
|
Exactly ; there's no point here to set it to false in the if statement as it is assigned to true just right after.
|
|
|
|
|
Sorry... it is in there for Justin Case
(yes|no|maybe)*
|
|
|
|
|
That's what you get when you pay coders by the line.
Heck, sometimes they'll even throw in documentation!
|
|
|
|
|
Bert Mitton wrote: documentation
What?
|
|
|
|
|
public FileContentResult ExportToExcel(object datasource)
{
var grid = new GridView();
grid.DataSource = datasource;
grid.DataBind();
var sw = new StringWriter();
var htw = new HtmlTextWriter(sw);
grid.RenderControl(htw);
byte[] excelFileBytesContent = this.Response.ContentEncoding.GetBytes(sw.ToString());
var excelFileContentResult = new FileContentResult(excelFileBytesContent, "application/vnd.ms-excel");
return excelFileContentResult;
}
It kinda works, but WTF???
|
|
|
|
|
Excel can load Html tables no problem. There are some CSS issues that arise from it. But it really does work quite well.
And while it doesn't appear that in this case you're going to have any styles being applied, if you did apply formatting to the GridView, they would be reflected in the excel document.
|
|
|
|
|
GibbleCH wrote: Excel can load Html tables no problem.
I agree, but for a business requirement?
|
|
|
|
|
I'm actually using a similar technique in a recent app we have written. However, the HTML passed to excel comes from the browser. This allows us to take the data, render HTML, the user then has the ability to hide/show columns, sort, filter, etc, then export the result to excel.
If I don't pass the HTML to excel (well, a per-processor that cleans it up), then I have to look at it, determine what they are currently showing, query the db all over, then try to create an excel document that mimics the displayed data WITH all the current formatting, which is a duplication of effort since all that work has already been done in rendering the HTML.
It also allows us to just modify the rendering of the HTML, and the export to excel is almost always working automatically without also having to modify the code that generates the excel document.
|
|
|
|
|
It is all good an well till you get to text that looks like numeric data to excel.
Eg: a telephone number with a leading 0. You end up with a number without the leading zero. Or a long number (say ID or SS nr), displays in exponential form.
|
|
|
|
|
Yea.. had the problem with the 0 in the excel part too.
But we used it too, because the calc method had a lot of logic to output HTML, so we reused it for the excel outtput. Worked like a bomb (but the 0 was problematic)
|
|
|
|
|
I generate my cells with classnames, then run the data through a filter, and setup proper mso-number-format styles on the cells prior to sending it to excel. It works well
|
|
|
|