void CBaseProjectSet::OnOK() { UpdateData(); CString strT1,strT2,strSql,strT3,strT4,strT5,strT6; combo1.GetWindowText(strT1); edit1.GetWindowText(strT2); edit2.GetWindowText(strT3); editPY.GetWindowText(strT4); editCode.GetWindowText(strT5); editStandardCash.GetWindowText(strT6); if( strT1.IsEmpty() || strT2.IsEmpty() || strT3.IsEmpty() || strT4.IsEmpty() || strT5.IsEmpty() ){ AfxMessageBox("请将所有内容填写正确再进行操作!!!"); return; } if( flag == 1 ){ //新增 strSql.Format(" INSERT INTO 费用项目表(费用编码,费用大类,费用名称,标准金额,name_py,name_BM,standard_cash ) \ VALUES( (select NVL(max(费用编码),0)+1 FROM 费用项目表),'%s','%s',\ %.2f ,'%s','%s' ,%.2f ) ",strT1,strT2,atof(strT3),strT4,strT5,atof(strT6) ); if(!COtherDecharge::WriteSQL(strSql)){ AfxMessageBox("添加失败"); return; } }
void display_admin(DbSortedRows *sorted_rows) { char *action = query_val(QUERY_PARAM_ACTION); HTML_LOG(1,"action = %s",action); if (!allow_admin()) { printf("admin disabled"); } else if (EMPTY_STR(action) || STRCMP(action,"ask")==0 || STRCMP(action,"Cancel")==0) { int show_donate = 1; if (strstr(NVL(getenv("QUERY_STRING")),"donate") ) { // we've come from the donate page. show_donate = 0; } if (show_donate) { if (exists(donated_file())) { struct STAT64 stat; if (util_stat(donated_file(),&stat) == 0) { HTML_LOG(0,"now=%u time = %u",time(NULL),stat.st_mtime); if (time(NULL) < stat.st_mtime ) { show_donate = 0; } } } } if (show_donate) { display_main_template("admin","donate",sorted_rows); } else { display_main_template("admin","admin",sorted_rows); } } else if (util_starts_with(action,"settings")) { display_main_template("admin","settings",sorted_rows); #define CONFIRM_PREFIX "confirm_" } else if (util_starts_with(action,CONFIRM_PREFIX)) { display_main_template("admin",action+strlen(CONFIRM_PREFIX),sorted_rows); #define TEMPLATE_PREFIX "template_" } else if (util_starts_with(action,TEMPLATE_PREFIX)) { display_main_template("admin",action+strlen(TEMPLATE_PREFIX),sorted_rows); } else { display_main_template("admin","completed",sorted_rows); } }
/* This is to save project-related global settings, NOT project file settings. */ void project_save_prefs(GKeyFile *config) { GeanyProject *project = app->project; if (cl_options.load_session) { const gchar *utf8_filename = (project == NULL) ? "" : project->file_name; g_key_file_set_string(config, "project", "session_file", utf8_filename); } g_key_file_set_string(config, "project", "project_file_path", NVL(local_prefs.project_file_path, "")); }
char *get_mount_command(NETFSProtocol proto,char *link,char *path,char *user,char *passwd) { char *cmd = NULL; char *log; char *host = strstr(link,"://"); ovs_asprintf(&log,"%s/logs/mnterr.log",appDir()); if (host) { host +=3; if (proto == PROTO_NFS_TCP || proto == PROTO_NFS ) { char *host_end = strpbrk(host,":/"); char *remote_path_start = strchr(host,'/'); char *opt=""; if (proto == PROTO_NFS_TCP) { opt=",proto=tcp"; } // iplink = nfs://host:/share // mount -t -o soft,nolock,timeo=10 host:/share /path/to/network ovs_asprintf(&cmd, "mkdir -p \"%s\" 2> \"%s\" && mount -o soft,nolock,timeo=10%s \"%.*s:%s\" \"%s\" 2>> \"%s\"", path,log,opt,host_end-host,host,remote_path_start,path,log); } else if (proto == PROTO_SMB) { // link = smb://host/share // mount -t cifs -o username=,password= //host/share /path/to/network if (EMPTY_STR(user)) { user = "******"; } ovs_asprintf(&cmd,"mkdir -p \"%s\" 2> \"%s\" && mount -t cifs -o \"nomand,noatime,nodiratime,username=%s,password=%s\" \"//%s\" \"%s\" 2> \"%s\"", path,log, user, NVL(passwd), host,path,log); } else { html_log(0,"Dont know how to mount [%s]",link); } } else { html_log(0,"Dont know how to mount host [%s]",link); } FREE(log); return cmd; }
void CLocalSetAdd::OnOK() { const int NOFIND=-1; UpdateData(); if ( ! (m_name.Find("'") == NOFIND && m_name.Find(";") == NOFIND && \ m_remark.Find("'") == NOFIND && m_remark.Find(";") == NOFIND && ! m_name.IsEmpty()) ) AfxMessageBox("输入的文字中不能含用单引号及分号等特殊字符"); strSql.Format("Insert into lsq_reside_local ( llocal,lname,lremark) values( \ (select Ltrim(to_char(NVL(max(llocal),0)+1,'009')) from lsq_reside_local),\ '%s','%s' ) ",m_name,m_remark); if( COtherDecharge::WriteSQL(strSql) )AfxMessageBox("新增成功"); else AfxMessageBox("新增失败..."); CDialog::OnOK(); }
void PETRI::places::loadInPlcs() { /* Data Model Changed string sql= " \ SELECT A.PLACE_ID,DECODE(E.ARC_TYPE,'P',1,0) PLACE_TYPE,C.PLACE_CUR_STATE,C.TOKEN_CNT \ FROM P_TRANSITION_PLACE_RELA A,P_PLACE_ATTR C,P_ARC_ATTR D,P_ARC_CHART_ATTR E \ WHERE A.TRANSITION_ID = :TRANSID \ AND A.PLACE_ID=C.PLACE_ID \ AND A.PLACE_TYPE='INT' \ AND D.ARC_START_TYPE='P' \ AND D.ARC_END_TYPE='T' \ AND D.ARC_START_ID=A.PLACE_ID \ AND D.ARC_ID=E.ARC_ID \ AND D.ARC_END_ID=A.TRANSITION_ID ORDER BY PLACE_TYPE \ "; */ try { string sql = " \ SELECT DISTINCT A.PLACE_ID,DECODE(E.ARC_TYPE,'P',1,0) PLACE_TYPE,NVL(C.PLACE_CUR_STATE,'0'),C.TOKEN_CNT ,C.DRAW_ID,C.PLACE_NAME \ FROM P_TRANSITION_PLACE_RELA A,P_PLACE_ATTR C,P_ARC_CHART_ATTR E \ WHERE A.TRANSITION_ID = :TRANSID \ AND A.PLACE_ID=C.PLACE_ID \ AND A.PLACE_TYPE='INT' \ AND A.ARC_ID=E.ARC_ID \ ORDER BY PLACE_TYPE \ "; DEFINE_PETRI_QUERY(query); query.close(); query.setSQL(sql.c_str()); query.setParameter("TRANSID",l_transID); query.open(); while(query.next()) { /* inPlcs.v_plcID.push_back(query.field(0).asInteger()); inPlcs.v_plcType.push_back(query.field(1).asInteger()); inPlcs.v_plcState.push_back(query.field(2).asString()); inPlcs.v_plcToknum.push_back(query.field(3).asInteger()); */ a_plcID[i_size] = query.field(0).asInteger(); a_plcType[i_size] = query.field(1).asInteger(); a_plcState[i_size] = query.field(2).asString(); a_plcToknum[i_size] = query.field(3).asInteger(); a_plcDrawID[i_size] = query.field(4).asLong(); strncpy(a_plcName[i_size],query.field(5).asString(),NAME_LENGTH); i_size++; } query.close(); }catch (TOCIException & toe){ LOG(toe.getErrMsg()); LOG(toe.getErrSrc()); } catch(...) { return; } return; };
/* Need this custom compare function to generate a symbol tree in a simgle pass from tag list */ int tm_symbol_tag_compare(const TMTag **t1, const TMTag **t2) { gint s1, s2; if (!t1 && !t2) return 0; if (t1 && t2 && !*t1 && !*t2) return 0; else if (!t1 || !*t1) return -1; else if (!t2 || !*t2) return 1; if ((tm_tag_file_t == (*t1)->type) && (tm_tag_file_t == (*t2)->type)) return 0; else if (tm_tag_file_t == (*t1)->type) return -1; else if (tm_tag_file_t == (*t2)->type) return 1; /* Compare on depth of scope - less depth gets higher priortity */ s1 = tm_tag_scope_depth(*t1); s2 = tm_tag_scope_depth(*t2); if (s1 != s2) return (s1 - s2); /* Compare of tag type using a symbol ordering routine */ s1 = SYM_ORDER(*t1); s2 = SYM_ORDER(*t2); if (s1 != s2) return (s1 - s2); /* Compare names alphabetically */ s1 = strcmp((*t1)->name, (*t2)->name); if (s1 != 0) return (s1); /* Compare scope alphabetically */ s1 = strcmp(NVL((*t1)->atts.entry.scope, ""), NVL((*t2)->atts.entry.scope, "")); if (s1 != 0) return s1; /* If none of them are function/prototype, they are effectively equal */ if ((tm_tag_function_t != (*t1)->type) && (tm_tag_prototype_t != (*t1)->type)&& (tm_tag_function_t != (*t2)->type) && (tm_tag_prototype_t != (*t2)->type)) return 0; /* Whichever is not a function/prototype goes first */ if ((tm_tag_function_t != (*t1)->type) && (tm_tag_prototype_t != (*t1)->type)) return -1; if ((tm_tag_function_t != (*t2)->type) && (tm_tag_prototype_t != (*t2)->type)) return 1; /* Compare the argument list */ s1 = tm_arglist_compare(*t1, *t2); if (s1 != 0) return s1; /* Functions go before prototypes */ if ((tm_tag_function_t == (*t1)->type) && (tm_tag_function_t != (*t2)->type)) return -1; if ((tm_tag_function_t != (*t1)->type) && (tm_tag_function_t == (*t2)->type)) return 1; /* Give up */ return 0; }
/* * Compares function argument lists. * FIXME: Compare based on types, not an exact string match. */ int tm_arglist_compare(const TMTag* t1, const TMTag* t2) { return strcmp(NVL(t1->atts.entry.arglist, ""), NVL(t2->atts.entry.arglist, "")); }
TMSymbol *tm_symbol_tree_new(GPtrArray *tags_array) { TMSymbol *root = NULL; GPtrArray *tags; #ifdef TM_DEBUG g_message("Building symbol tree.."); #endif if ((!tags_array) || (tags_array->len <= 0)) return NULL; #ifdef TM_DEBUG fprintf(stderr, "Dumping all tags..\n"); tm_tags_array_print(tags_array, stderr); #endif tags = tm_tags_extract(tags_array, tm_tag_max_t); #ifdef TM_DEBUG fprintf(stderr, "Dumping unordered tags..\n"); tm_tags_array_print(tags, stderr); #endif if (tags && (tags->len > 0)) { guint i; int j; int max_parents = -1; TMTag *tag; TMSymbol *sym = NULL, *sym1; char *parent_name; char *scope_end; gboolean matched; int str_match; SYM_NEW(root); tm_tags_custom_sort(tags, (TMTagCompareFunc) tm_symbol_tag_compare , FALSE); #ifdef TM_DEBUG fprintf(stderr, "Dumping ordered tags.."); tm_tags_array_print(tags, stderr); fprintf(stderr, "Rebuilding symbol table..\n"); #endif for (i=0; i < tags->len; ++i) { tag = TM_TAG(tags->pdata[i]); if (tm_tag_prototype_t == tag->type) { if (sym && (tm_tag_function_t == sym->tag->type) && (!sym->info.equiv) && (0 == strcmp(NVL(tag->atts.entry.scope, "") , NVL(sym->tag->atts.entry.scope, "")))) { sym->info.equiv = tag; continue; } } if (max_parents < 0) { if (SYM_ORDER(tag) > 2) { max_parents = i; if (max_parents > 0) qsort(root->info.children->pdata, max_parents , sizeof(gpointer), tm_symbol_compare); } } SYM_NEW(sym); sym->tag = tag; if ((max_parents <= 0) || (!tag->atts.entry.scope)) { sym->parent = root; if (!root->info.children) root->info.children = g_ptr_array_new(); g_ptr_array_add(root->info.children, sym); } else { parent_name = tag->atts.entry.scope; scope_end = strstr(tag->atts.entry.scope, "::"); if (scope_end) *scope_end = '\0'; matched = FALSE; if (('\0' != parent_name[0]) && (0 != strcmp(parent_name, "<anonymous>"))) { for (j=0; j < max_parents; ++j) { sym1 = TM_SYMBOL(root->info.children->pdata[j]); str_match = strcmp(sym1->tag->name, parent_name); if (str_match == 0) { matched = TRUE; sym->parent = sym1; if (!sym1->info.children) sym1->info.children = g_ptr_array_new(); g_ptr_array_add(sym1->info.children, sym); break; } else if (str_match > 0) break; } } if (!matched) { sym->parent = root; if (!root->info.children) root->info.children = g_ptr_array_new(); g_ptr_array_add(root->info.children, sym); } if (scope_end) *scope_end = ':'; } } #ifdef TM_DEBUG fprintf(stderr, "Done.Dumping symbol tree.."); tm_symbol_print(root, 0); #endif } if (tags) g_ptr_array_free(tags, TRUE); return root; }