예제 #1
0
//группы рабочих
void __fastcall TWorkersSettings::N1Click(TObject *Sender)
{
//добавить
    TWorkerGroup *wnd = new TWorkerGroup(this);
    if (wnd->ShowModal() == mrOk)
    {
        std::string group_name = AnsiString(wnd->group_name->Text).c_str();
        long r_kol = wnd->r_kol->Text.ToIntDef(0);

        TADOQuery *rez = DB->SendSQL(std::string("select count(*) as cnt from `manufacture`.`worker_groups` where name = '"+ group_name +"'").c_str());
        if (rez)
        {
            int cnt = (int)rez->FieldByName("cnt")->Value;
            if (!cnt)
            {
                std::stringstream sql;
                sql << "insert into `manufacture`.`worker_groups` (name,p_kol) values ('"<<group_name<<"','"<<r_kol<<"')";
                DB->SendCommand(sql.str().c_str());
            }
            delete rez;
        }
        LoadGroups();
    }
    delete wnd;
}
예제 #2
0
void __fastcall TfrmLerCartaPlotar::btnCarregarBDClick(TObject *Sender)
{
TADOQuery* q = frmLerCartaPlotar->ADOQuery1;
		q->Active = false;
    try
		{
				q->SQL->Text = "select pontos from carta_dinamometrica where(cod_poco=161)";
				q->ExecSQL();
		//		edtBD->Text = q->;
		}
		catch (Exception* e) {
				ShowMessage("Erro na consulta.");
    }
		q->SQL->Clear();
}
예제 #3
0
void __fastcall TFrmDemand::ButtonrefreshClick(TObject *Sender)
{
	ADOQuery_insert->SQL->Text = (AnsiString)"select * from Demand where project_id=1 order by id_dem";
	ADOQuery_insert->Open();

	 TADOQuery * ado = new TADOQuery(NULL);
	 ado->Connection = ADOConnection1;

		ado->SQL->Text = (AnsiString)"select * from Demand where project_id=1 order by id_dem";
		ado->Open();


	//TTreeNode* node = TreeView_doc_Struct->Items->AddObject(NULL, this->node_Name->Text, (void*)reqinfo);
	//node->Selected = true;

	for(ADOQuery_insert->First();!ADOQuery_insert->Eof;ADOQuery_insert->Next())
	{

		if(ADOQuery_insert->FieldByName("id_par")->Value.IsNull())//==0
		{
		Demand *reqinfo = new Demand;
		//записываем данные из бд в структуры
		reqinfo->name_dem = ADOQuery_insert->FieldByName("name_dem")->AsAnsiString.c_str();
		reqinfo->text_dem = ADOQuery_insert->FieldByName("text_dem")->AsAnsiString.c_str();
		reqinfo->type_dem = ADOQuery_insert->FieldByName("type_dem")->AsAnsiString.c_str();
		reqinfo->num_dem = ADOQuery_insert->FieldByName("num_dem")->AsAnsiString.c_str();
		reqinfo->code_dem = ADOQuery_insert->FieldByName("code_dem")->AsAnsiString.c_str();
		reqinfo->id_dem = ADOQuery_insert->FieldByName("id_dem")->Value;
		top_level.push_back(reqinfo);



		Recursive(reqinfo, ado);
		}
		/*reqinfo->name_dem = string(AnsiString(this->node_Name->Text).c_str());
		reqinfo->num_par = string(AnsiString("0").c_str());

		this->TreeView_doc_Struct->Items->Add(ADOQuery_insert->FieldValues["project_name"]);
		*/
	}
	for(int i = 0;i<top_level.size();i++)
	{
		TTreeNode* node = TreeView_doc_Struct->Items->AddObject(NULL, top_level[i]->name_dem.c_str(), (void*)(top_level[i]));
		RecursiveFChilds(top_level[i], node);
	}

}
예제 #4
0
void TWorkersSettings::LoadGroups(void)
{
    SGClear(sgGroups,1);
    ++sgGroups->RowCount;
    sgGroups->Cells[0][1] = "Все";
    sgGroups->Cells[1][1] = "...";
    sgGroups->Cells[2][1] = "...";
    TADOQuery *rez = DB->SendSQL("select "
                                 "convert(`a`.`group_id`, char) group_id, "
                                 "`a`.`name` name, "
                                 "convert(`a`.`p_kol`, char) p_kol, "
                                 "convert(count(`b`.`tab_no`), char) kol "
                                 "from `manufacture`.`worker_groups` `a` "
                                 "left join `manufacture`.`workers` `b` on `a`.`group_id` = `b`.`group_id` and `b`.`date_to` is null "
                                 "group by `a`.`group_id`");
    if (rez)
    {
        for (rez->First(); !rez->Eof; rez->Next())
        {
			size_t row = sgGroups->RowCount-1;
            sgGroups->Cells[0][row] = rez->FieldByName("name")->Value;
            sgGroups->Cells[1][row] = rez->FieldByName("kol")->Value;
            sgGroups->Cells[2][row] = rez->FieldByName("p_kol")->Value;
			sgGroups->Cells[3][row] = rez->FieldByName("group_id")->Value;//id
            ++sgGroups->RowCount;
        }
		if (sgGroups->RowCount > 2)
            --sgGroups->RowCount;
        delete rez;
    }

    AutoWidthSG(sgGroups);
}
예제 #5
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 "";
}
예제 #6
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;
}
예제 #7
0
void TWorkersSettings::LoadWorkers(std::string group_id)
{
    SGClear(sgWorkers,1);
    std::stringstream sql;
    sql << "select "
           "convert(`a`.`tab_no`, char) tab_no,"
           "convert(`a`.`family`, char) family,"
           "convert(`a`.`name`, char) name,"
           "convert(`a`.`otch`, char) otch,"
           "convert(`a`.`razr`, char) razr,"
           "convert(`a`.`proff`, char) proff "
           "from `manufacture`.`workers` `a` "
		   "where `a`.`date_to` is null ";
	if (!group_id.empty())
		sql << "and group_id = '"<<group_id<<"' ";
	sql << "order by tab_no";


    TADOQuery *rez = DB->SendSQL(sql.str().c_str());
    if (rez)
    {
        for (rez->First(); !rez->Eof; rez->Next())
        {
            size_t row = sgWorkers->RowCount-1;
            sgWorkers->Cells[0][row] = rez->FieldByName("tab_no")->Value;
            sgWorkers->Cells[1][row] = rez->FieldByName("family")->Value;
            sgWorkers->Cells[2][row] = rez->FieldByName("name")->Value;
            sgWorkers->Cells[3][row] = rez->FieldByName("otch")->Value;
            sgWorkers->Cells[4][row] = rez->FieldByName("proff")->Value;
            sgWorkers->Cells[5][row] = rez->FieldByName("razr")->Value;
            ++sgWorkers->RowCount;
        }
        if (sgWorkers->RowCount > 2)
            --sgWorkers->RowCount;
        delete rez;
    }

    AutoWidthSG(sgWorkers);
}
// ---------------------------------------------------------------------------
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();
	}

}