예제 #1
0
        //Add Row to Logic and GUI
        void AddRowToDataAndView()
        {
            int rowNumber = NewBalanceDataGridView.RowCount; // will be correct row index when we add a row

            NewBalanceDataGridView.Rows.Add();
            ViewData.AddRow();

            // prevent a bunch of event call updates and just update manually here
            for (int i = 0; i < NewBalanceDataGridView.ColumnCount; i++)
            {
                NewBalanceDataGridView.Rows[rowNumber].Cells[i].Value = ViewData.GetCell(rowNumber, i).Value;
            }

            for (int i = 0; i < NewBalanceDataGridView.ColumnCount; i++)
            {
                if (ViewData.GetCellType(rowNumber, i) == CellType.Multiple)
                {
                    MultipleCell mc = ViewData.GetCell(rowNumber, i) as MultipleCell;
                    mc.NotifyHeaderNameChange += mc_NotifyHeaderNameChange;
                    mc.CellValueChanged       += NewBalance_CellValueChanged;
                    mc.NotifyDependents       += NewBalance_NotifyDependents;

                    foreach (var cell in mc.CellOptions)
                    {
                        cell.CellValueChanged += NewBalance_CellValueChanged;
                        cell.NotifyDependents += NewBalance_NotifyDependents;
                    }
                }
                else
                {
                    Cell c = ViewData.GetCell(rowNumber, i);
                    c.CellValueChanged += NewBalance_CellValueChanged;
                    c.NotifyDependents += NewBalance_NotifyDependents;
                }
            }
        }
예제 #2
0
        private GridData GetClientGridLocal(GridState state)
        {
            ValidationUtils.NotNull(state, "Неверное значение входного параметра.");

            GridData model = new GridData();

            //model.AddColumn("Action", "Действие", Unit.Pixel(70));
            model.AddColumn("Number", "№ акк.", Unit.Pixel(35), align: GridColumnAlign.Right);
            model.AddColumn("CreationDate", "Дата создания", Unit.Pixel(20));
            model.AddColumn("LastActivityDate", "Последняя активность", Unit.Pixel(60));
            model.AddColumn("Type", "Тип", Unit.Pixel(100));
            model.AddColumn("DisplayName", "Название", Unit.Percentage(40));
            model.AddColumn("AdminDisplayName", "ФИО администратора", Unit.Percentage(30));
            model.AddColumn("AdminEmail", "E-mail администратора", Unit.Pixel(100));
            model.AddColumn("Phone", "Телефон", Unit.Pixel(100));
            model.AddColumn("PromoCode", "Промокод", Unit.Pixel(60));
            model.AddColumn("PrepaymentSum", "Неизрасх. аванс (руб.)", Unit.Pixel(67), align: GridColumnAlign.Right);
            model.AddColumn("CurrentConfiguration", "Текущая конфигурация", Unit.Percentage(30));
            model.AddColumn("DBServerName", "Сервер БД", Unit.Pixel(65));
            model.AddColumn("DBName", "БД", Unit.Pixel(90));
            model.AddColumn("Id", "", Unit.Pixel(0), GridCellStyle.Hidden);

            model.State = state;

            var clientList = clientRepository.GetFilteredList(state);

            foreach (var client in clientList)
            {
                var actions = new GridActionCell("Action");
                actions.AddAction("Заблокировать", "block_link");

                var currentConfigurationName = "";
                var currentServiceSet        = client.ServiceSets.Where(x => x.IsCurrent).FirstOrDefault();

                if (currentServiceSet != null)
                {
                    currentConfigurationName = currentServiceSet.Configuration.Name;
                }

                GridRowStyle style = GridRowStyle.Normal;
                // не заходили больше недели
                if ((DateTime.Now - client.LastActivityDate).Days > 7)
                {
                    style = GridRowStyle.Error;
                }
                // зарегистрированы сегодня
                if (client.CreationDate.Date == DateTime.Today)
                {
                    style = GridRowStyle.Success;
                }

                model.AddRow(new GridRow(
                                 //actions,
                                 new GridLabelCell("Number")
                {
                    Value = client.Number.ForDisplay()
                },
                                 new GridLabelCell("CreationDate")
                {
                    Value = client.CreationDate.ToShortDateString() + " " + client.CreationDate.ToShortTimeString()
                },
                                 new GridLabelCell("LastActivityDate")
                {
                    Value = client.LastActivityDate.ToShortDateString() + " " + client.LastActivityDate.ToShortTimeString()
                },
                                 new GridLabelCell("Type")
                {
                    Value = client.Type.GetDisplayName()
                },
                                 new GridLabelCell("DisplayName")
                {
                    Value = client.DisplayName
                },
                                 new GridLabelCell("AdminDisplayName")
                {
                    Value = client.Users.First(x => x.IsClientAdmin).DisplayName
                },
                                 new GridLabelCell("AdminEmail")
                {
                    Value = client.AdminEmail
                },
                                 new GridLabelCell("Phone")
                {
                    Value = client.Phone
                },
                                 new GridLabelCell("PromoCode")
                {
                    Value = client.PromoCode
                },
                                 new GridLabelCell("PrepaymentSum")
                {
                    Value = client.PrepaymentSum.ForDisplay()
                },
                                 new GridLabelCell("CurrentConfiguration")
                {
                    Value = currentConfigurationName
                },
                                 new GridLabelCell("DBServerName")
                {
                    Value = client.DBServerName
                },
                                 new GridLabelCell("DBName")
                {
                    Value = client.DBName
                },
                                 new GridHiddenCell("Id")
                {
                    Value = client.Id.ToString()
                }
                                 )
                {
                    Style = style
                });
            }

            return(model);
        }