strcat(cmd, tid);
callback_param_t cp = {MODE_LISTVIEW | MODE_DEBUG, NULL, wnd->hLV};
int rc = exec_sql_cmd (cmd, &cp);
}
void load_combobox(LVWnd_t * wnd, HWND hCombo)
{
char cmd[1024];
int ref_tid = table[wnd->tid][wnd->editCol].ref_tid;
int ref_cid = table[wnd->tid][wnd->editCol].ref_cid;
if (table[wnd->tid][wnd->editCol].type == CT_COMBO)
{
wsprintf(cmd, "SELECT id , \"%s\" FROM table_%02d_data",
table[ref_tid][ref_cid].name, ref_tid + 1);
}
else
if (table[wnd->tid][wnd->editCol].type == CT_COMBO_EX)
{
char part[256] = {0};
int isN, start, end;
GET_PARAM(isN, start, end, ref_cid);
if (isN)
{
strcat(part, "\"№\"||\"");
strcat(part, table[ref_tid][start++].name);
strcat(part, "\"|| \" \" ||");
}
for (int j = start; j <= end; j++)
{
if (j != start && !isN)
strcat(part, "|| \"");
else
strcat(part, "\"");
strcat(part, table[ref_tid][j].name);
strcat(part, "\" || \" \"");
}
wsprintf(cmd, "SELECT ID , %s FROM table_%02d_data",
part, ref_tid + 1);
}
callback_param_t cp = {MODE_COMBOBOX | MODE_DEBUG, NULL, hCombo};
int rc = exec_sql_cmd (cmd, &cp);
}
void update_item(LVWnd_t * wnd, char * data)
{
char cmd[256];
wsprintf(cmd, "UPDATE table_%02d_data SET \"%s\"=\"%s\" WHERE id=%d",
wnd->tid + 1, table[wnd->tid][wnd->editCol].name, data, get_row_id(wnd));
callback_param_t cp = {MODE_DEBUG};
int rc = exec_sql_cmd(cmd, &cp);
}
int delete_row(LVWnd_t * wnd)
{
char cmd[256];
wsprintf (cmd, "DELETE FROM table_%02d_data WHERE id=%d",
wnd->tid + 1, get_row_id(wnd));
int rc = exec_sql_cmd (cmd, NULL);
return rc;
}
int insert_row(LVWnd_t * wnd, char ** data)
{
char cmd[1024];
wsprintf (cmd, "INSERT INTO table_%02d_data(\"%s\"",
wnd->tid + 1, table[wnd->tid][1].name);
for (int i = 2; i < wnd->cols; i++)
{
strcat (cmd, ",\"");
strcat (cmd, table[wnd->tid][i].name);
strcat (cmd, "\"");
}
strcat (cmd,") values (\"");
strcat (cmd,data[1]);
strcat (cmd,"\"");
for (int i = 2; i < wnd->cols; i++)
{
strcat (cmd, ",\"");
strcat (cmd, data[i]);
strcat (cmd, "\"");
}
strcat (cmd, ")");
callback_param_t cp = {MODE_DEBUG};
int rc = exec_sql_cmd (cmd, &cp/*NULL*/);
/* rude hack */
SendMessage(wnd->hLV, LVM_DELETEALLITEMS, 0, 0);
load_table(wnd);
return rc;
}
Файл db\db_global.h :
enum CALLBACK_MODE
{
MODE_NULL,
MODE_LISTVIEW,
MODE_COMBOBOX,
MODE_INT,
MODE_STRING,
MODE_TABLES,
MODE_TABLE_CONF,
MODE_TABLE_DATA,
MODE_DEBUG = 0x80
};
struct callback_param_t
{
int mode;
void * buf;
/*void * res;*/
HWND hWnd;
};
/* forward declaration */
int db_init();
void db_close();
int get_count(const char * table);
void save_str(char *& dest, const char *src);
int exec_sql_cmd (const char * cmd, callback_param_t * param);
int get_hash (TCHAR * text);
void get_user_hash (TCHAR *);
void set_user_hash (TCHAR *, int);
void create_table(const char * caption, int cols, column_t * table);
void insert_column(int tid, column_t * column);
void load_table(LVWnd_t * wnd);
Уважаемый посетитель!
Чтобы распечатать файл, скачайте его (в формате Word).
Ссылка на скачивание - внизу страницы.