Ejemplo n.º 1
0
 /// <summary>
 /// 添加系统用户
 /// </summary>
 /// <param name="loginKey">登录凭证</param>
 /// <param name="err">错误信息</param>
 /// <param name="inEnt">实体类</param>
 /// <returns>添加系统用户</returns>
 public object User_Add(string loginKey, ref ProInterface.ErrorInfo err, ProInterface.Models.USER inEnt)
 {
     if (!GlobalFun.UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod()))
     {
         return(null);
     }
     using (DBEntities db = new DBEntities())
     {
         fa_user reEnt = Fun.ClassToCopy <ProInterface.Models.USER, fa_user>(inEnt);
         reEnt = db.fa_user.Add(reEnt);
         try
         {
             db.SaveChanges();
             GlobalFun.UserWriteLog(loginKey, MethodBase.GetCurrentMethod(), StatusType.UserLogType.Add);
             return(reEnt.ID);
         }
         catch (Exception e)
         {
             err.IsError = true;
             err.Message = e.Message;
             err.Excep   = e;
             return(null);
         }
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 修改系统用户
        /// </summary>
        /// <param name="loginKey">登录凭证</param>
        /// <param name="err">错误信息</param>
        /// <param name="inEnt">实体类</param>
        /// <returns>修改系统用户</returns>
        public bool User_Edit(string loginKey, ref ProInterface.ErrorInfo err, ProInterface.Models.USER inEnt)
        {
            if (!GlobalFun.UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod()))
            {
                return(false);
            }
            using (DBEntities db = new DBEntities())
            {
                try
                {
                    var ent = db.fa_user.SingleOrDefault(a => a.ID == inEnt.ID);
                    ent = Fun.ClassToCopy <ProInterface.Models.USER, fa_user>(inEnt, ent);

                    db.SaveChanges();
                    GlobalFun.UserWriteLog(loginKey, MethodBase.GetCurrentMethod(), StatusType.UserLogType.Edit);
                    return(true);
                }
                catch (Exception e)
                {
                    err.IsError = true;
                    err.Message = e.Message;
                    err.Excep   = e;
                    return(false);
                }
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 查询一条
 /// </summary>
 /// <param name="loginKey">登录凭证</param>
 /// <param name="err">错误信息</param>
 /// <param name="keyId">主键ID</param>
 /// <returns>查询一条</returns>
 public ProInterface.Models.USER User_SingleId(string loginKey, ref ProInterface.ErrorInfo err, int keyId)
 {
     if (!GlobalFun.UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod()))
     {
         return(null);
     }
     using (DBEntities db = new DBEntities())
     {
         var ent   = db.fa_user.SingleOrDefault(x => x.ID == keyId);
         var reEnt = new ProInterface.Models.USER();
         if (ent != null)
         {
             reEnt = Fun.ClassToCopy <fa_user, ProInterface.Models.USER>(ent);
         }
         return(reEnt);
     }
 }