Friday 2 January 2015

Login Page in windows

Imports AppGlobals
Imports AppGlobals.AppGlobal
Imports System.Data.SqlClient

Public Class frmLogin

#Region "Declaration Section"

    Private Shared objfrmLogin As frmLogin
    Private m_ObjDataAdaptor As SqlClient.SqlDataAdapter
    Private m_ObjDataSet As New Data.DataSet()
    Private objDBConnectPAR As New DbConnectPAR()
    Private dsPARUserDetails As New Data.DataSet()
    Public Shared m_PwdExpiryStatus As Boolean = False
    Private m_objCommonFunction As New clsCommonFunction()
    Private m_objGetMaster As New clsGetMaster()
    Private m_dtmSrvDateTime As DateTime

    Private m_lngTimerCntr As Int32 = 0

    'Private objMutex As System.Threading.Mutex

#End Region
    ''.........Start --  ''' This Code Added By RamVinay Singh on 18 Dec 2012
#Region "Properties"
    Public Shared Property m_Get_frmLogin() As frmLogin
        Get
            If objfrmLogin Is Nothing OrElse objfrmLogin.IsDisposed Then
                objfrmLogin = New frmLogin()
            End If
            m_Get_frmLogin = objfrmLogin
        End Get
        Set(ByVal Value As frmLogin)
            objfrmLogin = Value
        End Set
    End Property
    ''.........End --
#End Region
#Region "Form Object Procedures"

    Private Sub frmLogin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        'objMutex = New System.Threading.Mutex(False, "PM")
        'If objMutex.WaitOne(0, False) = False Then
        '    objMutex.Close()
        '    objMutex = Nothing
        '    MessageBox.Show("Another instance is already running!")
        '    End
        'End If
        lblHeading.Visible = False
        pbxRAMTeCH.Visible = False

        Dim objclsGlobals As New clsGlobals
        Dim DBStatus As Boolean = objclsGlobals.CheckDBSettings()
        'Dim PARDBStatus As Boolean = objclsGlobals.CheckPARDBSettings()

        If DBStatus = False Then
            MsgBox("Connection with database failed.", MsgBoxStyle.Critical, Application.ProductName)
            'Threading.Thread.Sleep(3000)
            'CType(My.Application.SplashScreen, PMSplashScreen).CloseForm()
            'If frmDBConfig.m_Get_frmDBConfig.fn_Initializeform() Then
            '    Cursor.Current = Cursors.Default
            '    If frmDBConfig.m_Get_frmDBConfig.ShowDialog() = Windows.Forms.DialogResult.Cancel Then
            '        Application.Exit()
            '    End If
            'End If
        End If
        g_dtmSrvDateTime = m_objGetMaster.m_fnGetServerDateTime()
        txtUserLoginId.Focus()
    End Sub

    Private Sub txtUserLoginId_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtUserLoginId.Enter
        txtUserLoginId.SelectAll()
    End Sub

    Private Sub txtPwd_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtPwd.Enter
        txtPwd.SelectAll()
    End Sub

    Private Sub txtUserLoginId_Validating(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtUserLoginId.Validating
        If String.IsNullOrEmpty(txtUserLoginId.Text) Then
            PMErrorProvider.SetError(txtUserLoginId, "Enter Login Id!")
        Else
            PMErrorProvider.SetError(txtUserLoginId, "")
        End If
    End Sub

    Private Sub txtPwd_Validating(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtPwd.Validating
        If String.IsNullOrEmpty(txtPwd.Text) Then
            PMErrorProvider.SetError(txtPwd, "Enter Password!")
        Else
            PMErrorProvider.SetError(txtPwd, "")
        End If
    End Sub

    Private Sub cmdLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLogin.Click
        Me.Cursor = Cursors.WaitCursor
        '''' START  This code added By Ramvinay Singh on 18 Dec 2012
        Dim objAppUsers As New AppUsers.clsAppUsers()
        Try
            glbblnLogin_Succeed = False
            If fnValidate_User_Login() = False Then
                txtUserLoginId.SelectAll()
            Else
                m_ObjDataAdaptor = New SqlClient.SqlDataAdapter(objAppUsers.fnGet_Login_User_Data(txtUserLoginId.Text.ToString, txtPwd.Text.ToString))
                m_ObjDataAdaptor.Fill(m_ObjDataSet)
           
                If (m_ObjDataSet.Tables.Count > 0) Then
                    If (m_ObjDataSet.Tables(0).Rows.Count > 0) Then
                        glblngUser_Id = m_ObjDataSet.Tables(0).Rows(0).Item("User_Id")
                        glbstrUser_Login_Id = m_ObjDataSet.Tables(0).Rows(0).Item("User_login_Id").ToString
                        glbstrUser_Name = m_ObjDataSet.Tables(0).Rows(0).Item("User_Name").ToString

                        ''' Coding by Ramvinay singh  (very  Happy New Year 2015-01-01)
                        '''''''''''' PAR User Details ......................
                        Dim sqlCmdPAR As New SqlCommand
                        Dim m_objDataAdapterPAR As New SqlDataAdapter

                        m_objDataAdapterPAR = New SqlClient.SqlDataAdapter()
                        objDBConnectPAR.OpenConnection()
                        sqlCmdPAR.Connection = objDBConnectPAR.GetConnection
                        sqlCmdPAR.CommandType = CommandType.StoredProcedure
                        sqlCmdPAR.CommandText = "spPRUserDetails"
                        sqlCmdPAR.Parameters.AddWithValue("@User_Login_Id", txtUserLoginId.Text)
                        sqlCmdPAR.Parameters.AddWithValue("@Flag", 2)
                        m_objDataAdapterPAR.SelectCommand = sqlCmdPAR
                        Try
                            m_objDataAdapterPAR = New SqlDataAdapter(sqlCmdPAR)
                            m_objDataAdapterPAR.Fill(dsPARUserDetails)

                            If (dsPARUserDetails.Tables.Count > 0) Then
                                If (dsPARUserDetails.Tables(0).Rows.Count > 0) Then
                                    glbUserType = dsPARUserDetails.Tables(0).Rows(0).Item("UserType").ToString
                                End If
                            End If
                       
                            Cursor.Current = Cursors.Default
                        Catch ex As Exception
                            Cursor.Current = Cursors.Default
                            MsgBox(ex.Message.ToString, MsgBoxStyle.Critical, g_strMessageCaption)
                        End Try


                        ''End



                        g_frmAppMDIForm = PMMain.m_GetPMMain
                        PMMain.m_GetPMMain.WindowState = FormWindowState.Maximized
                        PMMain.m_GetPMMain.Show()
                        Me.Close()
                    End If
                End If
             

                'If fnValidate_User_Pwd_Expiry(txtUserLoginId.Text.Trim) = False Then
                '    glbblnLogin_Succeed = True
                '    m_ObjDataSet.Dispose()
                '    Dim frmMessageF As New frmMessage()
                '    If frmMessageF.fnInitialize_Form = True Then
                '        frmMessageF.ShowDialog()
                '        g_frmAppMDIForm = PMMain.m_GetPMMain
                '        PMMain.m_GetPMMain.WindowState = FormWindowState.Maximized
                '        PMMain.m_GetPMMain.Show()
                '        Me.Close()
                '    Else
                '        g_frmAppMDIForm = PMMain.m_GetPMMain
                '        PMMain.m_GetPMMain.WindowState = FormWindowState.Maximized
                '        PMMain.m_GetPMMain.Show()
                '        Me.Close()
                '    End If
                'End If
            End If
        Catch ex As Exception
            MsgBox(ex.Message.ToString, MsgBoxStyle.Critical, g_strMessageCaption)
        Finally
            If Not m_ObjDataAdaptor Is Nothing Then
                m_ObjDataAdaptor.Dispose()
                g_frmAppMDIForm = PMMain.m_GetPMMain
                PMMain.m_GetPMMain.WindowState = FormWindowState.Maximized
                PMMain.m_GetPMMain.Show()
                Me.Close()
            End If
        End Try
        Me.Cursor = Cursors.Default

        '''END

        '''' This Code Commented By  Ramvinay Singh

        'Dim objAppUsers As New AppUsers.clsAppUsers()
        'Try

        '    If fnValidate_User_Login() = False Then Return

        '    m_ObjDataAdaptor = New SqlClient.SqlDataAdapter(objAppUsers.fnGet_Login_User_Data(txtUserLoginId.Text.ToString, txtPwd.Text.ToString))
        '    m_ObjDataAdaptor.Fill(m_ObjDataSet)
        '    glblngUser_Id = m_ObjDataSet.Tables(0).Rows(0).Item("User_Id")
        '    glbstrUser_Login_Id = m_ObjDataSet.Tables(0).Rows(0).Item("User_login_Id").ToString
        '    glbstrUser_Name = m_ObjDataSet.Tables(0).Rows(0).Item("User_Name").ToString
        '    If fnValidate_User_Pwd_Expiry(txtUserLoginId.Text.Trim) = False Then
        '        glbblnLogin_Succeed = True
        '        m_ObjDataSet.Dispose()

        '        g_frmAppMDIForm = PMMain.m_GetPMMain
        '        PMMain.m_GetPMMain.WindowState = FormWindowState.Maximized
        '        PMMain.m_GetPMMain.Show()

        '        Me.Close()
        '    End If

        'Catch ex As Exception
        '    MsgBox(ex.Message.ToString, MsgBoxStyle.Critical, g_strMessageCaption)
        'Finally
        '    If Not m_ObjDataAdaptor Is Nothing Then
        '        m_ObjDataAdaptor.Dispose()
        '    End If
        'End Try


    End Sub

    Private Sub cmdExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdExit.Click
        contextmenuCloseMinimize.Show(cmdExit.Left + cmdExit.Width, cmdExit.Top - contextmenuCloseMinimize.Height)
        'Application.Exit()
    End Sub

#End Region

#Region "User Defined Function & Procedures"

    Private Function fnValidate_User_Login() As Boolean

        If String.IsNullOrEmpty(txtUserLoginId.Text) Then
            PMErrorProvider.SetError(txtUserLoginId, "Enter Login Id!")
            txtUserLoginId.Focus()
            Return False
        Else
            PMErrorProvider.SetError(txtUserLoginId, "")
        End If

        If String.IsNullOrEmpty(txtPwd.Text) Then
            PMErrorProvider.SetError(txtPwd, "Enter Password!")
            txtPwd.Focus()
            Return False
        Else
            PMErrorProvider.SetError(txtPwd, "")
        End If

        Dim objAppUsers As New AppUsers.clsAppUsers()
        Dim lngResult As Long

        lngResult = objAppUsers.fnValidate_User_Login(txtUserLoginId.Text.ToString, txtPwd.Text.ToString)
        If lngResult = AppEnums.enumAppUserErrors.eInvalidLoginId Then
            MsgBox("Invalid user login id.", MsgBoxStyle.Exclamation, g_strMessageCaption)
            txtUserLoginId.Focus()
            Return False
        ElseIf lngResult = AppEnums.enumAppUserErrors.eInvalidPwd Then
            MsgBox("Invalid user password.", MsgBoxStyle.Exclamation, g_strMessageCaption)
            txtPwd.Focus()
            Return False
        ElseIf lngResult = AppEnums.enumAppUserErrors.eUserInactive Then
            MsgBox("User is no longer ACTIVE. Please contact your system administrator for details.", MsgBoxStyle.Exclamation, g_strMessageCaption)
            Return False
        ElseIf lngResult = AppEnums.enumAppUserErrors.eUserLocked Then
            MsgBox("User is LOCKED. Please contact your system administrator for details.", MsgBoxStyle.Exclamation, g_strMessageCaption)
            Return False
        End If

        Return True

    End Function

    'Private Function fnValidate_User_Pwd_Expiry(ByVal InStrUserLoginId As String) As Boolean

    '    Dim objDataSet As New Data.DataSet()
    '    Dim objDataAdapter As SqlClient.SqlDataAdapter = Nothing
    '    Dim objClsPassword As New clsPassword()
    '    Dim objclsAdmin_Config As New AppUsers.clsAdmin_Config()
    '    Dim dtPwdChangedDate As Date
    '    Dim dtCurrentDate As Date
    '    Dim intDaysDiff As Int16
    '    Dim intPwdExpPeriod As Int16
    '    Dim intPwdRemPeriod As Int16
    '    Dim intPwdExpDiff As Int16
    '    Dim intPwdRemDiff As Int16

    '    Try
    '        objDataSet.Clear()
    '        objDataAdapter = New SqlClient.SqlDataAdapter(objclsAdmin_Config.m_fnGet_Data(3))
    '        objDataAdapter.Fill(objDataSet, "AdminConfig")
    '        If objDataSet.Tables("AdminConfig").Rows.Count > 0 Then
    '            intPwdExpPeriod = Val(objDataSet.Tables("AdminConfig").Rows(0).Item("Pwd_Expiry_Period") & "")
    '            intPwdRemPeriod = Val(objDataSet.Tables("AdminConfig").Rows(0).Item("Pwd_Expiry_Reminder_Period") & "")
    '        End If

    '        If intPwdExpPeriod > 0 Then
    '            objDataSet.Clear()
    '            objDataAdapter = New SqlClient.SqlDataAdapter(objClsPassword.m_fnGet_User_Name(InStrUserLoginId, 3))
    '            objDataAdapter.Fill(objDataSet, "UserPwd")
    '            If objDataSet.Tables("UserPwd").Rows.Count > 0 Then
    '                If Not objDataSet.Tables("UserPwd").Rows(0).Item("Pwd_Changed_Date") & "" = "" Then
    '                    dtPwdChangedDate = Format(objDataSet.Tables("UserPwd").Rows(0).Item("Pwd_Changed_Date"), "Short Date")
    '                    dtCurrentDate = Format(Now(), "Short Date")
    '                    intDaysDiff = DateDiff(DateInterval.Day, dtPwdChangedDate, dtCurrentDate)
    '                Else
    '                    Return False
    '                End If
    '            Else
    '                Return False
    '            End If

    '            'intPwdExpDiff = intDaysDiff - intPwdExpPeriod
    '            'If intPwdExpDiff > 0 Then
    '            '    MsgBox("Your password has expired " & vbCrLf & "Please change password now.", MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, g_strMessageCaption)
    '            '    m_PwdExpiryStatus = True
    '            '    Cursor.Current = Cursors.WaitCursor
    '            '    Dim frmSetPasswordF As New frmSetPassword()
    '            '    Cursor.Current = Cursors.Default
    '            '    If frmSetPasswordF.fnInitialize_Form = True Then
    '            '        frmSetPasswordF.ShowDialog()
    '            '    End If
    '            '    Return True
    '            'End If

    '            'If intPwdRemPeriod > 0 Then
    '            '    intPwdRemDiff = intDaysDiff - (intPwdExpPeriod - intPwdRemPeriod)
    '            '    If intPwdRemDiff > 0 Then
    '            '        'If (intPwdRemPeriod - intPwdRemDiff) = 0 Then
    '            '        '    If MsgBox("Your password will expire today " & vbCrLf & "Do you want to change password now?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, g_strMessageCaption) = MsgBoxResult.Yes Then
    '            '        '        m_PwdExpiryStatus = False
    '            '        '        Cursor.Current = Cursors.WaitCursor
    '            '        '        Dim frmSetPasswordF As New frmSetPassword()
    '            '        '        Cursor.Current = Cursors.Default
    '            '        '        If frmSetPasswordF.fnInitialize_Form = True Then
    '            '        '            frmSetPasswordF.ShowDialog()
    '            '        '        End If
    '            '        '        Return False
    '            '        '    End If
    '            '        'ElseIf (intPwdRemPeriod - intPwdRemDiff) > 0 Then
    '            '        '    If MsgBox("Your password will expire after " & (intPwdRemPeriod - intPwdRemDiff) & " day(s)" & vbCrLf & "Do you want to change password now?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, g_strMessageCaption) = MsgBoxResult.Yes Then
    '            '        '        m_PwdExpiryStatus = False
    '            '        '        Cursor.Current = Cursors.WaitCursor
    '            '        '        Dim frmSetPasswordF As New frmSetPassword()
    '            '        '        Cursor.Current = Cursors.Default
    '            '        '        If frmSetPasswordF.fnInitialize_Form = True Then
    '            '        '            frmSetPasswordF.ShowDialog()
    '            '        '        End If
    '            '        '        Return False
    '            '        '    End If
    '            '        'End If
    '            '    End If
    '            'End If
    '        End If
    '        m_PwdExpiryStatus = False
    '        Return False
    '    Catch ex As Exception
    '        MsgBox(ex.Message.ToString, MsgBoxStyle.Critical, g_strMessageCaption)
    '    Finally
    '        objDataAdapter.Dispose()
    '        objDataSet.Dispose()
    '        objClsPassword = Nothing
    '        objclsAdmin_Config = Nothing
    '    End Try
    'End Function

#End Region

    Private Sub frmLogin_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Resize
        panelMain.Top = 0
        panelMain.Left = 0
        panelMain.Width = Me.Width
        panelMain.Height = Me.Height

        panelHeader.Top = 0
        panelHeader.Left = 0
        panelHeader.Width = panelMain.Width

        lblHeading.Top = (panelHeader.Height - lblHeading.Height) / 2
        lblHeading.Left = (panelMain.Width - lblHeading.Width) / 2
        Label4.Left = 460
        pbxProjMgr.Left = 460
        pbxRAMTeCH.Left = panelHeader.Width - pbxRAMTeCH.Width - 10

        panelLoginBox.Left = (panelMain.Width - panelLoginBox.Width) / 2
        panelLoginBox.Top = (panelMain.Height - panelLoginBox.Height) / 2

        cmdExit.Left = 25
        cmdExit.Top = panelMain.Height - cmdExit.Height - 25

    End Sub

    Private Sub objTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles objTimer.Tick
        If m_lngTimerCntr >= 3600 Then
            g_dtmSrvDateTime = m_objGetMaster.m_fnGetServerDateTime()
            m_lngTimerCntr = 0
            g_dtmSrvDateTime = m_objGetMaster.m_fnGetServerDateTime()
        Else
            g_dtmSrvDateTime = g_dtmSrvDateTime.AddSeconds(1)
        End If

        m_lngTimerCntr += 1

        lblHeading.Text = Format(g_dtmSrvDateTime, "dddd, MMMM d, yyyy") & vbNewLine & Format(g_dtmSrvDateTime, "HH:mm:ss")
    End Sub

    Private Sub menuExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles menuExit.Click
        Application.Exit()
    End Sub

    Private Sub menuMinimize_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles menuMinimize.Click
        Me.WindowState = FormWindowState.Minimized
    End Sub

 
End Class

View Record In DataGridView


Imports AppGlobals
Imports AppGlobals.AppGlobal
Imports System.Data.SqlClient
Imports System.Data
Public Class frmShowPRInformation
    '**************************************************************************************************
    '** Developed  By : Ramvinay Singh( Design And Coding)
    '** Created On : 01/08/2013
   '**************************************************************************************************

#Region "Declaration Section"

    'object Declaration
    Private Shared m_frmShowPRInformation As frmShowPRInformation
    Private m_intUser_Permission As AppEnums.enumUser_Permission
    Private mobjDBConnect As New DbConnectPAR()
    Private m_objDataSet As New Data.DataSet()
    Private m_objDataAdapter As SqlClient.SqlDataAdapter
    Private DSDeliveryID As New Data.DataSet()
    Private DSSourceType As New Data.DataSet()
    Private DSFeatureName As New Data.DataSet()
    Private SSpecDocItemNumbers As New Data.DataSet()
    Dim strSQL As String

#End Region

#Region "Properties"
    Public Shared Property m_GetfrmShowPRInformation() As frmShowPRInformation
        Get
            If m_frmShowPRInformation Is Nothing _
                OrElse m_frmShowPRInformation.IsDisposed Then
                m_frmShowPRInformation = New frmShowPRInformation()
            End If
            m_GetfrmShowPRInformation = frmShowPRInformation
        End Get
        Set(ByVal Value As frmShowPRInformation)
            m_frmShowPRInformation = Value
        End Set
    End Property


#End Region

#Region "Form Objects Procedures"
    '
    Private Sub cmdExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdExit.Click
        Me.Close()
    End Sub
 


    Private Sub cmdPreview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdPreview.Click
        Try
            Call fnMyAttendaceDetail()
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical, g_strMessageCaption)
        End Try
    End Sub
    Public Function fnFillStaus() As String
        Cursor.Current = Cursors.WaitCursor
        Try
            Dim strSQL As String
            Dim DSStatus As New Data.DataSet()
            strSQL = "SELECT StutusID,Status  FROM dbo.mstStatus"
            DSStatus.Clear()
            Dim sqlCmd As SqlCommand
            m_objDataAdapter = New SqlClient.SqlDataAdapter()
            mobjDBConnect.OpenConnection()
            sqlCmd = New SqlCommand(strSQL, mobjDBConnect.GetConnection)
            m_objDataAdapter.SelectCommand = sqlCmd
            m_objDataAdapter.Fill(DSStatus, "Status")
            If DSStatus.Tables("Status").Rows.Count <> 0 Then
                cmbStatus.DataSource = DSStatus.Tables("Status")
                cmbStatus.ValueMember = "StutusID"
                cmbStatus.DisplayMember = "Status"
            End If
        Catch ex As Exception
            Cursor.Current = Cursors.Default
            MsgBox(ex.Message.ToString, MsgBoxStyle.Critical, g_strMessageCaption)
        End Try

    End Function
    Private Function fnMyAttendaceDetail()
        Try
            m_FillRecordDatagrid()
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical, g_strMessageCaption)
        End Try
    End Function
    Public Sub m_FillRecordDatagrid()
        Try
            Dim sqlCmd As New SqlCommand
            Dim dsRec As New Data.DataSet()
            Dim DA As New SqlDataAdapter
            dgvPRInformation.AllowUserToAddRows = False
            dgvPRInformation.AllowUserToDeleteRows = False
            m_objDataAdapter = New SqlClient.SqlDataAdapter()
            mobjDBConnect.OpenConnection()
            Dim sqlpp As New SqlParameter
            sqlCmd.Connection = mobjDBConnect.GetConnection
            sqlCmd.CommandType = CommandType.StoredProcedure
            sqlCmd.CommandText = "spPRInformation"
            sqlCmd.Parameters.AddWithValue("@Flag", 8)
            Dim Status As String = ""
            If (cmbStatus.SelectedValue = 1) Then
                Status = ""
            ElseIf (cmbStatus.SelectedValue = 2) Then
                Status = "A"
            ElseIf (cmbStatus.SelectedValue = 3) Then
                Status = "R"
            ElseIf (cmbStatus.SelectedValue = 4) Then
                Status = "All"

            End If
            sqlCmd.Parameters.AddWithValue("@Status", Status)
            m_objDataAdapter.SelectCommand = sqlCmd
            Dim SQLP As SqlParameter = sqlCmd.Parameters.Add("RETURN_VALUE", SqlDbType.BigInt)
            SQLP.Direction = ParameterDirection.ReturnValue
            Try
                DA = New SqlDataAdapter(sqlCmd)
                DA.Fill(dsRec)
                dgvPRInformation.Rows.Clear()
                If dsRec.Tables(0).Rows.Count <> 0 Then
                    Dim ictr As Integer
                    dgvPRInformation.Rows.Add(dsRec.Tables(0).Rows.Count)
                    For ictr = 0 To dsRec.Tables(0).Rows.Count - 1
                        dgvPRInformation.Rows(ictr).Cells(1).Value = dsRec.Tables(0).Rows(ictr).Item("PRInfoId")
                        dgvPRInformation.Rows(ictr).Cells(2).Value = dsRec.Tables(0).Rows(ictr).Item("DeliveryVersion")
                        dgvPRInformation.Rows(ictr).Cells(3).Value = dsRec.Tables(0).Rows(ictr).Item("DeliveryID")
                        dgvPRInformation.Rows(ictr).Cells(4).Value = dsRec.Tables(0).Rows(ictr).Item("SourceType")
                        dgvPRInformation.Rows(ictr).Cells(5).Value = dsRec.Tables(0).Rows(ictr).Item("GridID")
                        dgvPRInformation.Rows(ictr).Cells(6).Value = dsRec.Tables(0).Rows(ictr).Item("LinenPageNo")
                        dgvPRInformation.Rows(ictr).Cells(7).Value = dsRec.Tables(0).Rows(ictr).Item("LinenSourceImagePath")
                        dgvPRInformation.Rows(ictr).Cells(8).Value = dsRec.Tables(0).Rows(ictr).Item("ServiceCardImagePath")
                        dgvPRInformation.Rows(ictr).Cells(9).Value = dsRec.Tables(0).Rows(ictr).Item("SiteID")
                        dgvPRInformation.Rows(ictr).Cells(10).Value = dsRec.Tables(0).Rows(ictr).Item("PostedBy")
                        dgvPRInformation.Rows(ictr).Cells(11).Value = dsRec.Tables(0).Rows(ictr).Item("FeatureName")
                        dgvPRInformation.Rows(ictr).Cells(12).Value = dsRec.Tables(0).Rows(ictr).Item("GisID")
                        dgvPRInformation.Rows(ictr).Cells(13).Value = dsRec.Tables(0).Rows(ictr).Item("StreetName")
                        dgvPRInformation.Rows(ictr).Cells(14).Value = dsRec.Tables(0).Rows(ictr).Item("IssueDescription")
                        dgvPRInformation.Rows(ictr).Cells(15).Value = dsRec.Tables(0).Rows(ictr).Item("SpecDocItemNumbers")
                        dgvPRInformation.Rows(ictr).Cells(16).Value = dsRec.Tables(0).Rows(ictr).Item("Status")

                        dgvPRInformation.Rows(ictr).Cells(0).ReadOnly = False
                        dgvPRInformation.Rows(ictr).Cells(1).ReadOnly = True
                        dgvPRInformation.Rows(ictr).Cells(2).ReadOnly = True
                        dgvPRInformation.Rows(ictr).Cells(3).ReadOnly = True
                        dgvPRInformation.Rows(ictr).Cells(4).ReadOnly = True
                        dgvPRInformation.Rows(ictr).Cells(5).ReadOnly = True
                        dgvPRInformation.Rows(ictr).Cells(6).ReadOnly = True
                        dgvPRInformation.Rows(ictr).Cells(7).ReadOnly = True
                        dgvPRInformation.Rows(ictr).Cells(8).ReadOnly = True
                        dgvPRInformation.Rows(ictr).Cells(9).ReadOnly = True
                        dgvPRInformation.Rows(ictr).Cells(10).ReadOnly = True
                        dgvPRInformation.Rows(ictr).Cells(11).ReadOnly = True
                        dgvPRInformation.Rows(ictr).Cells(12).ReadOnly = True
                        dgvPRInformation.Rows(ictr).Cells(13).ReadOnly = True
                        dgvPRInformation.Rows(ictr).Cells(14).ReadOnly = True
                        dgvPRInformation.Rows(ictr).Cells(15).ReadOnly = True
                        dgvPRInformation.Rows(ictr).Cells(16).ReadOnly = True

                    Next
                End If

             
                Cursor.Current = Cursors.Default
            Catch ex As Exception
                Cursor.Current = Cursors.Default
                MsgBox(ex.Message.ToString, MsgBoxStyle.Critical, g_strMessageCaption)
            End Try
        Catch ex As Exception
            Cursor.Current = Cursors.Default
            MsgBox(ex.Message.ToString, MsgBoxStyle.Critical, g_strMessageCaption)
        End Try
    End Sub
 

#End Region

#Region "User Defined Function"
    Public Function fnInitialize_Form() As Boolean
        Try
            m_intUser_Permission = fnGet_User_Permission()
            fnFillStaus()
            fnMyAttendaceDetail()

            Call subEnable_Disable_Controls()
            Return True
        Catch ex As Exception
            MsgBox(ex.Message.ToString, MsgBoxStyle.Critical, g_strMessageCaption)
            Return False
        End Try
    End Function
    Private Sub btnAprove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAprove.Click
        Try
            Dim isSelected As Boolean
            Dim IsRecord As Boolean = False
            If (dgvPRInformation.Rows.Count > 0) Then
                For Each row As DataGridViewRow In dgvPRInformation.Rows
                    isSelected = Convert.ToBoolean(row.Cells("checkBoxColumn").Value)
                    If isSelected = True Then
                        ApprovedRecords(row.Cells(1).Value)
                        IsRecord = True
                    End If
                Next
                If (IsRecord = True) Then
                    dgvPRInformation.Rows.Clear()
                    fnMyAttendaceDetail()
                End If
               
            End If
         
        Catch ex As Exception
        End Try

    End Sub

    Private Sub btnReject_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReject.Click
        Try
            Dim isSelected As Boolean
            Dim IsRecord As Boolean = False
            If (dgvPRInformation.Rows.Count > 0) Then
                For Each row As DataGridViewRow In dgvPRInformation.Rows
                    isSelected = Convert.ToBoolean(row.Cells("checkBoxColumn").Value)
                    If isSelected = True Then
                        RejectedRecords(row.Cells(1).Value)
                        IsRecord = True
                    End If
                Next
                If (IsRecord = True) Then
                    dgvPRInformation.Rows.Clear()
                    fnMyAttendaceDetail()
                End If
            End If
        Catch ex As Exception

        End Try
    End Sub

    Private Sub ApprovedRecords(ByVal PRInfoId As Integer)
        Dim CMD As New SqlCommand
        Dim RecIDCust As Long
        mobjDBConnect.OpenConnection()
        Dim sqlpp As New SqlParameter
        CMD.Connection = mobjDBConnect.GetConnection
        CMD.CommandType = CommandType.StoredProcedure
        CMD.CommandText = "spPRInformation"
        CMD.Parameters.AddWithValue("@PRInfoId", PRInfoId)
        CMD.Parameters.AddWithValue("@Status", "A")
        CMD.Parameters.AddWithValue("@ApprovedBy", mdlPMGlobal.glbstrUser_Name)
        CMD.Parameters.AddWithValue("@Flag", 6)
        RecIDCust = CMD.ExecuteNonQuery()
        If (RecIDCust > 0) Then
         
        End If


    End Sub
    Private Sub RejectedRecords(ByVal PRInfoId As Integer)
        Dim CMD As New SqlCommand
        Dim RecIDCust As Long
        mobjDBConnect.OpenConnection()
        Dim sqlpp As New SqlParameter
        CMD.Connection = mobjDBConnect.GetConnection
        CMD.CommandType = CommandType.StoredProcedure
        CMD.CommandText = "spPRInformation"
        CMD.Parameters.AddWithValue("@PRInfoId", PRInfoId)
        CMD.Parameters.AddWithValue("@Status", "R")
        CMD.Parameters.AddWithValue("@RejectedBy", mdlPMGlobal.glbstrUser_Name)
        CMD.Parameters.AddWithValue("@Flag", 7)
        RecIDCust = CMD.ExecuteNonQuery()
        If (RecIDCust > 0) Then
       
        End If


    End Sub
    Private Sub subEnable_Disable_Controls()
   
        If (m_intUser_Permission = AppEnums.enumUser_Permission.eView_Records) Or (m_intUser_Permission = AppEnums.enumUser_Permission.eAdd_Records) Or _
          (m_intUser_Permission = AppEnums.enumUser_Permission.eAdministrator) Then
            cmdPreview.Enabled = True
            grpHeader.Enabled = True
        End If
    End Sub

#End Region


    Private Sub frmAttn_FromTo_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
        '869, 535
        If Me.Width < 869 Or Me.Height < 535 Then
            Me.Width = 869
            Me.Height = 535
            Exit Sub
        End If
        '855, 48
        grpHeader.Width = Me.Width - 15
        '855, 457
        grpbxMstList.Width = Me.Width - 15
        grpbxMstList.Height = Me.Height - 78
        '844, 439
        dgvPRInformation.Width = grpbxMstList.Width - 10
        dgvPRInformation.Height = grpbxMstList.Height - 18
        dgvPRInformation.Columns(0).Width = 40
        dgvPRInformation.Columns(1).Width = dgvPRInformation.Width / 12
        dgvPRInformation.Columns(2).Width = dgvPRInformation.Width / 12
        dgvPRInformation.Columns(3).Width = dgvPRInformation.Width / 12
        dgvPRInformation.Columns(4).Width = dgvPRInformation.Width / 12
        dgvPRInformation.Columns(5).Width = dgvPRInformation.Width / 12
        dgvPRInformation.Columns(6).Width = dgvPRInformation.Width / 12
        dgvPRInformation.Columns(7).Width = dgvPRInformation.Width / 12
        dgvPRInformation.Columns(8).Width = dgvPRInformation.Width / 12
        dgvPRInformation.Columns(9).Width = dgvPRInformation.Width / 12
        dgvPRInformation.Columns(10).Width = dgvPRInformation.Width / 12
        dgvPRInformation.Columns(11).Width = dgvPRInformation.Width / 12
        dgvPRInformation.Columns(12).Width = dgvPRInformation.Width / 12
        dgvPRInformation.Columns(13).Width = (dgvPRInformation.Width / 12) * 2
        dgvPRInformation.Columns(15).Width = (dgvPRInformation.Width / 12)
        dgvPRInformation.Columns(14).Width = (dgvPRInformation.Width / 12) * 4


    End Sub

 

    Private Sub cmdResetFilter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdResetFilter.Click
        Try
            cmbStatus.SelectedIndex = 0
            fnMyAttendaceDetail()
        Catch ex As Exception

        End Try
    End Sub

 
    Private Sub dgvPRInformation_CellDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvPRInformation.CellDoubleClick
        Dim PRInfoId As Int16 = 0
        Dim DsgetValue As New DataSet
        Try

            Dim strReturnDataString As String
            strReturnDataString = ""
            fnFillDeliveryID()
            fnFillSourceType()
            fnFillFeatureName()
            fnFillSpecDocItemNumbers()

            frmInformationPRApproveReject.m_GetfrmInformationPRAR.getARPRInfoID = strReturnDataString & dgvPRInformation.SelectedRows(0).Cells(1).Value.ToString
            PRInfoId = frmInformationPRApproveReject.m_GetfrmInformationPRAR.getARPRInfoID
            If (PRInfoId <> 0) Then
                Dim sqlCmd As New SqlCommand
                Dim DA As New SqlDataAdapter

                mobjDBConnect.OpenConnection()

                sqlCmd.Connection = mobjDBConnect.GetConnection
                sqlCmd.CommandType = CommandType.StoredProcedure
                sqlCmd.CommandText = "spPRInformation"
                sqlCmd.Parameters.AddWithValue("@PRInfoId", PRInfoId)
                sqlCmd.Parameters.AddWithValue("@Flag", 3)
                DA.SelectCommand = sqlCmd
                Dim SQLP As SqlParameter = sqlCmd.Parameters.Add("RETURN_VALUE", SqlDbType.BigInt)
                SQLP.Direction = ParameterDirection.ReturnValue
                '
                DA = New SqlDataAdapter(sqlCmd)
                DA.Fill(DsgetValue)
                If DsgetValue.Tables(0).Rows.Count <> 0 Then

                    frmInformationPRApproveReject.m_GetfrmInformationPRAR.txtDivisionVersion.Text = DsgetValue.Tables(0).Rows(0).Item("DeliveryVersion")
                    frmInformationPRApproveReject.m_GetfrmInformationPRAR.txtServicesCardImagepath.Text = DsgetValue.Tables(0).Rows(0).Item("ServiceCardImagePath")
                    frmInformationPRApproveReject.m_GetfrmInformationPRAR.txtLinenSourcePath.Text = DsgetValue.Tables(0).Rows(0).Item("LinenSourceImagePath")
                    frmInformationPRApproveReject.m_GetfrmInformationPRAR.txtLinenPageNo.Text = DsgetValue.Tables(0).Rows(0).Item("LinenPageNo")
                    frmInformationPRApproveReject.m_GetfrmInformationPRAR.txtGridId.Text = DsgetValue.Tables(0).Rows(0).Item("GridID")
                    frmInformationPRApproveReject.m_GetfrmInformationPRAR.txtSiteID.Text = DsgetValue.Tables(0).Rows(0).Item("SiteID")
                    frmInformationPRApproveReject.m_GetfrmInformationPRAR.txtPostedBy.Text = DsgetValue.Tables(0).Rows(0).Item("PostedBy")
                    frmInformationPRApproveReject.m_GetfrmInformationPRAR.txtGISID.Text = DsgetValue.Tables(0).Rows(0).Item("GisID")
                    frmInformationPRApproveReject.m_GetfrmInformationPRAR.txtStreatName.Text = DsgetValue.Tables(0).Rows(0).Item("StreetName")
                    frmInformationPRApproveReject.m_GetfrmInformationPRAR.txtIssuesDisc.Text = DsgetValue.Tables(0).Rows(0).Item("IssueDescription")

                    frmInformationPRApproveReject.m_GetfrmInformationPRAR.cmbDeliveryID.SelectedIndex = Convert.ToInt32(DsgetValue.Tables(0).Rows(0).Item("DeliveryNo"))
                    frmInformationPRApproveReject.m_GetfrmInformationPRAR.cmbSourceType.SelectedIndex = Convert.ToInt32(DsgetValue.Tables(0).Rows(0).Item("SourceTypeID"))
                    frmInformationPRApproveReject.m_GetfrmInformationPRAR.cmbFeatureName.SelectedIndex = Convert.ToInt32(DsgetValue.Tables(0).Rows(0).Item("FeatureNameID"))
                    frmInformationPRApproveReject.m_GetfrmInformationPRAR.cmbSpecDoc.SelectedIndex = Convert.ToInt32(DsgetValue.Tables(0).Rows(0).Item("SpecDocID"))

                    frmInformationPRApproveReject.m_GetfrmInformationPRAR.btnApprove.Visible = True
                    frmInformationPRApproveReject.m_GetfrmInformationPRAR.btnReject.Visible = True

                End If
            End If
            With frmInformationPRApproveReject.m_GetfrmInformationPRAR
                .ShowInTaskbar = False
                .StartPosition = FormStartPosition.CenterScreen
                .ShowDialog()
            End With
            fnMyAttendaceDetail()

        Catch ex As Exception
            MsgBox(ex.Message.ToString, MsgBoxStyle.Critical, "Project Manager")
            Exit Try
        Finally
        End Try
    End Sub

 
    Public Function fnFillDeliveryID() As String
        Cursor.Current = Cursors.WaitCursor
        Try
            Dim strSQL As String
            strSQL = "SELECT DeliveryNo,DeliveryID  FROM dbo.mstDelivery  "
            DSDeliveryID.Clear()
            Dim sqlCmd As SqlCommand
            m_objDataAdapter = New SqlClient.SqlDataAdapter()
            mobjDBConnect.OpenConnection()
            sqlCmd = New SqlCommand(strSQL, mobjDBConnect.GetConnection)
            m_objDataAdapter.SelectCommand = sqlCmd
            m_objDataAdapter.Fill(DSDeliveryID, "Delivery")
            m_objDataAdapter.Fill(DSDeliveryID, "Delivery")
            Dim dr As DataRow = DSDeliveryID.Tables("Delivery").NewRow()
            dr(0) = "-1"
            dr(1) = "-- Select --"
            DSDeliveryID.Tables("Delivery").Rows.InsertAt(dr, 0)
            If DSDeliveryID.Tables("Delivery").Rows.Count <> 0 Then
                frmInformationPRApproveReject.m_GetfrmInformationPRAR.cmbDeliveryID.DataSource = DSDeliveryID.Tables("Delivery")
                frmInformationPRApproveReject.m_GetfrmInformationPRAR.cmbDeliveryID.ValueMember = "DeliveryNo"
                frmInformationPRApproveReject.m_GetfrmInformationPRAR.cmbDeliveryID.DisplayMember = "DeliveryID"
            End If
        Catch ex As Exception
            Cursor.Current = Cursors.Default
            MsgBox(ex.Message.ToString, MsgBoxStyle.Critical, g_strMessageCaption)
        End Try

    End Function

 

    Public Function fnFillSourceType() As String
        Cursor.Current = Cursors.WaitCursor
        Try
            Dim strSQL As String
            Dim m_objDataSetSourceType As New Data.DataSet()
            strSQL = "SELECT SourceTypeID,SourceType  FROM dbo.mstSourceType"
            DSSourceType.Clear()
            Dim sqlCmd As SqlCommand
            m_objDataAdapter = New SqlClient.SqlDataAdapter()
            mobjDBConnect.OpenConnection()
            sqlCmd = New SqlCommand(strSQL, mobjDBConnect.GetConnection)
            m_objDataAdapter.SelectCommand = sqlCmd
            m_objDataAdapter.Fill(DSSourceType, "SourceType")
            Dim dr As DataRow = DSSourceType.Tables("SourceType").NewRow()
            dr(0) = "-1"
            dr(1) = "-- Select --"
            DSSourceType.Tables("SourceType").Rows.InsertAt(dr, 0)
            If DSSourceType.Tables("SourceType").Rows.Count <> 0 Then
                frmInformationPRApproveReject.m_GetfrmInformationPRAR.cmbSourceType.DataSource = DSSourceType.Tables("SourceType")
                frmInformationPRApproveReject.m_GetfrmInformationPRAR.cmbSourceType.ValueMember = "SourceTypeID"
                frmInformationPRApproveReject.m_GetfrmInformationPRAR.cmbSourceType.DisplayMember = "SourceType"
            End If
        Catch ex As Exception
            Cursor.Current = Cursors.Default
            MsgBox(ex.Message.ToString, MsgBoxStyle.Critical, g_strMessageCaption)
        End Try

    End Function


    Public Function fnFillFeatureName() As String
        Cursor.Current = Cursors.WaitCursor
        Try
            Dim strSQLFeatureName As String
            Dim DSFeatureName As New Data.DataSet()
            strSQLFeatureName = "SELECT FeatureNameID,FeatureName  FROM dbo.mstFeatureName "
            DSFeatureName.Clear()
            Dim sqlCmd As SqlCommand
            m_objDataAdapter = New SqlClient.SqlDataAdapter()
            mobjDBConnect.OpenConnection()
            sqlCmd = New SqlCommand(strSQLFeatureName, mobjDBConnect.GetConnection)
            m_objDataAdapter.SelectCommand = sqlCmd
            m_objDataAdapter.Fill(DSFeatureName, "FeatureName")
            Dim dr As DataRow = DSFeatureName.Tables("FeatureName").NewRow()
            dr(0) = "-1"
            dr(1) = "-- Select --"
            DSFeatureName.Tables("FeatureName").Rows.InsertAt(dr, 0)
            If DSFeatureName.Tables("FeatureName").Rows.Count <> 0 Then
                frmInformationPRApproveReject.m_GetfrmInformationPRAR.cmbFeatureName.DataSource = DSFeatureName.Tables("FeatureName")
                frmInformationPRApproveReject.m_GetfrmInformationPRAR.cmbFeatureName.ValueMember = "FeatureNameID"
                frmInformationPRApproveReject.m_GetfrmInformationPRAR.cmbFeatureName.DisplayMember = "FeatureName"
            End If
        Catch ex As Exception
            Cursor.Current = Cursors.Default
            MsgBox(ex.Message.ToString, MsgBoxStyle.Critical, g_strMessageCaption)
        End Try

    End Function

    Public Function fnFillSpecDocItemNumbers() As String
        Cursor.Current = Cursors.WaitCursor
        Try
            Dim strSQLSpecDocItemNumbers As String
            Dim DSSpecDocItemNumbers As New Data.DataSet()
            strSQLSpecDocItemNumbers = "SELECT SpecDocID,SpecDocItemNumbers  FROM dbo.mstSpecDocItemNumbers"
            DSSpecDocItemNumbers.Clear()
            Dim sqlCmd As SqlCommand
            m_objDataAdapter = New SqlClient.SqlDataAdapter()
            mobjDBConnect.OpenConnection()
            sqlCmd = New SqlCommand(strSQLSpecDocItemNumbers, mobjDBConnect.GetConnection)
            m_objDataAdapter.SelectCommand = sqlCmd
            m_objDataAdapter.Fill(DSSpecDocItemNumbers, "SpecDocItemNumbers")
            Dim dr As DataRow = DSSpecDocItemNumbers.Tables("SpecDocItemNumbers").NewRow()
            dr(0) = "-1"
            dr(1) = "-- Select --"
            DSSpecDocItemNumbers.Tables("SpecDocItemNumbers").Rows.InsertAt(dr, 0)
            If DSSpecDocItemNumbers.Tables("SpecDocItemNumbers").Rows.Count <> 0 Then
                frmInformationPRApproveReject.m_GetfrmInformationPRAR.cmbSpecDoc.DataSource = DSSpecDocItemNumbers.Tables("SpecDocItemNumbers")
                frmInformationPRApproveReject.m_GetfrmInformationPRAR.cmbSpecDoc.ValueMember = "SpecDocID"
                frmInformationPRApproveReject.m_GetfrmInformationPRAR.cmbSpecDoc.DisplayMember = "SpecDocItemNumbers"
            End If
        Catch ex As Exception
            Cursor.Current = Cursors.Default
            MsgBox(ex.Message.ToString, MsgBoxStyle.Critical, g_strMessageCaption)
        End Try

    End Function

    Private Sub btnExportToExcel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExportToExcel.Click
        With frmDeliveryDilogBox.m_GetfrmDeliveryDilogBox
            If .fnInitialize_Form() Then
                .ShowInTaskbar = False
                .StartPosition = FormStartPosition.CenterScreen
                .ShowDialog()
            End If
        End With
    End Sub

    Private Sub frmShowPRInformation_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
        Try
            If e.KeyCode = Keys.Escape Then Me.Close()
        Catch ex As Exception

        End Try
    End Sub
End Class

Thursday 1 January 2015

Export To Excel Record from DataSet

Imports AppGlobals
Imports AppGlobals.AppGlobal
Imports System.Data.SqlClient
Imports System.Data
Imports Microsoft.Office.Interop.Excel


Public Class frmDeliveryDilogBox
    Private Shared objfrmDeliveryDilogBox As frmDeliveryDilogBox
    Private Shared m_objDataSet_DeliveryID As New Data.DataSet()
    Private Shared m_objDataSet_SourceType As New Data.DataSet()
    Private Shared m_objDataSet_FeatureName As New Data.DataSet()
    Private Shared m_objDataSet_SpecDocItemNumbers As New Data.DataSet()
    Private mobjDBConnect As New DbConnectPAR()
    Private m_objDataSetDelivery As New Data.DataSet()
    Private m_objDataAdapter As SqlClient.SqlDataAdapter
    Dim ds As New Data.DataSet()
    Dim strSQL As String
    Private Sub btnExportToExel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExportToExel.Click
        Try

            ExportToExcel()
        Catch ex As Exception

        End Try
    End Sub
    Public Sub ExportToExcel()
        Dim DSDelivery As New Data.DataSet()
        Dim sqlCmd As New SqlCommand
        Dim DA As New SqlDataAdapter
        mobjDBConnect.OpenConnection()
        sqlCmd.Connection = mobjDBConnect.GetConnection
        sqlCmd.CommandType = CommandType.StoredProcedure
        sqlCmd.CommandText = "spPRInformation"
        sqlCmd.Parameters.AddWithValue("@DeliveryNo", cmbDeliveryID.SelectedValue)
        sqlCmd.Parameters.AddWithValue("@Flag", 9)
        DA.SelectCommand = sqlCmd
        Dim SQLP As SqlParameter = sqlCmd.Parameters.Add("RETURN_VALUE", SqlDbType.BigInt)
        SQLP.Direction = ParameterDirection.ReturnValue
        '
        DA = New SqlDataAdapter(sqlCmd)
        DA.Fill(DSDelivery)
        If DSDelivery.Tables(0).Rows.Count <> 0 Then

            Dim strFilename As String = ""
            Dim intCol, intRow As Integer

            Dim Excel As Object = CreateObject("Excel.Application")
            If Excel Is Nothing Then
                MsgBox("It appears that Excel is not installed on this machine. This operation requires MS Excel to be installed on this machine.", MsgBoxStyle.Critical)
                Return
            End If

            Dim dlgSaveFile As New System.Windows.Forms.SaveFileDialog
            dlgSaveFile.Filter = "Execl files (*.xls)|*.xls"
            dlgSaveFile.ShowDialog()

            Try
                If dlgSaveFile.FileName = "" Then
                    Exit Sub
                End If

                With Excel
                    .SheetsInNewWorkbook = 1
                    .Workbooks.Add()
                    .Worksheets(1).Select()

                    Dim intI As Integer = 1
                    For intCol = 0 To DSDelivery.Tables(0).Columns.Count - 1
                        .cells(2, intI).value = DSDelivery.Tables(0).Columns(intCol).ColumnName
                        .cells(2, intI).EntireRow.Font.Bold = True
                        intI += 1
                    Next
                    intI = 3
                    Dim intK As Integer = 1
                    For intCol = 0 To DSDelivery.Tables(0).Columns.Count - 1
                        intI = 3
                        For intRow = 0 To DSDelivery.Tables(0).Rows.Count - 1
                            .Cells(intI, intK).Value = DSDelivery.Tables(0).Rows(intRow).ItemArray(intCol)
                            intI += 1
                        Next
                        intK += 1
                    Next
                    .ActiveCell.Worksheet.SaveAs(dlgSaveFile.FileName)
                End With
                System.Runtime.InteropServices.Marshal.ReleaseComObject(Excel)
                Excel = Nothing
                'MessageBox.Show("Record has been saved successfully.", g_strMessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
                MessageBox.Show("Data's are exported to Excel Succesfully in '" & dlgSaveFile.FileName & "'", g_strMessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
            ' The excel is created and opened for insert value. We most close this excel using this system
            Dim pro() As Process = System.Diagnostics.Process.GetProcessesByName("EXCEL")
            For Each i As Process In pro
                i.Kill()
            Next

        Else
            'lblMsg.Visible = True
            'lblMsg.Text = " Approved Data's are exported only  to Excel !"
           
        End If

    End Sub


#Region "Properties"
    Public Shared Property m_GetfrmDeliveryDilogBox() As frmDeliveryDilogBox
        Get
            If objfrmDeliveryDilogBox Is Nothing _
                OrElse objfrmDeliveryDilogBox.IsDisposed Then
                objfrmDeliveryDilogBox = New frmDeliveryDilogBox()
            End If
            m_GetfrmDeliveryDilogBox = frmDeliveryDilogBox
        End Get
        Set(ByVal Value As frmDeliveryDilogBox)
            objfrmDeliveryDilogBox = Value
        End Set
    End Property
#End Region
#Region "User Defined Function"
    Public Function fnInitialize_Form() As Boolean
        Try
            fnFillDeliveryID()
            Return True
        Catch ex As Exception
            MsgBox(ex.Message.ToString, MsgBoxStyle.Critical, g_strMessageCaption)
            Return False
        End Try
    End Function
#End Region
    Public Function fnFillDeliveryID() As String
        Cursor.Current = Cursors.WaitCursor
        Try
            Dim strSQL As String
            strSQL = "select distinct PRInformation.DeliveryNo, dbo.mstDelivery.DeliveryID from dbo.PRInformation Left Outer Join dbo.mstDelivery  on dbo.mstDelivery.DeliveryNo=PRInformation.DeliveryNo where PRInformation.Status='A'"
            m_objDataSetDelivery.Clear()
            Dim sqlCmd As SqlCommand
            m_objDataAdapter = New SqlClient.SqlDataAdapter()
            mobjDBConnect.OpenConnection()
            sqlCmd = New SqlCommand(strSQL, mobjDBConnect.GetConnection)
            m_objDataAdapter.SelectCommand = sqlCmd
            m_objDataAdapter.Fill(m_objDataSetDelivery, "Delivery")
            If m_objDataSetDelivery.Tables("Delivery").Rows.Count <> 0 Then
                cmbDeliveryID.DataSource = m_objDataSetDelivery.Tables("Delivery")
                cmbDeliveryID.ValueMember = "DeliveryNo"
                cmbDeliveryID.DisplayMember = "DeliveryID"
            End If
        Catch ex As Exception
            Cursor.Current = Cursors.Default
            MsgBox(ex.Message.ToString, MsgBoxStyle.Critical, g_strMessageCaption)
        End Try

    End Function
 
    Private Sub btncancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncancel.Click
        Try
            Me.Close()
        Catch ex As Exception

        End Try
    End Sub

    Private Sub frmDeliveryDilogBox_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
        Try
            If e.KeyCode = Keys.Escape Then Me.Close()
        Catch ex As Exception

        End Try

    End Sub

 
End Class

Save ,Update ,Delete ,View Record In windows Form


Imports AppGlobals
Imports AppGlobals.AppGlobal
Imports System.Data.SqlClient

Public Class frmInformationPR
#Region "Declaration"
    Private Shared objfrmInformationPR As frmInformationPR
    Private Shared m_objDataSet_DeliveryID As New Data.DataSet()
    Private Shared m_objDataSet_SourceType As New Data.DataSet()
    Private Shared m_objDataSet_FeatureName As New Data.DataSet()
    Private Shared m_objDataSet_SpecDocItemNumbers As New Data.DataSet()
    Private mobjDBConnect As New DbConnectPAR()
    Private m_objDataSetDelivery As New Data.DataSet()
    Private m_objDataAdapter As SqlClient.SqlDataAdapter
    Dim ds As New Data.DataSet()
    Dim strSQL As String
    Private m_strLookupReturnValue As String
    Dim PRInfoId As Int16 = 0
    Private m_intUser_Permission As AppEnums.enumUser_Permission
#End Region
#Region "~Property Declaration~"
    Public Shared Property m_GetfrmInformationPR() As frmInformationPR
        Get
            If objfrmInformationPR Is Nothing _
                OrElse objfrmInformationPR.IsDisposed Then
                objfrmInformationPR = New frmInformationPR()
            End If
            m_GetfrmInformationPR = frmInformationPR
        End Get
        Set(ByVal Value As frmInformationPR)
            objfrmInformationPR = Value
        End Set
    End Property

    Public Property getPRInfoID() As String
        Get
            Return PRInfoId
        End Get

        Set(ByVal value As String)
            PRInfoId = value
        End Set
    End Property

    Public Property LookupReturnValue() As String
        Get
            Return m_strLookupReturnValue
        End Get
        Set(ByVal Value As String)
            m_strLookupReturnValue = Value
        End Set
    End Property

#End Region

#Region "User defined Functions and Procedures"
    Public Function fnInitialize_Form() As Boolean
        Try
           
            m_intUser_Permission = AppEnums.enumUser_Permission.eAdministrator ''Hard Coded by ravindra
            Call subClear_Controls()
            m_intUser_Permission = fnGet_User_Permission()
            txtPostedBy.Text = mdlPMGlobal.glbstrUser_Name
            Return True
        Catch ex As Exception
            MsgBox(ex.Message.ToString, MsgBoxStyle.Critical, g_strMessageCaption)
            Return False
        End Try
    End Function

    Private Sub subClear_Controls()

        txtDivisionVersion.Text = ""
        txtServicesCardImagepath.Text = ""
        txtLinenSourcePath.Text = ""
        txtLinenPageNo.Text = ""
        txtGridId.Text = ""
        txtSiteID.Text = ""
        txtPostedBy.Text = ""
        txtGISID.Text = ""
        txtStreatName.Text = ""
        txtIssuesDisc.Text = ""
        cmbDeliveryID.SelectedIndex = -1
        cmbSourceType.SelectedIndex = -1
        cmbFeatureName.SelectedIndex = -1
        cmbSpecDoc.SelectedIndex = -1

    End Sub
    Public Function fnFillDeliveryID() As String
        Cursor.Current = Cursors.WaitCursor
        Try
            Dim strSQL As String
            strSQL = "SELECT DeliveryNo,DeliveryID  FROM dbo.mstDelivery  "
            m_objDataSetDelivery.Clear()
            Dim sqlCmd As SqlCommand
            m_objDataAdapter = New SqlClient.SqlDataAdapter()
            mobjDBConnect.OpenConnection()
            sqlCmd = New SqlCommand(strSQL, mobjDBConnect.GetConnection)
            m_objDataAdapter.SelectCommand = sqlCmd
            m_objDataAdapter.Fill(m_objDataSetDelivery, "Delivery")
            Dim dr As DataRow = m_objDataSetDelivery.Tables("Delivery").NewRow()
            dr(0) = "-1"
            dr(1) = "-- Select --"
            m_objDataSetDelivery.Tables("Delivery").Rows.InsertAt(dr, 0)
            If m_objDataSetDelivery.Tables("Delivery").Rows.Count <> 0 Then
                cmbDeliveryID.DataSource = m_objDataSetDelivery.Tables("Delivery")
                cmbDeliveryID.ValueMember = "DeliveryNo"
                cmbDeliveryID.DisplayMember = "DeliveryID"
            End If
        Catch ex As Exception
            Cursor.Current = Cursors.Default
            MsgBox(ex.Message.ToString, MsgBoxStyle.Critical, g_strMessageCaption)
        End Try

    End Function
    Public Function fnFillSourceType() As String
        Cursor.Current = Cursors.WaitCursor
        Try
            Dim strSQL As String
            Dim m_objDataSetSourceType As New Data.DataSet()
            strSQL = "SELECT SourceTypeID,SourceType  FROM dbo.mstSourceType"
            m_objDataSetSourceType.Clear()
            Dim sqlCmd As SqlCommand
            m_objDataAdapter = New SqlClient.SqlDataAdapter()
            mobjDBConnect.OpenConnection()
            sqlCmd = New SqlCommand(strSQL, mobjDBConnect.GetConnection)
            m_objDataAdapter.SelectCommand = sqlCmd
            m_objDataAdapter.Fill(m_objDataSetSourceType, "SourceType")
            Dim dr As DataRow = m_objDataSetSourceType.Tables("SourceType").NewRow()
            dr(0) = "-1"
            dr(1) = "-- Select --"
            m_objDataSetSourceType.Tables("SourceType").Rows.InsertAt(dr, 0)
            If m_objDataSetSourceType.Tables("SourceType").Rows.Count <> 0 Then
                cmbSourceType.DataSource = m_objDataSetSourceType.Tables("SourceType")
                cmbSourceType.ValueMember = "SourceTypeID"
                cmbSourceType.DisplayMember = "SourceType"
            End If
        Catch ex As Exception
            Cursor.Current = Cursors.Default
            MsgBox(ex.Message.ToString, MsgBoxStyle.Critical, g_strMessageCaption)
        End Try

    End Function
    Public Function fnFillFeatureName() As String
        Cursor.Current = Cursors.WaitCursor
        Try
            Dim strSQLFeatureName As String
            Dim m_objDataSetFeatureName As New Data.DataSet()
            strSQLFeatureName = "SELECT FeatureNameID,FeatureName  FROM dbo.mstFeatureName "
            m_objDataSetFeatureName.Clear()
            Dim sqlCmd As SqlCommand
            m_objDataAdapter = New SqlClient.SqlDataAdapter()
            mobjDBConnect.OpenConnection()
            sqlCmd = New SqlCommand(strSQLFeatureName, mobjDBConnect.GetConnection)
            m_objDataAdapter.SelectCommand = sqlCmd
            m_objDataAdapter.Fill(m_objDataSetFeatureName, "FeatureName")
            Dim dr As DataRow = m_objDataSetFeatureName.Tables("FeatureName").NewRow()
            dr(0) = "-1"
            dr(1) = "-- Select --"
            m_objDataSetFeatureName.Tables("FeatureName").Rows.InsertAt(dr, 0)
            If m_objDataSetFeatureName.Tables("FeatureName").Rows.Count <> 0 Then
                cmbFeatureName.DataSource = m_objDataSetFeatureName.Tables("FeatureName")
                cmbFeatureName.ValueMember = "FeatureNameID"
                cmbFeatureName.DisplayMember = "FeatureName"
            End If
        Catch ex As Exception
            Cursor.Current = Cursors.Default
            MsgBox(ex.Message.ToString, MsgBoxStyle.Critical, g_strMessageCaption)
        End Try
    End Function
    Public Function fnFillSpecDocItemNumbers() As String
        Cursor.Current = Cursors.WaitCursor
        Try
            Dim strSQLSpecDocItemNumbers As String
            Dim m_objDataSetSpecDocItemNumbers As New Data.DataSet()
            strSQLSpecDocItemNumbers = "SELECT SpecDocID,SpecDocItemNumbers  FROM dbo.mstSpecDocItemNumbers"
            m_objDataSetSpecDocItemNumbers.Clear()
            Dim sqlCmd As SqlCommand
            m_objDataAdapter = New SqlClient.SqlDataAdapter()
            mobjDBConnect.OpenConnection()
            sqlCmd = New SqlCommand(strSQLSpecDocItemNumbers, mobjDBConnect.GetConnection)
            m_objDataAdapter.SelectCommand = sqlCmd
            m_objDataAdapter.Fill(m_objDataSetSpecDocItemNumbers, "SpecDocItemNumbers")
            Dim dr As DataRow = m_objDataSetSpecDocItemNumbers.Tables("SpecDocItemNumbers").NewRow()
            dr(0) = "-1"
            dr(1) = "-- Select --"
            m_objDataSetSpecDocItemNumbers.Tables("SpecDocItemNumbers").Rows.InsertAt(dr, 0)
            If m_objDataSetSpecDocItemNumbers.Tables("SpecDocItemNumbers").Rows.Count <> 0 Then
                cmbSpecDoc.DataSource = m_objDataSetSpecDocItemNumbers.Tables("SpecDocItemNumbers")
                cmbSpecDoc.ValueMember = "SpecDocID"
                cmbSpecDoc.DisplayMember = "SpecDocItemNumbers"
            End If
        Catch ex As Exception
            Cursor.Current = Cursors.Default
            MsgBox(ex.Message.ToString, MsgBoxStyle.Critical, g_strMessageCaption)
        End Try
    End Function

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        Me.Close()
    End Sub

    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
        If fnValidate_Data() = True Then
            Try
                If (PRInfoId <> 0) Then
                    UpadteRecords(PRInfoId)
                    PRInfoId = 0
                Else
                    SaveRecord()
                    PRInfoId = 0
                End If

            Catch ex As Exception

            End Try
        End If
    End Sub
    Private Sub SaveRecord()
        Dim CMD As New SqlCommand
        Dim RecIDCust As Long
        mobjDBConnect.OpenConnection()
        Dim sqlpp As New SqlParameter
        CMD.Connection = mobjDBConnect.GetConnection
        CMD.CommandType = CommandType.StoredProcedure
        CMD.CommandText = "spPRInformation"
        CMD.Parameters.AddWithValue("@DeliveryVersion", txtDivisionVersion.Text)
        CMD.Parameters.AddWithValue("@DeliveryNo", cmbDeliveryID.SelectedValue)
        CMD.Parameters.AddWithValue("@SourceTypeID", cmbSourceType.SelectedValue)
        CMD.Parameters.AddWithValue("@GridID", txtGridId.Text)
        CMD.Parameters.AddWithValue("@LinenPageNo", txtLinenPageNo.Text)
        CMD.Parameters.AddWithValue("@LinenSourceImagePath", txtLinenSourcePath.Text)
        CMD.Parameters.AddWithValue("@ServiceCardImagePath", txtServicesCardImagepath.Text)
        CMD.Parameters.AddWithValue("@SiteID", txtSiteID.Text)
        CMD.Parameters.AddWithValue("@PostedBy", txtPostedBy.Text)
        CMD.Parameters.AddWithValue("@FeatureNameID", cmbFeatureName.SelectedValue)
        CMD.Parameters.AddWithValue("@GisID", txtGISID.Text)
        CMD.Parameters.AddWithValue("@StreetName", txtStreatName.Text)
        CMD.Parameters.AddWithValue("@IssueDescription", txtIssuesDisc.Text)
        CMD.Parameters.AddWithValue("@SpecDocSectionItemNo", cmbSpecDoc.SelectedValue)
        CMD.Parameters.AddWithValue("@Status", "")
        CMD.Parameters.AddWithValue("@Flag", 1)
        RecIDCust = CMD.ExecuteNonQuery()
        If (RecIDCust > 0) Then
            txtDivisionVersion.Text = ""
            txtServicesCardImagepath.Text = ""
            txtLinenSourcePath.Text = ""
            txtLinenPageNo.Text = ""
            txtGridId.Text = ""
            txtSiteID.Text = ""
            txtGISID.Text = ""
            txtStreatName.Text = ""
            txtIssuesDisc.Text = ""
            cmbDeliveryID.SelectedIndex = -1
            cmbSourceType.SelectedIndex = -1
            cmbFeatureName.SelectedIndex = -1
            cmbSpecDoc.SelectedIndex = -1
            txtDivisionVersion.Focus()
            txtPostedBy.Text = mdlPMGlobal.glbstrUser_Name
            MessageBox.Show("Record has been saved successfully.", g_strMessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
        End If
    End Sub
    Private Sub UpadteRecords(ByVal PRInfoId As Integer)
        Dim CMD As New SqlCommand
        Dim RecIDCust As Long
        mobjDBConnect.OpenConnection()
        Dim sqlpp As New SqlParameter
        CMD.Connection = mobjDBConnect.GetConnection
        CMD.CommandType = CommandType.StoredProcedure
        CMD.CommandText = "spPRInformation"
        CMD.Parameters.AddWithValue("@PRInfoId", PRInfoID)
        CMD.Parameters.AddWithValue("@DeliveryVersion", txtDivisionVersion.Text)
        CMD.Parameters.AddWithValue("@DeliveryNo", cmbDeliveryID.SelectedValue)
        CMD.Parameters.AddWithValue("@SourceTypeID", cmbSourceType.SelectedValue)
        CMD.Parameters.AddWithValue("@GridID", txtGridId.Text)
        CMD.Parameters.AddWithValue("@LinenPageNo", txtLinenPageNo.Text)
        CMD.Parameters.AddWithValue("@LinenSourceImagePath", txtLinenSourcePath.Text)
        CMD.Parameters.AddWithValue("@ServiceCardImagePath", txtServicesCardImagepath.Text)
        CMD.Parameters.AddWithValue("@SiteID", txtSiteID.Text)
        CMD.Parameters.AddWithValue("@PostedBy", txtPostedBy.Text)
        CMD.Parameters.AddWithValue("@FeatureNameID", cmbFeatureName.SelectedValue)
        CMD.Parameters.AddWithValue("@GisID", txtGISID.Text)
        CMD.Parameters.AddWithValue("@StreetName", txtStreatName.Text)
        CMD.Parameters.AddWithValue("@IssueDescription", txtIssuesDisc.Text)
        CMD.Parameters.AddWithValue("@SpecDocSectionItemNo", cmbSpecDoc.SelectedValue)
        CMD.Parameters.AddWithValue("@Status", "")
        CMD.Parameters.AddWithValue("@Flag", 4)
        RecIDCust = CMD.ExecuteNonQuery()
        If (RecIDCust > 0) Then
            txtDivisionVersion.Text = ""
            txtServicesCardImagepath.Text = ""
            txtLinenSourcePath.Text = ""
            txtLinenPageNo.Text = ""
            txtGridId.Text = ""
            txtSiteID.Text = ""
            txtGISID.Text = ""
            txtStreatName.Text = ""
            txtIssuesDisc.Text = ""
            cmbDeliveryID.SelectedIndex = -1
            cmbSourceType.SelectedIndex = -1
            cmbFeatureName.SelectedIndex = -1
            cmbSpecDoc.SelectedIndex = -1
            txtDivisionVersion.Focus()
            txtPostedBy.Text = mdlPMGlobal.glbstrUser_Name
            MessageBox.Show("Record has been Updated successfully.", g_strMessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
        End If

    End Sub
    Private Function fnValidate_Data() As Boolean
        fnValidate_Data = False
        If txtDivisionVersion.Text = "" Then
            MessageBox.Show("Delivery Version cannot be blank.", g_strMessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)
            txtDivisionVersion.Focus()
            Return False
        ElseIf txtLinenPageNo.Text = "" Then
            MessageBox.Show("Linen Page No cannot be blank.", g_strMessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)
            txtLinenPageNo.Focus()
            Return False
        ElseIf cmbDeliveryID.SelectedValue = -1 Then
            MessageBox.Show("Select Delivery ID.", g_strMessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)
            cmbDeliveryID.Focus()
            Return False
        ElseIf txtLinenSourcePath.Text = "" Then
            MessageBox.Show("Linen Source ImagePath cannot be blank.", g_strMessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)
            txtLinenSourcePath.Focus()
            Return False
        ElseIf cmbSourceType.SelectedValue = -1 Then
            MessageBox.Show("Select SourceType.", g_strMessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)
            cmbSourceType.Focus()
            Return False
        ElseIf txtServicesCardImagepath.Text = "" Then
            MessageBox.Show("Service Card Imagepath cannot be blank.", g_strMessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)
            txtServicesCardImagepath.Focus()
            Return False
        ElseIf txtGridId.Text = "" Then
            MessageBox.Show("Grid Id cannot be blank.", g_strMessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)
            txtGridId.Focus()
            Return False
        ElseIf txtSiteID.Text = "" Then
            MessageBox.Show("Site ID cannot be blank.", g_strMessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)
            txtSiteID.Focus()
            Return False
        ElseIf cmbFeatureName.SelectedValue = -1 Then
            MessageBox.Show("Select Feature Name", g_strMessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)
            cmbFeatureName.Focus()
            Return False
        ElseIf txtStreatName.Text = "" Then
            MessageBox.Show("Streat Name(s) cannot be blank.", g_strMessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)
            txtStreatName.Focus()
            Return False

        ElseIf txtGISID.Text = "" Then
            MessageBox.Show("GID ID cannot be blank.", g_strMessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)
            txtGISID.Focus()
            Return False
        ElseIf txtPostedBy.Text = "" Then
            MessageBox.Show("Posted By cannot be blank.", g_strMessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)
            txtPostedBy.Focus()
            Return False
        ElseIf cmbSpecDoc.SelectedValue = -1 Then
            MessageBox.Show("Select Spec Doc Section 4.1 Item No.", g_strMessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)
            cmbSpecDoc.Focus()
            Return False
        ElseIf txtIssuesDisc.Text = "" Then
            MessageBox.Show("Issue Description  cannot be blank.", g_strMessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)
            txtIssuesDisc.Focus()
            Return False
        End If
        Return True
    End Function


#End Region

    Private Sub frmInformationPR_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Resize
        If Me.Width < 816 Or Me.Height < 514 Then
            Me.Width = 816
            Me.Height = 514
            Exit Sub
        End If

    End Sub

 
    Private Sub btnShowRecord_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShowRecord.Click
        PRInfoId = 0
        If (PRInfoId = 0) Then
            With frmInformationPRLookUp.m_GetfrmShowPRInformationLookUp
                If .fnInitialize_Form() Then
                    .ShowInTaskbar = False
                    .StartPosition = FormStartPosition.CenterScreen

                    .ShowDialog()

                End If
            End With

        End If
   
     
    End Sub
    Private Sub frmInformationPR_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            If (PRInfoId <> 0) Then
                btnNew.Enabled = True
                btndelete.Enabled = True
                btnSave.Text = "Update"

            Else
                btnNew.Enabled = False
                btndelete.Enabled = False
                btnSave.Text = "Save"
            End If


            PRInfoId = getPRInfoID
            fnFillDeliveryID()
            fnFillSourceType()
            fnFillFeatureName()
            fnFillSpecDocItemNumbers()
        Catch ex As Exception

        End Try
       
     
    End Sub

    Private Sub btnNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNew.Click
        Try
            PRInfoId = 0
            txtDivisionVersion.Text = ""
            txtServicesCardImagepath.Text = ""
            txtLinenSourcePath.Text = ""
            txtLinenPageNo.Text = ""
            txtGridId.Text = ""
            txtSiteID.Text = ""
            txtGISID.Text = ""
            txtStreatName.Text = ""
            txtIssuesDisc.Text = ""
            cmbDeliveryID.SelectedIndex = 0
            cmbSourceType.SelectedIndex = 0
            cmbFeatureName.SelectedIndex = 0
            cmbSpecDoc.SelectedIndex = 0
            btnNew.Enabled = False
            btndelete.Enabled = False
            btnSave.Text = "Save"
            txtDivisionVersion.Focus()
            txtPostedBy.Text = mdlPMGlobal.glbstrUser_Name
        Catch ex As Exception
        End Try
    End Sub

    Private Sub btndelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndelete.Click
        Try
            Call DeleteRecord()

        Catch ex As Exception

        End Try
    End Sub
    Private Sub DeleteRecord()
        Dim CMD As New SqlCommand
        Dim RecIDCust As Long
        mobjDBConnect.OpenConnection()
        Dim sqlpp As New SqlParameter
        CMD.Connection = mobjDBConnect.GetConnection
        CMD.CommandType = CommandType.StoredProcedure
        CMD.CommandText = "spPRInformation"
        CMD.Parameters.AddWithValue("@PRInfoId", PRInfoId)
        CMD.Parameters.AddWithValue("@Flag", 5)
        RecIDCust = CMD.ExecuteNonQuery()
        If (RecIDCust > 0) Then
            txtDivisionVersion.Text = ""
            txtServicesCardImagepath.Text = ""
            txtLinenSourcePath.Text = ""
            txtLinenPageNo.Text = ""
            txtGridId.Text = ""
            txtSiteID.Text = ""

            txtGISID.Text = ""
            txtStreatName.Text = ""
            txtIssuesDisc.Text = ""
            cmbDeliveryID.SelectedIndex = -1
            cmbSourceType.SelectedIndex = -1
            cmbFeatureName.SelectedIndex = -1
            cmbSpecDoc.SelectedIndex = -1
            btnNew.Enabled = False
            btndelete.Enabled = False
            btnSave.Text = "Save"
            PRInfoId = 0
            txtDivisionVersion.Focus()
            txtPostedBy.Text = mdlPMGlobal.glbstrUser_Name
            MessageBox.Show("Record has been Deleted successfully.", g_strMessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
        End If


    End Sub

 
 
    Private Sub frmInformationPR_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
        Try
            If e.KeyCode = Keys.Escape Then Me.Close()
        Catch ex As Exception

        End Try
    End Sub
End Class