在3层Windows应用程序中验证 [英] Validation in 3 tier windows application

查看:66
本文介绍了在3层Windows应用程序中验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在3层c#windows应用程序中对用户输入进行验证。

放置验证码的确切位置在哪里(即在表示层或BAL中)并显示与之相关的适当按摩它。



例如:



if()

{

// errormessage ..............

}

else

{

// ok ......................

}



请提供解决方案以及示例代码



我尝试过:



if()

{

// errormessage ..............

}

其他

{

// ok ................ ......

}

I want to perform validation for user input in 3 tier c# windows application.
Where is the exact place to place the validation code (i.e. in presentation layer or BAL) and display appropriate massage related to it.

Eg:

if()
{
//errormessage..............
}
else
{
//ok......................
}

Please suggest solution along with sample code

What I have tried:

if()
{
//errormessage..............
}
else
{
//ok......................
}

推荐答案

你好Jayesh,



您想要执行哪些验证?



输入验证可能需要也可能不需要元数据来验证。如果您的验证需要元数据进行验证,那么您可能希望在业务层中保留验证,因为验证也是您业务的一部分。



如果您的输入验证是一个简单的非空/范围/有效字符,那么您可以将验证部分保留为表示层。



谢谢!
Hi Jayesh,

What are the validations you want to perform ?

Input validation may or may not require a metadata to validate. In case your validations require metadata to validate, then you might want to keep your validation in Business Layer as the validations are also part of your business.

If your input validations is a simple Non-empty / Range / Valid characters, then probably you can keep the validations part of Presentation layer.

Thanks !


这篇关于在3层Windows应用程序中验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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