コード例 #1
0
 public static void InitDefault()
 {
     try
     {
         DAL.ManagerDal managerdal = new DAL.ManagerDal();
         using (var dbconn = Pub.GetConn())
         {
             var items = managerdal.GetManagerMiniTop(dbconn, 2);
             if (items.Count == 0)
             {
                 managerdal.AddManager(dbconn, new Model.Manager()
                 {
                     AllowLogin    = 1,
                     CreateTime    = DateTime.Now,
                     LastLoginTime = null,
                     LoginName     = "run",
                     LoginPwd      = "",
                     ManagerId     = 0,
                     Name          = "张三",
                     Remark        = "",
                     State         = 0,
                     SubName       = "zhangthree",
                     UpdateTime    = null
                 });
             }
         }
     }
     catch (Exception ex) { }
 }
コード例 #2
0
        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;
                }
            }
        }