// status - value dictionary
    private void SetStatusTableValues(Anthem.Panel Container, Dictionary<CardStatuses, Int64> Values, double Multiplier = 100)
    {
        int Index = 0;

        for (int i = 0; i < Container.Controls.Count; i++)
          if (Container.Controls[i] is Anthem.Label)
          {
        // ���� ������ TextBox
        for (int j = i; j < Container.Controls.Count; j++)
          if (Container.Controls[j] is Anthem.TextBox)
          {
            Anthem.Label InfoLabel = Container.Controls[i] as Anthem.Label;
            Anthem.TextBox DataText = Container.Controls[j] as Anthem.TextBox;
            InfoLabel.Text = "";
            DataText.Text = "";
            DataText.BackColor = InfoLabel.BackColor;

            if (Index < StatusesArray.Length)
            {
              Int64 value = 0;
              if (Values.TryGetValue(StatusesArray[Index], out value))
              {
                InfoLabel.Text = StatusesArray[Index].ToString();
                DataText.Text = (value / Multiplier).ToString();
              }
              Index++;
            }

            InfoLabel.Visible = InfoLabel.Text != "";
            DataText.Visible = DataText.Text != "";
            break;
          }
          }
    }
 // Product discount values
 private void SetProductDiscountValues(Anthem.ListBox Container, Dictionary<Int32, Int64> Values, double Multiplier = 100)
 {
     UpdateVariables();
     Container.Items.Clear();
     if (Values != null)
       foreach (KeyValuePair<Int32, Int64> KVP in Values)
       {
     try
     {
       ActionProduct ap = Products.FindByID(KVP.Key);
       ListItem li = new ListItem(string.Format("{0} : '{1}' : {2:0.00}%", ap.ID, ap.Name, KVP.Value / Multiplier));
       Container.Items.Add(li);
     }
     catch { } // not found
       }
 }
 // Products list
 private void SetProducts(Anthem.ListBox Container, List<Int32> Values)
 {
     UpdateVariables();
     Container.Items.Clear();
     if (Values != null)
       foreach (Int32 ID in Values)
       {
     try
     {
       ActionProduct ap = Products.FindByID(ID);
       ListItem li = new ListItem(string.Format("{0} : '{1}'", ap.ID, ap.Name));
       Container.Items.Add(li);
     }
     catch { } // not found
       }
 }
 // holidays
 private void SetHolidaysValues(Anthem.ListBox Container, List<Holiday> Values)
 {
     Container.Items.Clear();
     foreach (Holiday holiday in Values)
     {
       string s = string.Format("{0:00}.{1:00}", holiday.Day, holiday.Month);
       if (holiday.Year != 0)
     s += string.Format(".{0:0000}", holiday.Year);
       Container.Items.Add(new ListItem(s));
     }
 }
 // hours
 private void SetHoursValues(Anthem.Panel Container, List<byte> Values)
 {
     for (int i = 0; i < Container.Controls.Count; i++)
       if (Container.Controls[i] is Anthem.CheckBox)
       {
     Anthem.CheckBox HourCheck = Container.Controls[i] as Anthem.CheckBox;
     HourCheck.Checked = false;
     byte Hour;
     if (byte.TryParse(HourCheck.Text, out Hour))
     {
       foreach (byte ValueHour in Values)
         if (ValueHour == Hour)
         {
           HourCheck.Checked = true;
           break;
         }
     }
       }
 }
    private void GetAntiFroadPanel(Anthem.Panel Container, CardCounters Counters, AntiFraudParameter Value)
    {
        CardCounter Counter = Counters[Value.CounterName];
        int Index = 0;

        for (int i = 0; i < Container.Controls.Count; i++)
          if (Container.Controls[i] is Anthem.CheckBox)
          {
        // ���� ������ TextBox
        for (int j = i; j < Container.Controls.Count; j++)
          if ((Container.Controls[j] is Anthem.TextBox) && (Container.Controls[j] as Anthem.TextBox).TextMode == TextBoxMode.SingleLine)
          {
            // ���� ������� TextBox
            for (int k = j; k < Container.Controls.Count; k++)
              if ((Container.Controls[k] is Anthem.TextBox) && (Container.Controls[k] as Anthem.TextBox).TextMode == TextBoxMode.MultiLine)
              {
                Anthem.CheckBox InfoCheck = Container.Controls[i] as Anthem.CheckBox;
                Anthem.TextBox LimitText = Container.Controls[j] as Anthem.TextBox;
                Anthem.TextBox MessageText = Container.Controls[k] as Anthem.TextBox;

                if (MessageText.Text.Length > 0 && MessageText.Text[MessageText.Text.Length-1] != '\n')
                  MessageText.Text += "\n";

                double LimitValue = 0;
                if (!double.TryParse(LimitText.Text, out LimitValue))
                  throw new Exception("�������� ������ ��� ��������� '" + Value.Name + "' ������ �������: " + LimitText.Text);

                if (Index == 0)
                {
                  Value.CheckMaximumValue = InfoCheck.Checked;
                  Value.MaximumValue = Counter.ObjectToValue(LimitValue);
                  Value.MaximumMessage = MessageText.Text;
                }
                else
                {
                  Value.CheckMinimumValue = InfoCheck.Checked;
                  Value.MinimumValue = Counter.ObjectToValue(LimitValue);
                  Value.MinimumMessage = MessageText.Text;
                }

                Index++;
                break;
              }
            break;
          }
          }
    }
 // day of week
 private void SetDayOfWeekValues(Anthem.Panel Container, List<DayOfWeek> Values)
 {
     for (int i = 0; i < Container.Controls.Count; i++)
       if (Container.Controls[i] is Anthem.CheckBox)
       {
     Anthem.CheckBox DOWCheck = Container.Controls[i] as Anthem.CheckBox;
     DOWCheck.Checked = false;
     byte DOW;
     if (byte.TryParse(DOWCheck.ID.Replace("APDayOfWeek", ""), out DOW))
     {
       foreach (DayOfWeek ValueDOW in Values)
         if ((byte)ValueDOW == DOW)
         {
           DOWCheck.Checked = true;
           break;
         }
     }
       }
 }
    private Dictionary<CardStatuses, Int64> GetStatusTableValues(Anthem.Panel Container, double Multiplier = 100)
    {
        Dictionary<CardStatuses, Int64> Values = new Dictionary<CardStatuses, Int64>();
        for (int i = 0; i < Container.Controls.Count; i++)
          if (Container.Controls[i] is Anthem.Label)
          {
        // ���� ������ TextBox
        for (int j = i; j < Container.Controls.Count; j++)
          if (Container.Controls[j] is Anthem.TextBox)
          {
            Anthem.Label InfoLabel = Container.Controls[i] as Anthem.Label;
            Anthem.TextBox DataText = Container.Controls[j] as Anthem.TextBox;

            for (int k = 0; k < StatusesArray.Length; k++)
              if (StatusesArray[k].ToString() == InfoLabel.Text)
              {
                double DataValue = 0;
                if (double.TryParse(DataText.Text, out DataValue))
                {
                  Values.Add(StatusesArray[k], (Int32)(DataValue * Multiplier));
                  break;
                }
                else
                {
                  DataText.BackColor = System.Drawing.Color.Red;
                  throw new Exception("�������� ��� " + InfoLabel.Text + " ������ �������");
                }
              }
            break;
          }
          }
        if (Values.Count > 0)
          return Values;
        else
          throw new Exception("GetStatusTableValues �� ������ ������");
    }
 private List<string> GetStringValues(Anthem.ListBox Container)
 {
     List<string> Values = new List<string>();
     foreach (ListItem item in Container.Items)
       Values.Add(item.Text);
     return Values;
 }
 private Dictionary<Int32, Int64> GetProductDiscountValues(Anthem.ListBox Container, double Multiplier = 100)
 {
     Dictionary<Int32, Int64> Values = new Dictionary<Int32, Int64>();
     foreach (ListItem item in Container.Items)
     {
       string[] parts = item.Text.Split(':');
       if (parts.Length >= 3)
       {
     Int32 ID;
     double Discount;
     if (Int32.TryParse(parts[0].Trim(), out ID))
     {
       if (double.TryParse(parts[2].Replace("%", "").Trim(), out Discount))
       {
         Values.Add(ID, Convert.ToInt64(Discount * Multiplier));
       }
       else
         throw new Exception("�������� ������ � ����.������� '" + item.Text + "'");
     }
     else
       throw new Exception("�������� ID �������� � ����.������� '" + item.Text + "'");
       }
       else
     throw new Exception("����.������� '"+item.Text+"' ����� �������� ������");
     }
     return Values;
 }
 private List<Int32> GetProducts(Anthem.ListBox Container)
 {
     List<Int32> Values = new List<Int32>();
     foreach (ListItem item in Container.Items)
     {
       string[] parts = item.Text.Split(':');
       if (parts.Length >= 2)
       {
     Int32 ID;
     if (Int32.TryParse(parts[0].Trim(), out ID))
     {
       Values.Add(ID);
     }
     else
       throw new Exception("�������� ID �������� � ������ '" + item.Text + "'");
       }
       else
     throw new Exception("������� '" + item.Text + "' ����� �������� ������");
     }
     return Values;
 }
 private List<byte> GetHoursValues(Anthem.Panel Container)
 {
     List<byte> Values = new List<byte>();
     for (int i = 0; i < Container.Controls.Count; i++)
       if (Container.Controls[i] is Anthem.CheckBox)
       {
     Anthem.CheckBox HourCheck = Container.Controls[i] as Anthem.CheckBox;
     if (HourCheck.Checked)
     {
       byte Hour;
       if (byte.TryParse(HourCheck.Text, out Hour))
         Values.Add(Hour);
     }
       }
     return Values;
     /*if (Values.Count > 0)
       return Values;
     else
       throw new Exception("GetHoursValues �� ������ ������");*/
 }
    private List<Holiday> GetHolidaysValues(Anthem.ListBox Container)
    {
        List<Holiday> Values = new List<Holiday>();
        foreach (ListItem item in Container.Items)
        {
          string[] parts = item.Text.Split('.');
          if (parts.Length < 2)
        throw new Exception("������ �������� ��������� '" + item.Text + "' ����� �������� ������");

          Holiday holiday = new Holiday(0, 0, 0);
          if (byte.TryParse(parts[0], out holiday.Day) && holiday.Day >= 1 && holiday.Day <= 31)
          {
        if (byte.TryParse(parts[1], out holiday.Month) && holiday.Month >= 1 && holiday.Month <= 12)
        {
          if (parts.Length > 2)
          {
            if (ushort.TryParse(parts[2], out holiday.Year) && holiday.Year >= DateTime.Now.Year - 10)
            {
              Values.Add(holiday);
            }
            else
              throw new Exception("���������� '���' ������ �������� ��������� '" + item.Text + "' ����� �������� ������");
          }
          else
            Values.Add(holiday);
        }
        else
          throw new Exception("���������� '�����' ������ �������� ��������� '" + item.Text + "' ����� �������� ������");
          }
          else
        throw new Exception("���������� '����' ������ �������� ��������� '" + item.Text + "' ����� �������� ������");
        }
        return Values;
        /*if (Values.Count > 0)
          return Values;
        else
          throw new Exception("GetHolidaysValues �� ������ ������");*/
    }
 private List<DayOfWeek> GetDayOfWeekValues(Anthem.Panel Container)
 {
     List<DayOfWeek> Values = new List<DayOfWeek>();
     for (int i = 0; i < Container.Controls.Count; i++)
       if (Container.Controls[i] is Anthem.CheckBox)
       {
     Anthem.CheckBox DOWCheck = Container.Controls[i] as Anthem.CheckBox;
     if (DOWCheck.Checked)
     {
       byte DOW;
       if (byte.TryParse(DOWCheck.ID.Replace("APDayOfWeek", ""), out DOW))
         Values.Add((DayOfWeek)DOW);
     }
       }
     return Values;
     /*if (Values.Count > 0)
       return Values;
     else
       throw new Exception("GetDayOfWeekValues �� ������ ������");*/
 }
Exemplo n.º 15
0
        private void SetupCheckBoxes(Anthem.CheckBoxList list)
        {
            // Setup the checkboxes so that full-control takes over the others,
            // and there cannot be an action that is both granted and denied
            // The list parameter determines the last checkbox list that changed status,
            // allowing to switch the proper checkbox pair
            if(lstActionsGrant.Items.Count > 0) {
                if(list == null) list = lstActionsGrant;
                Anthem.CheckBoxList other = list == lstActionsGrant ? lstActionsDeny : lstActionsGrant;

                // Verify whether full-control is checked
                // If so, disable all other checkboxes
                for(int i = 1; i < list.Items.Count; i++) {
                    if(list.Items[0].Selected) {
                        list.Items[i].Selected = false;
                        list.Items[i].Enabled = false;
                        other.Items[i].Enabled = true;
                    }
                    else {
                        list.Items[i].Enabled = true;
                    }
                }

                // Switch status of other list checkboxes
                for(int i = 0; i < other.Items.Count; i++) {
                    if(i > 0 && other.Items[0].Selected) {
                        other.Items[i].Selected = false;
                        other.Items[i].Enabled = false;
                    }
                    else {
                        if(other.Items[i].Enabled && list.Items[i].Enabled && list.Items[i].Selected) {
                            other.Items[i].Selected = false;
                        }
                    }
                }
            }
        }
    // Anti Froad
    private void SetAntiFraudPanel(Anthem.Panel Container, CardCounters Counters, AntiFraudParameter Value)
    {
        CardCounter Counter = Counters[Value.CounterName];
        int Index = 0;

        for (int i = 0; i < Container.Controls.Count; i++)
          if (Container.Controls[i] is Anthem.CheckBox)
          {
        // ���� ������ TextBox
        for (int j = i; j < Container.Controls.Count; j++)
          if ((Container.Controls[j] is Anthem.TextBox) && (Container.Controls[j] as Anthem.TextBox).TextMode == TextBoxMode.SingleLine)
          {
            // ���� ������� TextBox
            for (int k = j; k < Container.Controls.Count; k++)
              if ((Container.Controls[k] is Anthem.TextBox) && (Container.Controls[k] as Anthem.TextBox).TextMode == TextBoxMode.MultiLine)
              {
                Anthem.CheckBox InfoCheck = Container.Controls[i] as Anthem.CheckBox;
                Anthem.TextBox LimitText = Container.Controls[j] as Anthem.TextBox;
                Anthem.TextBox MessageText = Container.Controls[k] as Anthem.TextBox;

                InfoCheck.Checked = Index == 0 ? Value.CheckMaximumValue : Value.CheckMinimumValue;
                LimitText.Text = Index == 0 ? Counter.ValueToString(Value.MaximumValue) : Counter.ValueToString(Value.MinimumValue);
                MessageText.Text = Index == 0 ? Value.MaximumMessage : Value.MinimumMessage;

                Index++;
                break;
              }
            break;
          }
          }
    }
Exemplo n.º 17
0
 internal CallBackFilter(Anthem.Manager manager, Stream next)
 {
     _manager = manager;
     _next = next;
     _buffer = new MemoryStream();
 }
 // strings
 private void SetStringValues(Anthem.ListBox Container, List<string> Values)
 {
     Container.Items.Clear();
     if (Values != null)
       foreach (string s in Values)
     Container.Items.Add(new ListItem(s));
 }