// ------------------------------------------------------------------------------------- /// <summary> /// Form load event. If CurrentID is specified we are in update mode, so we must init /// then control's values. /// </summary> // ------------------------------------------------------------------------------------- private void frmDictionaryEdit_Load(object sender, EventArgs e) { if (CurrentID.IsNull) { m_data = new DictionaryContainer(); FillDatagrid(DBGuid.Null); } else { // Fill controls RetrieveData(); } txtWord.Select(); }
public virtual DictionaryContainer DictionarySelectAll() { TraceCallEnterEvent.Raise(); try { DictionaryContainer result; DataSet entitySet = m_DataContext.ndihdDictionarySelectAll(); result = new DictionaryContainer(entitySet.Tables[0]); TraceCallReturnEvent.Raise(); return result; } catch (Exception ex) { ExceptionManager.Publish(ex); TraceCallReturnEvent.Raise(false); throw; } }
// ------------------------------------------------------------------------------------- /// <summary> /// Fill datagrid with data, get relations for keyword /// </summary> // ------------------------------------------------------------------------------------- private void FillDatagrid(DBGuid wordRef) { try { string sortColumn = "Word"; int selectedRow = -1; // Storing the previous sort order if (dtgMain.DataSource != null) { sortColumn = ((DataTable) dtgMain.DataSource).DefaultView.Sort; } // Retrieving data from BusinessServices if (m_data == null) { m_data = new DictionaryContainer(); IDictionaryService srv = ServiceFactory.GetDictionaryService(); DictionaryAssocContainer assocs = srv.SelectChildrenByWordOfDictionary(wordRef); DictionaryContainer all = srv.DictionarySelectAll(); foreach (DictionaryAssoc ass in assocs.All) { if (ass.WordID == wordRef) { Dictionary related = (Dictionary) all[ass.RefWordId.ToString()]; if (related != null) { m_data.Add(related); } } } } DataTable dt = m_data.CurrentAsDatatable; dt.DefaultView.Sort = sortColumn; dtgMain.DataSource = dt; // locates the row specified by ID param if (! wordRef.IsNull) { BindingManagerBase bm = dtgMain.BindingContext[dtgMain.DataSource, dtgMain.DataMember]; DataRow dr; int nPositionStart = bm.Position; for (int i = 0; i < bm.Count; i++) { dr = ((DataRowView) bm.Current).Row; if (wordRef.Value.Equals(dr["ID"])) { selectedRow = i; break; } bm.Position += 1; } bm.Position = nPositionStart; } // makes the row selected if (selectedRow <= ((DataTable) dtgMain.DataSource).DefaultView.Count && selectedRow > -1) { dtgMain.Select(selectedRow); dtgMain.CurrentRowIndex = selectedRow; } } catch (Exception ex) { // --- Log exception ExceptionManager.Publish(ex); // --- Display Exception ErrorHandler.DisplayError("Nem várt hiba a lista frissítése során.", ex); } }
public DictionaryContainer DictionarySelectFiltered(Dictionary filter) { TraceCallEnterEvent.Raise(); try { DictionaryContainer result; DataSet entitySet = m_DataContext.ndihdDictionarySelectFiltered(filter.Word, filter.English, filter.FilterOnProfessional, filter.FilterOnIsactive); result = new DictionaryContainer(entitySet.Tables[0]); TraceCallReturnEvent.Raise(); return result; } catch (Exception ex) { ExceptionManager.Publish(ex); TraceCallReturnEvent.Raise(false); throw; } }