コード例 #1
0
ファイル: AgentController.cs プロジェクト: 21ki/kuanmai
        public ActionResult EditCustomer(int customerId)
        {
            CustomerManagement customerMgr = new CustomerManagement(User.Identity.GetUserId <int>());
            List <BCustomer>   customers   = customerMgr.FindCustomers(User.Identity.GetUserId <int>(), customerId, out total);

            if (customers == null || customers.Count <= 0)
            {
                ViewBag.Message = string.Format("编号为{0}的客户不存在", customerId);
                return(View("Error"));
            }
            BCustomer           customer = customers[0];
            CreateCustomerModel model    = new CreateCustomerModel()
            {
                Amount         = customer.RemainingAmount,
                ContactAddress = customer.ContactAddress,
                ContactEmail   = customer.ContactEmail,
                ContactPeople  = customer.ContactPeople,
                ContactPhone   = customer.ContactPhone,
                CreditAmount   = customer.CreditAmount,
                Description    = customer.Description,
                Id             = customer.Id,
                Name           = customer.Name,
                OpenAccount    = customer.OpenId,
                OpenType       = customer.OpenType
            };
            List <DictionaryTemplate> types = StaticDictionary.GetOpenTypeList();

            ViewBag.OpenTypes = new SelectList(types, "Id", "Value");
            return(View("CreateCustomer", model));
        }
コード例 #2
0
ファイル: AgentController.cs プロジェクト: 21ki/kuanmai
        public ActionResult CreateCustomer()
        {
            CreateCustomerModel model = new CreateCustomerModel();

            model.Id = 0;
            List <DictionaryTemplate> types = StaticDictionary.GetOpenTypeList();

            ViewBag.OpenTypes = new SelectList(types, "Id", "Value");
            model.OpenType    = 1;
            return(View(model));
        }
コード例 #3
0
ファイル: AgentController.cs プロジェクト: 21ki/kuanmai
        public ActionResult SaveCustomer(CreateCustomerModel model)
        {
            if (ModelState.IsValid)
            {
                CustomerManagement customerMgr = new CustomerManagement(User.Identity.GetUserId <int>());
                BCustomer          customer    = new BCustomer()
                {
                    AgentId         = User.Identity.GetUserId <int>(),
                    ContactAddress  = model.ContactAddress,
                    ContactEmail    = model.ContactEmail,
                    ContactPeople   = model.ContactPeople,
                    ContactPhone    = model.ContactPhone,
                    CreatedTime     = DateTimeUtil.ConvertDateTimeToInt(DateTime.Now),
                    CreditAmount    = model.CreditAmount,
                    Description     = model.Description,
                    Id              = model.Id,
                    Name            = model.Name,
                    OpenId          = model.OpenAccount,
                    OpenType        = model.OpenType,
                    RemainingAmount = model.Amount
                };

                try
                {
                    if (customerMgr.SaveCustomer(customer))
                    {
                        return(RedirectToAction("Customers"));
                    }
                }catch (KMBitException ex)
                {
                    ViewBag.Message = ex.Message;
                }
            }
            List <DictionaryTemplate> types = StaticDictionary.GetOpenTypeList();

            ViewBag.OpenTypes = new SelectList(types, "Id", "Value");
            return(View("CreateCustomer", model));
        }