简体   繁体   中英

Dynamic Formula in Crystal Report Formula with winform

I using Visual studio.

I have SQL table tbInvoice: amount1, amount2, invNumber.

In winform, i have checkbox1, checkbox2.

If checkbox1 is checked, then in CR should be @total = amount1.

If checkbox1 and checkedbox2 is checked, then in CR should be @total = amount1 + amount2

My formula to print :
frmInv.CrystalReportViewer1.SelectionFormula = "{tbInvoice.invNumber} = '" & FrmInvoice.txtInvNo.Text & "'"

How i accomplish this?

How formula @total in CR can read if checkbox is checked in winform?

I need something like this in CR @total:

if frmInvoice.checkbox1.checked = true and frmInvoice.checkbox2.checked = false then {tbInvoice.amount1}

elseif frmInvoice.checkbox1.checked = true and frmInvoice.checkbox2.checked = true then {tbInvoice.amount1} + {tbInvoice.amount2}

endif

Pls Help. Thank You

  1. Add a parameter to the report.
  2. The formula logic can depend on the parameter.
  3. Your code can set the parameter value.

I didn't understand your last question but here is an example for the {@YourValue} formula:

IF {?Your_Parameter} = "ABC" Then {tbInvoice.amount1} ELSE {tbInvoice.amount1} + {tbInvoice.amount2}

Then, simply SUM that formula at whatever level(s) you need.

Your code needs to set the parameter value.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM