コード例 #1
0
        public ActionResult Create(string ismobile, FormCollection collection)
        {
            Card c = new Card();
            db.Cards.Add(c);

            TryUpdateModel(c, "", new string[] { }, new string[] { "" }, collection);
            var query = (from o in db.Cards where o.ClientId == c.ClientId && !o.CancelTime.HasValue select o).FirstOrDefault();
            if (query != null)
            {
                ModelState.AddModelError("", "该客户已有卡");
            }
            Client client = db.Clients.Find(c.ClientId);
            if (ModelState.IsValid)
            {
                if ((client.State != ClientStateEnum.办卡客户))
                {
                    client.State = ClientStateEnum.办卡客户;
                    client.StateDate = DateTime.Today;
                    Utilities.AddLog(db, client.Id, Client.LogClass, "转办卡客户", "");
                }
                ClientActivity invite = (from o in db.ClientActivities where o.PlanTime.HasValue && o.Type.Equals("办卡邀约") && o.ClientId == c.ClientId select o).ToList().Where(o => DateTime.Compare(o.PlanTime.Value.Date, DateTime.Today) == 0).FirstOrDefault();
                if (invite != null)
                {
                    if (!invite.ActualTime.HasValue)
                        invite.ActualTime = DateTime.Today;
                    invite.IsDone = true;
                }
                db.SaveChanges();
                if (!string.IsNullOrEmpty(ismobile))
                {
                    return Redirect("../../Client/View/" + c.ClientId.ToString());
                }
                return Redirect("~/Content/close.htm");
            }
            return View(c);
        }
コード例 #2
0
ファイル: CardController.cs プロジェクト: honghuamin/HanWen
        public ActionResult Edit(int id, int storeId, FormCollection collection)
        {
            if (!UserInfo.CurUser.HasRight("门店销售-会员维护")) return Redirect("~/content/AccessDeny.htm");
            //ToDo:要限定不同店间权限吗?
            Card s = db.Cards.Find(id);
            if (s == null)
            {
                s = new Card();
                s.StoreId= storeId;
                s.ActiveDate = DateTime.Today;

                db.Cards.Add(s);
                TryUpdateModel(s, "", new string[] { }, new string[] {}, collection);
            }else
            {
                TryUpdateModel(s, "", new string[] { }, new string[] {"Store", "CardId","CardCode","ActiveDate"}, collection);
            }

            if(string.IsNullOrEmpty(s.CardCode))ModelState.AddModelError("CardCode","卡号不能为空");
            if (ModelState.IsValid)
            {

                db.SaveChanges();
                if (id == 0)
                {
                    BLL.Utilities.AddLogAndSave(s.Id, Card.LogClass, "创建", "");
                    return Redirect("../View/" + s.Id);
                }
                else
                {
                    BLL.Utilities.AddLogAndSave(s.Id, Card.LogClass, "修改", "");
                    return  Redirect("~/content/close.htm");
                }

            }

            return View(s);
        }
コード例 #3
0
ファイル: CardController.cs プロジェクト: honghuamin/HanWen
 public ActionResult Edit(int id, int storeId)
 {
     if (!UserInfo.CurUser.HasRight("门店销售-会员维护")) return Redirect("~/content/AccessDeny.htm");
     Card s = db.Cards.Find(id);
     if (s == null)
     {
         s = new Card();
     }
     return View(s);
 }
コード例 #4
0
ファイル: ImportData.cs プロジェクト: honghuamin/HanWen
 private void ImportCustomer(SqlConnection conn)
 {
     using (TransactionScope transcope = new TransactionScope())
     {
         using (OUContext db = new OUContext())
         {
             db.Configuration.ValidateOnSaveEnabled = false;
             db.Configuration.AutoDetectChangesEnabled = false;
             List<customer> listCustomer = conn.Query<customer>(customer.sql).ToList();
             foreach (var cust in listCustomer)
             {
                 Card card = new Card();
                 card.StoreId = StoreId;
                 card.ActiveDate = cust.l_createtime;
                 card.Birthday = cust.l_birth;
                 card.CardCode = "旧"+cust.l_memnum;
                 card.OldCode = cust.l_memnum;
                 card.CardId = "旧"+cust.l_cardnum;
                 switch (cust.l_membergradeid)
                 {
                     case 1:
                         card.CardType = "普通卡";
                         break;
                     case 2:
                         card.CardType = "金卡";
                         break;
                     case 3:
                         card.CardType = "白金卡";
                         break;
                 }
                 string email = cust.l_email1;
                 if (string.IsNullOrEmpty(cust.l_email1))
                 {
                     email = cust.l_email2;
                 }
                 else if (string.IsNullOrEmpty(cust.l_email2) == false)
                 {
                     email += " " + cust.l_email2;
                 }
                 card.Email = email;
                 if (cust.l_sex == "女" || cust.l_sex == "F")
                 {
                     card.Gender = GenderEnum.女;
                 }
                 else
                 {
                     card.Gender = GenderEnum.男;
                 }
                 string tel = "";
                 if (!string.IsNullOrEmpty(cust.l_hometel))
                 {
                     tel = cust.l_hometel;
                 }
                 if (!string.IsNullOrEmpty(cust.l_officetel))
                 {
                     tel += " " + cust.l_officetel;
                 }
                 if (!string.IsNullOrEmpty(cust.l_othertel))
                 {
                     tel += " " + cust.l_othertel;
                 }
                 card.Mobile = cust.l_mobile;
                 card.Phone = tel;
                 card.Remark = cust.l_standby;
                 card.OldSpendTotal = Convert.ToDecimal(cust.l_spenttotal);
                 switch (cust.l_status)
                 {
                     case 1:
                         card.State = ClientState.正常;
                         break;
                     case 2:
                         card.State = ClientState.冻结;
                         break;
                     case 3:
                         card.State = ClientState.失效;
                         break;
                 }
                 string name = string.Format("{0} {1} {2} {3} {4}", cust.l_givenname, cust.l_surname,
                                             cust.l_mandaringivenname, cust.l_mandarinsurname,
                                             string.IsNullOrEmpty(cust.l_spousename)
                                             ?"": string.Format("({0})", cust.l_spousename)
                                                 );
                 card.UserName = name;
                 db.Cards.Add(card);
                 db.SaveChanges();
             }
         }
         transcope.Complete();
     }
     Console.WriteLine(DateTime.Now.ToLongTimeString());
 }
コード例 #5
0
 //此id为clientid
 public ActionResult Create(int id)
 {
     Card c = new Card() { ClientId = id };
     c.GroupId = (from o in UserInfo.CurUser.Departments where o.DepartmentType == "小组" select o.Id).FirstOrDefault();
     return View(c);
 }