/// <summary>
 /// 添加分组表
 /// </summary>
 /// <param name="memberGroupList"></param>
 /// <param name="memberGroupListViewModel"></param>
 /// <returns></returns>
 public ActionResult AddMemberGroupList(MemberGroupList memberGroupList, MemberGroupListViewModel memberGroupListViewModel)
 {
     if (ModelState.IsValid)
     {
         if (EFMemberGroup.AddMemberGroupList(memberGroupList))
         {
             SignList         signList         = EFSignInfo.signLists.Where(s => s.SignID == memberGroupList.SignID).FirstOrDefault();
             ContributionList contributionList = EFContribution.ContributionLists.Where(c => c.ContributionID == memberGroupList.ContributionID).FirstOrDefault();
             if (signList != null && contributionList != null)
             {
                 signList.MemberGroupID         = memberGroupList.MemberGroupID;
                 signList.ContributionID        = memberGroupList.ContributionID;
                 contributionList.MemberGroupID = memberGroupList.MemberGroupID;
                 contributionList.SignID        = memberGroupList.SignID;
             }
             else if (signList != null)
             {
                 signList.MemberGroupID = memberGroupList.MemberGroupID;
             }
             else if (contributionList != null)
             {
                 contributionList.MemberGroupID = memberGroupList.MemberGroupID;
             }
             EFSignInfo.UpdateSignList(signList);
             EFContribution.UpdateContributionList(contributionList);
             ViewBag.Success          = "添加成功!";
             memberGroupListViewModel = UpdateMemberGroupListViewModel(memberGroupListViewModel);
         }
         else
         {
             ViewBag.Fault = "已存在该表!";
         }
     }
     else
     {
         ViewBag.Fault = "请检查信息!";
     }
     if (memberGroupListViewModel.MemberGroupListsPageLists == null)
     {
         memberGroupListViewModel = UpdateMemberGroupListViewModel(memberGroupListViewModel);
     }
     return(PartialView("_MemberGroupList", memberGroupListViewModel));
 }
        /// <summary>
        /// 添加签到表
        /// </summary>
        /// <param name="signList"></param>
        /// <param name="signListViewModel"></param>
        /// <returns></returns>
        public ActionResult AddSignList(SignList signList, SignListViewModel signListViewModel, bool CreateContribution = false, bool CreateMemberGroup = false)
        {
            DealViewBag("SignList");
            bool f = true;

            if (ModelState.IsValid)
            {
                if (signList.EndDateTime < signList.StartDateTime)
                {
                    ViewBag.Fault = "结束时间不能小于开始时间!";
                    f             = false;
                }
                if (f && signList.Active == true)
                {
                    if (signList.StartDateTime < DateTime.Now && signList.EndDateTime < DateTime.Now)
                    {
                        ViewBag.Fault = "选定的时间起止范围请不要小于当前时间,除非把该表设为禁用状态 !";
                        f             = false;
                    }
                }
                if (f && !string.IsNullOrEmpty(signList.ContributionID))
                {
                    if (CreateContribution)
                    {
                        ViewBag.Fault = "不要同时选择和创建贡献表!";
                        f             = false;
                    }
                }
                else
                {
                    if (CreateContribution)
                    {
                        signList.ContributionID = signList.SignID;
                    }
                }
                if (f && !string.IsNullOrEmpty(signList.MemberGroupID))
                {
                    if (CreateMemberGroup)
                    {
                        ViewBag.Fault = "不要同时选择和创建分组表!";
                        f             = false;
                    }
                }
                else
                {
                    if (CreateMemberGroup)
                    {
                        signList.MemberGroupID = signList.SignID;
                    }
                }
                if (f)
                {
                    signList.CreateTime = DateTime.Now;
                    if (!string.IsNullOrEmpty(signList.ContributionID))
                    {
                        ContributionList contributionList = new ContributionList
                        {
                            ContributionID = signList.ContributionID,
                            Type           = signList.Type,
                            CreateDateTime = signList.CreateTime,
                        };
                        EFContribution.AddContributionList(contributionList);
                    }
                    if (!string.IsNullOrEmpty(signList.MemberGroupID))
                    {
                        MemberGroupList memberGroupList = new MemberGroupList
                        {
                            MemberGroupID  = signList.MemberGroupID,
                            Type           = signList.Type,
                            CreateDateTime = signList.CreateTime,
                        };
                        EFMemberGroup.AddMemberGroupList(memberGroupList);
                    }
                    if (EFSignInfo.AddSignList(signList))
                    {
                        if (signList.ContributionID != null)
                        {
                            ContributionList contributionListResult = EFContribution.ContributionList(signList.ContributionID);
                            ContributionList contributionList       = new ContributionList
                            {
                                ContributionID = contributionListResult.ContributionID,
                                Type           = contributionListResult.Type,
                                CreateDateTime = contributionListResult.CreateDateTime,
                                SignID         = signList.SignID,
                                MemberGroupID  = signList.MemberGroupID
                            };
                            EFContribution.UpdateContributionList(contributionList);
                        }
                        if (signList.MemberGroupID != null)
                        {
                            MemberGroupList memberGroupListResult = EFMemberGroup.MemberGroupList(signList.MemberGroupID);
                            MemberGroupList memberGroupList       = new MemberGroupList
                            {
                                MemberGroupID  = memberGroupListResult.MemberGroupID,
                                Type           = memberGroupListResult.Type,
                                CreateDateTime = memberGroupListResult.CreateDateTime,
                                SignID         = signList.SignID,
                                ContributionID = signList.ContributionID,
                            };
                            EFMemberGroup.UpdateMemberGroupList(memberGroupList);
                        }
                        signListViewModel = UpdateSignListViewModel(signListViewModel);
                        ViewBag.Success   = "添加签到表成功!";
                    }
                    else
                    {
                        ViewBag.Fault = "添加签到表失败!";
                        f             = false;
                    }
                }
            }
            else
            {
                ViewBag.Fault = "输入数据有误!";
            }
            if (!f)
            {
                signListViewModel = UpdateSignListViewModel(signListViewModel);
            }
            return(PartialView("_SignList", signListViewModel));
        }