/// <summary> /// Fill datagrid with data /// </summary> // ------------------------------------------------------------------------------------- private void FillDatagrid(DBGuid ID) { try { string sortColumn = "PersonName"; int selectedRow = -1; // storing the previous sort order if (dtgMain.DataSource != null) { sortColumn = ((DataTable) dtgMain.DataSource).DefaultView.Sort; } // retrieving data from BusinessServices string personName = ""; string continuativeName = ""; string targetGroup = ""; if (txtPersonName.Text.Length > 0) personName = txtPersonName.Text; if (txtContinuativeName.Text.Length > 0) continuativeName = txtContinuativeName.Text; if (txtTargetGroup.Text.Length > 0) targetGroup = txtTargetGroup.Text; Continuative filter = new Continuative(DBGuid.Null); filter.PersonName = personName; filter.ContinuativeName = continuativeName; filter.TargetGrop = targetGroup; filter.FilterOnIsactive = DBInt.Null; if (cmbStatus.SelectedIndex > 0) { bool bIsActive = (cmbStatus.SelectedValue.ToString() == "1" ? true : false); filter.FilterOnIsactive = (DBInt) Convert.ToInt32(bIsActive); filter.IsActive = bIsActive; } IContinuativeService srv = ServiceFactory.GetContinuativeService(); m_ContinuativeContainer = srv.ContinuativeSelectFiltered(filter); DataTable dt = m_ContinuativeContainer.AllAsDatatable; dt.DefaultView.Sort = sortColumn; dtgMain.DataSource = dt; // locates the row specified by ID param if (!ID.IsNull) { BindingManagerBase bm = dtgMain.BindingContext[dtgMain.DataSource, dtgMain.DataMember]; DataRow dr; for (int i = 0; i < bm.Count; i++) { dr = ((DataRowView) bm.Current).Row; if (ID.Value.Equals(dr["ID"])) { selectedRow = i; break; } bm.Position += 1; } } // makes the row selected if (selectedRow <= ((DataTable) dtgMain.DataSource).DefaultView.Count && selectedRow > -1) { dtgMain.Select(selectedRow); dtgMain.CurrentRowIndex = selectedRow; } else if (((DataTable) dtgMain.DataSource).DefaultView.Count != 0) { dtgMain.Select(0); } // Enabling or disabling the buttons according to record count. // And is because of previous disable state. bool bIsEmptyGrid = (((DataTable) dtgMain.DataSource).DefaultView.Count == 0); tbbModify.Enabled = ! bIsEmptyGrid; tbbInactivate.Enabled = ! bIsEmptyGrid; } 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 virtual ContinuativeContainer SelectChildrenByContinuativeOfProgram(DBGuid IDVal) { TraceCallEnterEvent.Raise(); try { ContinuativeContainer result; DataSet entitySet = m_DataContext.ndihdContinuativeOfProgramSelectBy(IDVal); result = new ContinuativeContainer(entitySet.Tables[0]); TraceCallReturnEvent.Raise(); return result; } catch (Exception ex) { ExceptionManager.Publish(ex); TraceCallReturnEvent.Raise(false); throw; } }
public ContinuativeContainer ContinuativeSelectFiltered(Continuative filter) { TraceCallEnterEvent.Raise(); try { ContinuativeContainer result; DataSet entitySet = m_DataContext.ndihdContinuativeSelectFiltered(filter.PersonName, filter.ContinuativeName, filter.TargetGrop, filter.FilterOnIsactive); result = new ContinuativeContainer(entitySet.Tables[0]); TraceCallReturnEvent.Raise(); return result; } catch (Exception ex) { ExceptionManager.Publish(ex); TraceCallReturnEvent.Raise(false); throw; } }