Esempio n. 1
0
        public ActionResult ForumApply(FormCollection fc)
        {
            UserInfo userInfo = UserService.Get(User.Identity.Name);

            ViewBag.ForumGroupList = ForumService.GroupList();
            if (fc["forumGroups[]"] != null)
            {
                string[] forumGroupIds = fc["forumGroups[]"].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                List <ForumApplyUserInfo> modelList = new List <ForumApplyUserInfo>();
                ForumApplyUserInfo        model     = null;
                foreach (string id in forumGroupIds)
                {
                    int forumGroupId = Controleng.Common.TypeConverter.StrToInt(id, 0);
                    if (forumGroupId > 0)
                    {
                        model = new ForumApplyUserInfo()
                        {
                            UserId         = userInfo.Id,
                            UserName       = userInfo.UserName,
                            ForumGroupId   = forumGroupId,
                            ContactPerson  = fc["forumGroup_" + forumGroupId],
                            Status         = ForumApplyStatus.Applying,
                            CreateDateTime = DateTime.Now
                        };
                        modelList.Add(model);
                    }
                }
                ForumApplyUserService.Applying(modelList, userInfo.Id);

                ViewBag.Msg = "感谢您提交申请,我们会尽快审核,审核通过后您就可以您申请的事业部论坛浏览、发帖。 ";
            }
            ViewBag.ApplyList = ForumApplyUserService.ListByUserId(userInfo.Id);

            return(View(userInfo));
        }
Esempio n. 2
0
        //public static void Applying(List<ForumApplyUserInfo> modelList) {
        //    string strSQL = "INSERT INTO ForumApplyUsers(UserId,UserName,ForumGroupId,ContactPerson,[Status],CreateDateTime) VALUES(@UserId,@UserName,@ForumGroupId,@ContactPerson,0,GETDATE());";
        //    SqlParameter[] parms = null;
        //    foreach(var model in modelList){
        //        parms  = ParameterHelper.GetClassSqlParameters(model);
        //        Goodspeed.Library.Data.SQLPlus.ExecuteNonQuery(CommandType.Text,strSQL,parms);
        //    }
        //}
        public static IPageOfList <ForumApplyUserInfo> List(int pageIndex, int pageSize)
        {
            FastPaging fp = new FastPaging();

            fp.PageIndex   = pageIndex;
            fp.PageSize    = pageSize;
            fp.Ascending   = false;
            fp.TableName   = "ForumApplyUsers";
            fp.TableReName = "p";
            fp.PrimaryKey  = "ID";
            fp.QueryFields = "p.*,g.Name AS ForumGroupName";
            fp.OverOrderBy = "p.CreateDateTime DESC";
            fp.JoinSQL     = "LEFT JOIN dbo.ForumGroups AS g ON p.ForumGroupId = g.Id";


            IList <ForumApplyUserInfo> list  = new List <ForumApplyUserInfo>();
            ForumApplyUserInfo         model = null;
            DataTable dt = Goodspeed.Library.Data.SQLPlus.ExecuteDataTable(CommandType.Text, fp.Build2005());

            if (dt != null && dt.Rows.Count > 0)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    model = Get(dr);
                    if (model != null)
                    {
                        list.Add(model);
                    }
                }
            }
            int count = CountForList();

            return(new PageOfList <ForumApplyUserInfo>(list, pageIndex, pageSize, count));
        }
Esempio n. 3
0
        public static int Add(ForumApplyUserInfo model)
        {
            string strSQL = "INSERT INTO ForumApplyUsers(UserId,UserName,ForumGroupId,ContactPerson,[Status],CreateDateTime) VALUES(@UserId,@UserName,@ForumGroupId,@ContactPerson,0,GETDATE());SELECT @@IDENTITY;";

            SqlParameter[] parms = ParameterHelper.GetClassSqlParameters(model);
            return(Convert.ToInt32(Goodspeed.Library.Data.SQLPlus.ExecuteScalar(CommandType.Text, strSQL, parms)));
        }
Esempio n. 4
0
        public static void Update(ForumApplyUserInfo model)
        {
            string strSQL = "UPDATE ForumApplyUsers SET ContactPerson = @ContactPerson,[Status] = @Status WHERE Id = @Id";

            SqlParameter[] parms =
            {
                new SqlParameter("Id",            SqlDbType.Int),
                new SqlParameter("ContactPerson", SqlDbType.NVarChar),
                new SqlParameter("Status",        SqlDbType.Int)
            };
            parms[0].Value = model.Id;
            parms[1].Value = model.ContactPerson;
            parms[2].Value = (int)model.Status;
            Goodspeed.Library.Data.SQLPlus.ExecuteNonQuery(CommandType.Text, strSQL, parms);
        }
Esempio n. 5
0
        public static ForumApplyUserInfo Get(DataRow dr)
        {
            ForumApplyUserInfo model = new ForumApplyUserInfo();

            if (dr == null)
            {
                return(model);
            }
            model.Id             = dr.Field <int>("Id");
            model.ContactPerson  = dr.Field <string>("ContactPerson");
            model.CreateDateTime = dr.Field <DateTime>("CreateDateTime");
            model.ForumGroupId   = dr.Field <int>("ForumGroupId");
            model.ForumGroupName = dr.Field <string>("ForumGroupName");
            model.Status         = (ForumApplyStatus)Enum.Parse(typeof(ForumApplyStatus), dr["Status"].ToString());
            model.UserId         = dr.Field <int>("UserId");
            model.UserName       = dr.Field <string>("UserName");
            return(model);
        }