如何在业务层中处理业务规则 [英] How to handle business rule in Business Layer

查看:70
本文介绍了如何在业务层中处理业务规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友,

我有一个与dataGridView绑定的orderCollection,因此当我更新dataGrid中的订单数量时,应该对其进行验证(假设订单数量不应超过100).

因此,如何在用户更新数量时如何编写单独的业务规则类并与集合关联以触发规则.

我的问题是如何在业务层中处理业务对象,业务对象集合和业务对象规则.

请给我一个例子,如果可以的话........


谢谢

Hi Friends,

I am having an orderCollection which is bound with the dataGridView.So when I update the order Qty in the dataGrid it should be validated (let suppose order Qty should not be more than 100).

so how I can write a separate business Rule class and associate with collection to trigger the rule while user updates the Qty.

My question is here how I can handle the Business Object, Business Object Collection, Business Object Rules in the business Layer.

Please give me one example if you could........


Thanks

推荐答案

使用C#的ASP.NET中的3层体系结构 [ ^ ]
本文通过一个示例向您说明如何使用n层体系结构创建应用程序.经历一下.

希望对您有所帮助!
3-Tier Architecture in ASP.NET with C#[^]
The article explains you how to create application using n-tier architecture with an example. Go through it.

Hope this helps!


您可以利用DataGridView的CellValidating事件.处理它以调用将进行验证并返回结果的业务层方法.
You can make use of the CellValidating event of the DataGridView. Handle it to call the business layer method that would do the validation and return the result.


这是我根据您的评论所进行的新回复.您应该在单独的项目中有一个类(数据传输对象),所有层都应使用该类来共享周围的数据.

现在,您需要两件事:

1.当用户更改DataGridView中的值时,将字符串发送到您的业务层以对其进行验证.

2.编辑完成后,当用户选择保存之类的内容时,请跨数据源即DTO发送回业务部门,以便它可以验证对象.

使用DTO的三层体系结构的任何示例都将对您非常有帮助.
Here is my new reply based on your comment. You should have a class ( a data transfer object) in a separate project which should be used by all the layers to share the data around.

Now, you need two things:

1. When the user changes the value in the DataGridView, send across a string to your business layer to validate it.

2. When the user opts for something like save after he is done with the edits, send across the data source i.e. the DTO back to the business for it can validate the object.

Any example for a 3-tier architecture with the use of DTOs would be very helpful for you.


这篇关于如何在业务层中处理业务规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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