Mini Kabibi Habibi

Current Path : C:/Users/Public/Documents/DXperience 13.1 Demos/WinForms/VB/XpoTutorials/MSSQLServer/
Upload File :
Current File : C:/Users/Public/Documents/DXperience 13.1 Demos/WinForms/VB/XpoTutorials/MSSQLServer/MSSQLServer.vb

Imports Microsoft.VisualBasic
Imports System
Imports System.Drawing
Imports System.Collections
Imports System.ComponentModel
Imports System.Windows.Forms
Imports System.Data
Imports DevExpress.Xpo

Namespace DevExpress.Xpo.Demos
    Partial Public Class MSSQLServer
        Inherits TutorialControl
        Private dataProvider As String = ".NET Framework Data Provider for OLE DB"
        Public Overrides Property SetNewWhatsThisPadding() As Boolean
            Get
                Return True
            End Get
            Set(ByVal value As Boolean)
                MyBase.SetNewWhatsThisPadding() = value
            End Set
        End Property
        '<gridControl1>
        Private Shared connectionString As String = "packet size=4096;" & "user id=sa;data source=(local);persist security info=True;initial catalog=XPOProjects;password=;connection timeout=2"

        Public Sub New()
            InitializeComponent()

            Using session As Session = New Session()
                session.ConnectionString = connectionString
                Try
                    session.Connect()
                    session.Disconnect()
                    Me.unitOfWork1.ConnectionString = connectionString
                    dataProvider = ".NET Framework Data Provider for SQL Server"
                Catch e1 As DevExpress.Xpo.DB.Exceptions.UnableToOpenDatabaseException
                End Try
            End Using
        End Sub
        '</gridControl1>

#Region "Editors Initialization"
        Private Sub InitEditors()
            Me.repositoryItemImageComboBox1.Items.AddRange(New Object() {New DevExpress.XtraEditors.Controls.ImageComboBoxItem("Fixed", ProjectStatus.Fixed, 0), New DevExpress.XtraEditors.Controls.ImageComboBoxItem("New", ProjectStatus.New, 1), New DevExpress.XtraEditors.Controls.ImageComboBoxItem("Postponed", ProjectStatus.Postponed, 2), New DevExpress.XtraEditors.Controls.ImageComboBoxItem("Rejected", ProjectStatus.Rejected, 3)})
            Me.repositoryItemImageComboBox2.Items.AddRange(New Object() {New DevExpress.XtraEditors.Controls.ImageComboBoxItem("Bug", ProjectType.Bug, 0), New DevExpress.XtraEditors.Controls.ImageComboBoxItem("Request", ProjectType.Request, 1)})
            textEdit1.Text = dataProvider
        End Sub
#End Region

        Private Sub MSSQLServer_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
            InitEditors()
            If xpProjects.Count = 0 Then
                CreateProjects(unitOfWork1)
                xpProjects.Reload()
            End If
            If unitOfWork1.ConnectionString = connectionString Then
                DevExpress.XtraEditors.XtraMessageBox.Show("You have successfully connected to your local MS SQL Server.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information)
            Else
                DevExpress.XtraEditors.XtraMessageBox.Show("You have failed to connect to your local MS SQL Server." & Constants.vbLf & "XPO uses the MS Access OLEDB provider instead.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Warning)
            End If
        End Sub

        Private Sub bSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bSave.Click
            SaveChanges(unitOfWork1)
        End Sub

        Public Overrides Sub ReloadData()
            xpProjects.Reload()
        End Sub
    End Class
End Namespace