Example #1
0
void Game::Draw()
{
	//spr->Draw(0, 220);

	DrawRect(0, 220, 800, 210, 214, 237, 227);

	//text->Draw(850, 10, "Profit: $" + ThousandString(std::to_string(profit)) + ".00" );
	//text->Draw(850, 40, "Total waiting time caused: " + SecondsToTime(timeWasted) + " (+" + std::to_string(noOfWaitingCars) + ") per second");

	textTime->Draw(850, 100, ToTime((int)gTime));
	
	if (!gPause)
	{
		// Always have an array ready of cars waiting.
		carsWaiting.clear();
		for (unsigned i = 0; i < cars.size(); i++)
		{
			if (cars.at(i)->GetChargeMe())
			{
				carsWaiting.push_back(cars.at(i));
			}
		}

		ChargeCars();
		CalcWaitingTime();

		btnPause->Draw();
	}
	else
	{
		btnPlay->Draw();
	}

	for (unsigned i = 0; i < cars.size(); i++)
	{
		cars.at(i)->Draw();
	}
	
	DrawSchedule();
	UpdateButtons();

	text->Draw(825, 470, "Late Seconds: " + ToTime((int)dueLateness));
	text->Draw(825, 490, "Late Cars:    " + std::to_string(dueLatenessAmm));

	text->Draw(825, 570, "Late Seconds: " + ToTime((int)hodgeLateness));
	text->Draw(825, 590, "Late Cars:    " + std::to_string(hodgeLatenessAmm));

	
	
}
Example #2
0
void CheckDateTime()
{
	Time tm = GetSysTime();
	Date dt = tm;
	
	Value c;
	Value v = tm;
	RDUMP(v);
	ASSERT(v == dt);
	Date xx = v;
	ASSERT(xx == dt);
	c = v;
	RDUMP(c);
	ASSERT(c == dt);
	Value cv = v;
	RDUMP(cv);
	ASSERT(cv == dt);
	
	Value v2 = tm;
	RDUMP(v2);
	ASSERT(v2 == v);
	c = v;
	RDUMP(c);
	ASSERT(c == dt);
	ASSERT(c == tm);
	
	v = dt;
	v2 = ToTime(v);
	
	ASSERT(v == v2);
	ASSERT(GetHashValue(v) == GetHashValue(v2));
}
Example #3
0
void Game::DrawSchedule()
{
	double multi = 600.0f / ((double)finishTime);
	double offset = 0;

	double barOffset = GetTimeDouble() - (double)startTime;

	// Draw text to show it.
	textTime->Draw(10, 470, "By Due:");
	for (unsigned i = 0; i < carsByDue.size(); i++)
	{
		// RYAN! We need to draw a rectangle
		// from:	140 + (offset)*multi
		// to:		140 + (offset + carsByDue.at(i)->GetMaxChargeTime())*multi
		
		//MILTON!
		//My DrawRect function needs to be passed a Surface to draw on, but there's none in this class, not sure what to do

		SDL_Color color = carsByDue.at(i)->GetColor();
		DrawRect(200 + (offset)*multi + 2, 470, carsByDue.at(i)->GetMaxChargeTime()*multi - 2, 40, color.r, color.g, color.b);

		//carsByDue.at(i)->GetIcon()->Draw(180 + (offset + carsByDue.at(i)->GetMaxChargeTime())*multi - 49, 450);
		offset += carsByDue.at(i)->GetMaxChargeTime();

		if (startTime + offset > carsByDue.at(i)->GetDueTime())
		{
			text->Draw(200 + (offset - carsByDue.at(i)->GetMaxChargeTime())*multi + 10, 483
				, ToTime((int)(startTime + offset - carsByDue.at(i)->GetDueTime())), 255, 0, 0);

			//DrawRect(200 + (offset + (double)startTime - carsFinalDraw.at(i)->GetDueTime() + carsFinalDraw.at(i)->GetMaxChargeTime())*multi + 2, 570, 5, 3 * 4, 240, 0, 0);
		}
	}

	offset = 0;

	// Draw text to show it.
	textTime->Draw(10, 570, "Hodgson's:");
	for (unsigned i = 0; i < carsFinalDraw.size(); i++)
	{
		
		SDL_Color color = carsFinalDraw.at(i)->GetColor();
		DrawRect(200 + (offset)*multi + 2, 570, carsFinalDraw.at(i)->GetMaxChargeTime()*multi - 2, 40, color.r, color.g, color.b);


		//carsFinalDraw.at(i)->GetIcon()->Draw(180 + (offset + carsFinalDraw.at(i)->GetMaxChargeTime())*multi - 49, 550 + i*2);

		offset += carsFinalDraw.at(i)->GetMaxChargeTime();

		if (startTime + offset > carsFinalDraw.at(i)->GetDueTime())
		{
			text->Draw(200 + (offset - carsFinalDraw.at(i)->GetMaxChargeTime())*multi + 10, 583, ToTime((int)(startTime + offset - carsFinalDraw.at(i)->GetDueTime())), 255, 0, 0);

			//DrawRect(200 + (offset + (double)startTime - carsFinalDraw.at(i)->GetDueTime() + carsFinalDraw.at(i)->GetMaxChargeTime())*multi + 2, 570, 5, 3 * 4, 240, 0, 0);
		}
	}

	DrawRect(180 + barOffset*multi, 446, 3, 200, 0, 0, 0);

	//sprBar->Draw(180 + barOffset*multi, 446);
}
Example #4
0
void GuiDataHubI::STK_Alarms(const std::string& strVal, const ::Ice::Current&)
{
	STR_VEC vecStr=GetVecStrings(strVal);
	for(STR_VEC::iterator it=vecStr.begin();
		it!=vecStr.end();++it)
	{
		string strE= *it;
		STR_VEC Params=SplitString(*it,",");
		if(Params.size()==3)
		{
			int nID=atoi(Params[0].c_str());
			SYSTEMTIME timeStart=ToTime(Params[1]);
			SYSTEMTIME timeEnd=ToTime(Params[2]);
			m_pAMHSDrive->STKAlarms(nID, timeStart, timeEnd);
		}
	}
}
Example #5
0
Value ConvertTime::Format(const Value& q) const
{
	if(IsVoid(q) || q.IsNull())
		return String();
	else
	if(q.GetType() == TIME_V || timealways)
		return ToTime((Date)q) != (Time)q || timealways ? UPP::Format(Time(q), seconds) : UPP::Format(Date(q));
	else
		return Convert::Format(q);
}
Example #6
0
void Sqlite3Connection::GetColumn(int i, Ref f) const {
	ASSERT(NULL != current_stmt);
	if(i == -1) {
		f = Value(sqlite3_last_insert_rowid(db));
		return;
	}

	ASSERT(got_row_data);
	String coltype;
	const char *s = sqlite3_column_decltype(current_stmt,i);
	if(s) coltype = ToLower(s);
	switch (sqlite3_column_type(current_stmt,i)) {
		case SQLITE_INTEGER:
			f = sqlite3_column_int64(current_stmt,i);
			break;
		case SQLITE_FLOAT:
			f = sqlite3_column_double(current_stmt,i);
			break;
		case SQLITE_TEXT:
			if(coltype == "date" || f.GetType() == DATE_V){
				const char *s = (const char *)sqlite3_column_text(current_stmt, i);
				if(strlen(s) >= 10)
					f = Value(Date(atoi(s), atoi(s + 5), atoi(s + 8)));
				else
					f = Null;
			}
			else
			if(coltype == "datetime" || f.GetType() == TIME_V) {
				const char *s = (const char *)sqlite3_column_text(current_stmt, i);
				if(strlen(s) >= 19)
					f = Value(Time(atoi(s), atoi(s + 5), atoi(s + 8), atoi(s + 11), atoi(s + 14), atoi(s + 17)));
				else
				if(strlen(s) >= 10)
					f = Value(ToTime(Date(atoi(s), atoi(s + 5), atoi(s + 8))));
				else
					f = Null;
			}
			else
				f = Value(WString((const wchar*)sqlite3_column_text16(current_stmt,i)));
			break;
		case SQLITE_NULL:
			f = Null;
			break;
		case SQLITE_BLOB:
			f = Value(String( (const byte*)sqlite3_column_blob(current_stmt,i),
			                  sqlite3_column_bytes(current_stmt,i)                ));
			break;
		default:
			NEVER();
			break;
	}
	return;
}
Example #7
0
Time Value::GetOtherTime() const
{
	if(IsNull()) return Null;
	return ToTime(GetSmall<Date>());	
}
Example #8
0
String AsJSON(Date dt)
{
	return AsJSON(ToTime(dt));
}
Example #9
0
void Car::Draw()
{
	Update();

	if (yDraw < (float)(y - 1) || yDraw >(float)(y + 1))
	{
		yDraw += ((float)y - yDraw) / 10.0f;
	}

	int yInt = (int)yDraw;

	if (mode == 'n' && y <= -200)
	{
		DrawRect(x, y, 122, 135, color.r, color.g, color.b);

		if (btnBubble->ClickedOnThisFrame() && gPause)
		{
			mode = 'w';
			chargeCurrent = 0.0;
			timeDue = gTime + addTime;
			active = false;
		}

		btnBubble->Draw();
	}
	else
	{
		active = true;

		//sprite->Draw(x, yInt);
		DrawRect(x, yInt, 122, 192, color.r, color.g, color.b);


		text->Draw(x + 5, yInt + 10, "Chrg:     " + std::to_string(((int)chargeCurrent)) + "%");
		text->Draw(x + 5, yInt + 25, "ChrgRate: " + std::to_string((int)(chargeRate*gFramesToSeconds)) + "ps");

		text->Draw(x + 5, yInt + 50, "TimeWait: " + SecondsToTime(waitTime));

		if (timeDue + GetChargeTime() >= gTime) text->Draw(x + 5, yInt + 80, "TimeToCh: " + ToTime(GetChargeTime()), 0, 150, 0);
		else									text->Draw(x + 5, yInt + 80, "TimeToCh: " + ToTime(GetChargeTime()), 150, 0, 0);

		if (timeDue >= gTime)	text->Draw(x + 5, yInt + 95, "TimeDue:  " + SecondsToTime(timeDue), 0, 225, 0);
		else					text->Draw(x + 5, yInt + 95, "TimeDue:  " + SecondsToTime(timeDue), 225, 0, 0);


		//text->Draw(x + 20, yInt + 30, "Max: " + std::to_string((int)(chargeMax)) + "kWh");
		//text->Draw(x + 20, yInt + 110, "Use: " + std::to_string((int)(chargeUse*100.0f)) + "pf");

		std::string bar = "";
		for (unsigned i = 0; i < (int)chargeCurrent; i += 10)
		{
			bar += "|";
		}

		text->Draw(x + 24, yInt + 140, bar, 0, 200, 0);

		if (gPause)
		{
			btnReturn->y = yInt + 160;
			btnReturn->Draw();
		}

		if (btnReturn->ClickedOnThisFrame() && gPause)
		{
			Reset();
		}

		if (gPause)
		{
			btnL1->y = yInt + 75;
			btnR1->y = yInt + 75;
			btnL2->y = yInt + 92;
			btnR2->y = yInt + 92;

			if (btnL1->Clicked())
			{
				if (GetChargeTime() > 0.01)
				{
					chargeRate += 0.0005;
				}
			}
			if (btnR1->Clicked())
			{
				if (chargeRate > 0.005)
				{
					chargeRate -= 0.0005;

					if (timeDue < gTime + GetMaxChargeTime() + 1)
					{
						addTime = GetMaxChargeTime() + 1;
						timeDue = gTime + addTime;
					}
				}
			}

			if (btnR2->Clicked())
			{
				addTime += 0.1;
				timeDue = gTime + addTime;
			}
			if (btnL2->Clicked())
			{
				if (timeDue > gTime + GetMaxChargeTime() + 1)
				{
					addTime -= 0.1;
					timeDue = gTime + addTime;
				}
			}

			btnL1->Draw();
			btnR1->Draw();
			btnL2->Draw();
			btnR2->Draw();
		}
	}
}
Example #10
0
Value Scan(dword qtype, const String& text, const Value& def, bool *hastime) {
	Date date;
	const char *s;
	if(hastime)
		*hastime = false;
	switch(qtype) {
	case INT64_V:
	case INT_V:
	case BOOL_V:
		return StrIntValue(text);
	case DATE_V:
		if(text.IsEmpty()) return (Date) Null;
		s = StrToDate(date, text, (Date)def);
		if(s)
			for(;;) {
				if(IsDigit(*s))
					break;
				if(*s == '\0')
					return date;
				s++;
			}
		return ErrorValue(t_("Invalid date !"));
	case TIME_V: {
		if(text.IsEmpty()) return (Time) Null;
		s = StrToDate(date, text, (Date)def);
		if(s)
			try {
				CParser p(s);
				Time tm = ToTime(date);
				Time d = (Time)def;
				tm.hour = d.hour;
				tm.minute = d.minute;
				tm.second = d.second;
				if(p.IsEof())
					return tm;
				if(hastime)
					*hastime = true;
				int q = p.ReadInt();
				if(q < 0 || q > 23)
					throw CParser::Error("");
				tm.hour = q;
				if(p.IsEof())
					return tm;
				p.PassChar(':');
				q = p.ReadInt();
				if(q < 0 || q > 59)
					throw CParser::Error("");
				tm.minute = q;
				if(p.IsEof())
					return tm;
				p.PassChar(':');
				q = p.ReadInt();
				if(q < 0 || q > 59)
					throw CParser::Error("");
				tm.second = q;
				if(p.IsEof())
					return tm;
			}
			catch(CParser::Error) {}
		return ErrorValue(t_("Invalid time !"));
	}
	case STRING_V:
	case WSTRING_V:
		return text;
	case DOUBLE_V:
		return StrDblValue(text);
	default:
		ASSERT(0);
		break;
	}
	return Null;
}
Example #11
0
void Ide::SetupFormat() {
	FormatDlg dlg;
	dlg.Title("Format setup");
	WithSetupFontLayout<ParentCtrl> fnt;
	WithSetupHlLayout<ParentCtrl> hlt;
	WithSetupEditorLayout<ParentCtrl> edt;
	WithSetupIdeLayout<ParentCtrl> ide;
	WithSetupAssistLayout<ParentCtrl> assist;
	WithSetupMobilePlatformsLayout<ParentCtrl> mobile;
	AStyleSetupDialog ast(this);
#ifdef PLATFORM_WIN32
	ide.console_txt.Hide();
	ide.console.Hide();
	ide.kde.Hide();
	ide.gnome.Hide();
	ide.xterm.Hide();
	ide.mate.Hide();
	
#endif
	ide.kde <<= callback2(SetConsole, &ide.console, "/usr/bin/konsole -e");
	ide.gnome <<= callback2(SetConsole, &ide.console, "/usr/bin/gnome-terminal -x");
	ide.mate <<= callback2(SetConsole, &ide.console, "/usr/bin/mate-terminal -x");
	ide.xterm <<= callback2(SetConsole, &ide.console, "/usr/bin/xterm -e");
	
	edt.lineends
		.Add(LF, "LF")
		.Add(CRLF, "CRLF")
		.Add(DETECT_LF, "Detect with default LF")
		.Add(DETECT_CRLF, "Detect with default CRLF");
	
	edt.filetabs
		.Add(AlignedFrame::LEFT, "Left")
		.Add(AlignedFrame::TOP, "Top")
		.Add(AlignedFrame::RIGHT, "Right")
		.Add(AlignedFrame::BOTTOM, "Bottom")
		.Add(-1, "Off");
		
	edt.tabs_crosses
		.Add(AlignedFrame::LEFT, "Left")
		.Add(AlignedFrame::RIGHT, "Right")
		.Add(-1, "Off");
	
	dlg.Add(fnt, "Fonts");
	dlg.Add(hlt, "Syntax highlighting");
	dlg.Add(edt, "Editor");
	dlg.Add(assist, "Assist");
	dlg.Add(ide, "IDE");
	dlg.Add(ast, "Code formatting");
	dlg.Add(mobile, "Mobile platforms");
	dlg.WhenClose = dlg.Acceptor(IDEXIT);
	FontSelectManager ed, vf, con, f1, f2, tf;
	ed.Set(fnt.face, fnt.height, fnt.bold, fnt.italic, fnt.naa);
	vf.Set(fnt.vface, fnt.vheight, fnt.vbold, fnt.vitalic, fnt.vnaa);
	con.Set(fnt.cface, fnt.cheight, fnt.cbold, fnt.citalic, fnt.cnaa);
	tf.Set(fnt.tface, fnt.theight, fnt.tbold, fnt.titalic, fnt.tnaa);
	f1.Set(fnt.face1, fnt.height1, fnt.bold1, fnt.italic1, fnt.naa1);
	f2.Set(fnt.face2, fnt.height2, fnt.bold2, fnt.italic2, fnt.naa2);
	ed.Set(editorfont);
	vf.Set(veditorfont);
	con.Set(consolefont);
	tf.Set(tfont);
	f1.Set(font1);
	f2.Set(font2);
	DlCharset(edt.charset);
	edt.tabsize.MinMax(1, 100).NotNull();
	edt.tabsize <<= editortabsize;
	edt.indent_amount.MinMax(1, 100).NotNull();
	edt.indent_amount <<= indent_spaces ? indent_amount : editortabsize;
	edt.indent_amount.Enable(indent_spaces);
	CtrlRetriever rtvr;
	int hs = hilite_scope;
	rtvr
		(hlt.hilite_scope, hs)
		(hlt.hilite_bracket, hilite_bracket)
		(hlt.hilite_ifdef, hilite_ifdef)
		(hlt.hilite_if_endif, hilite_if_endif)
		(hlt.thousands_separator, thousands_separator)
		(hlt.hline, hline)

		(edt.indent_spaces, indent_spaces)
		(edt.no_parenthesis_indent, no_parenthesis_indent)
		(edt.showtabs, show_tabs)
		(edt.warnwhitespace, warnwhitespace)
		(edt.lineends, line_endings)
		(edt.numbers, line_numbers)
		(edt.bookmark_pos, bookmark_pos)
		(edt.bordercolumn, bordercolumn)
		(edt.bordercolor, bordercolor)
		(edt.findpicksel, find_pick_sel)
		(edt.findpicktext, find_pick_text)
		(edt.deactivate_save, deactivate_save)
		(edt.filetabs, filetabs)
		(edt.tabs_icons, tabs_icons)
		(edt.tabs_crosses, tabs_crosses)
		(edt.tabs_grouping, tabs_grouping)
		(edt.tabs_stacking, tabs_stacking)
		(edt.tabs_serialize, tabs_serialize)
		(edt.persistent_find_replace, persistent_find_replace)
		(edt.find_replace_restore_pos, find_replace_restore_pos)

		(assist.barline, barline)
		(assist.auto_enclose, auto_enclose)
		(assist.commentdp, editor.commentdp)
		(assist.header_guards, header_guards)
		(assist.insert_include, insert_include)
		(assist.mark_lines, mark_lines)
		(assist.qtfsel, qtfsel)
		(assist.assist, editor.auto_assist)

		(ide.showtime, showtime)
		(ide.show_status_bar, show_status_bar)
		(ide.toolbar_in_row, toolbar_in_row)
		(ide.splash_screen, splash_screen)
		(ide.sort, sort)
		(ide.mute_sounds, mute_sounds)
		(ide.wrap_console_text, wrap_console_text)
		(ide.hydra1_threads, hydra1_threads)
		(ide.gdbSelector, gdbSelector)
		(ide.chstyle, chstyle)
		(ide.console, LinuxHostConsole)
		(ide.output_per_assembly, output_per_assembly)

		(ast.BracketIndent,					astyle_BracketIndent)
		(ast.NamespaceIndent,               astyle_NamespaceIndent)
		(ast.BlockIndent,                   astyle_BlockIndent)
		(ast.CaseIndent,                    astyle_CaseIndent)
		(ast.ClassIndent,                   astyle_ClassIndent)
		(ast.LabelIndent,                   astyle_LabelIndent)
		(ast.SwitchIndent,                  astyle_SwitchIndent)
		(ast.PreprocessorIndent,            astyle_PreprocessorIndent)
		(ast.MinInStatementIndentLength,    astyle_MinInStatementIndentLength)
		(ast.MaxInStatementIndentLength,    astyle_MaxInStatementIndentLength)
		(ast.BreakClosingHeaderBracketsMode,astyle_BreakClosingHeaderBracketsMode)
		(ast.BreakElseIfsMode,              astyle_BreakElseIfsMode)
		(ast.BreakOneLineBlocksMode,        astyle_BreakOneLineBlocksMode)
		(ast.SingleStatementsMode,          astyle_SingleStatementsMode)
		(ast.BreakBlocksMode,               astyle_BreakBlocksMode)
		(ast.BreakClosingHeaderBlocksMode,  astyle_BreakClosingHeaderBlocksMode)
		(ast.BracketFormatMode,             astyle_BracketFormatMode)
		(ast.ParensPaddingMode,             astyle_ParensPaddingMode)
		(ast.ParensUnPaddingMode,           astyle_ParensUnPaddingMode)
		(ast.OperatorPaddingMode,           astyle_OperatorPaddingMode)
		(ast.EmptyLineFill,                 astyle_EmptyLineFill)
		(ast.TabSpaceConversionMode,        astyle_TabSpaceConversionMode)
		(ast.TestBox,						astyle_TestBox)
		
		(mobile.AndroidSDKPath, androidSDKPath)
	;
	hlt.hlstyle.AddColumn("Style");
	hlt.hlstyle.AddColumn("Color").Ctrls(HlPusherFactory);
	hlt.hlstyle.AddColumn("Bold").Ctrls<Option>();
	hlt.hlstyle.AddColumn("Italic").Ctrls<Option>();
	hlt.hlstyle.AddColumn("Underline").Ctrls<Option>();
	hlt.hlstyle.ColumnWidths("211 80 45 45 80");
	hlt.hlstyle.EvenRowColor().NoHorzGrid().SetLineCy(EditField::GetStdHeight() + 2);
	ReadHlStyles(hlt.hlstyle);
	edt.charset <<= (int)default_charset;
	edt.tabsize <<= rtvr <<=
		hlt.hlstyle.WhenCtrlsAction = ed.WhenAction = tf.WhenAction =
		con.WhenAction = f1.WhenAction = f2.WhenAction = dlg.Breaker(222);
	ide.showtimeafter <<= Nvl((Date)FileGetTime(ConfigFile("version")), GetSysDate() - 1);
	hlt.hl_restore <<= dlg.Breaker(333);
	ide.chstyle.Add(0, "Host platform");
	ide.chstyle.Add(1, "Standard");
	ide.chstyle.Add(2, "Classic");
	ide.chstyle.Add(3, "Host platform, blue bars");
	ide.chstyle.Add(4, "Standard, blue bars");

	FrameRight<Button> uscBrowse;
	uscBrowse.SetImage(CtrlImg::right_arrow());
	uscBrowse <<= callback1(AddPath, &ide.uscpath);
	ide.uscpath.AddFrame(uscBrowse);
	ide.uscpath <<= LoadFile(GetHomeDirFile("usc.path"));
	
	FrameRight<Button> androidSDKDownload;
	androidSDKDownload.SetImage(IdeImg::DownloadBlack());
	androidSDKDownload.Tip("Download");
	androidSDKDownload <<= callback1(LaunchWebBrowser, AndroidSDK::GetDownloadUrl());
	mobile.AndroidSDKPath.AddFrame(androidSDKDownload);
	
	FrameRight<Button> androidSDKBrowse;
	androidSDKBrowse.SetImage(CtrlImg::right_arrow());
	androidSDKBrowse.Tip("Select directory");
	androidSDKBrowse <<= callback1(InsertPath, &mobile.AndroidSDKPath);
	mobile.AndroidSDKPath.AddFrame(androidSDKBrowse);
	mobile.AndroidSDKPath <<= androidSDKPath;
	
	for(;;) {
		int c = dlg.Run();
		Upp::SaveFile(GetHomeDirFile("usc.path"), ~ide.uscpath);
		editorfont = ed.Get();
		tfont = tf.Get();
		veditorfont = vf.Get();
		consolefont = con.Get();
		font1 = f1.Get();
		font2 = f2.Get();
		editortabsize = Nvl((int)~edt.tabsize, 4);
		rtvr.Retrieve();
		console.SetSlots(minmax(hydra1_threads, 1, 256));
		hilite_scope = hs;
		if(indent_spaces)
			indent_amount = ~edt.indent_amount;
		else {
			indent_amount = editortabsize;
			edt.indent_amount <<= editortabsize;
		}
		edt.indent_amount.Enable(indent_spaces);
		default_charset = (byte)(int)~edt.charset;
		for(int i = 0; i < CodeEditor::HL_COUNT; i++)
			editor.SetHlStyle(i, hlt.hlstyle.Get(i, 1), hlt.hlstyle.Get(i, 2),
			                     hlt.hlstyle.Get(i, 3), hlt.hlstyle.Get(i, 4));
		UpdateFormat();
		if(c == IDEXIT)
			break;
		if(c == 333 && PromptYesNo("Restore default highlighting colors?")) {
			editor.DefaultHlStyles();
			ReadHlStyles(hlt.hlstyle);
		}
	}
	FileSetTime(ConfigFile("version"), ToTime(~ide.showtimeafter));
	FinishConfig();
	SaveConfig();
}
Example #12
0
void ComplexStatsWin::refresh()
{
	Time f; // from
	Time t; // to
	
	switch ( (En_stats_interval)((int)interval.GetData()) )
	{
		case siDay:
			{
				Date d = day_date.GetData();
				f = ToTime(d);
				t = Time(d.year, d.month, d.day, 23, 59, 59);
				break;
			}
		case siMonth:
			{
				Date from = FirstDayOfMonth(month_date.GetData());
				Date to = LastDayOfMonth(month_date.GetData());
				f = Time(from.year, from.month, from.day, 0, 0, 0);
				t = Time(to.year, to.month, to.day, 23, 59, 59);
				break;
			}
		case siDateRange:
			{
				Date from = date_from.GetData();
				Date to = date_to.GetData();
				f = Time(from.year, from.month, from.day, 0, 0, 0);
				t = Time(to.year, to.month, to.day, 23, 59, 59);
			}
	};
	
	//record count
	SQL & Select(SqlCountRows()).From(RECORD).Where(REC_DATE >= f && REC_DATE <= t);
	if (SQL.Fetch())
		record_count.SetText(~AsString(SQL[0]));
	
	//income
	SQL & Select(SqlSum(ITEM_PRICE))
		.From(RECORD_ITEM)
		.InnerJoin(RECORD).On(RECORD_ID.Of(RECORD_ITEM) == ID.Of(RECORD))
		.Where(REC_DATE.Of(RECORD) >= f && REC_DATE.Of(RECORD) <= t)
	;
	if (SQL.Fetch())
	{
		String s = ConvertMoney().Format(SQL[0]);
		income.SetText(~s);
	}
	
	//income from invoices only
	SQL & Select(SqlSum(ITEM_PRICE))
		.From(RECORD_ITEM)
		.InnerJoin(RECORD).On(RECORD_ID.Of(RECORD_ITEM) == ID.Of(RECORD))
		.Where(REC_DATE.Of(RECORD) >= f && REC_DATE.Of(RECORD) <= t && NotNull(INVOICE_ID.Of(RECORD)))
	;
	if (SQL.Fetch())
	{
		String s = ConvertMoney().Format(SQL[0]);
		income_inv.SetText(~s);
	}
	
	//income without invoices
	SQL & Select(SqlSum(ITEM_PRICE))
		.From(RECORD_ITEM)
		.InnerJoin(RECORD).On(RECORD_ID.Of(RECORD_ITEM) == ID.Of(RECORD))
		.Where(REC_DATE.Of(RECORD) >= f && REC_DATE.Of(RECORD) <= t && IsNull(INVOICE_ID.Of(RECORD)))
	;
	if (SQL.Fetch())
	{
		String s = ConvertMoney().Format(SQL[0]);
		income_noinv.SetText(~s);
	}
	
	//products
	products.Clear();
	SQL & Select(NAME.Of(LOV_PRODUCT), Count(LOV_PRODUCT))
		.From(RECORD_ITEM)
		.InnerJoin(LOV_PRODUCT).On(PROD_ID.Of(RECORD_ITEM) == ID.Of(LOV_PRODUCT))
		.InnerJoin(RECORD).On(RECORD_ID.Of(RECORD_ITEM) == ID.Of(RECORD))
		.Where(REC_DATE.Of(RECORD) >= f && REC_DATE.Of(RECORD) <= t)
		.GroupBy(NAME.Of(LOV_PRODUCT))
		.OrderBy(Descending(Count(LOV_PRODUCT)))
	;
	while(SQL.Fetch())
		products.Add(SQL);
	
	//clients
	unsigned c = 0;
	clients.Clear();
	SQL & Select(NAME.Of(LOV_TITLE), FIRST_NAME.Of(CLIENT), LAST_NAME.Of(CLIENT))
		.From(RECORD)
		.InnerJoin(PATIENT).On(PATIENT_ID.Of(RECORD) == ID.Of(PATIENT))
		.InnerJoin(CLIENT).On(CLIENT_ID.Of(PATIENT) == ID.Of(CLIENT))
		.LeftJoin(LOV_TITLE).On(TITLE_ID.Of(CLIENT) == ID.Of(LOV_TITLE))
		.Where(REC_DATE.Of(RECORD) >= f && REC_DATE.Of(RECORD) <= t)
		.OrderBy(REC_DATE.Of(RECORD))
	;
	while(SQL.Fetch() && ++c)
		clients.Add(SQL);
	client_count.SetText(AsString(c));
}