示例#1
0
 void btnAdd_Click(object sender, EventArgs e)
 {
     using (FormKeyDetails frmKeyDetails = new FormKeyDetails())
     {
         frmKeyDetails.ShowDialog();
         if (frmKeyDetails.Key != null)
         {
             AddKey(frmKeyDetails.Key);
         }
     }
 }
示例#2
0
        void btnAdd_Click(object sender, EventArgs e)
        {
            using (FormKeyDetails frmKeyDetails = new FormKeyDetails())
            {
                frmKeyDetails.ShowDialog();

                if (frmKeyDetails.Key != null)
                {
                    AddKey(frmKeyDetails.Key);
                }
            }
        }
示例#3
0
        void btnEdit_Click(object sender, EventArgs e)
        {
            if (lbDetails.SelectedItem != null)
            {
                string   detail = lbDetails.SelectedItem.ToString();
                string[] parts  = detail.Split(',');
                string   entity = parts[0].Trim();

                KeyData data    = ItemDataManager.KeyData[entity];
                KeyData newData = null;

                using (FormKeyDetails frmKeyData = new FormKeyDetails())
                {
                    frmKeyData.Key = data;
                    frmKeyData.ShowDialog();

                    if (frmKeyData.Key == null)
                    {
                        return;
                    }

                    if (frmKeyData.Key.Name == entity)
                    {
                        ItemDataManager.KeyData[entity] = frmKeyData.Key;
                        FillListBox();
                        return;
                    }

                    newData = frmKeyData.Key;
                }

                DialogResult result = MessageBox.Show(
                    "Name has changed. Do you want to add a new entry?",
                    "New Entry",
                    MessageBoxButtons.YesNo);

                if (result == DialogResult.No)
                {
                    return;
                }

                if (ItemDataManager.KeyData.ContainsKey(newData.Name))
                {
                    MessageBox.Show("Entry already exists. Use Edit to modify the entry.");
                    return;
                }

                lbDetails.Items.Add(newData);
                ItemDataManager.KeyData.Add(newData.Name, newData);
            }
        }
示例#4
0
        void btnEdit_Click(object sender, EventArgs e)
        {
            if (lbDetails.SelectedItem != null)
            {
                string detail = lbDetails.SelectedItem.ToString();
                string[] parts = detail.Split(',');
                string entity = parts[0].Trim();

                KeyData data = itemManager.KeyData[entity];
                KeyData newData = null;

                using (FormKeyDetails frmKeyData = new FormKeyDetails())
                {
                    frmKeyData.Key = data;
                    frmKeyData.ShowDialog();

                    if (frmKeyData.Key == null)
                        return;

                    if (frmKeyData.Key.Name == entity)
                    {
                        itemManager.KeyData[entity] = frmKeyData.Key;
                        FillListBox();
                        return;
                    }

                    newData = frmKeyData.Key;
                }

                DialogResult result = MessageBox.Show(
                    "Name has changed. Do you want to add a new entry?",
                    "New Entry",
                    MessageBoxButtons.YesNo);

                if (result == DialogResult.No)
                    return;

                if (itemManager.KeyData.ContainsKey(newData.Name))
                {
                    MessageBox.Show("Entry already exists. Use Edit to modify the entry.");
                    return;
                }

                lbDetails.Items.Add(newData);
                itemManager.KeyData.Add(newData.Name, newData);
            }
        }
示例#5
0
        public void Edit_Click(object sender, EventArgs e)
        {
            if (lbDetails.SelectedItem != null)
            {
                string detail = Convert.ToString(lbDetails.SelectedItem);
                string[] parts = detail.Split(',');
                string entity = parts[0];

                KeyData data = itemDataManager.KeyData[entity];
                KeyData key = null;

                using (FormKeyDetails frmKeyDetails = new FormKeyDetails())
                {
                    frmKeyDetails.Key = data;
                    frmKeyDetails.ShowDialog();

                    if (frmKeyDetails == null)
                    {
                        return;
                    }

                    if (frmKeyDetails.Key.Name == entity)
                    {
                        itemDataManager.KeyData[entity] = frmKeyDetails.Key;
                        FillListBox();
                        return;
                    }

                    key = frmKeyDetails.Key;
                }

                DialogResult result = MessageBox.Show("Name has changed. Do you want to add a new entry?",
                    "New Entry", MessageBoxButtons.YesNo);

                if (result == DialogResult.No)
                {
                    return;
                }

                if (itemDataManager.KeyData.ContainsKey(key.Name))
                {
                    MessageBox.Show("Entry already exists. Do you want to overwrite?", "Existing Entry",
                        MessageBoxButtons.YesNo);

                    return;
                }

                lbDetails.Items.Add(key);
                itemDataManager.KeyData.Add(key.Name, key);
            }
        }