コード例 #1
0
        protected void GridViewMissionsList_CellEditorInitialize(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewEditorEventArgs e)
        {
            var statusType = GridViewMissionsList.GetRowValuesByKeyValue(e.KeyValue, new string[] { "StatusDescription" });
            var dal = new MissionsDal();
            switch (e.Column.Name)
            {
                case "Name":
                    if (e.Editor != null)
                    {
                        var editorName = (e.Editor as ASPxTextEdit);
                        editorName.ReadOnly = (string)statusType == "In Progress";
                        editorName.Enabled = (string)statusType != "In Progress";
                    }
                    break;

                case "Description":
                    if (e.Editor != null)
                    {
                        var editorDescr = (e.Editor as ASPxMemo);
                        editorDescr.ReadOnly = (string)statusType == "In Progress";
                        editorDescr.Enabled = (string)statusType != "In Progress";
                    }
                    break;

                case "SkillsRequired":
                    if (e.Editor != null)
                    {
                        var editorSkills = (e.Editor as ASPxMemo);
                        editorSkills.ReadOnly = (string)statusType == "In Progress";
                        editorSkills.Enabled = (string)statusType != "In Progress";
                    }
                    break;
                case "StartDate":
                    if (e.Editor != null)
                    {
                        var editorStartDate = (e.Editor as ASPxDateEdit);
                        editorStartDate.ReadOnly = (string)statusType == "In Progress";
                        editorStartDate.Enabled = (string)statusType != "In Progress";
                    }
                    break;

                case "TypeId":
                    if (e.Editor != null)
                    {
                        var editorType = (e.Editor as ASPxComboBox);
                        editorType.ValueField = "TypeId";
                        editorType.TextField = "Description";

                        editorType.DataSource = dal.GetMissionTypes();
                        editorType.DataBind();
                        editorType.ReadOnly = (string) statusType == "In Progress";
                        editorType.Enabled = (string)statusType != "In Progress";
                    }
                    break;

                case "ComplexityId":
                    if (e.Editor != null)
                    {
                        var editorComplexity= (e.Editor as ASPxComboBox);
                        editorComplexity.ValueField = "ComplexityId";
                        editorComplexity.TextField = "Description";

                        editorComplexity.DataSource = dal.GetMissionComplexityList();
                        editorComplexity.DataBind();
                        editorComplexity.ReadOnly = (string)statusType == "In Progress";
                        editorComplexity.Enabled = (string)statusType != "In Progress";
                    }
                    break;
                case "PlayerType":
                    break;
                case "StatusId":
                    if (e.Editor != null)
                    {
                        var editorStatus= (e.Editor as ASPxComboBox);
                        editorStatus.ValueField = "StatusId";
                        editorStatus.TextField = "Description";
                        editorStatus.Enabled = AuthProvider.IsUserInRole(Session, AuthRoles.SystemAdmin) ||
                                               AuthProvider.IsUserInRole(Session, AuthRoles.Admin) ||
                                               AuthProvider.IsUserInRole(Session, AuthRoles.Moderator);
                        editorStatus.DataSource = dal.GetMissionStatuses(Convert.ToInt32(e.Editor.Value));
                        editorStatus.DataBind();
                    }
                    break;
                case "OwnerId":
                    if (e.Editor != null)
                    {
                        var editorOwner = (e.Editor as ASPxComboBox);
                        editorOwner.Enabled = AuthProvider.IsUserInRole(Session, AuthRoles.SystemAdmin) ||
                                              AuthProvider.IsUserInRole(Session, AuthRoles.Admin) ||
                                              AuthProvider.IsUserInRole(Session, AuthRoles.Moderator);

                        editorOwner.ValueField = "UserId";
                        editorOwner.TextField = "FullName";
                        editorOwner.DataSource = (new UsersDal()).GetOwnersList();
                        editorOwner.DataBind();
                    }
                    break;
                case "StageId":
                     if (e.Editor != null)
                    {
                        var editorStage = (e.Editor as ASPxComboBox);
                        editorStage.Enabled = AuthProvider.IsUserInRole(Session, AuthRoles.SystemAdmin) ||
                                              AuthProvider.IsUserInRole(Session, AuthRoles.Admin) ||
                                              AuthProvider.IsUserInRole(Session, AuthRoles.Moderator);

                        editorStage.ValueField = "StageId";
                        editorStage.TextField = "Description";
                        editorStage.DataSource = (new StagesDal()).GetNotCompletedStagesList();
                        editorStage.DataBind();
                        editorStage.ReadOnly = (string)statusType == "In Progress";
                        editorStage.Enabled = (string)statusType != "In Progress";
                    }
                    break;
            }
        }
コード例 #2
0
        private void LoadParameters()
        {
            var dal = new MissionsDal();
            tbMissionType.DataSource = dal.GetMissionTypes();
            tbMissionType.DataBind();

            tbMissionComplexity.DataSource = dal.GetMissionComplexityList();
            tbMissionComplexity.DataBind();

            tbMissionStartDate.Date = DateTime.Now;
            tbMissionEndDate.Date = DateTime.Now;
        }