我在保存正在输入的数据时遇到问题。我必须点击两次按钮才能启动它。
我正在尝试添加员工的群组详细信息。当我第一次单击“添加”按钮时,我添加的组详细信息将成功添加但当我再次尝试添加另一个时,它将不会被保存,我必须再次单击该按钮才能保存或按钮发挥作用。
单击“添加”按钮
时的代码 If ValidateGroup() = "" Then
taskoption = Request.QueryString("opt")
If taskoption = "opt_edit" Then
SaveGroup()
disp_Details()
Loadgv()
Me.btnUpdate.Enabled = True
Me.btnSave.Enabled = False
ElseIf taskoption = "opt_add" Then
disp_Blank()
Me.btnSave.Enabled = True
Me.btnUpdate.Enabled = False
ElseIf taskoption = "opt_ae" Then
SaveGroup()
disp_Details()
gvGroup.Visible = True
tblGroup.Visible = True
id_tm1.Visible = True
tblAddGrp.Visible = True
trgd.Visible = False
disp_Group()
Loadgv()
Me.btnUpdate.Enabled = True
Me.btnSave.Enabled = False
End If
Else
Me.MessageBox("alert('Please complete the following: \n" + ValidateGroup() + "\n')")
End If
这是我在Page_Load中的代码
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
userid = getUserid(SessionHandler.UserID, User.Identity.Name.ToUpper(), username)
bol_Admin = isAdmin(userid)
bol_GlobalHR = isGlobalHR(userid)
bol_RegionalHR = isRegionalHR(userid)
bol_LocalHR = isLocalHR(userid)
userEntity = getEntity(userid)
userLocation = getLocation(userid)
userRegion = getRegion(userid)
If KnownUser(userid) Then
If bol_Admin Or bol_GlobalHR Or bol_RegionalHR Or bol_LocalHR Then
If Not Page.IsPostBack Then
Dim win_id As String = User.Identity.Name
loadSetup()
If bol_Admin Or bol_GlobalHR Then
access = "GLOBAL"
ehr_utils.fillDDL("SELECT REGION FROM REGION_TBL ORDER BY REGION", ddl_Region, "REGION", "REGION")
ehr_utils.fillDDL("SELECT COUNTRY FROM COUNTRY_TBL ORDER BY COUNTRY", ddl_Country, "COUNTRY", "COUNTRY")
ehr_utils.fillDDL("SELECT ENTITY FROM ENTITY_TBL ORDER BY ENTITY", Me.ddl_Entity, "ENTITY", "ENTITY")
ehr_utils.fillDDL("SELECT LOCATION FROM LOCATION_TBL ORDER BY LOCATION", ddl_Location, "LOCATION", "LOCATION")
ehr_utils.fillDDL("SELECT DISTINCT C_PERIOD FROM PERIODSETUP_TBL", Me.ddl_period, "C_PERIOD", "C_PERIOD")
ehr_utils.fillDDL("SELECT SUBLOOKUP_NAME FROM SUBLOOKUP_TBL WHERE LOOKUP_NAME = 'YEAR'", Me.ddl_year, "SUBLOOKUP_NAME", "SUBLOOKUP_NAME")
ElseIf bol_RegionalHR Then
access = "REGIONAL"
ehr_utils.fillDDL("SELECT REGION FROM REGION_TBL where region = '" & userRegion & "' ORDER BY REGION", ddl_Region, "REGION", "REGION")
ehr_utils.fillDDL("SELECT COUNTRY FROM COUNTRY_TBL where region = '" & userRegion & "' ORDER BY COUNTRY", ddl_Country, "COUNTRY", "COUNTRY")
ehr_utils.fillDDL("SELECT ENTITY FROM ENTITY_TBL where region = '" & userRegion & "' ORDER BY ENTITY", Me.ddl_Entity, "ENTITY", "ENTITY")
ehr_utils.fillDDL("SELECT LOCATION FROM LOCATION_TBL where region = '" & userRegion & "' ORDER BY LOCATION", ddl_Location, "LOCATION", "LOCATION")
ehr_utils.fillDDL("SELECT DISTINCT C_PERIOD FROM PERIODSETUP_TBL", Me.ddl_period, "C_PERIOD", "C_PERIOD")
ehr_utils.fillDDL("SELECT SUBLOOKUP_NAME FROM SUBLOOKUP_TBL WHERE LOOKUP_NAME = 'YEAR'", Me.ddl_year, "SUBLOOKUP_NAME", "SUBLOOKUP_NAME")
ElseIf bol_LocalHR Then
access = "LOCAL"
Dim emp_id As String = Request.QueryString("emp_id")
selectedEmpEntity = getValueString("SELECT entity FROM EMP_MASTERTBL WHERE MASTERID = '" & emp_id & "'")
ehr_utils.fillDDL("SELECT REGION FROM REGION_TBL where region = '" & userRegion & "' ORDER BY REGION", ddl_Region, "REGION", "REGION")
ehr_utils.fillDDL("SELECT COUNTRY FROM COUNTRY_TBL where region = '" & userRegion & "' ORDER BY COUNTRY", ddl_Country, "COUNTRY", "COUNTRY")
'ehr_utils.fillDDL("SELECT ENTITY FROM ENTITY_TBL where entity = '" & userEntity & "' ORDER BY ENTITY", Me.ddl_Entity, "ENTITY", "ENTITY")
ehr_utils.fillDDL("SELECT ENTITY FROM LOCALHR_TBL WHERE USERID = '" & userid & "' ORDER BY ENTITY", Me.ddl_Entity, "ENTITY", "ENTITY")
ehr_utils.fillDDL("SELECT LOCATION FROM LOCATION_TBL where entity = '" & selectedEmpEntity & "' ORDER BY LOCATION", ddl_Location, "LOCATION", "LOCATION")
ehr_utils.fillDDL("SELECT DISTINCT C_PERIOD FROM PERIODSETUP_TBL", Me.ddl_period, "C_PERIOD", "C_PERIOD")
ehr_utils.fillDDL("SELECT SUBLOOKUP_NAME FROM SUBLOOKUP_TBL WHERE LOOKUP_NAME = 'YEAR'", Me.ddl_year, "SUBLOOKUP_NAME", "SUBLOOKUP_NAME")
End If
taskoption = Request.QueryString("opt")
updateBtnRmndr.Visible = False
If taskoption = "opt_edit" Then
gvGroup.Columns(9).Visible = True
gvGroup.Columns(10).Visible = True
disp_Details()
Loadgv()
loadSetup()
gvGroup.Visible = True
tblAddGrp.Visible = True
trgd.Visible = False
Me.btnUpdate.Enabled = True
Me.btnSave.Enabled = False
Me.ddl_BusinessUnit.Enabled = True
Me.ddl_SubClassification.Enabled = True
ehr_utils.fillDDL("SELECT BUSINESS_UNIT FROM BUSINESS_UNIT_TBL ORDER BY BUSINESS_UNIT", Me.ddl_BusinessUnit, "BUSINESS_UNIT", "BUSINESS_UNIT")
'Check if the user has access to use the UPDATE ALL function
hasAccess = CheckRecord("SELECT * FROM ACCESSLIST_TBL WHERE MODULE_ID = '1' AND ACCESS = '" & access & "'")
If hasAccess Then 'allowed to use the UPDATE ALL function
btnUpdateHistoryRecord.Visible = True
btnUpdateHistoryRecord.Enabled = True
Session("originalEmpNo") = lblval_Empno.Text
updateBtnRmndr.Visible = True
Else ' Not allowed to use the UPDATE ALL function
btnUpdateHistoryRecord.Visible = False
btnUpdateHistoryRecord.Enabled = False
End If
ElseIf taskoption = "opt_ae" Then
gvGroup.Columns(9).Visible = False
gvGroup.Columns(10).Visible = False
gvGroup.Columns(7).Visible = False
trgd.Visible = True
tblAddGrp.Visible = True
Loadgv()
disp_Details()
disp_Group()
gvGroup.Visible = False
tblGroup.Visible = False
id_tm1.Visible = False
Me.btnUpdate.Enabled = True
Me.btnSave.Enabled = False
'Check if the user has access to use the UPDATE ALL function
hasAccess = CheckRecord("SELECT * FROM ACCESSLIST_TBL WHERE MODULE_ID = '1' AND ACCESS = '" & access & "'")
If hasAccess Then 'allowed to use the UPDATE ALL function
btnUpdateHistoryRecord.Visible = True
btnUpdateHistoryRecord.Enabled = True
updateBtnRmndr.Visible = True
Session("originalEmpNo") = lblval_Empno.Text
Else ' Not allowed to use the UPDATE ALL function
btnUpdateHistoryRecord.Visible = False
btnUpdateHistoryRecord.Enabled = False
End If
Me.ddl_BusinessUnit.Enabled = True
Me.ddl_SubClassification.Enabled = True
ehr_utils.fillDDL("SELECT BUSINESS_UNIT FROM BUSINESS_UNIT_TBL ORDER BY BUSINESS_UNIT", Me.ddl_BusinessUnit, "BUSINESS_UNIT", "BUSINESS_UNIT")
ElseIf taskoption = "opt_add" Then
tblAddGrp.Visible = False
tblGroup.Visible = False
id_tm1.Visible = False
trgd.Visible = False
gvGroup.Visible = False
disp_Blank()
loadSetup()
Me.btnSave.Enabled = True
Me.btnUpdate.Enabled = False
'hide the UPDATE ALL function
btnUpdateHistoryRecord.Visible = False
btnUpdateHistoryRecord.Enabled = False
End If
div_birthDate.InnerText = txtBdate.Text
div_entryDate.InnerText = txtEdate.Text
Else
Dim scriptString As New StringBuilder
scriptString.Append("<script language=JavaScript>")
scriptString.Append("alert('You are not allowed to view this page.');")
scriptString.Append("window.location = 'eHR_Main.aspx';")
scriptString.Append("</script>")
If Not ClientScript.IsStartupScriptRegistered("Startup") Then
ClientScript.RegisterStartupScript(GetType(Page), "Startup", scriptString.ToString())
End If
End If
Else
MessageBox("alert('You're not allowed to view this page.');window.location='eHR_Main.aspx';")
End If
End If
End Sub