关于杜绝多用户同时访问系统即防止文件被重复打开的方法:可以用文件预处理公式和文件验证公式配合Exist函数和ExportTextFile函数来实现,以下是举例公式: 1、文件验证公式: If(usertype = 1,If(Exist(docdir+"X.txt") ,DelFile(docdir+"X.txt"),If(Exist(docdir+"X.txt.bak") ,DelFile(docdir+"X.txt.bak"), True)),If(Exist(docdir+"Y.txt") ,DelFile(docdir+"Y.txt"),If(Exist(docdir+"Y.txt.bak") ,DelFile(docdir+"Y.txt.bak"), True))) 2、文件预处理公式: If(usertype = 1,OpenMenu("admin") And OpenGrid("account") And If(Exist(docdir+"Y.txt") or Exist(docdir+"Y.txt.bak"),MsgBox("系统正在被其他用户使用,请不要进行保存操作!",0,4) And ExportTextFile(docdir+"X.txt" ,"," , Char(13),"account","流水号", "=" ,"000000001"),ExportTextFile(docdir+"X.txt" ,"," , Char(13),"account","流水号", "=" ,"000000001")),OpenMenu("ibmis") And OpenGrid("account") And If(Exist(docdir+"Y.txt") or Exist(docdir+"Y.txt.bak"),MsgBox("系统正在被其他用户使用,您不能打开,请与其他用户联系!",0,4) And ExportTextFile(docdir+"Y.txt" ,"," , Char(13),"account","流水号", "=" ,"000000001") and reset() and Exit(),If(Exist(docdir+"X.txt") or Exist(docdir+"X.txt.bak"),MsgBox("系统正在被管理员使用,请联系系统管理员!",0,4) And ExportTextFile(docdir+"Y.txt" ,"," , Char(13),"account","流水号", "=" ,"000000001") and reset() and Exit(),ExportTextFile(docdir+"Y.txt" ,"," , Char(13),"account","流水号", "=" ,"000000001")))) And CloseRGrid("subsidiary")
|