0
一部のフラグがテーブルの列で有効であることを確認する必要があります。一部のフラグがテーブル内で有効であることを確認する必要があります
フラグがアクティブな場合のみ、更新ステートメントが実行されます。 "0"がWebサービスのパッセージに合格する必要がある場合、MyフラグはHR_ActiveとUser_Activeです。
テーブル名がある:私は私のコードスニペットを言及してい以下HS_HR_EMPLOYEE
。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data;
using System.Configuration;
using System.Data.SqlClient;
namespace XXX_WebService
{
[WebService(Namespace = "http://XXXXXXX.com/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class EmployeeService : System.Web.Services.WebService
{
[WebMethod(Description = "Update Employee Email Address")]
public int Update(string USRACC_USER_ID, string EMP_OFFICE_EMAIL)
{
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("UPDATE HS_HR_EMPLOYEE SET EMP_OFFICE_EMAIL = @EMP_OFFICE_EMAIL FROM HS_SM_USER_ACCOUNT WHERE HS_SM_USER_ACCOUNT.EMP_NUMBER = HS_HR_EMPLOYEE.EMP_NUMBER AND USRACC_USER_ID = @USRACC_USER_ID"))
{
cmd.Parameters.AddWithValue("@USRACC_USER_ID", USRACC_USER_ID);
cmd.Parameters.AddWithValue("@EMP_OFFICE_EMAIL", EMP_OFFICE_EMAIL);
cmd.Connection = con;
con.Open();
int row = cmd.ExecuteNonQuery();
con.Close();
//return row;
}
string emp_number ="-1";
using (SqlCommand cmd = new SqlCommand("SELECT EMP_NUMBER FROM HS_SM_USER_ACCOUNT WHERE [email protected]_USER_ID"))
{
using (SqlDataAdapter sda = new SqlDataAdapter())
{
cmd.Parameters.AddWithValue("@USRACC_USER_ID", USRACC_USER_ID);
cmd.Connection = con;
sda.SelectCommand = cmd;
using (DataTable dt = new DataTable())
{
dt.TableName = "HS_SM_USER_ACCOUNT";
sda.Fill(dt);
if(dt.Rows.Count > 0)
emp_number = dt.Rows[0][0]==DBNull.Value ? "-1" : dt.Rows[0][0].ToString();
}
}
}
using (SqlCommand cmd = new SqlCommand("INSERT INTO HS_EMP_EMAIL_TEMP_LOG (EMP_NUMBER,USRACC_USER_ID,EMP_OFFICE_EMAIL,LOG_DATE_TIME) VALUES(@EMP_NUMBER,@USRACC_USER_ID,@EMP_OFFICE_EMAIL,GETDATE())"))
{
cmd.Parameters.AddWithValue("@EMP_NUMBER", emp_number);
cmd.Parameters.AddWithValue("@USRACC_USER_ID", USRACC_USER_ID);
cmd.Parameters.AddWithValue("@EMP_OFFICE_EMAIL", EMP_OFFICE_EMAIL);
cmd.Connection = con;
con.Open();
int row = cmd.ExecuteNonQuery();
con.Close();
// return row;
}
return 1;
}
}
}
}