复杂的情况 [英] A complex scenario

查看:83
本文介绍了复杂的情况的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,
我有一个非常复杂的场景要解决.我有解决的想法,但我担心C#的实现部分.

让我解释一下我的情况.我有2个表tblTranfer和tblTransferDetails
tblTranfer的样本数据从outletID = 1到outletID = 2和3

tranferID 1:00:00
2 1 3 3 16/4/09 2:00:00
3 3 1 2 1 2 4 17 18 09#2:00:00 br/> 3 3 3 1 1 2 2 800
4 4 4 1在ID上收到的价格是200在



上收到的价格是







<>然后transferID = 3接收到的平均价格现在跃升到500,这是由于物料价格错误而导致的错误,即800.

现在的情况是,从outletID = 2我们将商品转移到现在的exitID =下面的5是tblTransfer和tblTransferDetails.

tblTranfer的样本数据从outletID = 2到outletID = 5

tranferID outletFrom outletTo tranferDate tranferTime
1 2 4/09:1:00:00


tblTransferDetails

tranferDetails transferID itemID itemQty itemPrice
1的样本数据1 1 1 2 5 500
因此,根据我的情况,在这种情况下,从第一个直销商ID = 1到直销商ID = 2的transferID = 3的定价存在错误,并且该错误导致平均价格上涨.此后,这个错误的价格将被转移到outletID = 5,这种情况可以重复很多级别,但我保持在2个级别.

所以我的解决方案是,一旦我将价格更改为第一个位置,错误我也希望所有其他数据库中的更改也能更新.在这种情况下,每个outletID本身都是一个单独的数据库.

我的想法是,首先基于transferID的日期和时间去搜索要转移的位置,然后到达outletID = 2,然后从在这里,我将进行递归搜索,进一步搜索到outletID = 5,这可以递归地重复.

我在这里的问题不在话下,我有一个递归的想法,但我也想在一个事务中完成所有这一切,所以如果一个失败全部失败.

一个向我展示了一些C#代码如何实现我的解决方案?预先谢谢您.

Dear All,
        I have a very complex scenario to solve. I have got the idea how to solve but I worried on the implementation part of in C#.

Let me explain my scenario. I have 2 table tblTranfer and tblTransferDetails
Sample data of tblTranfer from outletID=1 to outletID=2 and 3

tranferID  outletFrom outletTo tranferDate tranferTime
1          1          2        16/4/09     1:00:00
2          1          3        16/4/09     2:00:00
3          1          2        17/4/09     1:00:00
4          1          3        18/4/09     2:00:00

Sample data of tblTransferDetails

tranferDetails transferID itemID itemQty itemPrice
1              1          1      2       200
2              2          1      2       200
3              3          1      2       800
4              4          1      2       900

Now upon receive the item in outletID=2
transferID=1 receive the average price is 200
then transferID=3 receive the average price now jump to 500 which wrong due to wrong price of item as 800.

Now the scenario is that from outletID=2 we transfer the goods out to now outletID=5 below is the tblTransfer and tblTransferDetails.

Sample data of tblTranfer from outletID=2 to outletID=5

tranferID  outletFrom outletTo tranferDate tranferTime
1          2          5        20/4/09     1:00:00


Sample data of tblTransferDetails

tranferDetails transferID itemID itemQty itemPrice
1              1          1      2       500

So based on my scenario in this case there was a mistake in the pricing at transferID=3 from the first outletID=1 to outletID=2 and this mistake cause the average to go up. Thereafter this wrong price will be transfered to outletID=5 and this scenario can repeat many level but I just keep to 2 level.

So my solution is that once I change the price at the first place of the mistake I want the changes to be updated across all the other databases too. In this scenario each outletID is a separate database by itself.

My idea is that based on the date and time of the transferID first I go and search where I transfer then I come to outletID=2 then from here I will do a recursive search go further to outletID=5 and this can repeat recursively.

My problem here offcourse I have the idea to do it recursively but I also want to do all of this in a transaction so if one fail all will fail.

Can any one show me some light in terms of C# code how to implement my solution ? Thank you in advance.

推荐答案

在这种情况下,我似乎认为错误在于将转移值编码到TransferDetails表中.没有快速的解决方案,因为您可能在系统中还遇到其他问题.显然,tblTransferDetails的第3行中的值不正确.在这种情况下,只有一种方法可能会导致值不正确,并且在我看来,由于用户输入错误而导致值不正确,这引出了一个问题,即为什么允许用户输入价格开始.

为此,我的解决方案是将商品价格提取到自己的表格中.工作流程如下:

1.用户创建转移.
2.两个出口(到"和来自")都将转移标记为已完成.
3.在那一点上,快照"显示在屏幕上.从物料库存成本表中提取值的一半,并将转移时的物料值作为交易存储在会计表中.资产成本为来自"下降了该数量,则"to"的资产成本就降低了.下降了那个数量.当以后更改项目2的成本并将某些数量的项目2转移到另一个位置时,整个过程将再次开始,并且接收该项目的第三个出口将支付新的价值.

话虽如此,可能会有折旧规则等需要处理.在这种情况下,您可能需要一种特定的方法来计算每个特定项目的账面价值,并逐项转移项目.

会计系统可能会变得非常复杂.希望我的建议对您有所帮助.
It seems to me in this situation that the mistake lies in having the transfer value coded into the TransferDetails table.  There's no quick solution to this, as you probably have other problems across the system.  Obviously the value in row 3 of tblTransferDetails is incorrect.  There's only one way in this situation that the value could be incorrect, and it seems to me that it would be incorrect based on incorrect user entry, which begs the question, why is the user being allowed to enter the price to begin with. 

My solution for this would be to abstract out the price of the item into it's own table.  Here would be the workflow:

1. User creates a transfer.
2. Both outlets (the "to" and the "from") mark the transfer as completed.
3. At that point, the "snapshot" of the value from the item inventory cost table is taken, and the value of the items at the time of the transfer is stored as a transaction in the accounting tables.  The asset cost at the "from" goes down by that amount, and the asset cost of the "to" goes down that amount.  When the cost of item 2 is later changed, and some quantity of item2 are transferred to yet another location, the whole process starts again and the third outlet that recieves the items will pay the new value. 

All that being said, there is probably going to be depreciation rules, etc that will need to be handled.  If this is the case, you'll probably need a specific way to count the book value of each particular item, and transfer items on an item by item basis. 

Accounting systems can get pretty complicated.  I hope my suggestions have helped.


这篇关于复杂的情况的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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