private void AddButtonClick(object sender, EventArgs e)
 {
     using (var dataForm = new FormEntityData())
     {
         dataForm.ShowDialog();
         if (dataForm.EntityData != null)
             AddEntity(dataForm.EntityData);
     }
 }
Exemple #2
0
 void btnAdd_Click(object sender, EventArgs e)
 {
     using (FormEntityData frmEntityData = new FormEntityData())
     {
         frmEntityData.ShowDialog();
         if (frmEntityData.EntityData != null)
         {
             AddEntity(frmEntityData.EntityData);
         }
     }
 }
Exemple #3
0
        void btnAdd_Click(object sender, EventArgs e)
        {
            using (FormEntityData frmEntityData = new FormEntityData())
            {
                frmEntityData.ShowDialog();

                if (frmEntityData.EntityData != null)
                {
                    AddEntity(frmEntityData.EntityData);
                }
            }
        }
        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();

                EntityData data    = entityDataManager.EntityData[entity];
                EntityData newData = null;

                using (FormEntityData frmEntityData = new FormEntityData())
                {
                    frmEntityData.EntityData = data;
                    frmEntityData.ShowDialog();

                    if (frmEntityData.EntityData == null)
                    {
                        return;
                    }

                    if (frmEntityData.EntityData.EntityName == entity)
                    {
                        entityDataManager.EntityData[entity] = frmEntityData.EntityData;
                        FillListBox();
                        return;
                    }

                    newData = frmEntityData.EntityData;
                }

                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 (entityDataManager.EntityData.ContainsKey(newData.EntityName))
                {
                    MessageBox.Show("Entry already exists. Use Edit to modify the entry.");
                    return;
                }

                lbDetails.Items.Add(newData);
                entityDataManager.EntityData.Add(newData.EntityName, newData);
            }
        }
Exemple #5
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();

                EntityData data = entityDataManager.EntityData[entity];
                EntityData newData = null;

                using (FormEntityData frmEntityData = new FormEntityData())
                {
                    frmEntityData.EntityData = data;
                    frmEntityData.ShowDialog();

                    if (frmEntityData.EntityData == null)
                        return;

                    if (frmEntityData.EntityData.EntityName == entity)
                    {
                        entityDataManager.EntityData[entity] = frmEntityData.EntityData;
                        FillListBox();
                        return;
                    }

                    newData = frmEntityData.EntityData;
                }

                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 (entityDataManager.EntityData.ContainsKey(newData.EntityName))
                {
                    MessageBox.Show("Entry already exists. Use Edit to modify the entry.");
                    return;
                }

                lbDetails.Items.Add(newData);
                entityDataManager.EntityData.Add(newData.EntityName, newData);
            }
        }
        private void EditButtonClick(object sender, EventArgs e)
        {
            if (DetailList.SelectedItem == null)
                return;

            string name = DetailList.SelectedItem.ToString().Split(':')[0];
            EntityData data = EntityManager.EntityData[name];
            EntityData newData;
            using (var dataForm = new FormEntityData())
            {
                dataForm.EntityData = data;
                dataForm.ShowDialog();
                if (dataForm.EntityData == null)
                    return;

                if (dataForm.EntityData.Name == name)
                {
                    EntityManager.EntityData[name] = dataForm.EntityData;
                    LoadClasses();
                    return;
                }

                newData = dataForm.EntityData;
            }
            DialogResult result = MessageBox.Show("Name has changed. Do you want to add a new entry?", "New Entry",
                                                  MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (result != DialogResult.Yes)
                return;

            if (EntityManager.EntityData.ContainsKey(newData.Name))
            {
                MessageBox.Show("Entry already exists. Use Edit to modify the entry.", "Entry Exists",
                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            DetailList.Items.Add(newData);
            EntityManager.EntityData.Add(newData.Name, newData);
        }