public void SetDataSource(object dataSource, bool retrieveStructure) { grdData.DataSource = dataSource; grdData.Refetch(); if (retrieveStructure) { grdData.RetrieveStructure(); RebindGridToolbox(); } }
public void SetDataSource(object dataSource, bool retrieveStructure) { grdData.DataSource = dataSource; grdData.Refetch(); if (retrieveStructure) { grdData.RetrieveStructure(); } ////<BugFix> ////TODO: esto es para salvar el error de la Janus que no hace la asignación de los campos al objeto cuando el DataSource está vacio if ((grdData.RecordCount == 0) && (grdData.DataSource is IList)) { bugFix = true; (grdData.DataSource as IList).Add(RequireCreatePersistent()); } ////</BugFix> }
public void SetDataSource(object dataSource, bool retrieveStructure) { if (dataSource is IList) { this.dataSource = dataSource as IList; Rebind(); } else { grdItems.DataSource = dataSource; } grdItems.Refetch(); if (retrieveStructure) { grdItems.RetrieveStructure(); if (ResetLayout != null) { ResetLayout(grdItems, ItemType); } } }
public override void Init() { GameService.DbContext.GameResultValueSet.Where(f => f.GameResult.Game.StageId == Stage.Id).Load(); Data = new Dictionary <CompetitionReferee, DataTable>(); var refereeIndex = 1; foreach (var referee in GameService.DbContext.CompetitionRefereeSet.Where(f => f.CompetitionId == Stage.CompetitionId)) { var page = new Janus.Windows.UI.Tab.UITabPage(referee.IsMainReferee ? "Гл. судья" : "Судья №" + refereeIndex.ToString()) { Tag = referee }; if (!referee.IsMainReferee) { refereeIndex++; } refereeTabs.TabPages.Add(page); var grid = new GridEX() { Dock = DockStyle.Fill, Name = "gridReferee" }; page.Controls.Add(grid); var dt = GetTable(Stage, referee); grid.DataSource = dt; grid.RetrieveStructure(); grid.RootTable.Columns["Команда"].EditType = EditType.NoEdit; if (grid.RootTable.Columns.Contains("Жеребьевка")) { grid.RootTable.Columns["Жеребьевка"].EditType = EditType.NoEdit; grid.RootTable.SortKeys.Add(grid.RootTable.Columns["Жеребьевка"], Janus.Windows.GridEX.SortOrder.Ascending); } else { grid.RootTable.SortKeys.Add(grid.RootTable.Columns["Команда"], Janus.Windows.GridEX.SortOrder.Ascending); } grid.GroupByBoxVisible = false; grid.ColumnAutoSizeMode = ColumnAutoSizeMode.ColumnHeader; grid.ColumnAutoResize = true; grid.RootTable.Columns.Cast <GridEXColumn>().ToList().ForEach(f => { if (dt.Columns[f.DataMember].DataType == typeof(int)) { var condition = new GridEXFormatCondition(); condition.Column = f; condition.ConditionOperator = ConditionOperator.IsEmpty; condition.FormatStyle.BackColor = Color.LightBlue; condition.TargetColumn = f; grid.RootTable.FormatConditions.Add(condition); } }); Data.Add(referee, dt); dt.RowChanged += dt_RowChanged; grid.RowHeaderContent = RowHeaderContent.RowPosition; grid.RowHeaders = InheritableBoolean.True; grid.EnsureVisible(1); } /* * var analizPage = new Janus.Windows.UI.Tab.UITabPage("Анализ") * { * * }; * * refereeTabs.TabPages.Add(analizPage); * var analiz = new StageResultCalculatorView() { Dock = DockStyle.Fill, Stage = Stage }; * analiz.Init(Stage.Competition); * analizPage.Controls.Add(analiz); */ }
public void Init() { // DbContext.TeamSet.Load(); //DbContext.CompetitionSet.Load(); //DbContext.CompetitionScoreSet.Load(); var teams = DbContext.TeamSet.Where(f => f.Used).ToList(); var competitions = DbContext.CompetitionSet.ToList(); var scores = DbContext.CompetitionScoreSet.ToList(); _table = new DataTable(); _table.Columns.Add("Команда", typeof(string)); _table.Columns.Add("Место", typeof(double)); _table.Columns.Add("Баллы", typeof(double)); var data = new Dictionary <Competition, Tuple <DataColumn, DataColumn> >(); foreach (var c in competitions) { data.Add(c, new Tuple <DataColumn, DataColumn>( _table.Columns.Add(c.Name + "- мeсто", typeof(double)), _table.Columns.Add(c.Name + "- баллы", typeof(double)))); } var teamScores = new List <TeamScore>(); foreach (var team in teams) { var row = _table.NewRow(); row["Команда"] = team.Name; double totalScore = 0; foreach (var c in competitions) { double place = teams.Count; var score = scores.FirstOrDefault(f => f.TeamId == team.Id && f.CompetitionId == c.Id); if (score != null) { place = score.Place; } double ball = place; if (c.Type == GameType.TourRelay) { ball = place * 3; } else { ball = place * 2; } totalScore += ball; row[data[c].Item1] = place; row[data[c].Item2] = ball; } row["Баллы"] = totalScore; _table.Rows.Add(row); teamScores.Add(new TeamScore() { Team = team, Score = totalScore }); } var nextPlace = 1; foreach (var g in teamScores.GroupBy(f => f.Score).OrderBy(f => f.Key)) { double place = 0; for (int i = nextPlace; i < nextPlace + g.Count(); i++) { place += i; } place = place / g.Count(); nextPlace += g.Count(); g.ToList().ForEach(f => { f.Place = place; }); } foreach (var row in _table.Rows.Cast <DataRow>()) { row["Место"] = teamScores.First(f => f.Team.Name == row["Команда"].ToString()).Place; } GridEX.DataSource = _table; GridEX.RetrieveStructure(); foreach (var h in GridEX.RootTable.Columns.Cast <GridEXColumn>()) { h.AutoSizeMode = ColumnAutoSizeMode.AllCellsAndHeader; h.AutoSize(); } GridEX.RootTable.SortKeys.Add(GridEX.RootTable.Columns["Баллы"]); }