protected override void Grid_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            if (e.CommandName == "add")
            {
                TextBox  NewNameTextBox       = (TextBox)e.Item.FindControl("NewNameTextBox");
                CheckBox NewIsVisibleCheckBox = (CheckBox)e.Item.FindControl("NewIsVisibleCheckBox");

                try
                {
                    AssetType assetType = AssetType.New();
                    assetType.Name      = NewNameTextBox.Text.Trim();
                    assetType.IsVisible = NewIsVisibleCheckBox.Checked;
                    AssetTypeManager.SaveAssetType(assetType);

                    AuditLogManager.LogUserAction(CurrentUser, AuditUserAction.AddAssetType, string.Format("Added Asset Type: {0}, AssetTypeId: {1}", assetType.Name, assetType.AssetTypeId));

                    ResetGridState();
                    MessageLabel1.SetSuccessMessage("Asset type added successfully");
                }
                catch (InvalidAssetTypeException imtex)
                {
                    MessageLabel1.SetErrorMessage("Unable to add asset type", imtex.Errors);
                    BindGrid(CurrentPage);
                }
            }
        }
Esempio n. 2
0
        public override object GetDataSource()
        {
            if (m_InternalData == null)
            {
                m_InternalData = (DisplayAll) ? AssetTypeCache.Instance.GetList() : AssetTypeCache.Instance.GetVisibleAssetTypeList();

                if (ShowSystemChooseOption)
                {
                    AssetType assetType = AssetType.New();
                    assetType.AssetTypeId = Int32.MinValue;
                    assetType.Name        = "Let the system choose";
                    m_InternalData.Insert(0, assetType);
                }
            }

            return(m_InternalData);
        }