自分では解決できない問題があります。始める前に、皆さんにお知らせしておくことが重要です
私が最初から最後まで書いたこの問題は、あなたに私の問題が何であるかを正しく理解してもらいたいです。これを読むのが面倒な人のために、許してください。
おそらく、このフォーラムの人々が私を助けてくれるでしょう。しかし、私はすでに問題の解決策を手に入れました(ただし、ロジックだけです。コードで証明できず、どこから始めればよいかわかりません)
さて、ここに私の場合があります:
I got a Quantity column in DataGridView, and i got a feature where user could edit the Quantity column in DataGridView and automatically updating the Quantity value in the Database.
例(まだケースにあります):
I have 1000 on Quantity in the Database, and i enter the value of 50 in the Quantity column in system and after that i add to the DataGridView by clicking a "OK" button, once clicked, the Quantity in the Database should update it Quantity become 950, from 1000. Because i use a formula
valueOfQuantityInDatabase - valueOfQuantityInSystem、it update properly and successful
これが私の問題です:
Let's say i got a DataGridView with Quantity column and the value of it is 50
(これにより、データベースの数量値が 950 になります) and let's say customer want to add his Quantity from 50 to 150, so i change the value of Quantity in DataGridView to 150 from 50, and when i click "OK" button, the Database should update based on the formula
valueOfQuantityInDatabase - valueOfQuantityInSystem、and the Quantity in Database should have 850 in Quantity value
(1000 - 150 のため)、but it is not as i expected, the Quantity value in database is 800
(最初に追加するのは 50 であるため、データベースの数量は 950 であり、次に別の 150 を追加すると、データベースの数量は800)、so it is like first entered value + second entered value.
ここに私が欲しいものがあります:
Whenever user edit the Quantity in DataGridView, it should goes to this formula
valueOfQuantityInDatabase - valueOfQuantityInSystem ------ (したがって、ユーザーが DataGridView の数量値を変更するたびに、50 から 150 に変更するとしましょう。データベースの数量はそれを認識し、DataGridView の数量の現在の値 (150) を差し引く必要があります。古いものではない (50)
これが私が持ってきた私の解決策です:
変更前のデータベースの数量の最初の値を取得します (1000)
数式によってユーザーから追加された Quantity の値を取得し
Quantity in DataGridView after changes - Quantity in DataGridView before changes
、それを数式で加算しますQuantity in DataGridView after changes - Quantity in DataGridView before changes
しかし、解決策1または2を取得する方法がわかりません。誰か助けてもらえますか? どうもありがとうございました!あなたの答えはとても感謝しています!