Exemplo n.º 1
0
        public static Firm EditFirm(Firm data)
        {
            var win = new FirmEditorForm();

            win.SetData(data);
            if (win.ShowDialog() == DialogResult.OK)
            {
                return(win.GetData());
            }
            return(null);
        }
Exemplo n.º 2
0
        private void butAddFirm_Click(object sender, EventArgs e)
        {
            var obj = FirmEditorForm.AddFirm();

            if (obj != null)
            {
                DataManager.Firms.Add(obj);
                DataManager.SaveFirm();

                lvFirms.Items.Add(CreateListViewItem(obj));
            }
        }
Exemplo n.º 3
0
        public static Firm AddFirm()
        {
            var win = new FirmEditorForm();
            var id  = DataManager.FirmGetNewId();

            win.lbId.Text            = id.ToString();
            win.cbSpec.SelectedIndex = 0;
            win.cbToo.SelectedIndex  = 0;
            if (win.ShowDialog() == DialogResult.OK)
            {
                return(win.GetData());
            }
            return(null);
        }
Exemplo n.º 4
0
        private void EditFirm()
        {
            if (lvFirms.Items == null || lvFirms.Items.Count == 0)
            {
                return;
            }
            Firm data = null;

            if (lvFirms.SelectedItems == null || lvFirms.SelectedItems.Count == 0)
            {
                lvFirms.Items[0].Selected = true;
                data = (Firm)lvFirms.Items[0].Tag;
            }
            else
            {
                data = (Firm)lvFirms.SelectedItems[0].Tag;
            }

            var obj = FirmEditorForm.EditFirm(data);

            if (obj != null)
            {
                for (var i = 0; i < DataManager.Firms.Count; i++)
                {
                    if (DataManager.Firms[i].Id == obj.Id)
                    {
                        DataManager.Firms[i] = obj;
                        break;
                    }
                }
                DataManager.SaveFirm();

                for (var i = 0; i < lvFirms.Items.Count; i++)
                {
                    if (((Firm)lvFirms.Items[i].Tag).Id == obj.Id)
                    {
                        lvFirms.Items[i] = CreateListViewItem(obj);
                        break;
                    }
                }
            }
        }