- 1
- 2
object res = DataConnection.ExecuteScalar(sql);
int count = (int)(long)res;
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+118
object res = DataConnection.ExecuteScalar(sql);
int count = (int)(long)res;
Чтокуда?
+117
WorksheetRow row = new WorksheetRow();
row.Cells.Add("");
// ispublished
row.Cells.Add(point.IsPublished ? "+" : "");
// id superregion
row.Cells.Add(point.Town.Region.SuperRegion.Id.ToString());
// name superregion
if (cleanupTags)
row.Cells.Add(CleanXMLTags(point.Town.Region.SuperRegion.Name));
else row.Cells.Add(point.Town.Region.SuperRegion.Name);
// id rregion
row.Cells.Add(point.Town.Region.Id.ToString());
// name region
if (cleanupTags)
row.Cells.Add(CleanXMLTags(point.Town.Region.DefaultText.Name));
else row.Cells.Add(point.Town.Region.DefaultText.Name);
...
StringBuilder subwayIDs = new StringBuilder("");
StringBuilder subwayNames = new StringBuilder("");
foreach (Subway subway in point.Subways)
{
subwayIDs.Append(subway.Id).Append(", ");
subwayNames.Append(subway.DisplayName).Append(", ");
}
string sIDs = subwayIDs.ToString();
if (sIDs.Length > 0) sIDs = sIDs.Substring(0, sIDs.Length - 2);
string sNames = subwayNames.ToString();
if (sNames.Length > 0) sNames = sNames.Substring(0, sNames.Length - 2);
Это 10% от метода. Там все в том же духе.
+116
public struct RowForReportBookRecordIssue
{
public string Column1 { get; set; }
public string Column2 { get; set; }
public string Column3 { get; set; }
public string Column4 { get; set; }
public string Column5 { get; set; }
public string Column6 { get; set; }
public string Column7 { get; set; }
public string Column8 { get; set; }
public string Column9 { get; set; }
public string Column10 { get; set; }
}
Использование соответствующее:
RowForReportBookRecordIssue.Column1 = ...; RowForReportBookRecordIssue.Column2 = ...;
Даже страшно, если что-то придется править... :(
+116
// Установка обработкчиков событий
tbTitle.TextChanged += (x, y) => _target.Title = tbTitle.Text;
cbContractorType.SelectedIndexChanged += (x, y) => _target.ContractorType = cbContractorType.SelectedIndex;
tbFullTitle.TextChanged += (x, y) => _target.Title = tbFullTitle.Text;
tbINN.TextChanged += (x, y) => _target.INN = tbINN.Text;
// Для физ. лица
dtpBirthDate.ValueChanged += (x, y) => _target.birthDate = dtpBirthDate.Value;
tbPassportSeria.TextChanged += (x, y) => _target.PassportSeria = tbPassportSeria.Text;
tbPassportNumber.TextChanged += (x, y) => _target.PassportNumber = tbPassportNumber.Text;
dtpPassportDateRegistred.ValueChanged += (x, y) => _target.PassportDateRegistred = dtpPassportDateRegistred.Value;
tbPassportOrganizationRegistred.TextChanged += (x, y) => _target.PassportOrganizationRegistred = tbPassportOrganizationRegistred.Text;
tbRegistredPassportAddress.TextChanged += (x, y) => _target.RegistredPassportAddress = tbRegistredPassportAddress.Text;
// Для юр лица
tbOgranizationJuridicalAddress.TextChanged += (x ,y) => _target.OgranizationJuridicalAddress = tbRegistredPassportAddress.Text;
tbOrganizationMainBankAcouuntNumber.TextChanged += (x, y) => _target.OrganizationMainBankAcouuntNumber = tbOrganizationMainBankAcouuntNumber.Text;
tbOrganizationKPP.TextChanged += (x, y) => _target.OrganizationKPP = tbOrganizationKPP.Text;
tbOrganizationOGRNIP.TextChanged += (x, y) => _target.OrganizationOGRNIP = tbOrganizationOGRNIP.Text;
tbOrganizationIFNS.TextChanged += (x, y) => _target.OrganizationIFNS = tbOrganizationIFNS.Text;
tbOrganizationOKATO.TextChanged += (x, y) => _target.OrganizationOKATO = tbOrganizationOKATO.Text;
tbOrganizationOKPO.TextChanged += (x, y) => _target.OrganizationOKPO = tbOrganizationOKPO.Text;
У меня денюха поэтому решил отмаппить форму по новому
+127
if (accNum > 0 && accNum < accModels.Count){
switch (accNum)
{
case 1: accModels[0].WorldMatrix = Matrix.CreateScale(0.7f) * Matrix.CreateRotationX(0.3f) * Matrix.CreateRotationY(chrYaw + MathHelper.Pi) * Matrix.CreateTranslation(plPos + Vector3.Up * 9.0f + Vector3.Transform(Vector3.Backward * 2.0f, Matrix.CreateRotationY(chrYaw + MathHelper.Pi))); break;
case 2: accModels[1].WorldMatrix = Matrix.CreateScale(0.5f) * Matrix.CreateRotationY(chrYaw + MathHelper.PiOver2) * Matrix.CreateTranslation(plPos + Vector3.Up * 11.0f + Vector3.Transform(Vector3.Backward + Vector3.Right * 3.0f, Matrix.CreateRotationY(chrYaw + MathHelper.PiOver2))); break;
case 3: accModels[2].WorldMatrix = Matrix.CreateScale(0.5f) * Matrix.CreateRotationY(chrYaw + MathHelper.PiOver2) * Matrix.CreateTranslation(plPos + Vector3.Up * 11.0f + Vector3.Transform(Vector3.Backward + Vector3.Right * 3.0f, Matrix.CreateRotationY(chrYaw + MathHelper.PiOver2))); break;
case 4: accModels[3].WorldMatrix = Matrix.CreateScale(0.5f) * Matrix.CreateRotationY(chrYaw - MathHelper.PiOver2) * Matrix.CreateTranslation(plPos + Vector3.Up * 5.0f + Vector3.Transform(Vector3.Backward * 0.0f + Vector3.Right * 0.7f, Matrix.CreateRotationY(chrYaw + MathHelper.PiOver2))); break;
case 5: accModels[4].WorldMatrix = Matrix.CreateScale(0.55f) * Matrix.CreateRotationZ(0.3f) * Matrix.CreateRotationY(chrYaw - MathHelper.PiOver2) * Matrix.CreateTranslation(plPos + Vector3.Up * 5.0f + Vector3.Transform(Vector3.Backward * 0.0f + Vector3.Right * 0.7f, Matrix.CreateRotationY(chrYaw + MathHelper.PiOver2))); break;
case 6: accModels[5].WorldMatrix = Matrix.CreateScale(0.5f) * Matrix.CreateRotationY(chrYaw - MathHelper.PiOver2) * Matrix.CreateTranslation(plPos + Vector3.Up * 18.0f + Vector3.Transform(Vector3.Right * -0.4f, Matrix.CreateRotationY(chrYaw - MathHelper.PiOver2))); break;
<...>
case 11: accModels[10].WorldMatrix = Matrix.CreateScale(1.2f) * Matrix.CreateRotationX(-0.3f) * Matrix.CreateRotationY(chrYaw) * Matrix.CreateTranslation(plPos + Vector3.Up * 8.5f + Vector3.Transform(Vector3.Backward * 1.4f, Matrix.CreateRotationY(chrYaw + MathHelper.Pi))); break;
case 12: accModels[11].WorldMatrix = Matrix.CreateScale(1.0f) * Matrix.CreateRotationX(0.3f) * Matrix.CreateRotationY(chrYaw + MathHelper.Pi) * Matrix.CreateTranslation(plPos + Vector3.Up * 9.0f + Vector3.Transform(Vector3.Backward * 2.0f, Matrix.CreateRotationY(chrYaw + MathHelper.Pi))); break;
case 13: accModels[12].WorldMatrix = Matrix.CreateScale(1.0f) * Matrix.CreateRotationY(chrYaw - MathHelper.PiOver2) * Matrix.CreateTranslation(plPos + Vector3.Up * -1.0f + Vector3.Transform(Vector3.Backward * 2.0f, Matrix.CreateRotationY(chrYaw + MathHelper.Pi))); break;
case 14: accModels[13].WorldMatrix = Matrix.CreateScale(1.0f) * Matrix.CreateRotationZ(-0.3f) * Matrix.CreateRotationY(chrYaw + MathHelper.PiOver2) * Matrix.CreateTranslation(plPos + Vector3.Up * 4.0f + Vector3.Transform(Vector3.Backward * 1.3f, Matrix.CreateRotationY(chrYaw + MathHelper.Pi))); break;
case 15: accModels[14].WorldMatrix = Matrix.CreateScale(0.4f) * Matrix.CreateRotationY(chrYaw) * Matrix.CreateTranslation(plPos + Vector3.Up * 22.0f + Vector3.Transform(Vector3.Right * 1.3f + Vector3.Backward * 3.8f, Matrix.CreateRotationY(chrYaw + MathHelper.Pi))); break;
default: accModels[accNum - 1].WorldMatrix = Matrix.CreateScale(0.7f) * Matrix.CreateRotationX(0.3f) * Matrix.CreateRotationY(chrYaw + MathHelper.Pi) * Matrix.CreateTranslation(plPos + Vector3.Up * 9.0f + Vector3.Transform(Vector3.Backward * 1.3f, Matrix.CreateRotationY(chrYaw + MathHelper.Pi))); break;
}
}
Ой как мне не хотелось это в XMLку выносить...
+132
delegate(AccountRegisterRecord record)
{
bool status = true;
status = record.Editable ? true : false;
return status;
}
Делегат проверки активности элемента контекстного меню
+109
try
{
//тут другой гавнокод связаный с регистрацией
}
catch(ApplicationException)
{
this.ModelState.AddModelError("DuplicateUser", Strings.DuplicateUser);
return View(model);
}
Вот так, если приложение падает значит юзверь уже существует....
+119
RegistryKey readKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Webzen\\Mu\\Config\\");
Microsoft.Win32.RegistryKey regKey = Microsoft.Win32.Registry.CurrentUser;
RegistryKey saveKey = Registry.CurrentUser.CreateSubKey("SOFTWARE\\Webzen\\Mu\\Config\\");
private void b_exit_Click(object sender, EventArgs e)
{
if (checkBox1.Checked == true)
saveKey.SetValue("WindowMode", (int)0x00000001, Microsoft.Win32.RegistryValueKind.DWord);
else
saveKey.SetValue("WindowMode", (int)0x00000000, Microsoft.Win32.RegistryValueKind.DWord);
if (checkBox2.Checked == true)
saveKey.SetValue("MusicOnOff", (int)0x00000001, Microsoft.Win32.RegistryValueKind.DWord);
else
saveKey.SetValue("MusicOnOff", (int)0x00000000, Microsoft.Win32.RegistryValueKind.DWord);
if (checkBox3.Checked == true)
saveKey.SetValue("SoundOnOff", (int)0x00000001, Microsoft.Win32.RegistryValueKind.DWord);
else
saveKey.SetValue("SoundOnOff", (int)0x00000000, Microsoft.Win32.RegistryValueKind.DWord);
if (comboBox1.SelectedItem == "800x600")
saveKey.SetValue("Resolution", (int)0x00000001, Microsoft.Win32.RegistryValueKind.DWord);
else if (comboBox1.SelectedItem == "1024x768")
saveKey.SetValue("Resolution", (int)0x00000002, Microsoft.Win32.RegistryValueKind.DWord);
else if (comboBox1.SelectedItem == "1280x1024")
saveKey.SetValue("Resolution", (int)0x00000003, Microsoft.Win32.RegistryValueKind.DWord);
saveKey.Close();
this.Close();
}
private void Options_Load(object sender, EventArgs e)
{
XmlDocument cfg = new XmlDocument();
cfg.Load("cfg.xml");
String lang = cfg.GetElementsByTagName("language")[0].InnerText;
if (lang == "en")
{
checkBox1.Text = "In window";
checkBox3.Text = "Music";
checkBox2.Text = "Sounds";
label1.Text = "Resolution game";
b_exit.Text = "Save";
b_cancel.Text = "Cancel";
}
int loadString = (int)readKey.GetValue("WindowMode");
if (loadString == 1)
checkBox1.Checked = true;
int loadString2 = (int)readKey.GetValue("MusicOnOff");
if (loadString2 == 1)
checkBox2.Checked = true;
int loadString3 = (int)readKey.GetValue("SoundOnOff");
if (loadString3 == 1)
checkBox3.Checked = true;
if (readKey.GetValue("Resolution") == null)
{
regKey.CreateSubKey("SOFTWARE\\Webzen\\Mu\\Config");
regKey.SetValue("Resolution", (int)0x00000001, Microsoft.Win32.RegistryValueKind.DWord);
}
else
{
int loadString4 = (int)readKey.GetValue("Resolution");
if (loadString4 == (int)0x00000001)
comboBox1.Text = "800x600";
else if (loadString4 == (int)0x00000002)
comboBox1.Text = "1024x768";
else if (loadString4 == (int)0x00000003)
comboBox1.Text = "1280x1024";
else
comboBox1.Text = "Выберите разрешение";
}
readKey.Close();
}
Код годичной давности, по сравнению с моими классами сейчас, это небо и земля.
+985
public void ptsb() {
DateTime NW = System.DateTime.Now;
int gh = NW.Day + 1;
int hj = NW.Month;
int NG = NW.Year;
bool vg = System.DateTime.IsLeapYear(NW.Year);
if (hj==2) {
if (vg) {
if (gh > 29) {
gh = 1;
hj = 3; } }
if (gh > 28) {
gh = 1;
hj = 3;
} }
else{
if (hj == 4) {
if (gh > 30)
{
gh = 1;
hj = 5; } }
else {
if (hj == 6) {
if (gh > 30) {
gh = 1;
hj = 7; } }
else
{
if (hj == 9) {
if (gh > 30) {
gh = 1;
hj = 10;
} }
else {
if (hj == 11) {
if (gh > 30) {
gh = 1;
hj = 12; } }
else {
if (gh > 31) {
gh = 1;
hj = hj + 1;
if (hj == 13){
hj = 1;
NG = NG + 1; }}}}}}}
if (NW.Month < 10) {
if (NW.Day < 10) {
d = "0" + NW.Month + "-" + "0" + NW.Day + "-" + NW.Year;
}
else {
d = "0" + NW.Month + "-" + NW.Day + "-" + NW.Year; } }
else {
if (NW.Day < 10) {
d = NW.Month + "-" + "0" + NW.Day + "-" + NW.Year; }
else {
d = NW.Month + "-" + NW.Day + "-" + NW.Year; } }
if (hj < 10) {
if (gh < 10) {
b = "0" + hj + "-" + "0" + gh + "-" + NG; }
else {
b = "0" + hj + "-" + gh + "-" + NG; } }
else {
if (gh < 10) {
b = hj + "-" + "0" + gh + "-" + NG; }
else {
b = hj + "-" +gh + "-" + NG; }}}
.....
+119
try
{
selectedDate = Calendar1.SelectedDate.AddMilliseconds(-1);
selectedDate = Calendar1.SelectedDate;
}
catch (Exception)
{
selectedDate = DateTime.Now.Date;
}
Ну вот как-то так пытался отловить дефолтовое значение календаря.