예제 #1
0
        private void btnSaveItem_Click(object sender, EventArgs e)
        {
            Regex reg = new Regex("\\d+");

            if (!reg.IsMatch(txtValue.Text))
            {
                txtValue.Text = "0";
                return;
            }
            if (editItemId == Guid.Empty)
            {
                OptionDTO option = new OptionDTO();
                option.DisplayName  = txtLabel.Text;
                option.Value        = int.Parse(txtValue.Text);
                option.Description  = MemoDescription.Text;
                option.OptionId     = Guid.NewGuid();
                option.DisplayOrder = OptionListBindingSource.Count + 1;
                OptionListBindingSource.Add(option);
            }
            else
            {
                OptionDTO option = OptionListBindingSource.Current as OptionDTO;
                if (option != null && option.OptionId == editItemId)
                {
                    option.DisplayName  = txtLabel.Text;
                    option.Value        = int.Parse(txtValue.Text);
                    option.Description  = MemoDescription.Text;
                    option.DisplayOrder = OptionListBindingSource.IndexOf(option);
                }
            }
        }
예제 #2
0
        private void BtnDeleteOption_Click(object sender, EventArgs e)
        {
            OptionDTO option = OptionListBindingSource.Current as OptionDTO;

            if (option != null)
            {
                OptionListBindingSource.Remove(option);
            }
        }
예제 #3
0
        private void BtnDown_Click(object sender, EventArgs e)
        {
            OptionDTO option = OptionListBindingSource.Current as OptionDTO;

            if (option != null)
            {
                OptionListBindingSource.MoveNext();
                var nextOption = OptionListBindingSource.Current as OptionDTO;
                if (nextOption != null)
                {
                    int orderIndex = nextOption.DisplayOrder ?? 0;
                    nextOption.DisplayOrder = option.DisplayOrder;
                    option.DisplayOrder     = orderIndex;
                    ListSort(nextOption, option);
                }
            }
        }
예제 #4
0
        private void BtnUp_Click(object sender, EventArgs e)
        {
            OptionDTO option = OptionListBindingSource.Current as OptionDTO;

            if (option != null)
            {
                OptionListBindingSource.MovePrevious();
                var preOption = OptionListBindingSource.Current as OptionDTO;
                if (preOption != null)
                {
                    int orderIndex = preOption.DisplayOrder ?? 0;
                    preOption.DisplayOrder = option.DisplayOrder;
                    option.DisplayOrder    = orderIndex;
                    ListSort(option, preOption);
                }
            }
        }