Files
2017-03-26 20:00:03 +02:00

77 lines
3.8 KiB
VB.net

Imports System
Imports System.ComponentModel
Imports System.Collections.Generic
Imports System.Diagnostics
Imports System.Text
Imports DevExpress.ExpressApp
Imports DevExpress.ExpressApp.Actions
Imports DevExpress.Persistent.Base
Imports DevExpress.ExpressApp.Editors
Imports DevExpress.Data.Filtering
Imports DevExpress.ExpressApp.Utils
Public Class RichTextViewVC
Inherits DevExpress.ExpressApp.ViewController
Public Sub New()
MyBase.New()
InitializeComponent()
RegisterActions(components)
End Sub
Protected Overrides Sub OnActivated()
MyBase.OnActivated()
Frame.GetController(Of RichTextViewVC).aViewRichText.Active.SetItemValue("", False)
Frame.GetController(Of RichTextViewVC).aViewRichText_Save.Active.SetItemValue("", False)
Frame.GetController(Of RichTextViewVC).aViewRichText_SaveAndClose.Active.SetItemValue("", False)
If View.Id = "ContractTemplate_DetailView" Then
Frame.GetController(Of RichTextViewVC).aViewRichText.Active.SetItemValue("", True)
End If
If View.Id = "RichTextView_DetailView" Then
Frame.GetController(Of RichTextViewVC).aViewRichText_Save.Active.SetItemValue("", True)
Frame.GetController(Of RichTextViewVC).aViewRichText_SaveAndClose.Active.SetItemValue("", True)
End If
End Sub
Private Sub aViewRichText_Execute(sender As System.Object, e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles aViewRichText.Execute
Try
If View.Id = "ContractTemplate_DetailView" Then
Dim _ocur As Xpo.XPObjectSpace = View.ObjectSpace
Dim _ContractTemplate As ContractTemplate = TryCast(View.SelectedObjects(0), ContractTemplate)
If _ContractTemplate Is Nothing Then Throw New Exception("*Váratlan hiba történt, a folyamat megszakadt!")
Dim _RichTextView As RichTextView = _ocur.CreateObject(Of RichTextView)()
_RichTextView.RichText = _ContractTemplate.DocumentBody
_RichTextView.ObjectGUID = _ContractTemplate.Oid
e.ShowViewParameters.CreatedView = Application.CreateDetailView(_ocur, "RichTextView_DetailView", False, _RichTextView)
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, String.Format(CaptionHelper.GetLocalizedText("Exceptions\SISBusinessExceptions", "MsgBoxCheckItAgain")))
End Try
End Sub
Private Sub aViewRichText_Save_Execute(sender As System.Object, e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles aViewRichText_Save.Execute
Try
Dim _ocur As Xpo.XPObjectSpace = View.ObjectSpace
Dim _RichTextView As RichTextView = TryCast(View.SelectedObjects(0), RichTextView)
If _RichTextView Is Nothing Then Throw New Exception("*Váratlan hiba történt, a folyamat megszakadt")
Dim _ContractTemplate As ContractTemplate = _ocur.FindObject(Of ContractTemplate)(CriteriaOperator.Parse("Oid=?", _RichTextView.ObjectGUID))
If _ContractTemplate IsNot Nothing Then
_ContractTemplate.DocumentBody = _RichTextView.RichText
If Not _ocur.IsNewObject(_ContractTemplate) Then _ocur.CommitChanges()
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, String.Format(CaptionHelper.GetLocalizedText("Exceptions\SISBusinessExceptions", "MsgBoxCheckItAgain")))
End Try
End Sub
Private Sub aViewRichText_SaveAndClose_Execute(sender As System.Object, e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles aViewRichText_SaveAndClose.Execute
Frame.GetController(Of RichTextViewVC).aViewRichText_Save.DoExecute()
View.Close()
End Sub
End Class