- 分享
- 0
- 人气
- 0
- 主题
- 4
- 帖子
- 672
- UID
- 122737
- 积分
- 476
- 阅读权限
- 16
- 注册时间
- 2008-2-3
- 最后登录
- 2015-5-11
- 在线时间
- 649 小时
|
<--------------------ajax部分----------------------------------------------------------------------------->
function Edit(uid) {
$("#divLoading").dialog('open');
$("#divLoading").dialog
({
bgiframe: true,
modal: true
});
$.ajax
({
type: "OST",
contentType: "application/json; charset=utf-8",
url: "../Ajax/LoadingData.asmx/LoadStaffInfo",
data: "{'sUId': '" + uid + "'}",
success: function(result) {
$("#<%=lbl_UserId.ClientID %>").html(result.d.UserID).css("color", "white");
$("#<%=txt_FirstNameEdit.ClientID %>").val(result.d.FirstName);
$("#<%=txt_LastNameEdit.ClientID %>").val(result.d.LastName);
$("#<%=drp_GenderEdit.ClientID %>").val(result.d.Gender);
$("#<%=txt_BirthDateEdit.ClientID %>").val(result.d.BirthDate);
$("#<%=drp_DepartmentEdit.ClientID %>").val(result.d.DepartmentID);
$("#<%=drp_PositionEdit.ClientID %>").val(result.d.PositionID);
$("#<%=txt_HPNumberEdit.ClientID %>").val(result.d.HPNo);
$("#<%=txt_HomeNoEdit.ClientID %>").val(result.d.HomeNo);
$("#<%=txt_AddressEdit.ClientID %>").val(result.d.Address);
$("#<%=txt_StateEdit.ClientID %>").val(result.d.State);
$("#<%=txt_CityEdit.ClientID %>").val(result.d.City);
$("#<%=txt_PostCodeEdit.ClientID %>").val(result.d.PostCode);
$("#<%=txt_EducationBackgroundEdit.ClientID %>").val(result.d.EducationBackground);
$("#<%=txt_EmailEdit.ClientID %>").val(result.d.Email);
$("#divLoading").dialog('close');
$("#divModelStaff").dialog('open');
$("#divModelStaff").dialog
({
bgiframe: true,
modal: true,
width: 400,
buttons:
{
"Update": function() {
$("#divUpdating").dialog('open');
$("#divUpdating").dialog
({
bgiframe: true,
modal: true
});
var objUser = new Object();
objUser.sUserId = $("#<%=lbl_UserId.ClientID %>").text();
objUser.sFN = $("#<%=txt_FirstNameEdit.ClientID %>").val();
objUser.sLN = $("#<%=txt_LastNameEdit.ClientID %>").val();
objUser.sGender = $("#<%=drp_GenderEdit.ClientID %>").val();
objUser.dtDOB = $("#<%=txt_BirthDateEdit.ClientID %>").val();
objUser.iDepartmentId = $("#<%=drp_DepartmentEdit.ClientID %>").val();
objUser.iPositionId = $("#<%=drp_PositionEdit.ClientID %>").val();
objUser.sHPNo = $("#<%=txt_HPNumberEdit.ClientID %>").val();
objUser.sHomeNo = $("#<%=txt_HomeNoEdit.ClientID %>").val();
objUser.sAdd = $("#<%=txt_AddressEdit.ClientID %>").val();
objUser.sState = $("#<%=txt_StateEdit.ClientID %>").val();
objUser.sCity = $("#<%=txt_CityEdit.ClientID %>").val();
objUser.sPostcode = $("#<%=txt_PostCodeEdit.ClientID %>").val();
objUser.sEducationBg = $("#<%=txt_EducationBackgroundEdit.ClientID %>").val();
objUser.sEmail = $("#<%=txt_EmailEdit.ClientID %>").val();
$.ajax
({
type: "OST",
contentType: "application/json; charset=utf-8",
url: "../Ajax/LoadingData.asmx/UpdateStaffInfo",
data: JSON.stringify(objUser),
success: function(result) {
if (result.d == true) {
$("#divLoading").dialog('close');
$("#divModelStaff").dialog('close');
$("#divUpdating").dialog('close');
}
else {
var sHTML = "";
sHTML += "<center><br/ ><br/><img src='../Icon/Warning.gif' width='20px'><font size='3px'>Update failure!</font></center>";
$("#divModal").html(sHTML);
$("#divModal").dialog('open');
$("#divModal").dialog
({
bgiframe: true,
modal: true
});
}
},
dataType: "json"
});
},
"Cancel": function() {
$(this).dialog('close');
}
}
});
},
dataType: "json"
});
}
<--------------------ajax部分----------------------------------------------------------------------------->
<--------------------c#部分----------------------------------------------------------------------------->
[WebMethod]
public Staff LoadStaffInfo(string sUId)
{
UserBLL objUserBLL = new UserBLL(context);
User objUser = new User();
Staff objStaff = new Staff();
objUser = objUserBLL.GetUserByID(sUId);
objStaff.UserID = sUId;
objStaff.FirstName = objUser.FirstName;
objStaff.LastName = objUser.LastName;
objStaff.Gender = objUser.Gender;
objStaff.BirthDate = objUser.DOB.Value.ToShortDateString();
objStaff.DepartmentID = objUser.Department.DepartmentId;
objStaff.PositionID = objUser.Position.PositionId;
objStaff.HPNo = objUser.HpNum;
objStaff.Address = objUser.Address;
objStaff.Email = objUser.Email;
objStaff.State = objUser.State;
objStaff.City = objUser.City;
objStaff.PostCode = objUser.PostCode;
objStaff.HomeNo = objUser.HomeNo;
objStaff.EducationBackground = objUser.EducationBackground;
return objStaff;
}
[WebMethod]
public bool UpdateStaffInfo(string sUserId, string sFN, string sLN, string sGender, DateTime dtDOB, int iDepartmentId, int iPositionId, string sHPNo, string sHomeNo, string sAdd, string sState, string sCity, string sPostcode, string sEducationBg, string sEmail)
{
try
{
Department objDepartment = new Department();
Position objPosition = new Position();
User objUser = new User();
DepartmentBLL objDepartmentBLL = new DepartmentBLL(context);
PositionBLL objPositionBLL = new PositionBLL(context);
UserBLL objUserBLL = new UserBLL(context);
objDepartment = objDepartmentBLL.GetDepartmentByID(iDepartmentId);
objPosition = objPositionBLL.GetPositionByID(iPositionId);
objUser.UserId = sUserId;
objUser.FirstName = sFN;
objUser.LastName = sLN;
objUser.Gender = sGender; //rbl_GenderEdit.Items
objUser.Department = objDepartment;
objUser.Position = objPosition;
objUser.DOB = dtDOB;
objUser.HpNum = sHPNo;
objUser.Address = sAdd;
objUser.Email = sEmail;
objUser.State = sState;
objUser.City = sCity;
objUser.PostCode = sPostcode;
objUser.HomeNo = sHomeNo;
objUser.EducationBackground = sEducationBg;
return objUserBLL.UpdateUser(objUser);
}
catch (Exception ex)
{
return false;
}
}
<--------------------c#部分----------------------------------------------------------------------------->
我debugging之后那些没被抓出来的user资料被设为null |
|