You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
3.6 KiB
C#

11 months ago
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using DSWeb.Models;
using DSWeb.EntityDA;
namespace DSWeb.Accounts
{
public partial class Account : System.Web.UI.Page
{
private string strUserID;
protected void Page_Load(object sender, EventArgs e)
{
if (Session["USERID"] != null)
{
strUserID = Session["USERID"].ToString();
}
if (strUserID != null)
{
GetUserInfo();
if (h_post.Value.Trim().Equals("1"))
{
SavePersonalInfo();
GetUserInfo();
}
}
}
private void GetUserInfo()
{
UserDA userDA = new UserDA();
UserEntity userEntity = new UserEntity();
userEntity = userDA.GetUserAllByID(strUserID);
if (userEntity != null)
{
if (userEntity.Gid != null)
{
UserBaseInfoEntity userBaseInfoEntity = new UserBaseInfoEntity();
userBaseInfoEntity = userEntity.BaseInfo;
txt_englishname.Value = userEntity.UserName;
txt_fax.Value = userBaseInfoEntity.FaxNum;
txt_officenum.Value = userBaseInfoEntity.OfficePhone;
txt_mobile.Value = userBaseInfoEntity.MobilePhone;
txt_email1.Value = userBaseInfoEntity.EmailAddressPrimary;
txt_email2.Value = userBaseInfoEntity.EmailAddressSecond;
txt_msn.Value = userBaseInfoEntity.MSN;
txt_qq.Value = userBaseInfoEntity.QQ;
}
}
}
private void SavePersonalInfo()
{
UserDA userDA = new UserDA();
UserEntity userEntity = new UserEntity();
userEntity = userDA.GetUserAllByID(strUserID);
UserBaseInfoEntity userBaseInfoEntity = userEntity.BaseInfo;
userEntity.UserName = Request.Form["txt_englishname"].ToString().Trim();
if (userBaseInfoEntity != null)
{
userBaseInfoEntity.UserID = strUserID;
userBaseInfoEntity.OfficePhone = Request.Form["txt_officenum"].ToString().Trim();
userBaseInfoEntity.FaxNum = Request.Form["txt_fax"].ToString().Trim();
userBaseInfoEntity.EmailAddressPrimary = Request.Form["txt_email1"].ToString().Trim();
userBaseInfoEntity.EmailAddressSecond = Request.Form["txt_email2"].ToString().Trim();
userBaseInfoEntity.MSN = Request.Form["txt_msn"].ToString().Trim();
userBaseInfoEntity.QQ = Request.Form["txt_qq"].ToString();
userBaseInfoEntity.MobilePhone = Request.Form["txt_mobile"].ToString();
}
userEntity.BaseInfo = userBaseInfoEntity;
userEntity.ModifiedUserID = strUserID;
int iResult = userDA.UpdateUserInfo(userEntity);
if (iResult == 1)
{
h_post.Value = "2";
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('信息保存成功');refresh()</script>");
}
else
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "key2", "<script>alert('信息保存失败');refresh()</script>");
}
}
}
}