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
No comments:
Post a Comment