예제 #1
0
        public JsonResult TransferSingleProcess(int newGroupId, int clientId, string ismobile)
        {
            Result result = new Result();
            Client client = db.Clients.Find(clientId);
            if (client.GroupId != newGroupId)
            {
                ClientTransfer ct = new ClientTransfer
                {
                    ClientId = clientId,
                    InGroup = newGroupId,
                    OutGroup = client.GroupId,
                    Person = UserInfo.CurUser.Id,
                    TransferDate = DateTime.Today
                };
                db.ClientTransfers.Add(ct);
                client.GroupId = newGroupId;
                db.SaveChanges();
                string check = Client.StateUpdate(client.Id, DateTime.Today);
                Utilities.AddLog(db, clientId, Client.LogClass, "客户转移",
                    string.Format("从{0}转移到{1} {2}", DepartmentBLL.GetNameById(ct.OutGroup),
                        DepartmentBLL.GetNameById(newGroupId), check));

            }
            else
            {
                result.success = false;
                result.obj = string.Format("此客户已在{0}中,不需要转移", DepartmentBLL.GetNameById(client.GroupId));
                return Json(result);
            }

            db.SaveChanges();
            result.success = true;
            result.obj = string.Format("转移客户成功");

            return Json(result);
        }
예제 #2
0
        public JsonResult TransferBatch(string selectedIds, int newGroupId)
        {
            Result result = new Result();
            int count = 0;
            string[] strs = selectedIds.Split(',');
            using (
                TransactionScope tran = new TransactionScope(TransactionScopeOption.RequiresNew, new TimeSpan(0, 5, 0)))
            {
                foreach (string s in strs)
                {
                    int clientId;
                    if (int.TryParse(s, out clientId))
                    {
                        Client client = db.Clients.Find(clientId);
                        if (client.GroupId != newGroupId)
                        {
                            ClientTransfer ct = new ClientTransfer
                            {
                                ClientId = clientId,
                                InGroup = newGroupId,
                                OutGroup = client.GroupId,
                                Person = UserInfo.CurUser.Id,
                                TransferDate = DateTime.Today
                            };
                            db.ClientTransfers.Add(ct);
                            client.GroupId = newGroupId;
                            db.SaveChanges();
                            string check = Client.StateUpdate(client.Id, DateTime.Today);
                            Utilities.AddLog(db, clientId, Client.LogClass, "客户转移",
                                string.Format("从{0}转移到{1} {2}", DepartmentBLL.GetNameById(ct.OutGroup),
                                    DepartmentBLL.GetNameById(newGroupId), check));
                            //client.StateDate = DateTime.Today;
                            count++;
                        }
                    }
                }
                db.SaveChanges();
                tran.Complete();
                result.success = true;
                result.obj = string.Format("已转移了{0}个客户", count);
            }

            return Json(result);
        }