Exemplo n.º 1
0
        private bool SaveItem()
        {
            bool success = false;

            if (IsMonitoringAdmin)
            {
                try {
                    bool isUpdate = (IView == ItemView.Edit);
                    item             = (isUpdate) ? new SPA.ServerType(ItemID) : new SPA.ServerType();
                    item.Name        = txtName.Text.Trim();
                    item.Description = txtDescription.Text.Trim();
                    item.ModifiedBy  = CurrentUser.DisplayName;

                    if (!isUpdate)
                    {
                        item.CreatedBy = item.ModifiedBy;
                        if (item.Insert())
                        {
                            success = true;
                        }
                    }
                    else
                    {
                        if (item.Update())
                        {
                            success = true;
                        }
                    }
                    ItemID = (success) ? item.ID : 0;
                } catch (Exception ex) {
                    SPA.Error.WriteError(ex);
                    if (ShowDebug)
                    {
                        lblErrorMessage.Text = ex.ToString();
                    }
                }
            }
            return(success);
        }