コード例 #1
0
        public ActionResult SignUp(string username, string password, string email)
        {
            var provider = new UserLoginProvider();

            if (!provider.CheckUserName(username))
            {
                var entity = new SysUser();
                entity.UserName = username.Trim();
                entity.Password = DEncrypt.Md5(password.Trim());
                entity.Email    = email.Trim();
                //entity.Phone = phone.Trim();
                entity.RuleType = RuleTypeEnum.Customer.ToString();
                //entity.DisplayName = displayname.Trim();
                entity.CreateDate = DateTime.Now;
                entity.Status     = 1;
                var i = provider.InsertUser(entity);
                if (i > 0)
                {
                    var customer = new SysCustomerInfo();
                    customer.CustomerID = UserService.GetCustomerNo();
                    customer.UserId     = i;
                    customer.IsDelete   = false;
                    customer.CreateDate = DateTime.Now;
                    customer.Address    = "";
                    customer.CityId     = 0;
                    customer.QQNumber   = "";
                    customer.WebChatNo  = "";
                    customer.Phone      = "";
                    var x = UserService.InsertCustomer(customer);
                    if (x > 0)
                    {
                        var userData = entity.UserName + "|" + entity.DisplayName + "|" + entity.Email;
                        FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(
                            1,
                            entity.UserName,
                            DateTime.Now,
                            DateTime.Now.AddMinutes(30),
                            false,
                            userData);

                        string     encTicket = FormsAuthentication.Encrypt(authTicket);
                        HttpCookie faCookie  = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket);
                        Response.Cookies.Add(faCookie);
                    }
                }
            }
            else
            {
                ViewBag.message = "用户名已存在";
                return(View());
            }
            return(RedirectToAction("Index", "Home"));
        }
コード例 #2
0
        //特别注意,如果是可空类型,建议以如下方式使用:
        // var data = reader["field"];
        // entity.stringData = data == null ? data : data.ToString();
        //如需要手工映射,请反注释如下代码,并注意转换类型

        /*
         * /// <summary>
         * /// 手工映射,建议使用1.2.0.5版本以上的VisitDataReader
         * /// </summary>
         * /// <returns>结果</returns>
         * public SysCustomerInfo OrmByHand(string sql)
         * {
         *  try
         *  {
         *      return baseDao.VisitDataReader<SysCustomerInfo>(sql, (reader) =>
         *      {
         *          SysCustomerInfo entity = new SysCustomerInfo();
         *                              if(reader.Read())
         *                              {
         *              entity.Address = reader["Address"];
         *              entity.CityId = reader["CityId"];
         *              entity.CreateDate = reader["CreateDate"];
         *              entity.CustomerID = reader["CustomerID"];
         *              entity.Id = reader["Id"];
         *              entity.IsDelete = reader["IsDelete"];
         *              entity.Phone = reader["Phone"];
         *              entity.QQNumber = reader["QQNumber"];
         *              entity.UserId = reader["UserId"];
         *              entity.WebChatNo = reader["WebChatNo"];
         *          }
         *          return entity;
         *      });
         *
         *      //SysCustomerInfo entity = new SysCustomerInfo();
         *      //using(var reader = baseDao.SelectDataReader(sql))
         *      //{
         *                              //if(reader.Read())
         *                              //{
         *              //entity.Address = reader["Address"];
         *              //entity.CityId = reader["CityId"];
         *              //entity.CreateDate = reader["CreateDate"];
         *              //entity.CustomerID = reader["CustomerID"];
         *              //entity.Id = reader["Id"];
         *              //entity.IsDelete = reader["IsDelete"];
         *              //entity.Phone = reader["Phone"];
         *              //entity.QQNumber = reader["QQNumber"];
         *              //entity.UserId = reader["UserId"];
         *              //entity.WebChatNo = reader["WebChatNo"];
         *              //}
         *      //}
         *      //return entity;
         *  }
         *  catch (Exception ex)
         *  {
         *      throw new DalException("调用SysCustomerInfoDao时,访问OrmByHand时出错", ex);
         *  }
         * }
         */
        /// <summary>
        ///  插入SysCustomerInfo
        /// </summary>
        /// <param name="sysCustomerInfo">SysCustomerInfo实体对象</param>
        /// <returns>新增的主键,如果有多个主键则返回第一个主键</returns>
        public long Insert(SysCustomerInfo sysCustomerInfo)
        {
            try
            {
                Object result  = baseDao.Insert <SysCustomerInfo>(sysCustomerInfo);
                long   iReturn = Convert.ToInt64(result);
                return(iReturn);
            }
            catch (Exception ex)
            {
                throw new DalException("调用SysCustomerInfo时,访问Insert时出错", ex);
            }
        }
コード例 #3
0
        /// <summary>
        /// 删除SysCustomerInfo
        /// </summary>
        /// <param name="sysCustomerInfo">SysCustomerInfo实体对象</param>
        /// <returns>状态代码</returns>
        public int Delete(SysCustomerInfo sysCustomerInfo)
        {
            try
            {
                Object result  = baseDao.Delete <SysCustomerInfo>(sysCustomerInfo);
                int    iReturn = Convert.ToInt32(result);

                return(iReturn);
            }
            catch (Exception ex)
            {
                throw new DalException("调用SysCustomerInfo时,访问Delete时出错", ex);
            }
        }
コード例 #4
0
        /// <summary>
        ///  检索SysCustomerInfo,带翻页
        /// </summary>
        /// <param name="obj">SysCustomerInfo实体对象检索条件</param>
        /// <param name="pagesize">每页记录数</param>
        /// <param name="pageNo">页码</param>
        /// <returns>检索结果</returns>
        public IList <SysCustomerInfo> GetListByPage(SysCustomerInfo obj, int pagesize, int pageNo)
        {
            try
            {
                StringBuilder sbSql = new StringBuilder(200);

                sbSql.Append(@"select Address, CityId, CreateDate, CustomerID, Id, IsDelete, Phone, QQNumber, UserId, WebChatNo from SysCustomerInfo (nolock) ");
                sbSql.Append(" order by Id desc ");
                sbSql.Append(string.Format("OFFSET {0} ROWS FETCH NEXT {1} ROWS ONLY", (pageNo - 1) * pagesize, pagesize));
                IList <SysCustomerInfo> list = baseDao.SelectList <SysCustomerInfo>(sbSql.ToString());
                return(list);
            }
            catch (Exception ex)
            {
                throw new DalException("调用SysCustomerInfoDao时,访问GetListByPage时出错", ex);
            }
        }
コード例 #5
0
 public static int UpdateCustomer(SysCustomerInfo entity)
 {
     return(customerDao.Update(entity));
 }
コード例 #6
0
 public static long InsertCustomer(SysCustomerInfo entity)
 {
     return(customerDao.Insert(entity));
 }