Ejemplo n.º 1
0
        private void addOrgStripButton_Click(object sender, EventArgs e)
        {
            try
            {
                EditOrgForm tmpForm = new EditOrgForm(_connection);
                tmpForm.Owner = this;
                DialogResult dRes = tmpForm.ShowDialog(this);
                if (dRes == DialogResult.OK)
                {
                    DataRowView row = _orgBS.AddNew() as DataRowView;
                    if (row != null)
                    {
                        row.BeginEdit();
                        row[Org.regnum]     = tmpForm.RegnumOrg;
                        row[Org.name]       = tmpForm.NameOrg;
                        row[Org.chief_post] = tmpForm.ChiefpostOrg;
                        row[Org.chief_fio]  = tmpForm.ChieffioOrg;
                        row[Org.booker_fio] = tmpForm.BookerfioOrg;
                        row.EndEdit();

                        int pos = _orgBS.Position;
                        _orgAdapter.Update(_orgTable);
                        _orgTable.Clear();
                        _orgAdapter.Fill(_orgTable);
                        _orgBS.Position = pos;
                        MainForm.ShowInfoMessage("Организация успешно добавлена!", "Добавление организации");
                        _dialogResult = DialogResult.OK;
                    }
                }
            }
            catch (Exception ex)
            {
                MainForm.ShowErrorMessage(ex.Message, "Ошибка добавления организации");
            }
        }
Ejemplo n.º 2
0
        private void editOrgStripButton_Click(object sender, EventArgs e)
        {
            DataRowView curOrg = (DataRowView)_orgBS.Current;

            if (curOrg == null)
            {
                MainForm.ShowInfoMessage("Необходимо выбрать запись!", "Ошибка выбора организации");
                return;
            }
            EditOrgForm tmpForm = new EditOrgForm(_connection);

            tmpForm.Owner        = this;
            tmpForm.OrgId        = (long)curOrg[Org.id];
            tmpForm.RegnumOrg    = (string)curOrg[Org.regnum];
            tmpForm.NameOrg      = (string)curOrg[Org.name];
            tmpForm.ChiefpostOrg = (string)curOrg[Org.chief_post];
            tmpForm.ChieffioOrg  = (string)curOrg[Org.chief_fio];
            tmpForm.BookerfioOrg = (string)curOrg[Org.booker_fio];
            DialogResult dRes = tmpForm.ShowDialog(this);

            if (dRes == DialogResult.OK)
            {
                curOrg.BeginEdit();
                curOrg[Org.regnum]     = tmpForm.RegnumOrg;
                curOrg[Org.name]       = tmpForm.NameOrg;
                curOrg[Org.chief_post] = tmpForm.ChiefpostOrg;
                curOrg[Org.chief_fio]  = tmpForm.ChieffioOrg;
                curOrg[Org.booker_fio] = tmpForm.BookerfioOrg;
                curOrg.EndEdit();

                int pos = _orgBS.Position;
                _orgAdapter.Update(_orgTable);
                _orgTable.Clear();
                _orgAdapter.Fill(_orgTable);
                _orgBS.Position = pos;
                MainForm.ShowInfoMessage("Изменения успешно сохранены!", "Изменение организации");
                _dialogResult = DialogResult.OK;
            }
        }