Example #1
0
        public ActionResult AuditJoinClubA(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction("AuditJoinClub"));
            }
            ApplyAudit apply = db.ApplyAudits.Find(id);

            if (apply == null)
            {
                return(HttpNotFound());
            }
            if (apply.Type.Id != (int)SQType.加入社团)
            {
                return(RedirectToAction("AuditJoinClub"));
            }
            AuditJoinClubModel model = new AuditJoinClubModel()
            {
                ClubName  = apply.Club.Name,
                UserInfo  = apply.ApplyUser,
                ApplyDesc = apply.ApplicationDesc,
                ApplyFile = apply.ApplicationFiled,
                ApplyDate = apply.ApplyDate?.ToString(),
                AuditDate = apply.AuditDate?.ToString(),
                AuditId   = (int)id,
                AuditTime = (int)apply.AuditTimes,
                State     = apply.CheckState == null ? "未知" : Enum.GetName(typeof(EnumAuditState), apply.CheckState)
            };

            return(View(model));
        }
Example #2
0
        public ActionResult ApplyClubSubmit([Bind(Include = "ClubId,ApplyDesc,ApplyFile")] ApplyClubSubModel model)
        {
            try
            {
                ClubNumber club = db.ClubNumbers.Find(model.ClubId);
                if (string.IsNullOrWhiteSpace(model.ApplyFile))
                {
                    ModelState.AddModelError("", "申请任务未上传审批文件!");
                    return(View(model));
                }
                if (club.User.UserId != User.Identity.Name)
                {
                    ModelState.AddModelError("", "非用户" + User.Identity.Name + "创建的申请不能由用户" + User.Identity.Name + "提交!");
                    return(View(model));
                }
                if (club.State != (int)EnumState.待提交)
                {
                    ModelState.AddModelError("", "请求状态错误不允许提交审批");
                    return(View(model));
                }
                ApplyAudit apply = new ApplyAudit()
                {
                    Type             = db.ApplyTypes.Find((int)SQType.注册社团),
                    ApplicationDesc  = model.ApplyDesc,
                    ApplicationFiled = model.ApplyFile,
                    ApplyUser        = club.User,
                    Club             = club,
                    ApplyDate        = DateTime.Now,
                    CheckState       = (int)EnumAuditState.创建,
                    AuditTimes       = 0
                };
                db.ApplyAudits.Add(apply);
                db.SaveChanges();

                AuditDetail audit = new AuditDetail()
                {
                    ApplyId    = apply.Id,
                    CheckState = (int)EnumAuditState.创建,
                    AuditUser  = club.User,
                    AuditDate  = DateTime.Now
                };
                db.AuditDetails.Add(audit);

                club.State   = (int)EnumState.待审批;
                club.AuditID = apply.Id;
                if (string.IsNullOrEmpty(club.HeadImg))
                {
                    club.HeadImg = "Content/images/head5.jpg";//设置社团默认头像图片
                }
                db.Entry(club).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("MyClubs", new { Msg = "社团编号[" + club.ClubId + "]一个申请已提交,牢记并使用申请任务凭证[" + apply.Id + "]查看申请进度" }));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(View(model));
            }
        }
Example #3
0
        public ActionResult AuditClubA(int?id)
        {
            if (id == null)
            {
                Session["Error"] = "未找到指定的社团申请";
                return(RedirectToAction("Error404", "Home"));
            }
            ApplyAudit AppA = db.ApplyAudits.Find(id);

            if (AppA == null)
            {
                Session["Error"] = "未找到指定的社团申请" + id;
                return(RedirectToAction("Error404", "Home"));
            }
            ClubNumber club = AppA.Club;

            if (club == null)
            {
                Session["Error"] = "未从申请任务[" + id + "]中发现社团信息";
                return(RedirectToAction("Error404", "Home"));
            }
            ApplyClubSubModel model = new ApplyClubSubModel()
            {
                ClubId     = club.ClubId,
                Type       = club.Type.Name,
                Name       = club.Name,
                HeadImg    = club.HeadImg,
                ShortDesc  = club.ShortDesc,
                Desc       = club.Desc,
                State      = Enum.GetName(typeof(EnumState), club.State),
                CreateDate = club.CreateDate == null ? "未知" : club.CreateDate.ToString(),
                User       = club.User.UserName,
                ApplyDesc  = AppA.ApplicationDesc,
                ApplyFile  = AppA.ApplicationFiled,
                AuditDate  = AppA.AuditDate == null ? "未知" : AppA.AuditDate.ToString(),
                AuditTime  = AppA.AuditTimes ?? 0,
                AuditId    = AppA.Id
            };

            return(View(model));
        }
Example #4
0
        public ActionResult AuditActA(string id)
        {
            if (id == null || (int.TryParse(id, out int intaid) == false))
            {
                return(RedirectToAction("Manage"));
            }
            Activities act = db.Activities.Where(a => a.AuditID == intaid).FirstOrDefault();

            if (act == null)
            {
                Session["Error"] = "未发现活动" + id;
                return(RedirectToAction("Error404", "Home"));
            }
            if (act.User.UserId != User.Identity.Name)
            {
                Session["Error"] = "访问被拒绝!编号为" + id + "的活动非当前登陆用户创建";
                return(RedirectToAction("Error404", "Home"));
            }
            ApplyAudit     AppA  = db.ApplyAudits.Find(intaid);
            ActiveSubModel model = new ActiveSubModel()
            {
                Id        = act.Id,
                Type      = act.Type.ToString(),
                State     = Enum.GetName(typeof(ActiveState), act.State),
                Title1    = act.Title1,
                Title2    = act.Title2,
                Content   = act.Content,
                Area      = act.Area == null ? act.Area0 : act.Area.Name,
                Time1     = act.Time1.ToString(),
                Time2     = act.Time2.ToString(),
                MaxUser   = act.MaxUser == null ? "无限制" : act.MaxUser.ToString(),
                Labels    = act.Label?.Split(',').ToList(),
                ApplyDesc = AppA.ApplicationDesc,
                ApplyFile = AppA.ApplicationFiled,
                AuditDate = AppA.AuditDate == null ? "未知" : AppA.AuditDate.ToString(),
                AuditTime = AppA.AuditTimes ?? 0,
                AuditId   = AppA.Id
            };

            return(View(model));
        }
Example #5
0
        public ActionResult ApplyClubInfo(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, "未找到指定的社团申请"));
            }
            ApplyAudit AppA = db.ApplyAudits.Find(id);

            if (AppA == null)
            {
                return(HttpNotFound("未找到指定的社团申请"));
            }
            if (AppA.CheckState == (int)EnumAuditState.通过 && AppA.ApplyUser.UserId == User.Identity.Name)
            {
                ClubNumber model = new ClubNumber();
                model = AppA.Club;
                return(View(model));
            }
            else
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
        }
Example #6
0
        public int AuditFun(int id, EnumAuditState state, string AuditDesc = "")
        {
            ApplyAudit AppA = db.ApplyAudits.Find(id);

            if (AppA == null)
            {
                return(0);
            }
            else if (AppA.CheckState != (int)EnumAuditState.创建)
            {
                return(0);
            }
            //ClubNumber club = AppA.Club;
            if (AppA.Type == null)
            {
                return(0);
            }
            AuditDetail audit = new AuditDetail()
            {
                ApplyId    = AppA.Id,
                CheckState = (int)state,
                AuditUser  = db.UserNumbers.Find(User.Identity.Name),
                AuditDesc  = AuditDesc,
                AuditDate  = DateTime.Now
            };

            //AuditDetail audit1 = db.AuditDetails.Where(a => a.ApplyId == AppA.Id).OrderByDescending(a => a.AuditDate).FirstOrDefault();
            //if (audit1 != null)
            //{
            //    audit.FromUser = audit1.AuditUser;
            //}
            if (state == EnumAuditState.通过)
            {
                AppA.AuditTimes += 1;
                AppA.AuditDate   = DateTime.Now;
                if (AppA.AuditTimes > 2)
                {
                    AppA.CheckState = (int)state;
                }
                db.Entry(AppA).State = System.Data.Entity.EntityState.Modified;
                db.AuditDetails.Add(audit);
                db.SaveChanges();
                if (AppA.AuditTimes > 2)
                {
                    return(2);
                }
                return(1);
            }
            else if (state == EnumAuditState.拒绝)
            {
                AppA.AuditTimes += 1;

                AppA.CheckState      = (int)state;
                AppA.AuditDate       = DateTime.Now;
                db.Entry(AppA).State = System.Data.Entity.EntityState.Modified;
                db.AuditDetails.Add(audit);
                db.SaveChanges();
                return(1);
            }
            else
            {
                return(0);
            }
        }
Example #7
0
        public ActionResult Submit([Bind(Include = "Id,ApplyDesc,ApplyFile")] ActiveSubModel model)
        {
            Activities act = db.Activities.Find(model.Id);

            if (act == null)
            {
                Session["Error"] = "未发现活动" + model.Id;
                return(RedirectToAction("Error404", "Home"));
            }
            ActiveSubModel model1 = new ActiveSubModel()
            {
                Id      = act.Id,
                Type    = act.Type.ToString(),
                State   = Enum.GetName(typeof(ActiveState), act.State),
                Title1  = act.Title1,
                Title2  = act.Title2,
                Content = act.Content,
                Area    = act.Area == null ? act.Area0 : act.Area.Name,
                Time1   = act.Time1.ToString(),
                Time2   = act.Time2.ToString(),
                MaxUser = act.MaxUser == null ? "无限制" : act.MaxUser.ToString(),
                Labels  = act.Label?.Split(',').ToList()
            };

            try
            {
                if (string.IsNullOrWhiteSpace(model.ApplyFile))
                {
                    ModelState.AddModelError("", "申请任务未上传审批文件!");
                    return(View(model1));
                }
                if (act.User.UserId != User.Identity.Name)
                {
                    ModelState.AddModelError("", "非用户" + User.Identity.Name + "创建的活动不能由用户" + User.Identity.Name + "提交!");
                    return(View(model1));
                }
                if (act.State != (int)ActiveState.待提交)
                {
                    ModelState.AddModelError("", "请求状态错误不允许提交审批");
                    return(View(model1));
                }
                ApplyType type = db.ApplyTypes.Find((int)SQType.创建活动);
                if (type == null || type.Enable != 1)
                {
                    ModelState.AddModelError("", "活动创建申请通道未启用,请联系管理员");
                    return(View(model1));
                }

                ApplyAudit apply = new ApplyAudit()
                {
                    Type             = db.ApplyTypes.Find((int)SQType.创建活动),
                    ApplicationDesc  = model.ApplyDesc,
                    ApplicationFiled = model.ApplyFile,
                    ApplyUser        = act.User,
                    Club             = act.Club,
                    ApplyDate        = DateTime.Now,
                    CheckState       = (int)EnumAuditState.创建,
                    AuditTimes       = 0
                };
                db.ApplyAudits.Add(apply);
                db.SaveChanges();

                AuditDetail audit = new AuditDetail()
                {
                    ApplyId    = apply.Id,
                    CheckState = (int)EnumAuditState.创建,
                    AuditUser  = act.User,
                    AuditDate  = DateTime.Now
                };
                db.AuditDetails.Add(audit);

                act.State   = (int)ActiveState.待审批;
                act.AuditID = apply.Id;

                db.Entry(act).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Manage", "Clubs", new { cid = act.Club.ClubId }));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(View(model1));
            }
        }
Example #8
0
        public bool AuditJoinClubFun(int id, EnumAuditState state, string AuditDesc = "")
        {
            ApplyAudit AppA = db.ApplyAudits.Find(id);

            if (AppA == null)
            {
                return(false);
            }
            else if (AppA.CheckState != (int)EnumAuditState.创建)
            {
                return(false);
            }
            UserClubs uc = db.UserClubs.Where(u => u.AuditID == id).FirstOrDefault();

            if (AppA.Type == null)
            {
                return(false);
            }
            if (uc == null || uc.State != (int)EnumState.待审批)
            {
                return(false);
            }
            AuditDetail audit = new AuditDetail()
            {
                ApplyId    = AppA.Id,
                CheckState = (int)state,
                AuditUser  = db.UserNumbers.Find(User.Identity.Name),
                AuditDesc  = AuditDesc,
                AuditDate  = DateTime.Now
            };

            //AuditDetail audit1 = db.AuditDetails.Where(a => a.ApplyId == AppA.Id).OrderByDescending(a => a.AuditDate).FirstOrDefault();
            //if (audit1 != null)
            //{
            //    audit.FromUser = audit1.AuditUser;
            //}
            if (state == EnumAuditState.通过)
            {
                AppA.AuditTimes += 1;
                if (AppA.AuditTimes > 2)
                {
                    AppA.CheckState    = (int)state;
                    uc.State           = (int)EnumState.正常;
                    uc.CreateDate      = DateTime.Now;
                    uc.Status          = (int)UCStatus.会员;
                    db.Entry(uc).State = System.Data.Entity.EntityState.Modified;
                }
                AppA.AuditDate       = DateTime.Now;
                db.Entry(AppA).State = System.Data.Entity.EntityState.Modified;
                db.AuditDetails.Add(audit);
                db.SaveChanges();
                return(true);
            }
            else if (state == EnumAuditState.拒绝)
            {
                AppA.AuditTimes += 1;

                AppA.CheckState = (int)state;
                AppA.AuditDate  = DateTime.Now;

                db.Entry(uc).State   = System.Data.Entity.EntityState.Deleted;
                db.Entry(AppA).State = System.Data.Entity.EntityState.Modified;
                db.AuditDetails.Add(audit);
                db.SaveChanges();
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #9
0
        public ActionResult JoinClub([Bind(Include = "ClubId,ApplyDesc,ApplyFile")] JoinClubSubModel model)
        {
            try
            {
                ClubNumber club = db.ClubNumbers.Find(model.ClubId);
                UserNumber me   = db.UserNumbers.Find(User.Identity.Name);
                if (string.IsNullOrWhiteSpace(model.ApplyFile))
                {
                    ModelState.AddModelError("", "申请任务未上传审批文件!");
                    return(View(model));
                }
                if (db.UserClubs.Where(uc => uc.Club.ClubId == model.ClubId && uc.User.UserId == User.Identity.Name && uc.State > 0 && uc.State < 5).Any())
                {
                    ModelState.AddModelError("", "你已经是该社团成员或已申请加入该社团,不允许重复申请加入");
                    return(View(model));
                }
                if (club.State != (int)EnumState.正常 && club.State != (int)EnumState.待提交)
                {
                    string state = club.State == null ? "未知" : Enum.GetName(typeof(EnumState), club.State);
                    ModelState.AddModelError("", "社团" + club.ClubId + "状态为:" + state + " 不允许申请加入");
                    return(View(model));
                }
                ApplyAudit apply = new ApplyAudit()
                {
                    Type             = db.ApplyTypes.Find((int)SQType.加入社团),
                    ApplicationDesc  = model.ApplyDesc,
                    ApplicationFiled = model.ApplyFile,
                    ApplyUser        = me,
                    Club             = club,
                    ApplyDate        = DateTime.Now,
                    CheckState       = (int)EnumAuditState.创建,
                    AuditTimes       = 0
                };
                db.ApplyAudits.Add(apply);
                db.SaveChanges();

                AuditDetail audit = new AuditDetail()
                {
                    ApplyId    = apply.Id,
                    CheckState = (int)EnumAuditState.创建,
                    AuditUser  = me,
                    AuditDate  = DateTime.Now
                };
                db.AuditDetails.Add(audit);

                UserClubs newuserClubs = new UserClubs()
                {
                    User       = me,
                    Club       = club,
                    State      = (int)EnumState.待审批,
                    CreateDate = DateTime.Now,
                    Status     = (int)UCStatus.申请中,
                    AuditID    = apply.Id
                };
                db.UserClubs.Add(newuserClubs);
                db.SaveChanges();
                return(RedirectToAction("MyClubs", new { Msg = "加入社团[" + club.ClubId + "]的一个申请已提交,牢记并使用申请任务凭证[" + apply.Id + "]查看申请进度" }));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(View(model));
            }
        }