//根据ShopGroup,进行PersonShopGroupPBs的排班插入
 public void ShopGroupPB(ShopGroups ShopGroup, UserWorkDate WorkDate, Kf_DepartMent kf_DepartMent)
 {
     if (ShopGroup.WorkDayOrNight != DayOrNight.全天)
     {
         PersonShopGroupPBs personShopGroupPBs = new PersonShopGroupPBs();
         personShopGroupPBs.WorkDayOrNight = ShopGroup.WorkDayOrNight;
         personShopGroupPBs.UserWorkDate   = WorkDate;
         personShopGroupPBs.UpdateTime     = System.DateTime.Now.Date;
         personShopGroupPBs._ShopGroups    = ShopGroup;
         personShopGroupPBs._User          = this.getAvailableUser(ShopGroup, personShopGroupPBs.WorkDayOrNight, WorkDate);
         this.Save(personShopGroupPBs);
     }
     else
     {
         for (int t = 0; t < 2; t++)
         {
             PersonShopGroupPBs personShopGroupPBs = new PersonShopGroupPBs();
             if (t == 0)
             {
                 personShopGroupPBs.WorkDayOrNight = DayOrNight.白班;
             }
             else
             {
                 personShopGroupPBs.WorkDayOrNight = DayOrNight.晚班;
             }
             personShopGroupPBs.UserWorkDate = WorkDate;
             personShopGroupPBs.UpdateTime   = System.DateTime.Now.Date;
             personShopGroupPBs._ShopGroups  = ShopGroup;
             personShopGroupPBs._User        = this.getAvailableUser(ShopGroup, personShopGroupPBs.WorkDayOrNight, WorkDate);
             this.Save(personShopGroupPBs);
         }
     }
 }
Ejemplo n.º 2
0
 public ActionResult Add_ShopGroupDetail(ShopGroups gp, string[] ids)
 {
     if (ids != null && ids.Length > 0)
     {
         var listShopGroupDetail = this.shopGroupDetailRepo.GetAll()
                                   .Where(it => it._ShopGroup == gp);
         foreach (var ShopGroupDetail in listShopGroupDetail)
         {
             shopGroupDetailRepo.Delete(ShopGroupDetail);
         }
         string strContentShops = "";
         for (int i = 0; i < ids.Length; i++)
         {
             ShopGroupDetails gd = new ShopGroupDetails()
             {
                 //_Shop = new Shop { ID = ids[i].ToInt() },
                 _Shop      = this.shopRepo.GetByDatabaseID(ids[i].ToInt()),
                 _ShopGroup = gp,
                 UpdateTime = DateTime.Now
             };
             shopGroupDetailRepo.Save(gd);
             strContentShops = strContentShops + gd._Shop.Name.Trim() + " | ";
         }
         strContentShops = strContentShops.Substring(0, strContentShops.Trim().Length - 1);
         gp.UpdateTime   = System.DateTime.Now;
         gp.ContentShops = strContentShops;
         this.ShopGroupRepo.Update(gp);
         return(Json(new { state = true, message = "添加或修改成功, 请刷新显示" }));
     }
     else
     {
         return(Json(new { state = false, message = "请选择店铺" }));
     }
 }
Ejemplo n.º 3
0
        public ActionResult Add_ShopGroupDetail(string id)
        {
            ShopGroups shopGroup = this.ShopGroupRepo.GetByDatabaseID(Convert.ToInt32(id));
            //根据shopGroupID取出哪些店铺在shopGroupDetail里面,在前台显示的时候如果在里面的,那么默认为选中。
            List <ShopGroupDetails> listShopGroupDetails = this.shopGroupDetailRepo.GetAll()
                                                           .Where(it => it._ShopGroup == shopGroup)
                                                           .ToList();

            ViewData["listShopGroupDetails"] = listShopGroupDetails;
            ViewData["shopGroup"]            = shopGroup;
            var list = shopRepo.GetData(this.Users().DepartMent.ID);

            return(View(list));
        }
Ejemplo n.º 4
0
        public string checkPersonShopGroupValid(ShopGroups shopGroup)
        {
            string strResult = "";
            //坚持班组在班组客服表中有无数据,如果有数据,则返回有效,如果没有数据,返回班组没有客服
            //List<ShopGroups> listShopGroup = this.ShopGroupRepo.GetAll().ToList();
            int intCount = this.GetAll()
                           .Where(it => it._ShopGroups == shopGroup)
                           .Count();

            if (intCount == 0)
            {
                strResult = "班组" + shopGroup.ShopGroupName.Trim() + "没有客服,请检查后再排班!";
                return(strResult);
            }
            strResult = "班组客服有效";
            return(strResult);
        }
Ejemplo n.º 5
0
        public ActionResult AddShopGroup(int?id)
        {
            Kf_DepartMentRepository      kf_DepartRepo  = new Kf_DepartMentRepository();
            IEnumerable <SelectListItem> listDepartMent = kf_DepartRepo.GetData(this.Users().DepartMent.ID)
                                                          .Select(p => new SelectListItem
            {
                Text  = p.DepartMentName,
                Value = p.ID.ToString().Trim(),
            });

            ViewData["listDepartMent"] = listDepartMent;
            if (id != null)
            {
                ShopGroups shopGroup = this.ShopGroupRepo.GetByDatabaseID(id.Value);
                return(View(shopGroup));
            }
            return(View());
        }
        //根据排班的内容返回可以排班的人员
        private User getAvailableUser(ShopGroups ShopGroup, DayOrNight dayOrNight, UserWorkDate WorkDate)
        {
            //取出都是哪些人能做这个班组。
            //目前只安排了第一个值班的人员,接下来要考虑的问题:
            //(1)不安排连班,如果该人员已经值该天的白班了,那么该人员不安排晚班了。
            //(2)不安排重复的值班类型的班组,也就是如果值一个白班班组了,那么就不能再排其他班组的白班。如果已经值一个晚班的班组,那么也不能排其他晚班的班组了。
            //(3)休班的问题怎么解决?

            PersonShopGroupRepository PersonShopGroupRepo      = new PersonShopGroupRepository();
            List <PersonShopGroup>    localListPersonShopGroup = PersonShopGroupRepo.GetAll()
                                                                 .Where(it => it._ShopGroups == ShopGroup)
                                                                 .OrderBy(it => it._User.UserStateID)
                                                                 .ToList();

            User userTemp = new User();
            //找该日期的值班类型有无该人,如果有,那么就不排,排下一个人。
            Boolean find = false;

            for (int i = 0; i <= localListPersonShopGroup.Count - 1; i++)
            {
                //找该日期的值班有无该人,如果有,那么就不排,排下一个人。
                if (this.checkRepeatDayOrNight(localListPersonShopGroup.ElementAt(i)._User, WorkDate) == false)
                {
                    //  if (this.checkAllToday(localListPersonShopGroup.ElementAt(i)._User, personShopGroupPBs.UserWorkDate) == false)
                    //  {
                    userTemp = localListPersonShopGroup.ElementAt(i)._User;
                    find     = true;
                    return(userTemp);
                    //  }
                }
            }
            if (find == false)//没有找到这样的,就用第一个
            {
                //localListPersonShopGroup.ElementAt(i)._User;
                userTemp = localListPersonShopGroup.FirstOrDefault()._User;
            }
            return(userTemp);
        }
Ejemplo n.º 7
0
        public ActionResult AddShopGroup(string ShopGroupName, string WorkDayOrNight, string _Kf_DepartMent, int?id)
        {
            //Kf_DepartMentRepository kf_DepartRepo = new Kf_DepartMentRepository();
            //IEnumerable<SelectListItem> listDepartMent = kf_DepartRepo.GetData(this.Users().DepartMent.ID)
            //    .Select(p => new SelectListItem
            //    {
            //        Text = p.DepartMentName,
            //        Value = p.ID.ToString().Trim(),
            //    });
            //ViewData["listDepartMent"] = listDepartMent;
            if (ShopGroupName.IsNullOrEmpty())
            {
                return(Json(new { state = false, message = "请填写分组名称!" }));
            }
            if (WorkDayOrNight.IsNullOrEmpty())
            {
                return(Json(new { state = false, message = "请选择值班类型!" }));
            }
            if (_Kf_DepartMent.IsNullOrEmpty())
            {
                return(Json(new { state = false, message = "请选择部门!" }));
            }

            ShopGroups shopGroup = new ShopGroups();

            if (id != null && id.Value > 0)
            {
                shopGroup = this.ShopGroupRepo.GetByDatabaseID(id.Value);
            }

            try
            {
                //赋值
                shopGroup.ShopGroupName  = ShopGroupName;
                shopGroup.WorkDayOrNight = WorkDayOrNight.ToEnum <DayOrNight>();
                shopGroup._Kf_DepartMent = new Kf_DepartMent {
                    ID = _Kf_DepartMent.ToInt()
                };

                //保存
                if (id != null && id.Value > 0)
                {
                    shopGroup.UpdateTime = System.DateTime.Today;
                    ShopGroupRepo.Update(shopGroup);
                }
                else
                {
                    if (ShopGroupRepo.ExistShopGroupsName(shopGroup.ShopGroupName))
                    {
                        return(Json(new { state = false, message = "添加失败 店铺已存在!" }));
                    }
                    shopGroup.ContentShops = "无";
                    shopGroup.UpdateTime   = System.DateTime.Today;
                    ShopGroupRepo.Save(shopGroup);
                }

                //alertMessage = "操作成功!";
                //ViewData["alertMessage"] = alertMessage;
                //return RedirectToAction("ShopGroupIndex");
                return(Json(new { state = true, message = "操作成功!" }));
            }
            catch (RuleException ex)
            {
                throw new RuleException(ex.Message, ex);
            }
        }