关于多表视图数据在grid中修改后,不能更新数据源表中的数据
我有kq和jj两个表,想通过建立视图,在grid表中对数据进行录入和修改,但是修改后的数据不能更新到两个原表中,我通过视图设计器进行建立的视图,修改的数据能够更新到原表,不知在编程中如何实现,请哪位老大帮忙.代码如下:
OPEN DATABASE gzbase
SET SAFETY Off
use
tmp_year=alltrim(str(thisform.spn_year.value)) &&定义查询数据的年份
**2012年1月修改
filepath="e:\gz\"+tmp_year+"年工资数据"
SET PATH TO &filepath
**以上行内容
tmp_month=alltrim(str(thisform.spn_month.value)) &&定义查询数据的月份
if len(tmp_month)=1 &&如果月份小于10月,月份前加零,否则不加零
fbs_name='bs_'+tmp_year+'0'+tmp_month+'.dbf'
fkq_name='kq_'+tmp_year+'0'+tmp_month+'.dbf'
fjj_name='jj_'+tmp_year+'0'+tmp_month+'.dbf'
else
fbs_name='bs_'+tmp_year+tmp_month+'.dbf'
fkq_name='kq_'+tmp_year+tmp_month+'.dbf'
fjj_name='jj_'+tmp_year+tmp_month+'.dbf'
ENDIF
IF file('&fbs_name')
USE &fbs_name ALIAS bs IN 2
else
MESSAGEBOX("没有数据表,请检查年月....",1,3000)
RETURN
ENDIF
** ADD TABLE &fkq_name
** ADD TABLE &fjj_name
*!*
*!* IF SUBSTR(ALLTRIM(thisform.treeview1.selectedItem.Text),1,1)='A'
*!* cbmdm=" "
*!* CREATE SQL VIEW kq_view2 as;
*!* SELECT kq.gh 工号,kq.name 姓名,kq.ycq 应勤,kq.scq 实勤,kq.sjts 事假,kq.bjts 病假,kq.bjlb 类别,kq.kgts 旷工,kq.gsts 工伤,kq.cjts 产假,kq.hjts 婚假,kq.tqjr 探亲假,;
*!* kq.sjr 丧假,kq.jbgr_sat 周六加班,kq.jbgr_sun 周日加班,kq.jr_jb 节日加班,jj.ccjj 超产奖金,jj.zljp 质量奖赔,jj.gwjt 岗位津贴,jj.qtjt 其它奖金,;
*!* jj.qtgz 其它工资,jj.flf 福利费,jj.jbgze1 周六加班费,jj.jbgze2 周日加班费,jj.jbgze3 节日加班费,jj.xybs 中班, jj.dybs 夜班,jj.dkk1 补扣保险费,jj.dkk2 代扣款项,jj.dk_cqj 违纪扣款,jj.dkdf 代扣电费,jj.gh 工号1;
*!* FROM &fkq_name kq ,&fjj_name jj;
*!* WHERE kq.gh=jj.gh ORDER BY kq.bmdm,kq.gh desc
*!* else
cbmdm=SUBSTR(ALLTRIM(thisform.treeview1.selectedItem.Text),1,5)
*!* CREATE SQL VIEW kq_view2 as;
*!* SELECT kq.gh 工号,kq.name 姓名,kq.ycq 应勤,kq.scq 实勤,kq.sjts 事假,kq.bjts 病假,kq.bjlb 类别,kq.kgts 旷工,kq.gsts 工伤,kq.cjts 产假,kq.hjts 婚假,kq.tqjr 探亲假,;
*!* kq.sjr 丧假,kq.jbgr_sat 周六加班,kq.jbgr_sun 周日加班,kq.jr_jb 节日加班,jj.ccjj 超产奖金,jj.zljp 质量奖赔,jj.gwjt 岗位津贴,jj.qtjt 其它奖金,;
*!* jj.qtgz 其它工资,jj.flf 福利费,jj.jbgze1 周六加班费,jj.jbgze2 周日加班费,jj.jbgze3 节日加班费,jj.xybs 中班,jj.dybs 夜班,jj.dkk1 补扣保险费,jj.dkk2 代扣款项,jj.dk_cqj 违纪扣款,jj.dkdf 代扣电费,jj.gh 工号1;
*!* FROM &fkq_name kq , &fjj_name jj ;
*!* WHERE kq.gh=jj.gh AND kq.bmdm=cbmdm ORDER BY kq.bmdm,kq.gh desc
*!* ENDIF
use kq_view
DBSetProp('kq_view',"View","SendUpdates",.T.)
DBSetProp('kq_view',"View","BatchUpdateCount",1)
DBSetProp('kq_view',"View","CompareMemo",.T.)
DBSetProp('kq_view',"View","FetchAsNeeded",.F.)
DBSetProp('kq_view',"View","FetchMemo",.T.)
DBSetProp('kq_view',"View","FetchSize",100)
DBSetProp('kq_view',"View","MaxRecords",-1)
DBSetProp('kq_view',"View","Prepared",.F.)
DBSetProp('kq_view',"View","UpdateType",1)
DBSetProp('kq_view',"View","UseMemoSize",255)
DBSetProp('kq_view',"View","Tables","kq_201509,jj_201509")
DBSetProp('kq_view',"View","WhereType",3)
DBSetProp("kq_view"+".工号","Field","DataType","C(8)")
DBSetProp("kq_view"+".工号","Field","UpdateName","kq.gh")
DBSetProp("kq_view"+".工号","Field","KeyField",.T.)
DBSetProp("kq_view"+".工号","Field","Updatable",.T.)
DBSetProp("kq_view"+".工号1","Field","DataType","C(8)")
DBSetProp("kq_view"+".工号1","Field","UpdateName","jj.gh")
DBSetProp("kq_view"+".工号1","Field","KeyField",.T.)
DBSetProp("kq_view"+".工号1","Field","Updatable",.T.)
DBSetProp("kq_view"+".姓名","Field","DataType","C(6)")
DBSetProp("kq_view"+".姓名","Field","UpdateName","kq.name")
DBSetProp("kq_view"+".姓名","Field","KeyField",.F.)
DBSetProp("kq_view"+".姓名","Field","Updatable",.T.)
DBSetProp("kq_view"+".应勤","Field","DataType","N(4,1)")
DBSetProp("kq_view"+".应勤","Field","UpdateName","kq.ycq")
DBSetProp("kq_view"+".应勤","Field","KeyField",.F.)
DBSetProp("kq_view"+".应勤","Field","Updatable",.T.)
DBSetProp("kq_view"+".实勤","Field","DataType","N(4,1)")
DBSetProp("kq_view"+".实勤","Field","UpdateName","kq.scq")
DBSetProp("kq_view"+".实勤","Field","KeyField",.F.)
DBSetProp("kq_view"+".实勤","Field","Updatable",.T.)
DBSetProp("kq_view"+".事假","Field","DataType","N(4,1)")
DBSetProp("kq_view"+".事假","Field","UpdateName","kq.sjts")
DBSetProp("kq_view"+".事假","Field","KeyField",.F.)
DBSetProp("kq_view"+".事假","Field","Updatable",.T.)
DBSetProp("kq_view"+".病假","Field","DataType","N(4,1)")
DBSetProp("kq_view"+".病假","Field","UpdateName","kq.bjts")
DBSetProp("kq_view"+".病假","Field","KeyField",.F.)
DBSetProp("kq_view"+".病假","Field","Updatable",.T.)
DBSetProp("kq_view"+".类别","Field","DataType","C(2)")
DBSetProp("kq_view"+".类别","Field","UpdateName","kq.bjlb")
DBSetProp("kq_view"+".类别","Field","KeyField",.F.)
DBSetProp("kq_view"+".类别","Field","Updatable",.T.)
DBSetProp("kq_view"+".旷工","Field","DataType","N(4,1)")
DBSetProp("kq_view"+".旷工","Field","UpdateName","kq.kgts")
DBSetProp("kq_view"+".旷工","Field","KeyField",.F.)
DBSetProp("kq_view"+".旷工","Field","Updatable",.T.)
DBSetProp("kq_view"+".工伤","Field","DataType","N(4,1)")
DBSetProp("kq_view"+".工伤","Field","UpdateName","kq.gsts")
DBSetProp("kq_view"+".工伤","Field","KeyField",.F.)
DBSetProp("kq_view"+".工伤","Field","Updatable",.T.)
DBSetProp("kq_view"+".产假","Field","DataType","N(4,1)")
DBSetProp("kq_view"+".产假","Field","UpdateName","kq.cjts")
DBSetProp("kq_view"+".产假","Field","KeyField",.F.)
DBSetProp("kq_view"+".产假","Field","Updatable",.T.)
DBSetProp("kq_view"+".婚假","Field","DataType","N(4,1)")
DBSetProp("kq_view"+".婚假","Field","UpdateName","kq.hjts")
DBSetProp("kq_view"+".婚假","Field","KeyField",.F.)
DBSetProp("kq_view"+".婚假","Field","Updatable",.T.)
DBSetProp("kq_view"+".探亲假","Field","DataType","N(4,1)")
DBSetProp("kq_view"+".探亲假","Field","UpdateName","kq.tqjr")
DBSetProp("kq_view"+".探亲假","Field","KeyField",.F.)
DBSetProp("kq_view"+".探亲假","Field","Updatable",.T.)
DBSetProp("kq_view"+".丧假","Field","DataType","N(4,1)")
DBSetProp("kq_view"+".丧假","Field","UpdateName","kq.sjr")
DBSetProp("kq_view"+".丧假","Field","KeyField",.F.)
DBSetProp("kq_view"+".丧假","Field","Updatable",.T.)
DBSetProp("kq_view"+".周六加班","Field","DataType","N(4,1)")
DBSetProp("kq_view"+".周六加班","Field","UpdateName","kq.jbgr_sat")
DBSetProp("kq_view"+".周六加班","Field","KeyField",.F.)
DBSetProp("kq_view"+".周六加班","Field","Updatable",.T.)
DBSetProp("kq_view"+".周日加班","Field","DataType","N(4,1)")
DBSetProp("kq_view"+".周日加班","Field","UpdateName","kq.jbgr_sun")
DBSetProp("kq_view"+".周日加班","Field","KeyField",.F.)
DBSetProp("kq_view"+".周日加班","Field","Updatable",.T.)
DBSetProp("kq_view"+".节日加班","Field","DataType","N(4,1)")
DBSetProp("kq_view"+".节日加班","Field","UpdateName","kq.jr_jb")
DBSetProp("kq_view"+".节日加班","Field","KeyField",.F.)
DBSetProp("kq_view"+".节日加班","Field","Updatable",.T.)
DBSetProp("kq_view"+".超产奖金","Field","DataType","N(12,2)")
DBSetProp("kq_view"+".超产奖金","Field","UpdateName","jj_201509.ccjj")
DBSetProp("kq_view"+".超产奖金","Field","KeyField",.F.)
DBSetProp("kq_view"+".超产奖金","Field","Updatable",.T.)
DBSetProp("kq_view"+".质量奖赔","Field","DataType","N(8,2)")
DBSetProp("kq_view"+".质量奖赔","Field","UpdateName","jj_201509.zljp")
DBSetProp("kq_view"+".质量奖赔","Field","KeyField",.F.)
DBSetProp("kq_view"+".质量奖赔","Field","Updatable",.T.)
DBSetProp("kq_view"+".岗位津贴","Field","DataType","N(8,2)")
DBSetProp("kq_view"+".岗位津贴","Field","UpdateName","jj_201509.gwjt")
DBSetProp("kq_view"+".岗位津贴","Field","KeyField",.F.)
DBSetProp("kq_view"+".岗位津贴","Field","Updatable",.T.)
DBSetProp("kq_view"+".其它奖金","Field","DataType","N(8,2)")
DBSetProp("kq_view"+".其它奖金","Field","UpdateName","jj_201509.qtjt")
DBSetProp("kq_view"+".其它奖金","Field","KeyField",.F.)
DBSetProp("kq_view"+".其它奖金","Field","Updatable",.T.)
DBSetProp("kq_view"+".其它工资","Field","DataType","N(8,2)")
DBSetProp("kq_view"+".其它工资","Field","UpdateName","jj_201509.qtgz")
DBSetProp("kq_view"+".其它工资","Field","KeyField",.F.)
DBSetProp("kq_view"+".其它工资","Field","Updatable",.T.)
DBSetProp("kq_view"+".福利费","Field","DataType","N(8,2)")
DBSetProp("kq_view"+".福利费","Field","UpdateName","jj_201509.flf")
DBSetProp("kq_view"+".福利费","Field","KeyField",.F.)
DBSetProp("kq_view"+".福利费","Field","Updatable",.T.)
DBSetProp("kq_view"+".周六加班费","Field","DataType","N(8,2)")
DBSetProp("kq_view"+".周六加班费","Field","UpdateName","jj_201509.jbgze1")
DBSetProp("kq_view"+".周六加班费","Field","KeyField",.F.)
DBSetProp("kq_view"+".周六加班费","Field","Updatable",.T.)
DBSetProp("kq_view"+".周日加班费","Field","DataType","N(8,2)")
DBSetProp("kq_view"+".周日加班费","Field","UpdateName","jj_201509.jbgze2")
DBSetProp("kq_view"+".周日加班费","Field","KeyField",.F.)
DBSetProp("kq_view"+".周日加班费","Field","Updatable",.T.)
DBSetProp("kq_view"+".节日加班费","Field","DataType","N(8,2)")
DBSetProp("kq_view"+".节日加班费","Field","UpdateName","jj_201509.jbgze3")
DBSetProp("kq_view"+".节日加班费","Field","KeyField",.F.)
DBSetProp("kq_view"+".节日加班费","Field","Updatable",.T.)
DBSetProp("kq_view"+".中班","Field","DataType","N(4)")
DBSetProp("kq_view"+".中班","Field","UpdateName","jj_201509.xybs")
DBSetProp("kq_view"+".中班","Field","KeyField",.F.)
DBSetProp("kq_view"+".中班","Field","Updatable",.T.)
DBSetProp("kq_view"+".夜班","Field","DataType","N(4)")
DBSetProp("kq_view"+".夜班","Field","UpdateName","jj_201509.dybs")
DBSetProp("kq_view"+".夜班","Field","KeyField",.F.)
DBSetProp("kq_view"+".夜班","Field","Updatable",.T.)
DBSetProp("kq_view"+".补扣保险费","Field","DataType","N(9,2)")
DBSetProp("kq_view"+".补扣保险费","Field","UpdateName","jj_201509.dkk1")
DBSetProp("kq_view"+".补扣保险费","Field","KeyField",.F.)
DBSetProp("kq_view"+".补扣保险费","Field","Updatable",.T.)
DBSetProp("kq_view"+".代扣款项","Field","DataType","N(9,2)")
DBSetProp("kq_view"+".代扣款项","Field","UpdateName","jj_201509.dkk2")
DBSetProp("kq_view"+".代扣款项","Field","KeyField",.F.)
DBSetProp("kq_view"+".代扣款项","Field","Updatable",.T.)
DBSetProp("kq_view"+".违纪扣款","Field","DataType","N(8,2)")
DBSetProp("kq_view"+".违纪扣款","Field","UpdateName","jj_201509.dk_cqj")
DBSetProp("kq_view"+".违纪扣款","Field","KeyField",.F.)
DBSetProp("kq_view"+".违纪扣款","Field","Updatable",.T.)
DBSetProp("kq_view"+".代扣电费","Field","DataType","N(8,2)")
DBSetProp("kq_view"+".代扣电费","Field","UpdateName","jj_201509.dkdf")
DBSetProp("kq_view"+".代扣电费","Field","KeyField",.F.)
DBSetProp("kq_view"+".代扣电费","Field","Updatable",.T.)
SELECT COUNT(*) FROM kq_view INTO ARRAY nbmrs
**SELECT COUNT(*) FROM tmp_kq WHERE 保险种类 in ("A1","A2","A4","A5") INTO ARRAY cb_rs
**SELECT COUNT(*) FROM tmp_kq WHERE (保险种类="A3") INTO ARRAY notcb_rs
thisform.text1.Value=nbmrs
thisform.grid1.RecordSourceType=1
thisform.grid1.RecordSource="kq_view"
thisform.grid1.ReadOnly= .F.
WITH thisform.grid1
.column1.width=50
.column2.width=45
.column3.width=35
.column4.width=35
.column5.width=35
.column6.width=35
.column7.width=35
.column8.width=35
.column9.width=35
.column10.width=35
.column11.width=35
.column12.width=40
.column13.width=35
.column14.width=40
.column15.width=40
.column16.width=40
.column17.width=50
.column18.width=40
.column19.width=35
.column20.width=35
.column21.width=35
.column22.width=35
.column23.width=35
.column24.width=35
.column25.width=35
.column26.width=30
.column27.width=30
.column28.width=35
.column29.width=35
.column30.width=35
.column31.width=35
** .column17.width=80
endwith
thisform.grid1.Refresh
[ 本帖最后由 jsfchqf 于 2015-9-19 15:35 编辑 ]