Ejemplo n.º 1
0
        public ActionResult EditEmployeeInfoNew(EditEmployeeInfoModel model)
        {
            //  获取当前员工已经被哪些车使用过 如果对应的员工类型已经关联了相关的车辆 则不能取消绑定
            List <VehicleEmployeeInfoDDLModel> list = EmployeeInfoBLL.GetEmployeeInfoUsedToVehicle(model.ID);

            if (list != null && list.Count > 0)
            {
                if (!model.IsDriver)
                {
                    if (list.Find(o => o.Type == 1) != null)
                    {
                        ModelState.AddModelError("DriveCode", DataAnnotations.DriverError);
                    }
                }

                if (!model.IsCarrier && ModelState.IsValid)
                {
                    if (list.Find(o => o.Type == 2) != null)
                    {
                        ModelState.AddModelError("DriveCode", DataAnnotations.CarrierError);
                    }
                }
            }

            if (ModelState.IsValid)
            {
                var result = EmployeeInfoBLL.EditEmployeeInfoNew(model, base.CurrentUserID);
                base.DoLog(OperationTypeEnum.Edit, result, "ID:" + model.ID);
                return(Json(result));
            }
            else
            {
                // 证件类型
                model.CertificateTypeSelectList = new SelectList(EmployeeInfoBLL.GetCertificateTypes(), "CertificateTypeID", "CertificateTypeName");
                return(PartialView("_EditEmployeeInfoNew", model));
            }
        }