Imports System Imports System.ComponentModel Imports DevExpress.Xpo Imports DevExpress.Data.Filtering Imports DevExpress.ExpressApp Imports DevExpress.Persistent.Base Imports DevExpress.Persistent.BaseImpl Imports DevExpress.Persistent.Validation Imports DevExpress.ExpressApp.ConditionalAppearance Imports System.Net.Mail Public Enum eInvoiceState eNoState = 0 eInvoiceReadyState = 1 'Számlázható eNOInvoiceState = 2 ' NEM számlázható End Enum _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1 ", AppearanceItemType.ViewItem, " WorkSheetState<>'eClosed'", TargetItems:="DateClosed", visibility:=Editors.ViewItemVisibility.Hide)> _ _ _ _ _ _ Public Class WorkSheet_Header Inherits BaseObject Private _WorkSheetType As WorkSheetType 'Munkalap tipusa Private _WorkSheetState As eWorkSheetState ' munkalap állapota Private _WorkPlace As WorkPlace 'Munkahely Private _WorkState As WorkState 'Munkafolyamat Private _InvoiceState As eInvoiceState 'Számlázási állapot Private _Question As Question ' Internetes hibabejelentés Private _CustomersFrom As CustomersFrom 'Saját cég Private _Customers As Customers ' Partner, akire a munkalapot nyitották Private _Contacts As Contacts 'Kapcsolattartó Private _CurrencyName As CurrencyName 'Pénznem Private _DocumentNumber As String 'Munkalap száma Private _DateCreated As Date 'Létrehozás dátuma Private _DateExecution As Date 'Teljesítés dátuma Private _ExcelProperty As String ' Excel Private _ExcelFile As FileData 'Excel file Private _ObjectCreated As Date ' Létrehozva Private _UserCreated As User 'Létrehozó Private _Recipe As Recipe 'Milyen recept alapján kell gyártani Private _WorkSheetFile_Original As FileData 'Generált pdf, amit letölt az alvállalkozó Private _WorkSheetFile As FileData 'Csatolt alvállalkozói munkalap Private _SubcontractorInvoice As FileData 'Csatolt alvállalkozói számla Private _IsSubcontractor As Boolean 'Alvállalkozóhoz tartozik-e? Private _SubcontractorCustomers As Customers 'Alvállalkozó aki nyitotta Private _Description As String 'Belső megjeygszés alvállalkozói lezáráshoz Private _DateClosed As Date 'Lezárás dátuma Private _WorkHour As Double 'Munkaóra amit megadhat, nem kötelező (WEB) Private _WorkDescription As String 'Elvégzett munka leírása (nem kötelező WEB) Private _WorkUsedMaterialDescription As String 'Felhasznált anyag leírása (nem kötelező WEB) Private _WorkDescriptionOther As String 'Egyéb az alvállalkozó által megadott megjegyzés (nem kötelező WEB) Private _WorkTravelKm As Long 'Mennyit utaztak (nem kötelező WEB) Private _RegistryHeader As RegistryHeader 'Iktatáshoz kapcsolódó munkalap '-- Jelölő adatok !!! Private _JobNumberObjects As JobNumberObjects Private _UniqueObjects As UniqueObjects Private _CostPlace As CostPlace Private _CostHolder As CostHolder '-- Nonpersistent propertyk !!! Private _row_RowGroup1 As String 'Csoportosító sor1 Private _row_RowGroup2 As String 'Csoportosító sor2 Private _row_ShortName As String 'Megnevezés Private _row_Description As String 'Leírás Private _row_Quantity As Double 'Mennyiség Private _row_Units As Units 'Mennyiségi egység Private _row_WorkType As eWorkType 'A sor milyen (Fizetős, garancia vagy vegyes) Private _row_WorkRowType As eWorkRowType 'Az adott sor mit tartalmaz Private _row_Services As Services 'Szolgáltatás törzsből Public Sub New(ByVal session As Session) MyBase.New(session) End Sub Public Overrides Sub AfterConstruction() MyBase.AfterConstruction() Me.WorkSheetState = eWorkSheetState.eOpened Me.CurrencyName = Session.FindObject(Of CurrencyName)(CriteriaOperator.Parse("ShortName='HUF'")) End Sub Protected Overrides Sub OnSaving() MyBase.OnSaving() If DocumentNumber = "" Then DocumentNumber = Me.WorkSheetType.NumberGenerator.GetNewNumber(Me.WorkSheetType.NumberGenerator) End If If Session.IsNewObject(Me) Then ObjectCreated = GetSQLTime(Session) UserCreated = Session.GetObjectByKey(Of User)(Session.GetKeyValue(SecuritySystem.CurrentUser)) Try Dim _WebParameters As WebParameters = Session.FindObject(Of WebParameters)(CriteriaOperator.Parse("1=1")) If _WebParameters Is Nothing Then Throw New Exception("*Nincsnek e-mail paraméterek beállítva!") If _WebParameters.SMTPHost Is Nothing Then Throw New Exception("*Nincs SMTP server beállítva!") If _WebParameters.SMTPUserName = "" Then Throw New Exception("*Nincs felhasználói név beállítva!") If _WebParameters.SMTPPort = 0 Then Throw New Exception("*Nincs SMTP port beállítva!") Dim _MailMessage As New MailMessage Dim _SmtpClient As SmtpClient = New SmtpClient(_WebParameters.SMTPHost) _MailMessage.From = New MailAddress(_WebParameters.Email_SupportAdmin) If Customers.Contacts.Count > 0 Then For Each _Contacts As Contacts In Customers.Contacts If Not String.IsNullOrEmpty(_Contacts.Email) Then _MailMessage.To.Add(_Contacts.Email) Next ElseIf Not String.IsNullOrEmpty(Customers.Email) Then _MailMessage.To.Add(Customers.Email) Else 'Throw New Exception("*Nincs email cím beállítva!") End If _MailMessage.Subject = "Új munkalap készült" _MailMessage.IsBodyHtml = True _MailMessage.Body = String.Format("{0} számmal új munkalap készült az Ön(ök) részére.", DocumentNumber) _SmtpClient.Port = _WebParameters.SMTPPort _SmtpClient.Credentials = New System.Net.NetworkCredential(_WebParameters.SMTPUserName, _WebParameters.SMTPPassword) _SmtpClient.EnableSsl = _WebParameters.EnableSsl _SmtpClient.Send(_MailMessage) If UserCreated IsNot Nothing Then If Not String.IsNullOrEmpty(UserCreated.Email) Then _MailMessage.To.Clear() _MailMessage.To.Add(UserCreated.Email) _MailMessage.Body = String.Format("Ön {0} számmal új munkalapot hozott létre a(z) {1} ügyfél részére.", DocumentNumber, Customers.FullName) _SmtpClient.Send(_MailMessage) End If End If Catch ex As Exception Dim sf As StackFrame = New StackFrame() Dim _uow As New UnitOfWork(Session.DataLayer) Dim _ErrorLog As New ErrorLog(_uow) _ErrorLog.Description = ex.Message _ErrorLog.SubName = TryCast(sf.GetMethod(), System.Reflection.MethodBase).Name _uow.CommitTransaction() End Try '-------------IsOperationalLog------------- If WorkSheetType.IsOperationalLog Then Dim _OperationalLogParameters As OperationalLogParameters = Session.FindObject(Of OperationalLogParameters)(CriteriaOperator.Parse("WorkPlace=? AND CustomersFrom=?", WorkPlace, CustomersFrom)) If _OperationalLogParameters IsNot Nothing Then Dim _OperationalLog As New OperationalLog(Session) With _OperationalLog .CustomersFrom = CustomersFrom .Customers = Customers .OperationalLogParameters = _OperationalLogParameters .WorkState = WorkState .WorkPlace = WorkPlace .Description = String.Format(WorkSheetType.OperationalLogDescription, DocumentNumber, ObjectCreated.ToString, UserCreated.UserName) End With _OperationalLog.Save() ' Session.CommitTransaction() End If End If End If End Sub Property WorkSheetState() As eWorkSheetState Get Return _WorkSheetState End Get Set(ByVal value As eWorkSheetState) SetPropertyValue("WorkSheetState", _WorkSheetState, value) End Set End Property Property WorkSheetType() As WorkSheetType Get Return _WorkSheetType End Get Set(ByVal value As WorkSheetType) SetPropertyValue("WorkSheetType", _WorkSheetType, value) If Session.IsObjectsLoading = False And Session.IsObjectsSaving = False Then If Session.IsNewObject(Me) = True Then Me.ExcelProperty = value.ExcelProperty Me.ExcelFile = value.ExcelFile End If End If End Set End Property Property WorkPlace As WorkPlace Get Return _WorkPlace End Get Set(value As WorkPlace) SetPropertyValue("WorkPlace", _WorkPlace, value) End Set End Property Property WorkState As WorkState Get Return _WorkState End Get Set(value As WorkState) SetPropertyValue("WorkState", _WorkState, value) End Set End Property Property InvoiceState As eInvoiceState Get Return _InvoiceState End Get Set(value As eInvoiceState) SetPropertyValue("InvoiceState", _InvoiceState, value) End Set End Property Property Question() As Question Get Return _Question End Get Set(ByVal value As Question) SetPropertyValue("Question", _Question, value) End Set End Property Property CustomersFrom() As CustomersFrom Get Return _CustomersFrom End Get Set(ByVal value As CustomersFrom) SetPropertyValue("CustomersFrom", _CustomersFrom, value) End Set End Property Property Customers As Customers Get Return _Customers End Get Set(value As Customers) SetPropertyValue("Customers", _Customers, value) End Set End Property Property Contacts As Contacts Get Return _Contacts End Get Set(value As Contacts) SetPropertyValue("Contacts", _Contacts, value) End Set End Property Property CurrencyName As CurrencyName Get Return _CurrencyName End Get Set(value As CurrencyName) SetPropertyValue("CurrencyName", _CurrencyName, value) End Set End Property Property DocumentNumber() As String Get Return _DocumentNumber End Get Set(ByVal value As String) SetPropertyValue("DocumentNumber", _DocumentNumber, value) End Set End Property Property DateCreated() As Date Get Return _DateCreated End Get Set(ByVal value As Date) SetPropertyValue("DateCreated", _DateCreated, value) End Set End Property Property DateExecution() As Date Get Return _DateExecution End Get Set(ByVal value As Date) SetPropertyValue("DateExecution", _DateExecution, value) End Set End Property Property ExcelProperty As String Get Return _ExcelProperty End Get Set(value As String) SetPropertyValue("ExcelProperty", _ExcelProperty, value) End Set End Property Property ExcelFile As FileData Get Return _ExcelFile End Get Set(value As FileData) SetPropertyValue("ExcelFile", _ExcelFile, value) End Set End Property Property ObjectCreated As Date Get Return _ObjectCreated End Get Set(value As Date) SetPropertyValue("ObjectCreated", _ObjectCreated, value) End Set End Property Property UserCreated As User Get Return _UserCreated End Get Set(value As User) SetPropertyValue("UserCreated", _UserCreated, value) End Set End Property Property Recipe As Recipe Get Return _Recipe End Get Set(value As Recipe) SetPropertyValue("Recipe", _Recipe, value) End Set End Property Property WorkSheetFile_Original As FileData Get Return _WorkSheetFile_Original End Get Set(value As FileData) SetPropertyValue("WorkSheetFile_Original", _WorkSheetFile_Original, value) End Set End Property Property WorkSheetFile As FileData Get Return _WorkSheetFile End Get Set(value As FileData) SetPropertyValue("WorkSheetFile", _WorkSheetFile, value) End Set End Property Property SubcontractorInvoice As FileData Get Return _SubcontractorInvoice End Get Set(value As FileData) SetPropertyValue("SubcontractorInvoice", _SubcontractorInvoice, value) End Set End Property Property IsSubcontractor As Boolean Get Return _IsSubcontractor End Get Set(value As Boolean) SetPropertyValue("IsSubcontractor", _IsSubcontractor, value) End Set End Property Property SubcontractorCustomers As Customers Get Return _SubcontractorCustomers End Get Set(value As Customers) SetPropertyValue("SubcontractorCustomers", _SubcontractorCustomers, value) End Set End Property Property Description As String Get Return _Description End Get Set(value As String) SetPropertyValue("Description", _Description, value) End Set End Property Property DateClosed As Date Get Return _DateClosed End Get Set(value As Date) SetPropertyValue("DateClosed", _DateClosed, value) End Set End Property Property WorkHour As Double Get Return _WorkHour End Get Set(value As Double) SetPropertyValue("WorkHour", _WorkHour, value) End Set End Property Property WorkDescription As String Get Return _WorkDescription End Get Set(value As String) SetPropertyValue("WorkDescription", _WorkDescription, value) End Set End Property Property WorkUsedMaterialDescription As String Get Return _WorkUsedMaterialDescription End Get Set(value As String) SetPropertyValue("WorkUsedMaterialDescription", _WorkUsedMaterialDescription, value) End Set End Property Property WorkDescriptionOther As String Get Return _WorkDescriptionOther End Get Set(value As String) SetPropertyValue("WorkDescriptionOther", _WorkDescriptionOther, value) End Set End Property Property WorkTravelKm As Long Get Return _WorkTravelKm End Get Set(value As Long) SetPropertyValue("WorkTravelKm", _WorkTravelKm, value) End Set End Property Property RegistryHeader As RegistryHeader Get Return _RegistryHeader End Get Set(value As RegistryHeader) SetPropertyValue("RegistryHeader", _RegistryHeader, value) If Session.IsObjectsLoading = False And Session.IsObjectsSaving = False Then Me.Customers = value.Customers Me.Description = value.ShortName End If End Set End Property '-- Jelölő adatok !!! _ Property JobNumberObjects As JobNumberObjects Get Return _JobNumberObjects End Get Set(value As JobNumberObjects) SetPropertyValue("JobNumberObjects", _JobNumberObjects, value) End Set End Property _ Property UniqueObjects As UniqueObjects Get Return _UniqueObjects End Get Set(value As UniqueObjects) SetPropertyValue("UniqueObjects", _UniqueObjects, value) End Set End Property _ Property CostPlace As CostPlace Get Return _CostPlace End Get Set(value As CostPlace) SetPropertyValue("CostPlace", _CostPlace, value) End Set End Property _ Property CostHolder As CostHolder Get Return _CostHolder End Get Set(value As CostHolder) SetPropertyValue("CostHolder", _CostHolder, value) End Set End Property '----------Nonpersistent propertyk !!! _ _ Property row_RowGroup1 As String Get Return _row_RowGroup1 End Get Set(value As String) SetPropertyValue("row_RowGroup1", _row_RowGroup1, value) End Set End Property _ _ Property row_RowGroup2 As String Get Return _row_RowGroup2 End Get Set(value As String) SetPropertyValue("row_RowGroup2", _row_RowGroup2, value) End Set End Property _ _ Property row_ShortName As String Get Return _row_ShortName End Get Set(value As String) SetPropertyValue("row_ShortName", _row_ShortName, value) End Set End Property _ _ Property row_Description As String Get Return _row_Description End Get Set(value As String) SetPropertyValue("row_Description", _row_Description, value) End Set End Property _ _ Property row_Quantity As Double Get Return _row_Quantity End Get Set(value As Double) SetPropertyValue("row_Quantity", _row_Quantity, value) End Set End Property _ _ Property row_Units As Units Get Return _row_Units End Get Set(value As Units) SetPropertyValue("row_Units", _row_Units, value) End Set End Property _ _ _ Property row_WorkType() As eWorkType Get Return _row_WorkType End Get Set(ByVal value As eWorkType) SetPropertyValue("row_WorkType", _row_WorkType, value) End Set End Property _ _ _ Property row_WorkRowType As eWorkRowType Get Return _row_WorkRowType End Get Set(value As eWorkRowType) SetPropertyValue("row_WorkRowType", _row_WorkRowType, value) End Set End Property _ _ _ Property row_Services As Services Get Return _row_Services End Get Set(value As Services) SetPropertyValue("row_Services", _row_Services, value) End Set End Property '--------------------ReadOnly-------------------- _ _ ReadOnly Property WorkSheet_Rows() As XPCollection(Of WorkSheet_Rows) Get Return GetCollection(Of WorkSheet_Rows)("WorkSheet_Rows") End Get End Property _ _ ReadOnly Property Worksheet_Documets As XPCollection(Of Worksheet_Documets) Get Return GetCollection(Of Worksheet_Documets)("Worksheet_Documets") End Get End Property _ ReadOnly Property StorageOutRows As XPCollection(Of StorageOutRows) Get Return New XPCollection(Of StorageOutRows)(Session, CriteriaOperator.Parse("StorageOutHeader.WorkSheet_Header=?", Me)) End Get End Property _ ReadOnly Property Worksheet_CostRows As XPCollection(Of Worksheet_CostRows) Get Return GetCollection(Of Worksheet_CostRows)("Worksheet_CostRows") End Get End Property _ ReadOnly Property WorkSheet_ReopenReason As XPCollection(Of WorkSheet_ReopenReason) Get Return GetCollection(Of WorkSheet_ReopenReason)("WorkSheet_ReopenReason") End Get End Property _ _ _ ReadOnly Property WorkSheet_Header_HRPerson As XPCollection(Of WorkSheet_Header_HRPerson) Get Return GetCollection(Of WorkSheet_Header_HRPerson)("WorkSheet_Header_HRPerson") End Get End Property End Class