VS 上的更新按钮工作 SQL SP,在 IIS 上它只保存已经存在的信息,没有更新
Update button on VS works SQL SP, on IIS it just saves the information already there, no update
我有一个显示一些 header 信息的 Web 表单,您可以更改该信息(文本框、复选框等)并点击更新信息按钮以 post 信息到一个 SQL 存储过程..
当我 运行 在 Visual Studio 上点击按钮时,信息会更新。
====VISUAL STUDIO====
declare @p14 varchar(200)
set @p14=NULL
declare @p15 int
set @p15=NULL
exec DLI_BENEFITS_HEADER_UPDATE @EMP_ID=N'ADA04',@K401_TYPE=N'DECLINED',@CONTRIBUTION_RATE_401K_AMOUNT=NULL,@CONTRIBUTION_RATE_401K_PCT=NULL,@COMPANY_LIFE_EMP=1,@COMPANY_LIFE_SPOUSE=0,@COMPANY_LIFE_CHILD=1,@COMPANY_LIFE_DEPENDENTS=99,@HEALTH_DECLINE=1,@DENTAL_DECLINE=0,@VISION_DECLINE=1,@LIFE_DECLINE=0,@NOTES=N'MY RECORD NEW RECORD INFO',@SP_MESSAGE=@p14 output,@SP_ERROR_NUMBER=@p15 output
select @p14, @p15
go
exec sp_reset_connection
go
当我在 IIS 中 运行 完全相同的东西时,它基本上只是将信息放回 SQL,就好像什么都没有改变一样。
=====IIS=====
declare @p14 varchar(200)
set @p14=NULL
declare @p15 int
set @p15=NULL
exec DLI_BENEFITS_HEADER_UPDATE @EMP_ID=N'ADA04',@K401_TYPE=N'DECLINED',@CONTRIBUTION_RATE_401K_AMOUNT=NULL,@CONTRIBUTION_RATE_401K_PCT=NULL,@COMPANY_LIFE_EMP=1,@COMPANY_LIFE_SPOUSE=0,@COMPANY_LIFE_CHILD=1,@COMPANY_LIFE_DEPENDENTS=99,@HEALTH_DECLINE=1,@DENTAL_DECLINE=0,@VISION_DECLINE=1,@LIFE_DECLINE=0,@NOTES=N'MY RECORD NEW RECORD INFO',@SP_MESSAGE=@p14 output,@SP_ERROR_NUMBER=@p15 output
select @p14, @p15
我将文本框 99 更改为 4,并将我的记录新记录更改为我的记录新记录信息,此处带有新注释,然后点击提交按钮。
@COMPANY_LIFE_DEPENDENTS=99比4
和 @NOTES 到 @NOTES=N'我的记录新记录信息这里有新的注释'
我不确定我在这里遗漏了什么..抱歉,如果它是非常基本的东西,我应该知道得更多,但我已经四处搜索试图找出它。
SQL 连接 SQL 用户名和密码未集成。
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="EmployeeBenefits.aspx.cs" Inherits="DLI_EMPLOYEE_BENEFITS.EmployeeBenefits" MaintainScrollPositionOnPostback="true" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>DLI Employee Benefit Maintenance</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<style>
html, body {
height: 90%;
padding: 10px;
}
html {
display: table;
margin: auto;
}
body {
display: table-cell;
vertical-align: top;
width: 1024px;
height: 768px;
margin: 0; /* Space from this element (entire page) and others*/
padding: 20; /*space from content and border*/
border: solid blue;
border-width: thin;
overflow: hidden;
display: block;
box-sizing: border-box;
}
.HeaderLogo {
text-align: center;
}
.PageTitle {
text-align: center;
font-size: x-large;
font-weight: bold;
}
.LoginName {
text-align: right;
}
.NavBar {
text-align: center;
margin: auto;
padding: 10px;
}
.DivCenter {
text-align: center;
}
.auto-style1 {
width: 100%;
border-collapse: collapse;
}
.auto-style2 {
width: 100%;
}
.auto-style3 {
width: 20%;
height: 25px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div id="BODY_DIV">
<div id="PageTitle" class="PageTitle">
EMPLOYEE BENEFIT MAINTENANCE<hr />
</div>
<div id="EMPLOYEE_BENEFITS_HEADER">
<table class="auto-style1">
<tr>
<td style="vertical-align: middle; text-align: right; width: 15%; font-weight: bold;">EMP ID :</td>
<td style="vertical-align: middle; text-align: right; width: 15%">
<asp:TextBox ID="tbEMPLOYEE_ID" runat="server" Width="92px"></asp:TextBox>
<asp:ImageButton ID="ibGET" runat="server" ImageUrl="~/Image/elcmark.png" OnClick="ibGET_Click" />
<asp:ImageButton ID="ibRESET" runat="server" ImageUrl="~/Image/reset.png" PostBackUrl="https://dlihome.deseretlabs.com/HR/EMP_BENEFITS/EmployeeBenefits.aspx" />
</td>
<td style="vertical-align: middle; text-align: center; width: 40%">
<asp:Label ID="lbEMPLOYEE_NAME" runat="server" Text="DOE, JOHN" Font-Bold="True" Font-Size="X-Large" ForeColor="Red"></asp:Label>
</td>
<td style="vertical-align: middle; text-align: right; width: 15%; font-weight: bold;">HIRE DATE :</td>
<td style="vertical-align: middle; text-align: center; width: 15%">
<asp:Label ID="lbHIRE_DATE" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td style="vertical-align: middle; text-align: right; width: 15%; font-weight: bold;">ENROLL DATE :</td>
<td style="vertical-align: middle; text-align: center; width: 15%">
<asp:Label ID="lbENROLL_DATE" runat="server"></asp:Label>
</td>
<td style="vertical-align: middle; text-align: right; width: 55%; font-weight: bold;" colspan="2">INITAL MEETING :</td>
<td style="vertical-align: middle; text-align: center; width: 15%">
<asp:Label ID="lbINITIAL_MEETING" runat="server"></asp:Label>
<asp:ImageButton ID="ibINITIAL_DATE" runat="server" ImageUrl="~/Image/plus16.gif" />
</td>
</tr>
</table>
<hr />
<table class="auto-style1" cellpadding="10px">
<tr>
<td style="vertical-align: middle; text-align: right; width: 20%; font-weight: bold;">401K :</td>
<td style="vertical-align: middle; text-align: left; width: 20%" colspan="4">
<asp:DropDownList ID="ddl401_TYPE" runat="server">
<asp:ListItem></asp:ListItem>
<asp:ListItem>DECLINED</asp:ListItem>
<asp:ListItem>401K</asp:ListItem>
<asp:ListItem>ROTH</asp:ListItem>
</asp:DropDownList>
♦
<asp:TextBox ID="tb401_PCT" runat="server" Width="25px" Wrap="False" style="text-align:center"></asp:TextBox>
PERCENT ♦ $
<asp:TextBox ID="tb401_AMOUNT" runat="server" Width="64px" Wrap="False"></asp:TextBox>
AMOUNT</td>
</tr>
<tr>
<td style="vertical-align: middle; text-align: right; width: 20%; font-weight: bold;">COMPANY LIFE :</td>
<td style="vertical-align: middle; text-align: left; width: 20%" colspan="4"> <asp:CheckBox ID="cbCOMP_LIFE_EMP" runat="server" Text="EMPLOYEE" />
♦ <asp:CheckBox ID="cbCOMP_LIFE_SPOUSE" runat="server" Text="SPOUSE" />
♦ <asp:CheckBox ID="cbCOMP_LIFE_CHILDREN" runat="server" Text="CHILDREN" />
♦ <asp:TextBox ID="TbCOMP_LIFE_DEPENDENTS" runat="server" Width="25px" Wrap="False" style="text-align:center"></asp:TextBox>
DEPENDENTS</td>
</tr>
<tr>
<td style="vertical-align: middle; text-align: right; width: 20%; font-weight: bold;">DECLINED BENEFITS :</td>
<td style="vertical-align: middle; text-align: left; width: 20%" colspan="4">
<asp:CheckBox ID="cbDECLINE_HEALTH" runat="server" Text="HEALTH" />
♦ <asp:CheckBox ID="cbDECLINE_DENTAL" runat="server" Text="DENTAL" />
♦ <asp:CheckBox ID="cbDECLINE_VISION" runat="server" Text="VISION" />
♦ <asp:CheckBox ID="cbDECLINE_LIFE" runat="server" Text="VOLUNTARY LIFE" />
</td>
</tr>
<tr>
<td style="vertical-align: middle; text-align: RIGHT; width: 20%; font-weight: bold;">NOTES:</td>
<td style="vertical-align: middle; text-align: LEFT; width: 80%" colspan="4">
<asp:TextBox ID="tbNOTES" runat="server" style="margin-left: 0px" TextMode="MultiLine" Width="100%" Height="50px"></asp:TextBox>
</td>
</tr>
<tr>
<td style="vertical-align: middle; text-align: CENTER; width: 100%; font-weight: bold;" colspan="2">
<asp:ImageButton ID="ibUPDATE_HEADER" runat="server" ImageUrl="~/Image/button_update-record.png" OnClick="ibUPDATE_HEADER_Click" />
<br />
<asp:Label ID="lblSPMessageSuccess" runat="server"></asp:Label><asp:Label ID="lblSPMessageError" runat="server"></asp:Label>
</td>
</tr>
</table>
<hr style="border: 1px solid red;"/>
</div>
<div id="ENROLLED_BENEFITS">
<asp:GridView ID="gvEnrolledBenfits" runat="server" AllowPaging="True" AutoGenerateColumns="False" CellPadding="4" DataSourceID="dsEnrolledBenefits" Width="100%" BackColor="White" BorderColor="#CC9966" BorderStyle="None" BorderWidth="1px">
<Columns>
<asp:BoundField DataField="INS_DESCRIPTION" HeaderText="DESCRIPTION" SortExpression="INS_DESCRIPTION">
<HeaderStyle Font-Bold="True" Font-Size="Small" HorizontalAlign="Center" VerticalAlign="Middle" Width="20%" />
<ItemStyle Font-Size="Small" HorizontalAlign="Center" VerticalAlign="Middle" />
</asp:BoundField>
<asp:BoundField DataField="AMOUNT" DataFormatString="{0:c}" HeaderText="AMOUNT PPC" SortExpression="AMOUNT" >
<HeaderStyle Font-Bold="True" Font-Size="Small" HorizontalAlign="Center" VerticalAlign="Middle" Width="10%" />
<ItemStyle Font-Size="Small" HorizontalAlign="Center" VerticalAlign="Middle" Width="10%" />
</asp:BoundField>
<asp:BoundField DataField="LIFE_AMOUNT" DataFormatString="{0:c}" HeaderText="LIFE AMOUNT" SortExpression="LIFE_AMOUNT" >
<HeaderStyle Font-Bold="True" Font-Size="Small" HorizontalAlign="Center" VerticalAlign="Middle" Width="10%" />
<ItemStyle Font-Size="Small" HorizontalAlign="Center" VerticalAlign="Middle" Width="10%" />
</asp:BoundField>
<asp:BoundField DataField="DEPENDENT_CHIDREN" HeaderText="DEPENDENT CHIDREN" SortExpression="DEPENDENT_CHIDREN" >
<HeaderStyle Font-Bold="True" Font-Size="Small" HorizontalAlign="Center" VerticalAlign="Middle" Width="10%" />
<ItemStyle Font-Size="Small" HorizontalAlign="Center" VerticalAlign="Middle" Width="10%" />
</asp:BoundField>
<asp:BoundField DataField="START_DATE" DataFormatString="{0:d}" HeaderText="START DATE" SortExpression="START_DATE" >
<HeaderStyle Font-Bold="True" Font-Size="Small" HorizontalAlign="Center" VerticalAlign="Middle" Width="10%" />
<ItemStyle Font-Size="Small" HorizontalAlign="Center" VerticalAlign="Middle" Width="10%" />
</asp:BoundField>
<asp:BoundField DataField="END_DATE" DataFormatString="{0:d}" HeaderText="END DATE" SortExpression="END_DATE" >
<HeaderStyle Font-Bold="True" Font-Size="Small" HorizontalAlign="Center" VerticalAlign="Middle" Width="10%" />
<ItemStyle Font-Size="Small" HorizontalAlign="Center" VerticalAlign="Middle" Width="10%" />
</asp:BoundField>
</Columns>
<FooterStyle BackColor="#FFFFCC" ForeColor="#330099" />
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="#FFFFCC" />
<PagerStyle BackColor="#FFFFCC" ForeColor="#330099" HorizontalAlign="Center" />
<RowStyle BackColor="White" ForeColor="#330099" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="#663399" />
<SortedAscendingCellStyle BackColor="#FEFCEB" />
<SortedAscendingHeaderStyle BackColor="#AF0101" />
<SortedDescendingCellStyle BackColor="#F6F0C0" />
<SortedDescendingHeaderStyle BackColor="#7E0000" />
</asp:GridView>
<asp:SqlDataSource ID="dsEnrolledBenefits" runat="server" ConnectionString="<%$ ConnectionStrings:PAYROLL %>" SelectCommand="DLI_BENEFITS_EMPLOYEE_ENROLLED" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:ControlParameter ControlID="tbEMPLOYEE_ID" Name="EID" PropertyName="Text" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
</div>
</div>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
namespace DLI_EMPLOYEE_BENEFITS
{
public partial class EmployeeBenefits : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//if (!IsPostBack)
//{
// lbEMPLOYEE_NAME.Text = "";
// tbEMPLOYEE_ID.Text = "";
//}
ibINITIAL_DATE.Visible = false;
lblSPMessageSuccess.Text = "";
string qsEmpID = Request.QueryString["qsEmpID"];
if (string.IsNullOrEmpty(qsEmpID))
{
}
else
{
tbEMPLOYEE_ID.Text = qsEmpID.ToUpper();
MyLookup();
}
}
protected void ibGET_Click(object sender, ImageClickEventArgs e)
{
MyLookup();
}
private void MyLookup()
{
if (string.IsNullOrEmpty(tbEMPLOYEE_ID.Text))
{
lbEMPLOYEE_NAME.Text = "INVALID EMPLOYEE ID";
}
else
{
lbEMPLOYEE_NAME.Text = tbEMPLOYEE_ID.Text.ToUpper();
tbEMPLOYEE_ID.Text = tbEMPLOYEE_ID.Text.ToUpper();
int EmpID = -1;
string constr = ConfigurationManager.ConnectionStrings["PAYROLL"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("DLI_BENEFITS_EMP_ID_VALIDATE"))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@EmployeeID", tbEMPLOYEE_ID.Text.ToUpper());
cmd.Connection = con;
con.Open();
EmpID = Convert.ToInt32(cmd.ExecuteScalar());
con.Close();
}
}
if (EmpID != -1)
{
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("DLI_BENEFITS_HEADER"))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@EmployeeID", tbEMPLOYEE_ID.Text.ToUpper());
cmd.Connection = con;
con.Open();
SqlDataReader dataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
while (dataReader.Read())
{
lbEMPLOYEE_NAME.Text = dataReader["EMPLOYEE_NAME"].ToString();
ddl401_TYPE.SelectedValue = dataReader["401K_TYPE"].ToString();
tb401_PCT.Text = dataReader["CONTRIBUTION_RATE_401K_PCT"].ToString();
tb401_AMOUNT.Text = dataReader["CONTRIBUTION_RATE_401K_AMOUNT"].ToString();
cbCOMP_LIFE_EMP.Checked = Convert.ToBoolean(dataReader["COMPANY_LIFE_EMP"]);
cbCOMP_LIFE_SPOUSE.Checked = Convert.ToBoolean(dataReader["COMPANY_LIFE_SPOUSE"]);
cbCOMP_LIFE_CHILDREN.Checked = Convert.ToBoolean(dataReader["COMPANY_LIFE_CHILD"]);
TbCOMP_LIFE_DEPENDENTS.Text = dataReader["COMPANY_LIFE_DEPENDENTS"].ToString();
cbDECLINE_HEALTH.Checked = Convert.ToBoolean(dataReader["HEALTH_DECLINE"]);
cbDECLINE_DENTAL.Checked = Convert.ToBoolean(dataReader["DENTAL_DECLINE"]);
cbDECLINE_VISION.Checked = Convert.ToBoolean(dataReader["VISION_DECLINE"]);
cbDECLINE_LIFE.Checked = Convert.ToBoolean(dataReader["LIFE_DECLINE"]);
tbNOTES.Text = dataReader["NOTES"].ToString();
lbENROLL_DATE.Text = Convert.ToDateTime(dataReader["ENROLL"]).ToString("MM/dd/yyyy");
lbHIRE_DATE.Text = Convert.ToDateTime(dataReader["HIRE_DATE"]).ToString("MM/dd/yyyy");
lbINITIAL_MEETING.Text = "";
ibINITIAL_DATE.Visible = true;
if (dataReader["INIT_MEETING"].GetType() != typeof(DBNull))
{
lbINITIAL_MEETING.Text = Convert.ToDateTime(dataReader["INIT_MEETING"]).ToString("MM/dd/yyyy");
ibINITIAL_DATE.Visible = false;
}
}
con.Close();
}
}
}
else
{
lbEMPLOYEE_NAME.Text = tbEMPLOYEE_ID.Text.ToUpper() + " is not valid.";
}
}
}
protected void ibUPDATE_HEADER_Click(object sender, ImageClickEventArgs e)
{
string @EMP_ID = Convert.ToString(tbEMPLOYEE_ID.Text).ToUpper();
string @K401_TYPE = Convert.ToString(ddl401_TYPE.SelectedValue).ToUpper();
string @NOTES = Convert.ToString(tbNOTES.Text).ToUpper();
string cnString = ConfigurationManager.ConnectionStrings["PAYROLL"].ConnectionString;
//Response.Write(cnString);
lblSPMessageSuccess.Text = "";
SqlConnection cn = null;
try
{
cn = new SqlConnection(cnString);
cn.Open();
SqlCommand cmd = new SqlCommand("DLI_BENEFITS_HEADER_UPDATE", cn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@EMP_ID", @EMP_ID);
cmd.Parameters.AddWithValue("@K401_TYPE", @K401_TYPE.ToString());
if (decimal.TryParse(tb401_AMOUNT.Text, out decimal parsed))
{
cmd.Parameters.AddWithValue("@CONTRIBUTION_RATE_401K_AMOUNT", decimal.Parse(tb401_AMOUNT.Text));
}
else
{
cmd.Parameters.AddWithValue("@CONTRIBUTION_RATE_401K_AMOUNT", DBNull.Value);
}
if (Int16.TryParse(tb401_PCT.Text, out Int16 parsed1))
{
cmd.Parameters.AddWithValue("@CONTRIBUTION_RATE_401K_PCT", Int16.Parse(tb401_PCT.Text));
}
else
{
cmd.Parameters.AddWithValue("@CONTRIBUTION_RATE_401K_PCT", DBNull.Value);
}
cmd.Parameters.AddWithValue("@COMPANY_LIFE_EMP", cbCOMP_LIFE_EMP.Checked);
cmd.Parameters.AddWithValue("@COMPANY_LIFE_SPOUSE", cbCOMP_LIFE_SPOUSE.Checked);
cmd.Parameters.AddWithValue("@COMPANY_LIFE_CHILD", cbCOMP_LIFE_CHILDREN.Checked);
if (Int16.TryParse(TbCOMP_LIFE_DEPENDENTS.Text, out Int16 parsed2))
{
cmd.Parameters.AddWithValue("@COMPANY_LIFE_DEPENDENTS", Int16.Parse(TbCOMP_LIFE_DEPENDENTS.Text));
}
else
{
cmd.Parameters.AddWithValue("@COMPANY_LIFE_DEPENDENTS", DBNull.Value);
}
cmd.Parameters.AddWithValue("@HEALTH_DECLINE", cbDECLINE_HEALTH.Checked);
cmd.Parameters.AddWithValue("@DENTAL_DECLINE", cbDECLINE_DENTAL.Checked);
cmd.Parameters.AddWithValue("@VISION_DECLINE", cbDECLINE_VISION.Checked);
cmd.Parameters.AddWithValue("@LIFE_DECLINE", cbDECLINE_LIFE.Checked);
cmd.Parameters.AddWithValue("@NOTES", @NOTES.ToString());
cmd.Parameters.Add("@SP_MESSAGE", SqlDbType.VarChar, 200).Direction = ParameterDirection.Output;
cmd.Parameters.Add("@SP_ERROR_NUMBER", SqlDbType.Int).Direction = ParameterDirection.Output;
cmd.ExecuteNonQuery();
int output = (int)cmd.Parameters["@SP_ERROR_NUMBER"].Value;
string output_message = (string)cmd.Parameters["@SP_MESSAGE"].Value;
if (output == -1)
{
lblSPMessageSuccess.Text = "";
lblSPMessageError.Text = output_message;
}
else
{
lblSPMessageError.Text = "";
lblSPMessageSuccess.Text = output_message;
//dsEnrolledBenefits.EnableCaching = false;
//dsEnrolledBenefits.EnableCaching = true;
//this.dsEnrolledBenefits.DataBind();
//this.gvOpenProjects.DataBind();
}
}
catch (Exception ex)
{
lblSPMessageError.Text = ex.Message;
}
finally
{
if (cn != null)
{
cn.Close();
MyLookup();
}
}
}
}
}
USE [PAYDEMO]
GO
/****** Object: StoredProcedure [dbo].[DLI_BENEFITS_HEADER_UPDATE] Script Date: 7/23/2019 8:46:39 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[DLI_BENEFITS_HEADER_UPDATE]
@EMP_ID [varchar](15),
@K401_TYPE [nvarchar](10),
@CONTRIBUTION_RATE_401K_AMOUNT [decimal](12, 2),
@CONTRIBUTION_RATE_401K_PCT [tinyint],
@COMPANY_LIFE_EMP [bit],
@COMPANY_LIFE_SPOUSE [bit],
@COMPANY_LIFE_CHILD [bit],
@COMPANY_LIFE_DEPENDENTS [tinyint],
@HEALTH_DECLINE [bit],
@DENTAL_DECLINE [bit],
@VISION_DECLINE [bit],
@LIFE_DECLINE [bit],
@NOTES [nvarchar](max),
@SP_MESSAGE varchar(200) OUTPUT,
@SP_ERROR_NUMBER int OUTPUT
AS
BEGIN
SET @SP_ERROR_NUMBER = 0
IF @SP_ERROR_NUMBER = 0
BEGIN
UPDATE EMPLOYEE_PTO_401k
SET [401K_TYPE] = @K401_TYPE, CONTRIBUTION_RATE_401K_AMOUNT = @CONTRIBUTION_RATE_401K_AMOUNT, CONTRIBUTION_RATE_401K_PCT = @CONTRIBUTION_RATE_401K_PCT, COMPANY_LIFE_EMP = @COMPANY_LIFE_EMP,
COMPANY_LIFE_SPOUSE = @COMPANY_LIFE_SPOUSE, COMPANY_LIFE_CHILD = @COMPANY_LIFE_CHILD, COMPANY_LIFE_DEPENDENTS = @COMPANY_LIFE_DEPENDENTS, HEALTH_DECLINE = @HEALTH_DECLINE, DENTAL_DECLINE = @DENTAL_DECLINE,
VISION_DECLINE = @VISION_DECLINE, LIFE_DECLINE = @LIFE_DECLINE, NOTES = @NOTES
WHERE (EMP_ID = @EMP_ID)
SELECT @SP_MESSAGE = 'RECORD UPDATED SUCCESSFULLY', @SP_ERROR_NUMBER = 0
END
END
非常感谢任何帮助。
根据你的描述和代码,我发现你在页面加载方法中调用了MyLookup。如果查询字符串 qsEmpID 有值。它将再次调用 MyLookup 方法。
如果调用按钮单击事件,如果查询字符串具有调用更新方法之前的值,它将re-binding 服务器控件。我建议你可以 re-desgin 你的页面加载方法。
我有一个显示一些 header 信息的 Web 表单,您可以更改该信息(文本框、复选框等)并点击更新信息按钮以 post 信息到一个 SQL 存储过程..
当我 运行 在 Visual Studio 上点击按钮时,信息会更新。
====VISUAL STUDIO====
declare @p14 varchar(200)
set @p14=NULL
declare @p15 int
set @p15=NULL
exec DLI_BENEFITS_HEADER_UPDATE @EMP_ID=N'ADA04',@K401_TYPE=N'DECLINED',@CONTRIBUTION_RATE_401K_AMOUNT=NULL,@CONTRIBUTION_RATE_401K_PCT=NULL,@COMPANY_LIFE_EMP=1,@COMPANY_LIFE_SPOUSE=0,@COMPANY_LIFE_CHILD=1,@COMPANY_LIFE_DEPENDENTS=99,@HEALTH_DECLINE=1,@DENTAL_DECLINE=0,@VISION_DECLINE=1,@LIFE_DECLINE=0,@NOTES=N'MY RECORD NEW RECORD INFO',@SP_MESSAGE=@p14 output,@SP_ERROR_NUMBER=@p15 output
select @p14, @p15
go
exec sp_reset_connection
go
当我在 IIS 中 运行 完全相同的东西时,它基本上只是将信息放回 SQL,就好像什么都没有改变一样。
=====IIS=====
declare @p14 varchar(200)
set @p14=NULL
declare @p15 int
set @p15=NULL
exec DLI_BENEFITS_HEADER_UPDATE @EMP_ID=N'ADA04',@K401_TYPE=N'DECLINED',@CONTRIBUTION_RATE_401K_AMOUNT=NULL,@CONTRIBUTION_RATE_401K_PCT=NULL,@COMPANY_LIFE_EMP=1,@COMPANY_LIFE_SPOUSE=0,@COMPANY_LIFE_CHILD=1,@COMPANY_LIFE_DEPENDENTS=99,@HEALTH_DECLINE=1,@DENTAL_DECLINE=0,@VISION_DECLINE=1,@LIFE_DECLINE=0,@NOTES=N'MY RECORD NEW RECORD INFO',@SP_MESSAGE=@p14 output,@SP_ERROR_NUMBER=@p15 output
select @p14, @p15
我将文本框 99 更改为 4,并将我的记录新记录更改为我的记录新记录信息,此处带有新注释,然后点击提交按钮。
@COMPANY_LIFE_DEPENDENTS=99比4 和 @NOTES 到 @NOTES=N'我的记录新记录信息这里有新的注释'
我不确定我在这里遗漏了什么..抱歉,如果它是非常基本的东西,我应该知道得更多,但我已经四处搜索试图找出它。
SQL 连接 SQL 用户名和密码未集成。
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="EmployeeBenefits.aspx.cs" Inherits="DLI_EMPLOYEE_BENEFITS.EmployeeBenefits" MaintainScrollPositionOnPostback="true" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>DLI Employee Benefit Maintenance</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<style>
html, body {
height: 90%;
padding: 10px;
}
html {
display: table;
margin: auto;
}
body {
display: table-cell;
vertical-align: top;
width: 1024px;
height: 768px;
margin: 0; /* Space from this element (entire page) and others*/
padding: 20; /*space from content and border*/
border: solid blue;
border-width: thin;
overflow: hidden;
display: block;
box-sizing: border-box;
}
.HeaderLogo {
text-align: center;
}
.PageTitle {
text-align: center;
font-size: x-large;
font-weight: bold;
}
.LoginName {
text-align: right;
}
.NavBar {
text-align: center;
margin: auto;
padding: 10px;
}
.DivCenter {
text-align: center;
}
.auto-style1 {
width: 100%;
border-collapse: collapse;
}
.auto-style2 {
width: 100%;
}
.auto-style3 {
width: 20%;
height: 25px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div id="BODY_DIV">
<div id="PageTitle" class="PageTitle">
EMPLOYEE BENEFIT MAINTENANCE<hr />
</div>
<div id="EMPLOYEE_BENEFITS_HEADER">
<table class="auto-style1">
<tr>
<td style="vertical-align: middle; text-align: right; width: 15%; font-weight: bold;">EMP ID :</td>
<td style="vertical-align: middle; text-align: right; width: 15%">
<asp:TextBox ID="tbEMPLOYEE_ID" runat="server" Width="92px"></asp:TextBox>
<asp:ImageButton ID="ibGET" runat="server" ImageUrl="~/Image/elcmark.png" OnClick="ibGET_Click" />
<asp:ImageButton ID="ibRESET" runat="server" ImageUrl="~/Image/reset.png" PostBackUrl="https://dlihome.deseretlabs.com/HR/EMP_BENEFITS/EmployeeBenefits.aspx" />
</td>
<td style="vertical-align: middle; text-align: center; width: 40%">
<asp:Label ID="lbEMPLOYEE_NAME" runat="server" Text="DOE, JOHN" Font-Bold="True" Font-Size="X-Large" ForeColor="Red"></asp:Label>
</td>
<td style="vertical-align: middle; text-align: right; width: 15%; font-weight: bold;">HIRE DATE :</td>
<td style="vertical-align: middle; text-align: center; width: 15%">
<asp:Label ID="lbHIRE_DATE" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td style="vertical-align: middle; text-align: right; width: 15%; font-weight: bold;">ENROLL DATE :</td>
<td style="vertical-align: middle; text-align: center; width: 15%">
<asp:Label ID="lbENROLL_DATE" runat="server"></asp:Label>
</td>
<td style="vertical-align: middle; text-align: right; width: 55%; font-weight: bold;" colspan="2">INITAL MEETING :</td>
<td style="vertical-align: middle; text-align: center; width: 15%">
<asp:Label ID="lbINITIAL_MEETING" runat="server"></asp:Label>
<asp:ImageButton ID="ibINITIAL_DATE" runat="server" ImageUrl="~/Image/plus16.gif" />
</td>
</tr>
</table>
<hr />
<table class="auto-style1" cellpadding="10px">
<tr>
<td style="vertical-align: middle; text-align: right; width: 20%; font-weight: bold;">401K :</td>
<td style="vertical-align: middle; text-align: left; width: 20%" colspan="4">
<asp:DropDownList ID="ddl401_TYPE" runat="server">
<asp:ListItem></asp:ListItem>
<asp:ListItem>DECLINED</asp:ListItem>
<asp:ListItem>401K</asp:ListItem>
<asp:ListItem>ROTH</asp:ListItem>
</asp:DropDownList>
♦
<asp:TextBox ID="tb401_PCT" runat="server" Width="25px" Wrap="False" style="text-align:center"></asp:TextBox>
PERCENT ♦ $
<asp:TextBox ID="tb401_AMOUNT" runat="server" Width="64px" Wrap="False"></asp:TextBox>
AMOUNT</td>
</tr>
<tr>
<td style="vertical-align: middle; text-align: right; width: 20%; font-weight: bold;">COMPANY LIFE :</td>
<td style="vertical-align: middle; text-align: left; width: 20%" colspan="4"> <asp:CheckBox ID="cbCOMP_LIFE_EMP" runat="server" Text="EMPLOYEE" />
♦ <asp:CheckBox ID="cbCOMP_LIFE_SPOUSE" runat="server" Text="SPOUSE" />
♦ <asp:CheckBox ID="cbCOMP_LIFE_CHILDREN" runat="server" Text="CHILDREN" />
♦ <asp:TextBox ID="TbCOMP_LIFE_DEPENDENTS" runat="server" Width="25px" Wrap="False" style="text-align:center"></asp:TextBox>
DEPENDENTS</td>
</tr>
<tr>
<td style="vertical-align: middle; text-align: right; width: 20%; font-weight: bold;">DECLINED BENEFITS :</td>
<td style="vertical-align: middle; text-align: left; width: 20%" colspan="4">
<asp:CheckBox ID="cbDECLINE_HEALTH" runat="server" Text="HEALTH" />
♦ <asp:CheckBox ID="cbDECLINE_DENTAL" runat="server" Text="DENTAL" />
♦ <asp:CheckBox ID="cbDECLINE_VISION" runat="server" Text="VISION" />
♦ <asp:CheckBox ID="cbDECLINE_LIFE" runat="server" Text="VOLUNTARY LIFE" />
</td>
</tr>
<tr>
<td style="vertical-align: middle; text-align: RIGHT; width: 20%; font-weight: bold;">NOTES:</td>
<td style="vertical-align: middle; text-align: LEFT; width: 80%" colspan="4">
<asp:TextBox ID="tbNOTES" runat="server" style="margin-left: 0px" TextMode="MultiLine" Width="100%" Height="50px"></asp:TextBox>
</td>
</tr>
<tr>
<td style="vertical-align: middle; text-align: CENTER; width: 100%; font-weight: bold;" colspan="2">
<asp:ImageButton ID="ibUPDATE_HEADER" runat="server" ImageUrl="~/Image/button_update-record.png" OnClick="ibUPDATE_HEADER_Click" />
<br />
<asp:Label ID="lblSPMessageSuccess" runat="server"></asp:Label><asp:Label ID="lblSPMessageError" runat="server"></asp:Label>
</td>
</tr>
</table>
<hr style="border: 1px solid red;"/>
</div>
<div id="ENROLLED_BENEFITS">
<asp:GridView ID="gvEnrolledBenfits" runat="server" AllowPaging="True" AutoGenerateColumns="False" CellPadding="4" DataSourceID="dsEnrolledBenefits" Width="100%" BackColor="White" BorderColor="#CC9966" BorderStyle="None" BorderWidth="1px">
<Columns>
<asp:BoundField DataField="INS_DESCRIPTION" HeaderText="DESCRIPTION" SortExpression="INS_DESCRIPTION">
<HeaderStyle Font-Bold="True" Font-Size="Small" HorizontalAlign="Center" VerticalAlign="Middle" Width="20%" />
<ItemStyle Font-Size="Small" HorizontalAlign="Center" VerticalAlign="Middle" />
</asp:BoundField>
<asp:BoundField DataField="AMOUNT" DataFormatString="{0:c}" HeaderText="AMOUNT PPC" SortExpression="AMOUNT" >
<HeaderStyle Font-Bold="True" Font-Size="Small" HorizontalAlign="Center" VerticalAlign="Middle" Width="10%" />
<ItemStyle Font-Size="Small" HorizontalAlign="Center" VerticalAlign="Middle" Width="10%" />
</asp:BoundField>
<asp:BoundField DataField="LIFE_AMOUNT" DataFormatString="{0:c}" HeaderText="LIFE AMOUNT" SortExpression="LIFE_AMOUNT" >
<HeaderStyle Font-Bold="True" Font-Size="Small" HorizontalAlign="Center" VerticalAlign="Middle" Width="10%" />
<ItemStyle Font-Size="Small" HorizontalAlign="Center" VerticalAlign="Middle" Width="10%" />
</asp:BoundField>
<asp:BoundField DataField="DEPENDENT_CHIDREN" HeaderText="DEPENDENT CHIDREN" SortExpression="DEPENDENT_CHIDREN" >
<HeaderStyle Font-Bold="True" Font-Size="Small" HorizontalAlign="Center" VerticalAlign="Middle" Width="10%" />
<ItemStyle Font-Size="Small" HorizontalAlign="Center" VerticalAlign="Middle" Width="10%" />
</asp:BoundField>
<asp:BoundField DataField="START_DATE" DataFormatString="{0:d}" HeaderText="START DATE" SortExpression="START_DATE" >
<HeaderStyle Font-Bold="True" Font-Size="Small" HorizontalAlign="Center" VerticalAlign="Middle" Width="10%" />
<ItemStyle Font-Size="Small" HorizontalAlign="Center" VerticalAlign="Middle" Width="10%" />
</asp:BoundField>
<asp:BoundField DataField="END_DATE" DataFormatString="{0:d}" HeaderText="END DATE" SortExpression="END_DATE" >
<HeaderStyle Font-Bold="True" Font-Size="Small" HorizontalAlign="Center" VerticalAlign="Middle" Width="10%" />
<ItemStyle Font-Size="Small" HorizontalAlign="Center" VerticalAlign="Middle" Width="10%" />
</asp:BoundField>
</Columns>
<FooterStyle BackColor="#FFFFCC" ForeColor="#330099" />
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="#FFFFCC" />
<PagerStyle BackColor="#FFFFCC" ForeColor="#330099" HorizontalAlign="Center" />
<RowStyle BackColor="White" ForeColor="#330099" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="#663399" />
<SortedAscendingCellStyle BackColor="#FEFCEB" />
<SortedAscendingHeaderStyle BackColor="#AF0101" />
<SortedDescendingCellStyle BackColor="#F6F0C0" />
<SortedDescendingHeaderStyle BackColor="#7E0000" />
</asp:GridView>
<asp:SqlDataSource ID="dsEnrolledBenefits" runat="server" ConnectionString="<%$ ConnectionStrings:PAYROLL %>" SelectCommand="DLI_BENEFITS_EMPLOYEE_ENROLLED" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:ControlParameter ControlID="tbEMPLOYEE_ID" Name="EID" PropertyName="Text" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
</div>
</div>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
namespace DLI_EMPLOYEE_BENEFITS
{
public partial class EmployeeBenefits : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//if (!IsPostBack)
//{
// lbEMPLOYEE_NAME.Text = "";
// tbEMPLOYEE_ID.Text = "";
//}
ibINITIAL_DATE.Visible = false;
lblSPMessageSuccess.Text = "";
string qsEmpID = Request.QueryString["qsEmpID"];
if (string.IsNullOrEmpty(qsEmpID))
{
}
else
{
tbEMPLOYEE_ID.Text = qsEmpID.ToUpper();
MyLookup();
}
}
protected void ibGET_Click(object sender, ImageClickEventArgs e)
{
MyLookup();
}
private void MyLookup()
{
if (string.IsNullOrEmpty(tbEMPLOYEE_ID.Text))
{
lbEMPLOYEE_NAME.Text = "INVALID EMPLOYEE ID";
}
else
{
lbEMPLOYEE_NAME.Text = tbEMPLOYEE_ID.Text.ToUpper();
tbEMPLOYEE_ID.Text = tbEMPLOYEE_ID.Text.ToUpper();
int EmpID = -1;
string constr = ConfigurationManager.ConnectionStrings["PAYROLL"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("DLI_BENEFITS_EMP_ID_VALIDATE"))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@EmployeeID", tbEMPLOYEE_ID.Text.ToUpper());
cmd.Connection = con;
con.Open();
EmpID = Convert.ToInt32(cmd.ExecuteScalar());
con.Close();
}
}
if (EmpID != -1)
{
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("DLI_BENEFITS_HEADER"))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@EmployeeID", tbEMPLOYEE_ID.Text.ToUpper());
cmd.Connection = con;
con.Open();
SqlDataReader dataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
while (dataReader.Read())
{
lbEMPLOYEE_NAME.Text = dataReader["EMPLOYEE_NAME"].ToString();
ddl401_TYPE.SelectedValue = dataReader["401K_TYPE"].ToString();
tb401_PCT.Text = dataReader["CONTRIBUTION_RATE_401K_PCT"].ToString();
tb401_AMOUNT.Text = dataReader["CONTRIBUTION_RATE_401K_AMOUNT"].ToString();
cbCOMP_LIFE_EMP.Checked = Convert.ToBoolean(dataReader["COMPANY_LIFE_EMP"]);
cbCOMP_LIFE_SPOUSE.Checked = Convert.ToBoolean(dataReader["COMPANY_LIFE_SPOUSE"]);
cbCOMP_LIFE_CHILDREN.Checked = Convert.ToBoolean(dataReader["COMPANY_LIFE_CHILD"]);
TbCOMP_LIFE_DEPENDENTS.Text = dataReader["COMPANY_LIFE_DEPENDENTS"].ToString();
cbDECLINE_HEALTH.Checked = Convert.ToBoolean(dataReader["HEALTH_DECLINE"]);
cbDECLINE_DENTAL.Checked = Convert.ToBoolean(dataReader["DENTAL_DECLINE"]);
cbDECLINE_VISION.Checked = Convert.ToBoolean(dataReader["VISION_DECLINE"]);
cbDECLINE_LIFE.Checked = Convert.ToBoolean(dataReader["LIFE_DECLINE"]);
tbNOTES.Text = dataReader["NOTES"].ToString();
lbENROLL_DATE.Text = Convert.ToDateTime(dataReader["ENROLL"]).ToString("MM/dd/yyyy");
lbHIRE_DATE.Text = Convert.ToDateTime(dataReader["HIRE_DATE"]).ToString("MM/dd/yyyy");
lbINITIAL_MEETING.Text = "";
ibINITIAL_DATE.Visible = true;
if (dataReader["INIT_MEETING"].GetType() != typeof(DBNull))
{
lbINITIAL_MEETING.Text = Convert.ToDateTime(dataReader["INIT_MEETING"]).ToString("MM/dd/yyyy");
ibINITIAL_DATE.Visible = false;
}
}
con.Close();
}
}
}
else
{
lbEMPLOYEE_NAME.Text = tbEMPLOYEE_ID.Text.ToUpper() + " is not valid.";
}
}
}
protected void ibUPDATE_HEADER_Click(object sender, ImageClickEventArgs e)
{
string @EMP_ID = Convert.ToString(tbEMPLOYEE_ID.Text).ToUpper();
string @K401_TYPE = Convert.ToString(ddl401_TYPE.SelectedValue).ToUpper();
string @NOTES = Convert.ToString(tbNOTES.Text).ToUpper();
string cnString = ConfigurationManager.ConnectionStrings["PAYROLL"].ConnectionString;
//Response.Write(cnString);
lblSPMessageSuccess.Text = "";
SqlConnection cn = null;
try
{
cn = new SqlConnection(cnString);
cn.Open();
SqlCommand cmd = new SqlCommand("DLI_BENEFITS_HEADER_UPDATE", cn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@EMP_ID", @EMP_ID);
cmd.Parameters.AddWithValue("@K401_TYPE", @K401_TYPE.ToString());
if (decimal.TryParse(tb401_AMOUNT.Text, out decimal parsed))
{
cmd.Parameters.AddWithValue("@CONTRIBUTION_RATE_401K_AMOUNT", decimal.Parse(tb401_AMOUNT.Text));
}
else
{
cmd.Parameters.AddWithValue("@CONTRIBUTION_RATE_401K_AMOUNT", DBNull.Value);
}
if (Int16.TryParse(tb401_PCT.Text, out Int16 parsed1))
{
cmd.Parameters.AddWithValue("@CONTRIBUTION_RATE_401K_PCT", Int16.Parse(tb401_PCT.Text));
}
else
{
cmd.Parameters.AddWithValue("@CONTRIBUTION_RATE_401K_PCT", DBNull.Value);
}
cmd.Parameters.AddWithValue("@COMPANY_LIFE_EMP", cbCOMP_LIFE_EMP.Checked);
cmd.Parameters.AddWithValue("@COMPANY_LIFE_SPOUSE", cbCOMP_LIFE_SPOUSE.Checked);
cmd.Parameters.AddWithValue("@COMPANY_LIFE_CHILD", cbCOMP_LIFE_CHILDREN.Checked);
if (Int16.TryParse(TbCOMP_LIFE_DEPENDENTS.Text, out Int16 parsed2))
{
cmd.Parameters.AddWithValue("@COMPANY_LIFE_DEPENDENTS", Int16.Parse(TbCOMP_LIFE_DEPENDENTS.Text));
}
else
{
cmd.Parameters.AddWithValue("@COMPANY_LIFE_DEPENDENTS", DBNull.Value);
}
cmd.Parameters.AddWithValue("@HEALTH_DECLINE", cbDECLINE_HEALTH.Checked);
cmd.Parameters.AddWithValue("@DENTAL_DECLINE", cbDECLINE_DENTAL.Checked);
cmd.Parameters.AddWithValue("@VISION_DECLINE", cbDECLINE_VISION.Checked);
cmd.Parameters.AddWithValue("@LIFE_DECLINE", cbDECLINE_LIFE.Checked);
cmd.Parameters.AddWithValue("@NOTES", @NOTES.ToString());
cmd.Parameters.Add("@SP_MESSAGE", SqlDbType.VarChar, 200).Direction = ParameterDirection.Output;
cmd.Parameters.Add("@SP_ERROR_NUMBER", SqlDbType.Int).Direction = ParameterDirection.Output;
cmd.ExecuteNonQuery();
int output = (int)cmd.Parameters["@SP_ERROR_NUMBER"].Value;
string output_message = (string)cmd.Parameters["@SP_MESSAGE"].Value;
if (output == -1)
{
lblSPMessageSuccess.Text = "";
lblSPMessageError.Text = output_message;
}
else
{
lblSPMessageError.Text = "";
lblSPMessageSuccess.Text = output_message;
//dsEnrolledBenefits.EnableCaching = false;
//dsEnrolledBenefits.EnableCaching = true;
//this.dsEnrolledBenefits.DataBind();
//this.gvOpenProjects.DataBind();
}
}
catch (Exception ex)
{
lblSPMessageError.Text = ex.Message;
}
finally
{
if (cn != null)
{
cn.Close();
MyLookup();
}
}
}
}
}
USE [PAYDEMO]
GO
/****** Object: StoredProcedure [dbo].[DLI_BENEFITS_HEADER_UPDATE] Script Date: 7/23/2019 8:46:39 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[DLI_BENEFITS_HEADER_UPDATE]
@EMP_ID [varchar](15),
@K401_TYPE [nvarchar](10),
@CONTRIBUTION_RATE_401K_AMOUNT [decimal](12, 2),
@CONTRIBUTION_RATE_401K_PCT [tinyint],
@COMPANY_LIFE_EMP [bit],
@COMPANY_LIFE_SPOUSE [bit],
@COMPANY_LIFE_CHILD [bit],
@COMPANY_LIFE_DEPENDENTS [tinyint],
@HEALTH_DECLINE [bit],
@DENTAL_DECLINE [bit],
@VISION_DECLINE [bit],
@LIFE_DECLINE [bit],
@NOTES [nvarchar](max),
@SP_MESSAGE varchar(200) OUTPUT,
@SP_ERROR_NUMBER int OUTPUT
AS
BEGIN
SET @SP_ERROR_NUMBER = 0
IF @SP_ERROR_NUMBER = 0
BEGIN
UPDATE EMPLOYEE_PTO_401k
SET [401K_TYPE] = @K401_TYPE, CONTRIBUTION_RATE_401K_AMOUNT = @CONTRIBUTION_RATE_401K_AMOUNT, CONTRIBUTION_RATE_401K_PCT = @CONTRIBUTION_RATE_401K_PCT, COMPANY_LIFE_EMP = @COMPANY_LIFE_EMP,
COMPANY_LIFE_SPOUSE = @COMPANY_LIFE_SPOUSE, COMPANY_LIFE_CHILD = @COMPANY_LIFE_CHILD, COMPANY_LIFE_DEPENDENTS = @COMPANY_LIFE_DEPENDENTS, HEALTH_DECLINE = @HEALTH_DECLINE, DENTAL_DECLINE = @DENTAL_DECLINE,
VISION_DECLINE = @VISION_DECLINE, LIFE_DECLINE = @LIFE_DECLINE, NOTES = @NOTES
WHERE (EMP_ID = @EMP_ID)
SELECT @SP_MESSAGE = 'RECORD UPDATED SUCCESSFULLY', @SP_ERROR_NUMBER = 0
END
END
非常感谢任何帮助。
根据你的描述和代码,我发现你在页面加载方法中调用了MyLookup。如果查询字符串 qsEmpID 有值。它将再次调用 MyLookup 方法。
如果调用按钮单击事件,如果查询字符串具有调用更新方法之前的值,它将re-binding 服务器控件。我建议你可以 re-desgin 你的页面加载方法。