public bool UpdateManager(WebDomain.Model.Manager model) { if (string.IsNullOrEmpty(model.Name)) { throw new MException(MExceptionCode.BusinessError, "名称不能为空!"); } using (var dbconn = Pub.GetConn()) { if (!string.IsNullOrEmpty(model.LoginName)) { if (managerdal.ExistLoginName(dbconn, model.LoginName, model.ManagerId) > 0) { throw new MException(MExceptionCode.BusinessError, "登录名已存在!"); } } dbconn.BeginTransaction(); try { int r = managerdal.UpdateManager(dbconn, model); if (r <= 0) { throw new MException(MExceptionCode.BusinessError, "更新失败"); } dbconn.Commit(); //添加操作日志 new OperationLogBll().AddLog(new WebDomain.Model.OperationLog { Module = "员工管理", OperationName = Utils.CurrUserName(), OperationContent = "修改" + model.LoginName + "的信息", OperationTitle = "修改信息", Createtime = DateTime.Now }); return(true); } catch (Exception ex) { dbconn.Rollback(); throw ex; } } }
public Model.Manager AddManager(WebDomain.Model.Manager model) { if (string.IsNullOrEmpty(model.Name)) { throw new MException(MExceptionCode.BusinessError, "名称不能为空!"); } using (var dbconn = Pub.GetConn()) { if (!string.IsNullOrEmpty(model.LoginName)) { if (managerdal.ExistLoginName(dbconn, model.LoginName, 0) > 0) { throw new MException(MExceptionCode.BusinessError, "登录名已存在!"); } } dbconn.BeginTransaction(); try { model.LoginPwd = RLib.Utils.Security.MakeMD5((model.LoginPwd ?? "000000").Trim()); model = managerdal.AddManager(dbconn, model); dbconn.Commit(); //添加操作日志 new OperationLogBll().AddLog(new WebDomain.Model.OperationLog { Module = "员工管理", OperationName = Utils.CurrUserName(), OperationContent = "新增" + model.LoginName + "的信息", OperationTitle = "新增信息", Createtime = DateTime.Now }); return(model); } catch (Exception ex) { dbconn.Rollback(); throw ex; } } }