Exemplo n.º 1
0
String TUrovenList::Init()
{
	TADOQuery *q = new TADOQuery(DM);
	TUroven *s;

	try {
		q->Connection = DM->AsConnection1;
		q->SQL->Clear();
		q->SQL->Add("SELECT * FROM Uroven");
		q->Open();

		while (!q->Eof)	{
			s = new TUroven;
			s->UrovenID = q->FieldByName("UrovenID")->AsInteger;
			s->UrovenYear = q->FieldByName("UrovenYear")->AsString;
			s->UrovenName = q->FieldByName("UrovenName")->AsString;
			s->PackageType = q->FieldByName("PackageType")->AsInteger;
			Add(s);
			q->Next();
		}
		q->Close();
	} catch (...) {
		return "error in UrovenList init!";
	}
	return "";
}
Exemplo n.º 2
0
int CmAuthentication(SOCKET ClientSocket, TMemoryStream *ms)
{
	char user[20];
	char password[20];
	char *tmp = new char[ms->Size];
	int r;
	TADOQuery *q;
	String test[2];

	CoInitialize(NULL);
	q = DM->UsersQuery;

	ms->Seek(0, soFromBeginning);
	ms->Read(tmp, ms->Size);

	sscanf(tmp, "user=%s password=%s", &user, &password);

	q->Parameters->ParseSQL(q->SQL->Text, true);

	q->Close();
	try {
		test[0] = WideString(user);
		q->Parameters->ParamByName("user")->Value = WideString(user);
		test[1] = WideString(password);
		q->Parameters->ParamByName("password")->Value = WideString(password);
		q->Open();
		if (q->RecordCount)
			r = 1;
		else
			r = 0;
	} catch (...) {
		r = 0;
	}
		
	delete []tmp;
//	delete q;

	return r;
}
// ---------------------------------------------------------------------------
void __fastcall TFrPrintProductCatalog::LoadPicList(TStrings *NameUser,
	TStrings *Status, TStrings *Activities_KC, TStrings *ComboBox9)
{ // Загрузка нового листа выбора
	TStrings *S;
	AnsiString Sl;
	TField *F, *Fi;
	TADOQuery *Qi;
	Qi = Qw;

	if (Status != NULL) {
		S = Status;
		Qi->Close();
		Qi->SQL->Clear();
		Qi->SQL->Add
			("select -1,' ВСЕ' union select 0,' Не распределен' union select idn,iText from spl_LbText256 where iLvl=1156 and datedel is null Order by 2 "
			);
		Qi->Open();
		Fi = Qi->Fields->Fields[0];
		F = Qi->Fields->Fields[1];
		S->Clear();
		while (Qi->Eof == false) {
			S->AddObject(F->AsString, (TObject*)Fi->AsInteger);
			Qi->Next();
		}
		Qi->Close();
	}
	if (Activities_KC != NULL) {
		S = Activities_KC;
		Qi->Close();
		Qi->SQL->Clear();
		Qi->SQL->Add
			("select -1,' ВСЕ' union select Idn,iText from spl_LbText256 where iLvl=1199 and DateDel is null"
			);
		Qi->Open();
		Fi = Qi->Fields->Fields[0];
		F = Qi->Fields->Fields[1];
		S->Clear();
		while (Qi->Eof == false) {
			S->AddObject(F->AsString, (TObject*)Fi->AsInteger);
			Qi->Next();
		}
		Qi->Close();
	}
	if (ComboBox9 != NULL) {
		S = ComboBox9;
		Qi->Close();
		Qi->SQL->Clear();
		Qi->SQL->Add
			("select -1,' ВСЕ' union select 0,' Нет менеджера' union SELECT idManager,u.auFamIO FROM cch_CallManager LEFT JOIN aa_Users u on u.auId=idManager WHERE TypeM=0 ORDER BY 2 "
			);
		Qi->Open();
		Fi = Qi->Fields->Fields[0];
		F = Qi->Fields->Fields[1];
		S->Clear();
		while (Qi->Eof == false) {
			S->AddObject(F->AsString, (TObject*)Fi->AsInteger);
			Qi->Next();
		}
		Qi->Close();
	}

}