Exemplo n.º 1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            CustomRowset cr = new CustomRowset(txtRowsetName.Text, rdEnable.Checked, txtIdentifier.Text, cbType.Text);

            if (rdAddRowset.Checked)
            {
                if (CustomRowset.GetAllCustomRowsets().ContainsKey(cr.name))
                {
                    logger.LogMessage(String.Format("rowset name {0} already exists. Use edit to modify this rowset", cr.name), MessageOptions.Dialog);
                    return;
                }
                CustomRowset.Add(cr);
            }
            else if (rdEditRowset.Checked)
            {
                CustomRowset.Save(cbSelectRowset.Text, cr);
            }
            else if (rdDelete.Checked)
            {
                if (cbSelectRowset.Text.Trim().Length == 0)
                {
                    logger.LogMessage(String.Format("The rowset list is either empty or you haven't chosen anything to delete yet. try again", cr.name), MessageOptions.Dialog);
                    return;
                }
                CustomRowset.Delete(cbSelectRowset.Text);
            }

            if (CustomRowset.GetAllCustomRowsets().Count == 0)
            {
                rdAddRowset.Checked = true;
            }
            PopulateRowset(null);
            Application.DoEvents();
            this.Refresh();
        }
Exemplo n.º 2
0
        void PopulateRowset(String DefaultItem)
        {
            cbSelectRowset.Items.Clear();
            SortedDictionary <string, CustomRowset> cr = CustomRowset.GetAllCustomRowsets();

            if (cr.Count == 0)
            {
                cbSelectRowset.Text = "";
                cbSelectRowset.Refresh();
                Application.DoEvents();
                return;
            }

            foreach (String key in cr.Keys)
            {
                cbSelectRowset.Items.Add(key);
            }

            if (null == DefaultItem)
            {
                cbSelectRowset.SelectedIndex = 0;
            }
            else
            {
                cbSelectRowset.SelectedItem = DefaultItem;
            }

            cbSelectRowset.Refresh();
            Application.DoEvents();
        }