Example #1
0
        public ActionResult Create(CustomerViewModel model)
        {
            ServiceResult result = new ServiceResult();
            if (ModelState.IsValid)
            {
                try
                {
                    CustomerService.Create(model);
                    result.Message = "添加Customer成功!";
                    LogHelper.WriteLog("添加Customer成功");
                }
                catch (Exception ex)
                {
                    result.Message = Utilities.GetInnerMostException(ex);
                    result.AddServiceError(result.Message);
                    LogHelper.WriteLog("添加Customer错误", ex);
                }
            }
            else
            {
                result.Message = "请检查表单是否填写完整!";
                result.AddServiceError("请检查表单是否填写完整!");

            }

            return Json(result);
        }
Example #2
0
 public ActionResult Create(int ID)
 {
     var model = new CustomerViewModel()
     {
         CompanyID = ID
     };
     ViewBag.Data_JobID = Utilities.GetSelectListData(JobCateService.GetALL(), x => x.ID, x => x.CateName, true);
     return PartialView(model);
 }
Example #3
0
        public Customer Create(CustomerViewModel model)
        {
            Customer entity = new Customer();
            entity.Name = model.Name;
            entity.Address = model.Address;
            entity.AddTime = DateTime.Now;
            entity.AddUser = 227;
            entity.ReMark = model.ReMark;

            if (model.AddBirthDay)
            {
                entity.AddBirthDay = model.AddBirthDay;
                entity.IsLeap = model.IsLeap;
                if (entity.IsLeap)
                {
                    entity.BirthDay1 = Utilities.GetLunarStringOnlyMonthDay(model.BirthDay);
                }
                entity.BirthDay = model.BirthDay;
            }
            else
            {
                entity.BirthDay = Utilities.TimeZero;
            }
            entity.CompanyID = model.CompanyID;
            entity.Email = model.Email;
            entity.Favorite = model.Favorite;
            entity.JobID = model.JobID;
            entity.Jobs = model.Jobs;
            entity.LastTime = DateTime.Now;
            entity.LastUser = 227;
            entity.Mobile = model.Mobile;
            entity.Mobile1 = model.Mobile1;
            entity.Phone = model.Phone;
            entity.QQ = model.QQ;
            db.Add<Customer>(entity);
            db.Commit();
            return entity;
        }
Example #4
0
        public ActionResult Details(int ID)
        {
            var entity = CustomerService.Find(ID);

            var model = new CustomerViewModel()
            {
                ID = entity.ID,

                JobID = entity.JobID,

                CompanyID = entity.CompanyID,

                Name = entity.Name,

                Mobile = entity.Mobile,

                Mobile1 = entity.Mobile1,

                Phone = entity.Phone,

                AddBirthDay = entity.AddBirthDay,

                IsLeap = entity.IsLeap,

                BirthDay = entity.BirthDay,

                QQ = entity.QQ,

                Jobs = entity.Jobs,

                Email = entity.Email,

                Favorite = entity.Favorite,

                Address = entity.Address,

                ReMark = entity.ReMark,
            };

            return PartialView(model);
        }
Example #5
0
        public ActionResult Edit(int ID)
        {
            var entity = CustomerService.GetALL().Single(x => x.ID == ID);

            var model = new CustomerViewModel()
            {
                ID = entity.ID,

                JobID = entity.JobID,

                CompanyID = entity.CompanyID,

                Name = entity.Name,

                Mobile = entity.Mobile,

                Mobile1 = entity.Mobile1,

                Phone = entity.Phone,

                AddBirthDay = entity.AddBirthDay,

                IsLeap = entity.IsLeap,

                BirthDay = entity.BirthDay,

                QQ = entity.QQ,

                Jobs = entity.Jobs,

                Email = entity.Email,

                Favorite = entity.Favorite,

                Address = entity.Address,

                ReMark = entity.ReMark,
            };
            ViewBag.Data_JobID = Utilities.GetSelectListData(JobCateService.GetALL(), x => x.ID, x => x.CateName, model.JobID, true);
            return PartialView(model);
        }