Higlight use multiple condition

edited February 2018 in FastReport .NET
Currently the following condition working fine for the field where values between (1 to 45) change(highlight) the color to red if the values
Value >0 and Value <=48
wrote:
Question
Now I need to consider not only the value from the field but also need to consider the parameter dates difference:
like if the report date range from the 'Form' dates parameters difference is (DateTimePicker1.Value) and (DateTimePicker2.Value) is 14 days do 'x' or if 7days difference do 'Y'.

If the user selected date from above paramters and their DateDiff between 14 days calculate 'X' and for chosen date difference if 7 days than <=7 than 'Y' shown example below:
but generates errors ' String contraints must end with double quote.

Simple condition

So through date parameter if the user chose the two weeks range the criteria is different but if the user chose 1 week difference than criteria is different along with the value of the field




I've written the following code in 'Edit Expression' but doesn't like it
IIF(DateDiff([StartDate],[EndDate]) <=14 ,Value >0 or Value <=48,IIF(DateDiff([StartDate],[EndDate]) <=7, Value >0 or Value <=24))

Appreciate your help!
Thanks
Farhan

Comments

  • edited February 2018
    use script
      public class ReportScript
      {
        int diff;
        
        private void Text1_BeforePrint(object sender, EventArgs e)
        {
          int value = (int) Report.GetColumnValue("Orders.OrderID");
          if (diff <=7)
          {
            if (value > 0 && value <=24)
              Text1.TextColor = Color.Red;
            else
              Text1.TextColor = Color.Black;
          }
          else if (diff <= 14)
          {
            if (value > 0 && value <=48)
              Text1.TextColor = Color.Blue;
            else
              Text1.TextColor = Color.Black;
          }
          else
          {
              Text1.TextColor = Color.Yellow;
          }
        }
    
        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
          DateTime date1 = DateTimePicker1.Value;
          DateTime date2 = DateTimePicker2.Value;
          diff = date2.Subtract(date1).Days;
        }
      }
    
  • edited 8:17AM
    Thanks for your swift response
    I'm not good in C# , can understand bit coding .
    I will try to translate into VB syntax , may come back to you if its ok
    Thanks
    Farhan
    ipong wrote: »
    use script
      public class ReportScript
      {
        int diff;
        
        private void Text1_BeforePrint(object sender, EventArgs e)
        {
          int value = (int) Report.GetColumnValue("Orders.OrderID");
          if (diff <=7)
          {
            if (value > 0 && value <=24)
              Text1.TextColor = Color.Red;
            else
              Text1.TextColor = Color.Black;
          }
          else if (diff <= 14)
          {
            if (value > 0 && value <=48)
              Text1.TextColor = Color.Blue;
            else
              Text1.TextColor = Color.Black;
          }
          else
          {
              Text1.TextColor = Color.Yellow;
          }
        }
    
        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
          DateTime date1 = DateTimePicker1.Value;
          DateTime date2 = DateTimePicker2.Value;
          diff = date2.Subtract(date1).Days;
        }
      }
    

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.