Mini Kabibi Habibi

Current Path : C:/Users/Public/Documents/DXperience 13.1 Demos/WinForms/VB/GridMainDemo/Modules/
Upload File :
Current File : C:/Users/Public/Documents/DXperience 13.1 Demos/WinForms/VB/GridMainDemo/Modules/ucValidation.vb

Imports System.Collections
Imports System.ComponentModel

Namespace DevExpress.XtraGrid.Demos
	''' <summary>
	''' Summary description for UserControl1.
	''' </summary>
	Partial Public Class ValidationControl
		Inherits System.Windows.Forms.UserControl

		Public Sub New()
			SetStyle(ControlStyles.SupportsTransparentBackColor, True)
			' This call is required by the Windows.Forms Form Designer.
			InitializeComponent()

			' TODO: Add any initialization after the InitForm call

		End Sub

		Private fCaption As String
		Public Event ValidateCondition As EventHandler

		Private Sub imageComboBoxEdit1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles imageComboBoxEdit1.SelectedIndexChanged
			Dim visibleNextCondition As Boolean = CInt(Fix(imageComboBoxEdit1.EditValue)) < 2
			spinEdit2.Visible = visibleNextCondition
			imageComboBoxEdit2.Visible = spinEdit2.Visible
			label2.Visible = imageComboBoxEdit2.Visible
			RaiseValidateCondition()
		End Sub

		Private Sub imageComboBoxEdit2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles imageComboBoxEdit2.SelectedIndexChanged
			label2.Enabled = Not imageComboBoxEdit2.EditValue.Equals(0)
			spinEdit2.Visible = label2.Enabled
			RaiseValidateCondition()
		End Sub

		Private Sub spinEdit_EditValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles spinEdit1.EditValueChanged, spinEdit2.EditValueChanged
			RaiseValidateCondition()
		End Sub

		Protected Sub RaiseValidateCondition()
			RaiseEvent ValidateCondition(Me, New EventArgs())
		End Sub
		<Localizable(True)> _
		Public Property Caption() As String
			Get
				Return fCaption
			End Get
			Set(ByVal value As String)
				fCaption = value
				label1.Text = fCaption
			End Set
		End Property

		Public Function IsTrueCondition(ByVal val As Object) As Object()
			Dim dValue As Decimal = Convert.ToDecimal(val)
			Dim value1 As Decimal = Convert.ToDecimal(spinEdit1.EditValue)
			Dim value2 As Decimal = Convert.ToDecimal(spinEdit2.EditValue)
			Dim condition1 As Integer = imageComboBoxEdit1.SelectedIndex
			Dim condition2 As Integer = imageComboBoxEdit2.SelectedIndex
			Dim greater As Boolean = False
			Dim reply As String = ""
			If condition1 = 2 Then
				reply = String.Format(My.Resources.ValueLess, value1)
				Return New Object() { (dValue < value1), reply }
			End If
			If condition1 = 3 Then
				reply = String.Format(My.Resources.ValueLessEqual, value1)
				Return New Object() { (dValue <= value1), reply }
			End If
			If condition1 = 4 Then
				reply = String.Format(My.Resources.ValueNotEqual, value1)
				Return New Object() { (dValue <> value1), reply }
			End If
			If condition1 = 0 Then
				reply = String.Format(My.Resources.ValueGreater, value1)
				greater = dValue > value1
			End If
			If condition1 = 1 Then
				reply = String.Format(My.Resources.ValueGreaterEqual, value1)
				greater = dValue >= value1
			End If
			If condition2 = 0 Then
				Return New Object() { greater, reply }
			End If
			If greater Then
				If condition2 = 1 Then
					reply = String.Format(My.Resources.ValueLess, value2)
					Return New Object() { (greater AndAlso dValue < value2), reply }
				End If
				If condition2 = 2 Then
					reply = String.Format(My.Resources.ValueLessEqual, value2)
					Return New Object() { (greater AndAlso dValue <= value2), reply }
				End If
			End If
			Return New Object() { False, reply }
		End Function
	End Class
End Namespace