0

I have some stored Procedures on one form and at the end I do not commit or rollback. A new form loads and a question prompts the user "Are there any other products in the box?" When the user clicks YES the transaction must rollback. When NO the transaction must commit.

My question is how can I pass the transaction value to the new form?

Werner van den Heever
  • 745
  • 6
  • 17
  • 40
  • Like others, I agree your separation of concerns is poor, but if you want to make some progress now one way would be the BeginTransaction method (and it's siblings) of wahtever Connection class you are using. – Tony Hopkinson May 27 '13 at 12:40

2 Answers2

0

I don't think transactions belong anywhere near a form. Forms are views; transactions are owned and managed by services. Your design doesn't sound like it's layered properly.

duffymo
  • 305,152
  • 44
  • 369
  • 561
  • What is your suggestion then? – Werner van den Heever May 27 '13 at 12:24
  • Create an interface-based service layer and have the form call it to fulfill the use case. The service will commit or roll back the transaction. The user indicates that the transaction needs to commit when they check out their shopping cart. I'd also recommend searching stack overflow for "shopping cart". You aren't the first. – duffymo May 27 '13 at 12:24
0

You must create Layers: Data Access Layer,Business Logic Layer and Presentation Layer.This is 3-tier architecture,your transaction must be in Data Access Layer, use this link: http://www.codeproject.com/Articles/36847/Three-Layer-Architecture-in-C-NET but in this situation I think you use MessageBox for showing your question,you must get Dialog Result.Use this code:

if (XtraMessageBox.Show("your question", "Heading", MessageBoxButtons.YesNo,MessageBoxIcon.Question) == DialogResult.Yes)
        {
            Transaction.Commit();
        }
Rauf Zeynalov
  • 28
  • 2
  • 6