公司员工非常多 ,经常需要更新个人通讯信息
比如 私人手机号码 短号 邮箱
步骤分为两部
第一步获取 员工信息 并以表单页面 形式 发给前端
在 UserController 下面 添加 一个获取 员工 的短号 邮箱 手机 这些
public ActionResult GetInfo( )
{
string errMsg;
errMsg = string.Empty;
// var cc= GetCurrentUser(_Request);
// Sys_User user = CommonOperate.GetEntity<Sys_User>(x => x.Id == userId && !x.IsDeleted && x.IsValid && x.IsActivated, string.Empty, out errMsg);
var code = Request.Cookies["UserName"].Value.ToString(); //_Request.Cookies["UserName"].ToString();
//通过Cookies 获取用户名
string officephone=string.Empty;
string mobile = string.Empty;
string shortcode = string.Empty;
string email = string.Empty;
var emp = CommonOperate.GetEntity<OrgM_Emp>(x => x.Code==code,string.Empty ,out errMsg);
if (emp == null)
{
ViewBag.error = "您的账号非员工账户,只能修改密码";
return RedirectToAction("error");
}
if (emp.OfficePhone == null)
{
officephone = string.Empty;
}
else
{
officephone = emp.OfficePhone.ToString();
}
if (emp.Mobile == null)
{
mobile= string.Empty;
}
else
{
mobile = emp.Mobile.ToString();
}
if (emp.ShortCode == null)
{
shortcode = string.Empty;
}
else
{
shortcode = emp.ShortCode.ToString();
}
if (emp.Email == null)
{
email = string.Empty;
}
else
{
email = emp.Email.ToString();
}
ViewBag.data = emp;
return View();
}
第 二步 在UserController 下 添加一次 一个 处理 前端 提交过来的信息
public JsonResult ChangeInfo()
{
string code1 = Request[“Code”].ObjToStr();
string email1= Request[“Email”].ObjToStr();
string Mobile1 = Request[“Mobile”].ObjToStr();
string ShortCode1 = Request[“ShortCode”].ObjToStr();
string OfficePhone1 = Request[“OfficePhone”].ObjToStr();
string errMsg = string.Empty;
var rst = CommonOperate.UpdateRecordsByExpression<OrgM_Emp>(new { OfficePhone = OfficePhone1 ,email=email1, Mobile= Mobile1, ShortCode=ShortCode1 },p=>p.Code==code1,out errMsg);
if (rst)
{
return Json(new ReturnResult() { Success = true, Message = "更新失败!" });
}
else {
return Json(new ReturnResult() { Success = string.IsNullOrEmpty(errMsg), Message = errMsg });
}
}