示例#1
0
 /// <summary>
 /// 添加实体
 /// </summary>
 /// <param name="sysCompany"></param>
 /// <param name="sysUser"></param>
 public bool InsertEntities(TSysCompany sysCompany, TSysUser sysUser)
 {
     using (teaCRMDBContext db = new teaCRMDBContext())
     {
         if (db.Connection.State != ConnectionState.Open)
         {
             db.Connection.Open();
         }
         var tran = db.Connection.BeginTransaction();
         try
         {
             db.TSysCompanies.Insert(sysCompany);
             db.TSysUsers.Insert(sysUser);
             tran.Commit();
             return true;
         }
         catch (Exception ex)
         {
             tran.Rollback();
             LogHelper.Error("注册失败,",ex);
             return false;
         }
         finally
         {
             if (db.Connection.State != ConnectionState.Closed)
             {
                 db.Connection.Close();
             }
         }
     }
 }
示例#2
0
        /// <summary>
        /// 公司注册 2014-08-21 14:58:50 By 唐有炜
        /// </summary>
        /// <param name="httpContext">HttpContext</param>
        /// <param name="accountType">账号类型(email,phone)</param>
        /// <param name="userName">用户名</param>
        /// <param name="userPassword">密码</param>
        /// <returns>ResponseMessage</returns>
        public ResponseMessage Register(HttpContext httpContext, string accountType, string userName,
            string userPassword)
        {
            ResponseMessage rmsg = ValidateAccount("register", null, userName, userPassword);
            if (rmsg.Status)
            {
                //注册验证成功成功
                //随机编号
                var compNum = RandomHelper.GetComoanyNumber();
                TSysCompany sysCompany = new TSysCompany()
                {
                    CompNum = compNum
                };

                userPassword = DESEncrypt.Encrypt(userPassword);
                string userEmail = null;
                string userPhone = null;
                switch (accountType)
                {
                    case "email":
                        userEmail = userName;
                        break;
                    case "phone":
                        userPhone = userName;
                        break;
                    default:
                        break;
                }
                TSysUser sysUser = new TSysUser()
                {
                    CompNum = compNum,
                    UserLname = "admin", //默认公司超级管理员用户名是admin
                    UserPassword = userPassword,
                    UserEmail = userEmail,
                    UserPhone = userPhone,
                    RoleId = 1, //默认角色
                    DepId = 1 //默认部门
                };

                if (CompanyUserDao.InsertEntities(sysCompany, sysUser))
                {
                    rmsg.Status = true;
                    rmsg.Msg = "注册成功";
                }
                else
                {
                    rmsg.Status = false;
                    rmsg.Msg = "注册失败";
                }
            }

            //注册成功
            if (rmsg.Status)
            {
                //获取用户信息
                var compUser = GetVCompanyUserByAccountTypeAndUserName(accountType, userName);
                //书写SessionCookie
                WriteSessionCookie(httpContext, compUser, userName, userPassword);
            }

            return rmsg;
        }
示例#3
0
 /// <summary>
 /// 修改实体
 /// </summary>
 /// <param name="entity">实体对象</param>
 public bool UpadateEntity(TSysCompany entity)
 {
     using (teaCRMDBContext db=new teaCRMDBContext())
     {
        int rows= db.TSysCompanies.Update(entity);
        if (rows > 0)
         {
             return true;
         }
         else
         {
             return false;
         }
     }
 }