Пример #1
0
        public StdFoxProAttrsDialog(SEPO_STD_FOXPRO_ATTRS attr, IRepository <SEPO_STD_FOXPRO_ATTRS> repo)
            : this(repo)

        {
            DialogType = DialogType.Edit;
            this.Text  = "Редактирование атрибута";
            Attr       = attr;
        }
Пример #2
0
        private void AddItem(SEPO_STD_FOXPRO_ATTRS attr)
        {
            ListViewItem item = new ListViewItem(attr.SHORTNAME);

            item.SubItems.Add(attr.NAME);
            item.SubItems.Add(attr.TYPENAME);
            item.Tag = attr.ID;

            this.Items.Add(item);
        }
Пример #3
0
        private void OnEditItemClick(object sender, EventArgs args)
        {
            if (this.SelectedItems.Count > 0)
            {
                ListViewItem item = this.SelectedItems[0];

                int id = (int)item.Tag;
                SEPO_STD_FOXPRO_ATTRS attr = attrsRepo.GetById(id);

                StdFoxProAttrsDialog dlg = new StdFoxProAttrsDialog(attr, attrsRepo);

                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    UpdateItem(item, dlg.Attr);
                }
            }
        }
Пример #4
0
        private void OnDeleteItemClick(object sender, EventArgs args)
        {
            if (this.SelectedItems.Count > 0)
            {
                ListViewItem item = this.SelectedItems[0];
                decimal      id   = (int)item.Tag;

                try
                {
                    SEPO_STD_FOXPRO_ATTRS attr = attrsRepo.GetById(id);
                    attrsRepo.Delete(attr);

                    this.Items.Remove(item);
                }
                catch (Exception exc)
                {
                    MessageBox.Show(exc.Message);
                }
            }
        }
Пример #5
0
        private void OnOkClicked(object sender, EventArgs args)
        {
            if (DialogType == DialogType.Add)
            {
                try
                {
                    SEPO_STD_FOXPRO_ATTRS attr = new SEPO_STD_FOXPRO_ATTRS();

                    attr.NAME      = nameBox.Text;
                    attr.SHORTNAME = shortnameBox.Text;
                    attr.TYPE_     = (short)typeBox.SelectedValue;

                    attrsRepo.Create(attr);
                    Attr = attr;

                    DialogResult = DialogResult.OK;
                }
                catch (Exception exc)
                {
                    MessageBox.Show(exc.Message);
                }
            }
            else
            {
                try
                {
                    Attr.SHORTNAME = shortnameBox.Text;
                    Attr.NAME      = nameBox.Text;
                    Attr.TYPE_     = (short)typeBox.SelectedValue;

                    attrsRepo.Update(Attr);

                    DialogResult = DialogResult.OK;
                }
                catch (Exception exc)
                {
                    MessageBox.Show(exc.Message);
                }
            }
        }
Пример #6
0
 private void UpdateItem(ListViewItem item, SEPO_STD_FOXPRO_ATTRS attr)
 {
     item.SubItems[0].Text = attr.SHORTNAME;
     item.SubItems[1].Text = attr.NAME;
     item.SubItems[2].Text = attr.TYPENAME;
 }