private void CopyPacketForm_Load(object sender, EventArgs e) { label2.Text += _listId; _orgTable = Org.CreateTable(); _orgTable.Columns.Add(ViewCol); _orgBS = new BindingSource(); _orgBS.DataSource = _orgTable; orgsComboBox.DataSource = _orgBS; orgsComboBox.ValueMember = Org.id; orgsComboBox.DisplayMember = ViewCol; if (_operator == null) { MainForm.ShowErrorMessage("Пользователь не найден", "Ошибка"); this.Close(); return; } string selectText; if (_operator.candeleteVal == 0) { selectText = Org.GetSelectCommandText(); } else { selectText = Org.GetSelectTextByOperator(_operator.idVal); } SQLiteDataAdapter adapter = new SQLiteDataAdapter(selectText, _connection); _orgTable.Rows.Clear(); adapter.Fill(_orgTable); foreach (DataRow rowItem in _orgTable.Rows) { rowItem[ViewCol] = string.Format("{0} {1}", rowItem[Org.regnum], rowItem[Org.name]); } _orgTable.AcceptChanges(); if (_orgBS.Count < 1) { copyButton.Enabled = false; } //TODO: this.SetPrivilege(); }
private void ReloadData() { int position = -1; if (_orgBS != null) { position = _orgBS.Position; } _orgTable = Org.CreateTable(); _orgTable.Columns.Add(ViewCol); _orgBS = new BindingSource(); _orgBS.DataSource = _orgTable; string selectText = _operator.candeleteVal == 0 ? Org.GetSelectCommandText() : Org.GetSelectTextByOperator(_operator.idVal); SQLiteDataAdapter adapter = new SQLiteDataAdapter(selectText, _mainConnection); adapter.Fill(_orgTable); foreach (DataRow rowItem in _orgTable.Rows) { rowItem[ViewCol] = string.Format("{0} {1}", rowItem[Org.regnum], rowItem[Org.name]); } _orgTable.AcceptChanges(); orgBox.DataSource = _orgBS; orgBox.DisplayMember = ViewCol; _orgBS.Position = position; SetPrivilege(); statusLabel.Text = _operator.nameVal; }