新华书店进销存管理系统部分程序源代码.docx
附录2新华书店进销存管理系统部分程序源代码1、 主程序MAIN.PRG程序代码SET DEFAULT TO C:毕业设计PUBLIC nkfgl,nxsgl,ncggl,nkcgl,nxtglSTORE .f. TO nkfgl,nxsgl,ncggl,nkcgl,nxtglPUBLIC nname,ndepartmentSTORE "" TO nname,ndepartmentDo Form loginfRead EventsDo Form mainRead EventsQuit2、 主表单MAIN.SCX代码2.1 表单Init过程程序代码do mmenu.mpr with this,.T.this.label2.caption = nnamethis.label4.caption = ndepartment3、 系统登入表单LOGINF.SCX代码3.1 表单登入按钮Click事件程序代码SELECT userGO TOP*检查用户名和密码是否输入If empty(thisform.text1.value) then thisform.label3.caption = "请输入用户名" returnelse if empty(thisform.text2.value) then thisform.label3.caption = "请输入密码" return endifendif*操作USER表,查询满足条件记录locate for name = alltrim(thisform.text1.value) if !found() thisform.label3.caption="用户不存在" returnelse if user.password != alltrim(thisform.text2.value) then thisform.label3.caption="密码错误" return endifendifnname = user.namendepartment = user.departmentnkfgl = user.kfglnxsgl = user.xsglncggl = user.cgglnkcgl = user.kcglnxtgl = user.xtglthisform.releaseclear events4、 系统管理表单XTGLF.SCX代码4.1 表单Init过程程序代码thisform.text1.enabled = .f.thisform.text2.enabled = .f.thisform.text3.enabled = .f.thisformxbo1.enabled = .f.thisform.check1.enabled = .f.thisform.check2.enabled = .f.thisform.check3.enabled = .f.thisform.check4.enabled = .f.thisform.check5.enabled = .f.thisform.label5.visible = .f.thisform.text3.visible = .f.thisformxmand10.enabled = .f.thisformxmand11.enabled = .f.thisform.dis_recordthisform.dis_reccommand4.2 表单自定义过程DIS_RECORD程序代码PUBLIC newcommandSTORE .f. TO newcommandif reccount("user") = 0 thisform.text1.value = "" thisform.text2.value = "" thisformxbo1.value = "" thisform.check1.value = 0 thisform.check2.value = 0 thisform.check3.value = 0 thisform.check4.value = 0 thisform.check5.value = 0else thisform.text1.value = user.namethisform.text2.value = user.passwordthisformxbo1.value = user.departmentif user.kfgl then thisform.check1.value = 1else thisform.check1.value = 0endifif user.xsgl then thisform.check2.value = 1else thisform.check2.value = 0endifif user.cggl then thisform.check3.value = 1else thisform.check3.value = 0endifif user.kcgl then thisform.check4.value = 1else thisform.check4.value = 0endifif user.xtgl then thisform.check5.value = 1else thisform.check5.value = 0endifendifthisform.refresh4.3 表单自定义过程DIS_RECCOMMAND程序代码private nstore 0 to nn = reccount("user") if n=1 .or. n=0 then thisformxmand1.enabled = .f. thisformxmand2.enabled = .f. thisformxmand3.enabled = .f. thisformxmand4.enabled = .f.else if recno("user")=1 then thisformxmand1.enabled = .f. thisformxmand2.enabled = .f. thisformxmand3.enabled = .t. thisformxmand4.enabled = .t. else if recno("user")=n then thisformxmand1.enabled = .t. thisformxmand2.enabled = .t. thisformxmand3.enabled = .f. thisformxmand4.enabled = .f. else thisformxmand1.enabled = .t. thisformxmand2.enabled = .t. thisformxmand3.enabled = .t. thisformxmand4.enabled = .t. endif endifendifthisform.refresh4.4 表单保存按钮Click事件程序代码if empty(thisform.text1.value) then =messagebox("请输入用户名",0+48+0,"出错") thisform.text1.setfocus thisform.refresh returnendifif empty(thisform.text2.value) then =messagebox("请输入密码",0+48+0,"出错") thisform.text2.setfocus thisform.refresh returnendifif .not.(alltrim(thisform.text2.value) = alltrim(thisform.text3.value) then =messagebox("密码重复错误,请重新输入",0+48+0,"出错") thisform.text2.value = "" thisform.text3.value = "" thisform.text2.setfocus thisform.refresh returnendifif empty(thisformxbo1.value) then =messagebox("请选择所属部门",0+48+0,"出错") thisformxbo1.setfocus thisform.refresh returnendifif thisform.check1.value=0.and.thisform.check2.value=0.and.thisform.check3.value=0.and.thisform.check4.value=0.and.thisform.check5.value=0 then =messagebox("至少选择一个用户权限",0+48+0,"出错") thisform.check1.setfocus thisform.refresh returnendifif thisform.check1.value=1.and.thisform.check2.value=1.and.thisform.check3.value=1.and.thisform.check4.value=1.and.thisform.check5.value=1 then mesbox=messagebox("此用户将具有全部权限,请确认",4+48+0,"警告") if mesbox=7 then thisform.check1.setfocus thisform.refresh return endifendif*用户权限处理PRIVATE nname,npassword,ndepartment,nkf,nxs,ncg,nkc,nxtnname = alltrim(thisform.text1.value)npassword = alltrim(thisform.text2.value)ndepartment = alltrim(thisformxbo1.value)if thisform.check1.value = 1 then nkf = .t.else nkf = .f.endifif thisform.check2.value = 1 then nxs = .t.else nxs = .f.endifif thisform.check3.value = 1 then ncg = .t.else ncg = .f.endifif thisform.check4.value = 1 then nkc = .t.else nkc = .f.endifif thisform.check5.value = 1 then nxt = .t.else nxt = .f.endif*判断是新记录保存还是修改记录If newcommand then && newcommand = .t. 是新记录保存 locate for user.name=alltrim(thisform.text1.value) if found() then =messagebox("用户已经存在",0+48+0,"出错") thisform.text1.setfocus thisform.refresh return endif *数据表user保存记录 insert into user(name,password,department,kfgl,xsgl,cggl,kcgl,xtgl) values (nname,npassword,ndepartment,nkf,nxs,ncg,nkc,nxt) =messagebox("保存完毕",0+48+0,"提示")else update user set password= npassword,department=ndepartment,kfgl=nkf,xsgl=nxs,cggl=ncg,kcgl=nkc,xtgl=nxt where name= nname =messagebox("修改完成",0+48+0,"提示")endif *表单初始化 thisform.text1.enabled = .f. thisform.text2.enabled = .f. thisform.text3.enabled = .f. thisformxbo1.enabled = .f. thisform.check1.enabled = .f. thisform.check2.enabled = .f. thisform.check3.enabled = .f. thisform.check4.enabled = .f. thisform.check5.enabled = .f. thisformxmand1.enabled = .t. thisformxmand2.enabled = .t. thisformxmand3.enabled = .t. thisformxmand4.enabled = .t. thisformxmand5.enabled = .t. thisformxmand6.enabled = .t. thisformxmand7.enabled = .t. thisformxmand8.enabled = .t. thisformxmand9.enabled = .t. thisformxmand10.enabled =.f. thisformxmand11.enabled =.f. thisformxmand12.enabled = .t. thisform.label5.visible = .f. thisform.text3.visible = .f. thisform.dis_reccommand thisform.dis_record newcommand = .f. thisform.refresh4.5 表单浏览按钮Click事件程序代码DEFINE WINDOW browsewin FROM 1,1 TO 30,80 noFLOAT CLOSE nominimize nogrow nozoom systembrow fields name,department,kfgl,xsgl,cggl,kcgl window browsewin noappend nomodify nodeleterelease window browsewin5、 图书管理表单TSGL.SCX代码5.1 自定义过程AUTO_BOOKID程序代码select bookset order to bookidgo bottomprivate autoid1,autoid2,autoid3,autoid4autoid1 = alltrim(str(val(substr(alltrim(book.bookid),2,6)+1,6,0)autoid2 = len(autoid1)if autoid2 != 6 then for n = autoid2 to 5 autoid1 = "0" + autoid1 endforendifautoid4 = "B" + alltrim(autoid1)thisform.text1.value = autoid45.2 新建按钮Click事件程序代码thisform.text2.enabled = .t.thisform.text3.enabled = .t.thisform.text4.enabled = .t.thisform.text5.enabled = .t.thisform.text6.enabled = .t.thisformxbo1.enabled = .t.thisform.text7.enabled = .t.thisform.text8.enabled = .t.thisformxmand1.enabled = .f.thisformxmand2.enabled = .f.thisformxmand3.enabled = .f.thisformxmand4.enabled = .f.thisformxmand5.enabled = .f.thisformxmand6.enabled = .f.thisformxmand7.enabled = .f.thisformxmand8.enabled = .f.thisformxmand9.enabled = .f.thisformxmand10.enabled =.t.thisformxmand11.enabled =.t.thisformxmand12.enabled = .t.thisform.text2.value = ""thisform.text3.value = ""thisform.text4.value = ""thisform.text5.value = ""thisform.text6.value = ""thisformxbo1.value = ""thisform.text7.value = 0thisform.text8.value = 0thisform.auto_bookidthisform.text2.setfocusthisform.newcommand = .t.thisform.refresh5.3 删除按钮Click事件程序代码if reccount("book")=1 then =messagebox("只有一条记录,不能删除",0+16+0,"出错") returnelse nbookid = alltrim(thisform.text1.value) nbookname = alltrim(thisform.text2.value) mesbox=messagebox("是否删除"+nbookid+"号图书",4+48+0,"警告") if mesbox=7 then return else use book EXCLUSIVE delete from book where bookid=nbookid pack =messagebox(nbookid+"图书已经删除",0+48+0,"提示") endifendifthisform.dis_recordthisform.dis_reccommandthisform.grid1.recordsource = "book"thisform.refresh5.4 保存按钮Click事件程序代码if empty(thisform.text2.value) =messagebox("请输入书名",0+48+0,"出错") thisform.text2.setfocus thisform.refresh returnendifif empty(thisform.text3.value) =messagebox("请输入书号",0+48+0,"出错") thisform.text3.setfocus thisform.refresh returnendifif empty(thisform.text4.value) =messagebox("请输入出版社",0+48+0,"出错") thisform.text4.setfocus thisform.refresh returnendifif empty(thisform.text5.value) =messagebox("请输入作者信息",0+48+0,"出错") thisform.text5.setfocus thisform.refresh returnendifif empty(thisformxbo1.value) =messagebox("请选择图书类型",0+48+0,"出错") thisformxbo1.setfocus thisform.refresh return endifif thisform.text7.value = 0 =messagebox("请输入价格",0+48+0,"出错") thisformxbo1.setfocus thisform.refresh return endif PRIVATE nbookid,nbookname,nbookno,nbookphouse,nbookwriter,nbookcd,nbookclass,nbookprice,nbookdiscountnbookid = alltrim(thisform.text1.value)nbookname = alltrim(thisform.text2.value)nbookno = alltrim(thisform.text3.value)nbookphouse = alltrim(thisform.text4.value)nbookwriter = alltrim(thisform.text5.value)nbookcd = alltrim(thisform.text6.value)nbookclass = alltrim(thisformxbo1.value)nbookprice = thisform.text7.valuenbookdiscount = thisform.text8.value*判断是新记录保存还是修改记录If thisform.newcommand then && newcommand = .t. 是新记录保存 *数据表book保存记录 insert into book (bookid,bookname,bookno,bookphouse,bookwriter,bookcd,bookclass,bookprice,bookdiscount) values (nbookid,nbookname,nbookno,nbookphouse,nbookwriter,nbookcd,nbookclass,nbookprice,nbookdiscount) =messagebox("保存完毕",0+48+0,"提示")else update book set bookname=nbookname,bookno=nbookno,bookphouse=nbookphouse,bookwriter=nbookwriter,bookcd=nbookcd,bookclass=nbookclass,bookprice=nbookprice,bookdiscount=nbookdiscount where bookid=nbookid =messagebox("修改完成",0+48+0,"提示")endif *表单初始化thisform.text2.enabled = .f.thisform.text3.enabled = .f.thisform.text4.enabled = .f.thisform.text5.enabled = .f.thisform.text6.enabled = .f.thisformxbo1.enabled = .f.thisform.text7.enabled = .f.thisform.text8.enabled = .f.thisformxmand5.enabled = .t.thisformxmand6.enabled = .t.thisformxmand7.enabled = .t.thisformxmand8.enabled = .t.thisformxmand9.enabled = .t.thisformxmand10.enabled =.f.thisformxmand11.enabled =.f.thisformxmand12.enabled = .t.thisform.dis_recordthisform.dis_reccommandthisform.newcommand = .f. thisform.refresh5.5 浏览按钮Click事件程序代码DEFINE WINDOW browsewin FROM 1,1 TO 30,160 noFLOAT CLOSE nominimize nogrow nozoom systembrow fields bookid,bookname,bookno,bookphouse,bookwriter,bookcd,bookclass,bookprice,bookdiscount window browsewin noappend nomodify nodeleterelease window browsewin6、 会员输入表单KFGL_HYSR.SCX程序代码6.1 自定义过程AUTO_VIPID程序代码select vipset order to vipidgo bottomprivate autoid1,autoid2,autoid3,autoid4autoid1 = alltrim(str(val(substr(alltrim(vip.vipid),2,6)+1,6,0)autoid2 = len(autoid1)if autoid2 != 6 then for n = autoid2 to 5 autoid1 = "0" + autoid1 endforendifautoid4 = "V" + alltrim(autoid1)thisform.text1.value = autoid46.2 保存按钮Click事件程序代码*输入数据校验if empty(thisform.text2.value) =messagebox("请输入会员姓名",0+16+0,"出错") thisform.text2.setfocus returnendifif thisform.optiongroup1.value = 0 =messagebox("请选择会员性别",0+16+0,"出错") thisform.optiongroup1.option1.setfocus returnelse private nvipsex store "" to nvipsex if thisform.optiongroup1.value = 1 store "男" to nvipsex else stor "女" to nvipsex endifendifif empty(thisform.text4.value) =messagebox("请输入会员联系地址",0+16+0,"出错") thisform.text4.setfocus returnendifif empty(thisform.text5.value) =messagebox("请输入会员x",0+16+0,"出错") thisform.text5.setfocus returnendifif empty(thisform.text6.value) =messagebox("请输入邮政编码",0+16+0,"出错") thisform.text6.setfocus returnendif*保存数据private nvipid,nvipname,nvipadd,nvipphone,nvipcodenvipid = alltrim(thisform.text1.value)nvipname = alltrim(thisform.text2.value)nvipadd = alltrim(thisform.text4.value)nvipphone = alltrim(thisform.text5.value)nvipcode = alltrim(thisform.text6.value)insert into vip (vipid,vipname,vipsex,vipadd,vipphone,vipcode,vipsum,vipdiscount) values (nvipid,nvipname,nvipsex,nvipadd,nvipphone,nvipcode,0,0)=messagebox("保存成功",0+48+0,"提示")nmesbox=messagebox("是否打印会员卡?",4+32+0,"会员卡打印")if nmesbox = 6 select vip.vipid,vip.vipname,vip.vipsex,vip.vipadd,vip.vipphone,vip.vipcode from vip where vip.vipid = nvipid into cursor vipcard select vipcard report form vipcard.frx to print use in vipcardendifthisform.auto_vipidthisformxmand2.click6.3 清除按钮Click事件程序代码thisform.text2.value = ""thisform.optiongroup1.value = 0thisform.text4.value = ""thisform.text5.value = ""thisform.text6.value = ""thisform.text1.setfocusthisform.refresh7、 会员查询表单KFGL_HYCX.SCX程序代码7.1 表单自定义过程DIS_GRID程序代码thisform.grid1.readonly = .t.thisform.grid1.columncount = 8thisform.grid1.column1.header1.caption = "会员编号"thisform.grid1.column1.width = 80thisform.grid1.column1.movable = .f.thisform.grid1.column1.resizable = .f.thisform.grid1.column2.header1.caption = "会员姓名"thisform.grid1.column2.width = 80thisform.grid1.column2.movable = .f.thisform.grid1.column2.resizable = .f.thisform.grid1.column3.header1.caption = "会员性别"thisform.grid1.column3.width = 80thisform.grid1.column3.movable = .f.thisform.grid1.column3.resizable = .f.thisform.grid1.column4.header1.caption = "联系地址"thisform.grid1.column4.width = 250thisform.grid1.column4.movable = .f.thisform.grid1.column4.resizable = .f.thisform.grid1.column5.header1.caption = "x"thisform.grid1.column5.width = 80thisform.grid1.column5.movable = .f.thisform.grid1.column5.resizable = .f.thisform.grid1.column6.header1.caption = "邮政编码"thisform.grid1.column6.width = 80thisform.grid1.column6.movable = .f.thisform.grid1.column6.resizable