应用程序范围的键值对

 

(1)登陆成功,根据登录信息,操作员的Id放到应用程序范围的键值对中。

new T_OperationLogDAL().Insert(op.Id,"登录成功");
Application.Current.Properties["OperatorId"]=op.Id;//应用程序范围的键值对

(2)CommonHelper中增加一个取得当前操作员的Id的方法:

public static Guid GetOperatorId()
{
return (Guid)Application.Current.Properties["OperatorId"];
}

(3)调用该方法就可以取得当前的操作员Id了

if (IsAddNew)
{
Employee employee = (Employee)gridEmployee.DataContext;
new EmployeeDAL().Insert(employee);
Guid operatorId = CommonHelper.GetOperatorId();
new T_OperationLogDAL().Insert(operatorId, "新增员工" + employee.Name);
}

posted @ 2015-07-29 15:40  Alfred.Xu  阅读(192)  评论(0编辑  收藏  举报