public void SetDelgate(string itcode, string delegateItcode) { User user = UserDa.GetUserByItCode(itcode); if (user == null) { throw new BusinessObjectLogicException("Invalid input!"); } if (String.IsNullOrEmpty(delegateItcode)) { delegateItcode = itcode; // 处理输入 } if (user.DelegateUser == delegateItcode) { return; // 无实际操作 } if (itcode != delegateItcode) { User delegateUser = UserDa.GetUserByItCode(delegateItcode); // 验证输入 if (delegateUser == null) { throw new BusinessObjectLogicException("Invalid delegate user!"); } } user.DelegateUser = delegateItcode; string title = null; string body = null; string toUser = null; string ccUsers = null; string domain = "@" + Utils.SysDomain(); if (user.ItCode == delegateItcode) { // 取消授权 title = "TQMP Authorization notice"; body = "The authorization from " + user.ItCode + " is canceled."; toUser = delegateItcode + domain; } else { // 设置授权 title = "TQMP Authorization notice"; body = "The approval operation is authorized to " + delegateItcode + "."; toUser = delegateItcode + domain; } UserDa.UpdateUserDelegate(itcode, delegateItcode); new Mail.MailBl().SendMail(toUser, ccUsers, title, body, System.Net.Mail.MailPriority.Normal, null); }