- 1
- 2
bool isManualExecute = (Request.QueryString["Manual"] != null && Request.QueryString["Manual"].ToLower() == "true")
|| (Request.QueryString["manual"] != null && Request.QueryString["manual"].ToLower() == "true");
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+121
bool isManualExecute = (Request.QueryString["Manual"] != null && Request.QueryString["Manual"].ToLower() == "true")
|| (Request.QueryString["manual"] != null && Request.QueryString["manual"].ToLower() == "true");
Передаю Вовчику привет!
+129
if (obj == null)
return 0;
if (obj == DBNull.Value)
return 0;
return int.Parse (obj.ToString ());
в столбце хранится Integer...
+144
Response.Write ("<script>window.open (\"~/DownloadFile.aspx?FileID=" + e.id + "\")</script>");
+125
class SystemErrorCodes
{
public const Int32 ERROR_ACCESS_DENIED = 5;
public const Int32 ERROR_ADAP_HDW_ERR = 57;
public const Int32 ERROR_ALREADY_ASSIGNED = 85;
// ещё две сотни подобных строк
public string ToString(Int32 ERR)
{
switch (ERR)
{
case 0: return "The operation completed successfully.";
case 1: return "Incorrect function.";
case 10: return "The environment is incorrect.";
// и снова две сотни таких строк
default: return "unknown.";
}
}
}
http://msdn.microsoft.com/en-us/library/ms681382(VS.85).aspx
внизу страницы, заготовка класса для использования в C# системных кодов ошибок, получаемых в нативном коде вызовом GetLastError(), и их описаний :)
И не лень было мартышке писать это?
Всё гораздо проще: получение кода ошибки - Marshal.GetLastWin32Error()
получение описания этого кода - new Win32Exception().Message
+118
SqlCommand command = new SqlCommand ();
command.Connection = connection;
command.CommandText = "select data from filestorage where id=@id;";
command.Parameters.AddWithValue ("@id", fileId);
command.CommandType = CommandType.Text;
byte [] data = (byte []) command.ExecuteScalar ();
System.IO.Stream outStream = Response.OutputStream;
Response.ContentType = "Application/octet-stream";
Response.AppendHeader ("Connection", "keep-alive");
Response.AppendHeader ("Content-Disposition", " attachment; filename = \"" + fName+"\"" );
outStream.Write (data, 0, data.Length);
Response.End ();
продолжение http://govnokod.ru/4227
+125
command = new System.Data.SqlClient.SqlCommand();
command.Connection = connection;
command.CommandText = "select data from filestorage where id=@id;";
command.Parameters.AddWithValue("@id", fileId);
command.CommandType = CommandType.Text;
byte[] data = (byte[])command.ExecuteScalar();
command.CommandText = "select filename from filestorage where id=@id;";
string fName = (string)command.ExecuteScalar();
command.CommandText = "select sizebytes from filestorage where id=@id;";
long lngFileSize = (int)command.ExecuteScalar();
command.CommandText = "select foldername from filestorage where id=@id;";
string store= command.ExecuteScalar().ToString();
+144
public class ВсеБудетХорошо : Exception
{
public ВсеБудетХорошо()
{
throw new ВсеБудетХорошо();
}
}
throw new ВсеБудетХорошо();
+129
private const int _multiple_cols = 0x0000060D; //0001000001101 - (Multiple view)
private const int _single_cols = 0x000007F1; //0001111110001 - (Single view)
private void SetGridColumnVisibility()
{
int bits = _view_type == NotificationContactViewType.Multiple ? _multiple_cols : _single_cols;
DataControlFieldCollection cols = gvContacts.Columns;
DataControlField col;
for (int i = 0; i < cols.Count; i++)
{
col = cols[i];
int bit = (int)Math.Pow(2, i);
col.Visible = ((bits & bit) == bit);
}
}
Интересный способ установки видимости колонкам в гриде :)
+121
if(Model.User != null && Model.User.t_ApplicationPropertyValue != null && Model.User.t_ApplicationPropertyValue.Count > 0)
{
foreach (var applicationPropertyValue in Model.User.t_ApplicationPropertyValue)
{
if (applicationPropertyValue.t_ApplicationProperty != null && applicationPropertyValue.t_ApplicationProperty.t_DisplayType != null
&& propertyValues.ContainsKey(applicationPropertyValue.t_ApplicationProperty.PropertyName + "_" +
applicationPropertyValue.t_ApplicationProperty.t_DisplayType.DisplayTypeName) == false
&& String.IsNullOrEmpty(applicationPropertyValue.PropertyValue) == false)
propertyValues.Add(applicationPropertyValue.t_ApplicationProperty.PropertyName + "_" +
applicationPropertyValue.t_ApplicationProperty.t_DisplayType.DisplayTypeName, applicationPropertyValue.PropertyValue);
else if (applicationPropertyValue.t_ApplicationProperty != null && applicationPropertyValue.t_ApplicationProperty.t_DisplayType != null
&& propertyValues.ContainsKey(applicationPropertyValue.t_ApplicationProperty.PropertyName + "_" +
applicationPropertyValue.t_ApplicationProperty.t_DisplayType.DisplayTypeName) == false
&& String.IsNullOrEmpty(applicationPropertyValue.PropertyValue) == true && string.IsNullOrEmpty(applicationPropertyValue.t_ApplicationProperty.DefaultValue) == false)
propertyValues.Add(applicationPropertyValue.t_ApplicationProperty.PropertyName + "_" +
applicationPropertyValue.t_ApplicationProperty.t_DisplayType.DisplayTypeName, applicationPropertyValue.t_ApplicationProperty.DefaultValue);
}
}
Логика внутри View
+145
public double FindMax(double num1, double num2, double num3)
{
double max = num1;
if (num2 > max)
{
max = num2;
}
if (num3 > max)
{
max = num3;
}
return max;
}