- 1
- 2
- 3
if (f > 1) { }
else
chart5.Series[1].Points.AddXY(i, f);
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+128
if (f > 1) { }
else
chart5.Series[1].Points.AddXY(i, f);
Было замечено за коллегой
+131
xlApp = new Excel.Application();
try
{
xlApp.Workbooks.Add(Type.Missing);
xlApp.Interactive = false;
xlApp.EnableEvents = false;
xlSheet = (Excel.Worksheet)xlApp.Sheets[1];
xlSheet.Name = "Данные";
DataTable dt = GetData();
int collInd = 0;
int rowInd = 0;
string data = "";
for (int i = 0; i < dt.Columns.Count; i++)
{
data = dt.Columns[i].ColumnName.ToString();
xlSheet.Cells[1, i + 1] = data;
xlSheetRange = xlSheet.get_Range("A1:Z1", Type.Missing);
xlSheetRange.WrapText = true;
xlSheetRange.Font.Bold = true;
}
for (rowInd = 0; rowInd < dt.Rows.Count; rowInd++)
{
for (collInd = 0; collInd < dt.Columns.Count; collInd++)
{
data = dt.Rows[rowInd].ItemArray[collInd].ToString();
xlSheet.Cells[rowInd + 2, collInd + 1] = data;
}
}
xlSheetRange = xlSheet.UsedRange;
xlSheetRange.Columns.AutoFit();
xlSheetRange.Rows.AutoFit();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
finally
{
xlApp.Visible = true;
xlApp.Interactive = true;
xlApp.ScreenUpdating = true;
xlApp.UserControl = true;
releaseObject(xlSheetRange);
releaseObject(xlSheet);
releaseObject(xlApp);
}
+136
private Action<Action, Action<Exception>> ToCallbackAction(Action a)
{
return (sc, ec) =>
{
try
{
a();
sc();
}
catch (Exception e)
{
ec(e);
}
};
}
толково или говно? Мнения разделились
+135
void ConvertingExpressions()
{
float.TryParse(transform.position.x.ToString(), out x);
float.TryParse(transform.position.y.ToString(), out y);
float.TryParse(transform.position.z.ToString(), out z);
}
Я просто искал решение проблем и нашел это:
http://itech.do.am/publ/7-1-0-58
+135
this.xlWorkSheet.get_Range("V" + (i + 3).ToString(), Missing.Value).Value2 = Convert.ToDouble(sample_info.Rows[i]["id"].ToString().Replace(Program.separator, Program.new_separator));
Классика. Меняем точку на запятую.
+133
try
{
using (var context = new vbEntities())
{
var DBF = new DBF();
var dt = DBF.GetAll(@"C:\Users\.........\Documents\BNKSEEK.DBF");
int i = 0;
progressBar1.Maximum = dt.Rows.Count;
foreach (DataRow dr in dt.Rows)
{
var row = new Bank();
row.BIK = dr["RKC"].ToString();
row.CityName = dr["NNP"].ToString();
row.Address = dr["ADR"].ToString();
row.Name = dr["NAMEP"].ToString();
row.KS = dr["KSNP"].ToString();
row.Phone = dr["TELEF"].ToString();
row.OKPO = dr["OKPO"].ToString();
context.Bank.Add(row);
progressBar1.Value = i++;
}
context.SaveChanges();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
+129
class WorkDBF
{
private OdbcConnection _connection = null;
public DataTable Execute(string command)
{
DataTable dt = null;
if (_connection != null)
{
try
{
_connection.Open();
dt = new DataTable();
System.Data.Odbc.OdbcCommand oCmd = _connection.CreateCommand();
oCmd.CommandText = command;
dt.Load(oCmd.ExecuteReader());
_connection.Close();
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
}
return dt;
}
public DataTable GetAll(string dbpath)
{
return Execute("SELECT * FROM " + dbpath);
}
public WorkDBF()
{
this._connection = new System.Data.Odbc.OdbcConnection();
_connection.ConnectionString = @"Driver={Microsoft dBase Driver (*.dbf)};" +
"SourceType=DBF;Exclusive=No;" +
"Collate=Machine;NULL=NO;DELETED=NO;" +
"BACKGROUNDFETCH=NO;";
}
}
+129
[System.Runtime.Serialization.DataMember(Name = "o")]
public OnlineOperator[] AvailableOperators
{
get
{
List<OnlineOperator> o = new List<OnlineOperator>();
if (this.AllOperators != null)
{
Boolean flag = false;
List<OnlineOperator> o2 = new List<OnlineOperator>();
foreach (OnlineOperator oo in this.AllOperators)
{
if (oo.Status != OperatorStatus.Offline)
{
if (oo.Priority == 0)
{
if (oo.Status == OperatorStatus.Online)
{
flag = true;
}
o.Add(oo);
}
if (!flag)
{
o2.Add(oo);
}
}
}
if (!flag)
{
o = o2;
}
}
//if (o.Count < 1)
{
o.Add(new OnlineOperator()
{
Id = 0,
UserDisplayName = String.Format(Resources.pattern_offline, this.OfflineNote),
Status = OperatorStatus.None
});
}
return o.ToArray();
}
set
{
;
}
}
Логика конечно странновато реализована, но реализация ReadOnly свойства меня просто убила
+139
foreach (sp_GetPropertiesAffiliateResult paf in PropertiesAffiliate)
{
...
phConfigAffiliate.Controls.Add(new LiteralControl("<tr>"));
phConfigAffiliate.Controls.Add(new LiteralControl("<td><strong>"));
phConfigAffiliate.Controls.Add(litPropertyId);
phConfigAffiliate.Controls.Add(new LiteralControl("</strong></td>"));
phConfigAffiliate.Controls.Add(new LiteralControl("<td><strong>"));
phConfigAffiliate.Controls.Add(litPropertyName);
phConfigAffiliate.Controls.Add(new LiteralControl("</strong></td>"));
phConfigAffiliate.Controls.Add(new LiteralControl("<td>"));
phConfigAffiliate.Controls.Add(txtPropertyCode);
phConfigAffiliate.Controls.Add(rfvTxtPropertyCode);
phConfigAffiliate.Controls.Add(new LiteralControl("</td>"));
phConfigAffiliate.Controls.Add(new LiteralControl("<td>"));
phConfigAffiliate.Controls.Add(new LiteralControl(@"<table cellpadding=""2"" cellspacing=""2"" border=""0"">"));
phConfigAffiliate.Controls.Add(new LiteralControl("<tr>"));
phConfigAffiliate.Controls.Add(new LiteralControl(@"<td style=""border: 0px;"">"));
....
}
+139
public string ValidationTitle
{
get { return this.Title; }
set { }
}