--===================================================================================================
-- Application Name:
-- IRICRM Online Application
--
-- Code Description:
-- This is the subroutine where a request is validated and saved to the database. The required
-- information is dictated by the request type, so the validation had to be customized depending
-- on the request type selected by the user. If the validation passes, then the data is saved
-- using the RequestFile object.
--
--===================================================================================================
Protected Sub Save_Add_Request_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Save_Add_Request.Click
Dim oRequest As New RequestFile()
Dim strAction As String = ""
Dim strError As String = ""
Dim strReqCode As String = ""
If ddlRequestCode.Text = "102" Then
ddlConvRequest.Enabled = True
ddlEquipmentType.Enabled = True
End If
If ddlRequestCode.Text = "" Then
strError = strError & "
Please select a valid Request Code!"
End If
If ddlRequestCode.Text = "100" Then
If MyDataFuncs.HasRequestCode("100", Panelist_ID.Value) Then
strError = strError & "Cannot request another New ScanKey/ScanBase for current Panelist!"
End If
End If
If ddlRequestCode.Text = "102" And ddlConvRequest.Text = "" Then
strError = strError & "Please select a valid Conversion Request!"
End If
If ddlRequestCode.Text = "102" And ddlEquipmentType.Text = "" Then
strError = strError & "Please select a valid Equipment Type!"
End If
If ddlRequestCode.Text = "102" And ddlConvRequest.Text = "Y" And ddlEquipmentType.Text = EF_Equipment_Type_ID.Value Then
strError = strError & "Cannot select the same Equipment Type currently held by the Panelist!"
End If
If ddlRequestCode.Text = "102" And ddlConvRequest.Text = "N" And ddlEquipmentType.Text <> EF_Equipment_Type_ID.Value Then
strError = strError & "Cannot select a different Equipment Type currently held by the Panelist!"
End If
If ddlRequestCode.Text <> "102" And ddlConvRequest.Text <> "" Then
strError = strError & "Please un-select Conversion Request!"
End If
If ddlRequestCode.Text = "216" Then
If Not IsDate(Request_Expire_Date.Text) Or Request_Expire_Date.Text.Trim() = "" Then
strError = strError & "Please enter a valid Expiration Date!"
Request_Expire_Date.Enabled = True
Else
If CDate(Request_Expire_Date.Text) > Now().AddYears(2) Then
strError = strError & "Expiration Date cannot exceed 2 years!"
Request_Expire_Date.Enabled = True
End If
End If
End If
If Not Validations.MyValidation.IsValidCharacters(Add_Request_Comment.Text) Then
strError = strError & "Please use valid characters in Comment field!"
End If
If Not Validations.MyValidation.IsValidLength(Add_Request_Comment.Text, 0, 1000) Then
strError = strError & "Comment field cannot have more than 1000 characters!"
End If
If PointsTotal.Text <> "" Then
If CLng(PointsTotal.Text) > 1000 Then
strError = strError & "Total Points cannot be greater than 1000!"
End If
End If
If InStr("200_201_202", ddlRequestCode.Text) > 0 And EF_ScanKey_Install_Week.Text = "" Then
strError = strError & "Cannot save Incentive Points Request, Panelist has no Install Week!"
End If
If InStr("200_201_202", ddlRequestCode.Text) > 0 And EF_ScanKey_Install_Week.Text <> "" Then
If InStr(Add_Request_Comment.Text, "CC2 ") = 0 Then
strError = strError & "Please enter a valid Comment (missing CC2)!"
If ddlRequestCode.Text = "200" Then
ddlPointsCommentType.Enabled = True
ddlPointsCommentType.BackColor = Drawing.Color.Yellow
PointsStartWeek.Enabled = True
PointsStartWeek.BackColor = Drawing.Color.Yellow
PointsEndWeek.Enabled = True
PointsEndWeek.BackColor = Drawing.Color.Yellow
ddlPointsCommentType.Items.Clear()
ddlPointsCommentType.Items.Add(New ListItem("Select From List", ""))
ddlPointsCommentType.Items.Add(New ListItem("Scankey Credit [40 Points]", "40"))
ddlPointsCommentType.Items.Add(New ListItem("RxPulse Credit [15 Points]", "15"))
ddlPointsCommentType.Items.Add(New ListItem("Card Credit [20 Points]", "20"))
ddlPointsCommentType.Items.Add(New ListItem("Expired Points", "0"))
End If
If ddlRequestCode.Text = "201" Then
PointsPoints.Enabled = False
PointsPoints.BackColor = Drawing.Color.White
ddlPointsCommentType.Enabled = False
ddlPointsCommentType.BackColor = Drawing.Color.White
PointsStartWeek.Enabled = False
PointsStartWeek.BackColor = Drawing.Color.White
PointsEndWeek.Enabled = False
PointsEndWeek.BackColor = Drawing.Color.White
End If
If ddlRequestCode.Text = "202" Then
ddlPointsCommentType.Enabled = True
ddlPointsCommentType.BackColor = Drawing.Color.Yellow
PointsPoints.Enabled = True
PointsPoints.BackColor = Drawing.Color.Yellow
PointsStartWeek.Enabled = False
PointsStartWeek.BackColor = Drawing.Color.White
PointsEndWeek.Enabled = False
PointsEndWeek.BackColor = Drawing.Color.White
ddlPointsCommentType.Items.Clear()
ddlPointsCommentType.Items.Add(New ListItem("Select From List", ""))
ddlPointsCommentType.Items.Add(New ListItem("SRVY", "SRVY"))
ddlPointsCommentType.Items.Add(New ListItem("MISC", "MISC"))
End If
End If
End If
'========================================================
' Busines Rule #2 Swaps as of June, 2008
' a) A panelist can not be Swap Converted to a
' Classic Set, if he/she belongs to market 1,3,7, or 10.
'
' b) A panelist can not be Swap Converted to an Opticon
' KeyPad (eq.type 11 or 12)
'========================================================
If InStr("001_003_007_010", App.MyApp.GetMarketID(Panelist_ID.Value)) And _
ddlEquipmentType.Text = "01" And ddlRequestCode.Text = "102" And _
ddlConvRequest.Text = "Y" Then
strError = strError & "Cannot swap Panelist to Classic Set!"
End If
If InStr("11_12", ddlEquipmentType.Text) > 0 And ddlRequestCode.Text = "102" _
And ddlEquipmentType.Text <> "" And ddlConvRequest.Text = "Y" Then
strError = strError & "Cannot swap Panelist to Opticon-Keypad!"
End If
'========================================================
' #5) RxPulse panelists cannot be swapped to Opticon
' Modem as of June, 2008
' Panelists who participate in the #2_RxPulse Panel Program
' cannot have a conversion Swap to equipment type
' #8_OpKeyLessPhone or #12_OpKeyPadPhone.
'========================================================
If MyDataFuncs.IsInRxPulseProgram(Panelist_ID.Value) And _
InStr("08_12", ddlEquipmentType.Text) > 0 And _
ddlRequestCode.Text = "102" And _
ddlEquipmentType.Text <> "" Then
strError = strError & "Cannot swap RxPulse Panelist to Opticon-Keyless Phone or Keypad Phone!"
End If
If strError = "" Then
oRequest.Panelist_ID = Panelist_ID.Value
oRequest.Request_Code = ddlRequestCode.Text
oRequest.Conversion_Request = ddlConvRequest.Text
oRequest.First_Name = First_Name.Text
oRequest.Last_Name = Last_Name.Text
oRequest.Mail_To_Street = ""
oRequest.Mail_To_City = ""
oRequest.Mail_To_State = ""
oRequest.Mail_To_Zip = ""
oRequest.Mail_To_Zip_4 = ""
oRequest.Comments = Add_Request_Comment.Text
oRequest.Equipment_Type = ddlEquipmentType.Text
oRequest.Panel_Program = ddlPanelProgram.Text
oRequest.Unique_Transaction_ID = App.MyApp.GetUniqueTransID()
oRequest.Date_Time_Requested = App.MyApp.GetCentralDateTime()
oRequest.Data_Type = App.MyApp.T2RDataType()
If oRequest.Save_To_SQL() Then
If ddlRequestCode.Text = "216" Then
Dim oExpireDate As New RequestExpireDate()
oExpireDate.Unique_Transaction_ID = oRequest.Unique_Transaction_ID
oExpireDate.Panelist_ID = Panelist_ID.Value
oExpireDate.Expire_Date = Request_Expire_Date.Text
If Not oExpireDate.Save_To_SQL() Then
strError = strError & "Request Date Saved, but an Error occurred saving Request Expiration Date!"
strError = strError & "
" & oRequest.Get_SQL_Error()
End If
oExpireDate = Nothing
End If
strError = "Add Request Data Was Saved!"
Add_Request.Enabled = True
pnlAddRequest.Visible = False
Else
strError = "Error saving Add Request Data!"
strError = strError & "
" & oRequest.Get_SQL_Error()
End If
End If
oRequest = Nothing
lblError.Text = strError
End Sub