如何在VB.NET中设置会计年度(财政年度)? [英] How to set fiscal year(financial year) in VB.NET ?

查看:61
本文介绍了如何在VB.NET中设置会计年度(财政年度)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想设定财年如2016-2017,2017-2018,2018-2019,2019-2020等。



财政年度应从每年的4月1日起自动开始,并在每年的3月31日结束。



当新财政年度开始时,上一个财政年度的所有数据都应该是不可见的,并刷新数据库中的所有类别。



例如:

如果我们将从Combo Box中选择2016-2017上一财政年度,那么所有数据应仅在2016年4月1日至2017年3月31日期间显示,并且像这样。



请帮忙。



我尝试了什么:



i不知道如何使这成为可能。请帮我完成我的项目

解决方案

  Dim  selectedYear 作为 字符串 = ComboBox1.SelectedValue ' < span class =code-comment>2016-2017 
Dim initialYear As 整数 = CInt (selectedYear.Substring( 0 4 ))
Dim fiscalYearStart 作为 日期 = DateTime(initialYear, 4 1
Dim fiscalYearEnd 作为 日期 = fiscalYearStart.AddYears( 1 )。AddDays(-1)





现在,当您启动两个变量时,您必须创建参数化查询 [ ^ ]到您的数据库:

  Dim  qry  As  < span class =code-keyword> String  =   SELECT< set_of_columns> &安培; vbCr& _ 
FROM YourTable& vbCr& _
WHERE SomeDate> = @ fys AND SomeDate> = @ fye





如何执行?根据数据库类型,您必须使用正确的 .net框架数据提供程序 [ ^ ]。



如果您的数据库位于MS SQL Server上,请检查: SqlCommand.Parameters Property(System.Data.SqlClient) [ ^ ]


I want to set Fiscal Year Like 2016-2017, 2017-2018, 2018-2019, 2019-2020 and so on.

Financial Year should be started automatic from 1st April of every year and end on 31st March of every year.

When New Financial Year Starts all data of last financial years should be invisible and refresh all category in data base.

for Example:
if we will select last financial year 2016-2017 from Combo Box then all data should be shown from 1st April 2016 to 31st March 2017 only and like this.

please help.

What I have tried:

i dont know how to make this possible. Please help me to complete my project

解决方案

Dim selectedYear As String = ComboBox1.SelectedValue '"2016-2017"
Dim initialYear As Integer = CInt(selectedYear.Substring(0, 4))
Dim fiscalYearStart As Date = New DateTime(initialYear, 4,1)
Dim fiscalYearEnd As Date = fiscalYearStart.AddYears(1).AddDays(-1)



Now, when you've got initiated both variables, you have to create parameterized query[^] to your database:

Dim qry As String = "SELECT <set_of_columns>" & vbCr & _ 
"FROM YourTable" & vbCr & _
"WHERE SomeDate>=@fys AND SomeDate>=@fye"



How to execute it? Depending on database type, you have to use proper .net framework data provider[^].

If your database is located on MS SQL Server, check this: SqlCommand.Parameters Property (System.Data.SqlClient)[^]


这篇关于如何在VB.NET中设置会计年度(财政年度)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆