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); }
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); }