求助vb大神,个人收支管理添加一个新功能
开普敦老船长
2024-11-29 17:36:11
最佳回答
添加类别:option1.value = false and option2.value = false thendim str1 as integerstr1 = msgbox("请选择收支类型,否则将默认为-收", 4128, "收支类型必须指明")option1.value = trues = "收"elseif option1.value = true thens = "收"elseif option2.value = true thens = "支"end ifif text_class_add.text = "" or text_class_add.text = "(不超过12字)" thendim str2 as integerstr2 = msgbox("请输入收支类型的名称", 4128, "收支名称必须指明")elseon error goto showerrorwith rst.addnew.fields.item("收支类型").value = text_class_add.text.fields.item("收支").value = s.fields.item("说明").value = text_shuoming.update.requeryend with'------------显示全部记录l**t_class.clearrst.movefirsti = 0do while not rst.eofl**t_class.l**t(i) = rst.fields("收支类型").valuel**t_shouzhi.l**t(i) = rst.fields("收支").valuerst.movenexti = i + 1loop'------------结束goto jumpshowerror: msgbox err.descriptionwith dbsif .state = adstateopen then.closeend if.provider = "microsoft.jet.oledb.4.0".connectionstring = app.path & "\mymoney.mdb".openend withwith rstif .state = adstateopen then.closeend if.locktype = adlockoptim**tic.activeconnection = dbs.cursorlocation = aduseclient.cursortype = adopenkeyset.open "收支类型表", options:=adcmdtableend withjump:end iftext_class_add.text = ""text_shuoming.text = ""option1.value = falseoption2.value = falseend sub修改类别:with rstif .state = adstateopen then.closeend if.locktype = adlockoptim**tic.activeconnection = dbs.cursorlocation = aduseclient.cursortype = adopenkeyset.open "收支类型表", options:=adcmdtableend withrst.movefirstdo while not rst.eofif ss = rst.fields("收支类型").value thenif option1.value = true thens = "收"elseif option2.value = true thens = "支"end ifif text_class_add.text = "" or text_class_add.text = "(不超过12字)" thendim str2 as integerstr2 = msgbox("请输入收支类型的名称", 4128, "收支名称必须指明")elseon error goto showerrorwith rst.fields.item("收支类型").value = text_class_add.text.fields.item("收支").value = s.fields.item("说明").value = text_shuoming.update.requeryend with'------------显示全部记录l**t_class.clearrst.movefirsti = 0do while not rst.eofl**t_class.l**t(i) = rst.fields("收支类型").valuel**t_shouzhi.l**t(i) = rst.fields("收支").valuerst.movenexti = i + 1loop'------------结束goto jumpshowerror:msgbox err.descriptionwith dbsif .state = adstateopen then.closeend if.provider = "microsoft.jet.oledb.4.0".connectionstring = app.path & "\mymoney.mdb".openend withwith rstif .state = adstateopen then.closeend if.locktype = adlockoptim**tic.activeconnection = dbs.cursorlocation = aduseclient.cursortype = adopenkeyset.open "收支类型表", options:=adcmdtableend withjump:text_class_add.text = ""text_shuoming.text = ""option1.value = falseoption2.value = falseend ifexit doend ifrst.movenextloopcommand_update.enabled = falsecommand_class_add.enabled = trueend sub收支类型说明:ss = l**t_class.textm = 0 '<----------判断哪条记录被选定for i = 0 to l**t_class.l**tcount - 1if l**t_class.selected(i) = true thenm = iexit forend ifnext il**t_shouzhi.selected(m) = truerst.requerydo while not rst.eofif l**t_class.text = rst.fields("收支类型").value thencommand_class_add.enabled = falsecommand_update.enabled = truetext_class_add.text = rst.fields("收支类型")if ****(rst.fields("说明").value) thenlabel_shuoming.caption = "无详细说明"text_shuoming.text = ""elselabel_shuoming.caption = rst.fields("说明").valuetext_shuoming.text = rst.fields("说明").valueend ifif rst.fields("收支") = "收" thenoption1.value = trueelseoption2.value = trueend ifexit doend ifrst.movenextlooprst.requeryend sub**添加:with rst.addnew.fields(0).value = text_cardnum.text.fields(1).value = text_cardname2.text.fields(2).value = text_bankname2.text.fields(3).value = dtpicker_card2.value.fields(4).value = text_cardmore2.text.update.requeryend with'------------显示全部记录l**t_cardname.clear' rst.movefirsti = 0do while not rst.eofl**t_cardname.l**t(i) = rst.fields(1).valuerst.movenexti = i + 1loop'------------结束text_cardnum.text = ""text_cardname2.text = ""text_bankname2.text = ""dtpicker_card2.value = datetext_cardmore2.text = ""goto jumpshowerror: msgbox err.descriptionc**atarsttable "**表"jump:end sub**删除:s = msgbox("确定要删除该卡吗?删除后该卡的所有收支记录会丢失", vbyesno, "删除选定**")if s = 6 thenon error goto showerrorrst.requeryrst.move (l**t_cardname.l**tindex)rst.deleterst.requery'------------显示全部记录l**t_cardname.clear' rst.movefirsti = 0do while not rst.eofl**t_cardname.l**t(i) = rst.fields(1).valuerst.movenexti = i + 1looptext_cardname1.text = ""text_bankname1.text = ""dtpicker_card1.value = datetext_cardmore1.text = ""goto jumpshowerror: msgbox err.descriptionc**atarsttable "**表"jump:end ifend sub支出查询:c**ata'<---------初始显示当月全部类型的支出if combo_class.text = "" or combo_class.text = "全部支出类型" then'-------所有支出类型查询if check_zhi_all.value = 1 then'--------所有类型,所有日期查询sql = "select 收支名称 as 支出名称,收支类型表.收支类型 as 项目,收支日期 as 支出日期,金额,备注 from 收支记录表,收支类型表 where 收支记录表.收支类型=收支类型表.收支类型 and 收支='支'and 收支记录表.收支类型 <> '银行存款'"elseif check_zhi_all.value = 0 then'---------所有类型,按月查询sql = "select 收支名称 as 支出名称,收支类型表.收支类型 as 项目,收支日期 as 支出日期,金额,备注 from 收支记录表,收支类型表 where 收支记录表.收支类型=收支类型表.收支类型 and 收支='支'and 收支记录表.收支类型 <> '银行存款' and 收支记录表.收支日期 between #" & rtrim(combo_year.text) & "-" & rtrim(combo_month.text) & "-1#" & "and#" & rtrim(combo_year.text) & "-" & rtrim(combo_month.text) & "-" & daynum & "#"end ifelse'--------固定类型查询if check_zhi_all.value = 1 then'---------固定类型,所有日期查询sql = "select 收支名称 as 支出名称,收支类型表.收支类型 as 项目,收支日期 as 支出日期,金额,备注 from 收支记录表,收支类型表 where 收支记录表.收支类型=收支类型表.收支类型 and 收支='支'and 收支类型表.收支类型='" & rtrim(combo_class.text) & "'"elseif check_zhi_all.value = 0 then'----------固定类型,按日期查询sql = "select 收支名称 as 支出名称,收支类型表.收支类型 as 项目,收支日期 as 支出日期,金额,备注 from 收支记录表,收支类型表 where 收支记录表.收支类型=收支类型表.收支类型 and 收支='支'and 收支类型表.收支类型='" & rtrim(combo_class.text) & "'and 收支记录表.收支日期 between #" & rtrim(combo_year.text) & "-" & rtrim(combo_month.text) & "-1#" & "and#" & rtrim(combo_year.text) & "-" & rtrim(combo_month.text) & "-" & daynum & "#"end ifend if 20210311