Exemple #1
0
        public ActionResult CreateRoute(RouteViewModel model, List <TransitionalViewModel> modelItem)
        {
            try {
                var train = new TrainDTO
                {
                    Number           = model.Number,
                    DepartureStation = model.DepartureStation,
                    ArrivalStation   = model.ArrivalStation,
                    Departure        = model.Departure,
                    Seats            = model.Seats.Select(s => new SeatDTO {
                        Type     = s.Type,
                        Quantity = s.Quantity,
                        Price    = s.Price
                    }).Where(q => q.Quantity > 0).ToList()
                };
                var stopovers = modelItem.Select(m => new StopoverDTO {
                    StopStation = m.StopStation,
                    Departure   = m.Departure,
                    Arrival     = m.Arrival
                }).ToList();
                rs.AddRoute(train, stopovers, model.SelectedRoute);
                Unit.Save();
                Unit.Dispose();

                return(RedirectToAction("AvailableTrains"));
            }
            catch (Exception ex)
            {
                return(View(ex.Message));
            }
        }
Exemple #2
0
        public ActionResult EntryAddCheck(long id)
        {
            if (id <= 0)
            {
                return(Json(new AjaxResult {
                    Status = "0", ErrorMsg = "未知培训"
                }));
            }
            TrainDTO train = trainService.GetById(id);

            if (train == null)
            {
                return(Json(new AjaxResult {
                    Status = "0", ErrorMsg = "未知培训"
                }));
            }
            if (train.StatusName == "已结束")
            {
                return(Json(new AjaxResult {
                    Status = "0", ErrorMsg = "活动已结束"
                }));
            }
            if (train.UpToOne != 0)
            {
                if (train.EntryCount >= train.UpToOne)
                {
                    return(Json(new AjaxResult {
                        Status = "0", ErrorMsg = "报名人数已满,无法新增报名用户"
                    }));
                }
            }
            return(Json(new AjaxResult {
                Status = "1", Data = "/train/entryadd?id=" + id
            }));
        }
Exemple #3
0
        public ActionResult Delete(long id)
        {
            if (id <= 0)
            {
                return(Json(new AjaxResult {
                    Status = "0", ErrorMsg = "参数错误"
                }));
            }
            TrainDTO train = trainService.GetById(id);

            if (train.EntryCount > 0)
            {
                return(Json(new AjaxResult {
                    Status = "0", ErrorMsg = "该培训已产生报名,无法删除。"
                }));
            }
            if (!trainService.Delete(id))
            {
                return(Json(new AjaxResult {
                    Status = "0", ErrorMsg = "删除失败"
                }));
            }
            return(Json(new AjaxResult {
                Status = "1", Data = "/train/list"
            }));
        }
Exemple #4
0
        public void EditTrain(TrainDTO trainDto)
        {
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap <TrainDTO, Train>()).CreateMapper();
            var item   = mapper.Map <TrainDTO, Train>(trainDto);

            _Database.Trains.Update(item);
        }
 public IResult Update(TrainDTO dto)
 {
     Repo.Update(Mapper.DeMap(dto));
     return(new Result()
     {
         Message = ResponseMessageType.None,
         ResponseStatusType = ResponseStatusType.Successed
     });
 }
Exemple #6
0
        public void MakeTrain(TrainDTO trainDto)
        {
            Train train = new Train
            {
                Description = trainDto.Description,
                Name        = trainDto.Name
            };

            _Database.Trains.Create(train);
            _Database.Save();
        }
        public async Task <TrainDTO> GetByIdAsync(string id)
        {
            if (id == null)
            {
                throw new BusinessLogicException("Требуется идентификатор", "");
            }

            TrainDTO trainDTO = await Mapper.Map <Task <Train>, Task <TrainDTO> >(unitOfWork.Trains.GetByIdAsynс(id));

            return(trainDTO);
        }
        public async Task UpdateAsync(TrainDTO trainDTO)
        {
            if (trainDTO == null)
            {
                throw new BusinessLogicException("Требуется услуга", "");
            }

            Train train = Mapper.Map <TrainDTO, Train>(trainDTO);

            unitOfWork.Trains.Update(train);
            await unitOfWork.CommitAsync();
        }
        public ActionResult EditTrain(int?id)
        {
            TrainDTO trainDto = _trainService.GetTrain(id);

            if (trainDto == null)
            {
                throw new ValidationException("Не установлено id поезда", "");
            }
            var mapper    = new MapperConfiguration(cfg => cfg.CreateMap <TrainDTO, TrainViewModel>()).CreateMapper();
            var trainView = mapper.Map <TrainDTO, TrainViewModel>(trainDto);

            return(View(trainView));
        }
Exemple #10
0
 public ActionResult CreateTrain(TrainViewModel train)
 {
     try
     {
         var trainDto = new TrainDTO {
             Name = train.Name, Description = train.Description
         };
         _trainService.MakeTrain(trainDto);
         return(Content("Вы успешно создали поезд"));
     }
     catch (ValidationException ex)
     {
         ModelState.AddModelError(ex.Property, ex.Message);
     }
     return(View(train));
 }
Exemple #11
0
        private TrainDTO ToDTO(TrainEntity entity)
        {
            TrainDTO dto = new TrainDTO();

            dto.Address        = entity.Address;
            dto.CreateDateTime = entity.CreateDateTime;
            dto.Description    = entity.Description;
            dto.EndTime        = entity.EndTime.ToString("yyyy-MM-dd HH:mm:ss");
            dto.EntryFee       = entity.EntryFee;
            dto.Id             = entity.Id;
            dto.Img            = entity.Img;
            dto.StartTime      = entity.StartTime.ToString("yyyy-MM-dd HH:mm:ss");
            dto.StatusName     = entity.Status.Name;
            dto.Title          = entity.Title;
            dto.UpToOne        = entity.UpToOne;
            dto.EntryCount     = entity.EntryCount;
            dto.VisitCount     = entity.VisitCount;
            dto.IsDisplayed    = entity.IsDisplayed;
            return(dto);
        }
        public async Task CreateAsync(TrainDTO trainDTO)
        {
            if (trainDTO == null)
            {
                throw new BusinessLogicException("Требуется услуга", "");
            }

            Train train = new Train()
            {
                ArrivalDate      = trainDTO.ArrivalDate,
                ArrivalStation   = trainDTO.ArrivalStation,
                DepartureDate    = trainDTO.DepartureDate,
                DepartureStation = trainDTO.DepartureStation,
                Provider         = trainDTO.Provider,
                TravellerId      = trainDTO.TravellerId
            };

            unitOfWork.Trains.Create(train);
            await unitOfWork.CommitAsync();
        }
Exemple #13
0
        public string AddRoute(TrainDTO tr, List <StopoverDTO> stops, string selected)
        {
            Train train = new Train {
                Number           = tr.Number,
                DepartureStation = tr.DepartureStation,
                ArrivalStation   = tr.ArrivalStation,
                Departure        = tr.Departure,
                Seats            = tr.Seats.Select(s => new Seat {
                    Type     = s.Type,
                    Quantity = s.Quantity,
                    Price    = s.Price
                }).ToList()
            };

            var stopovers = stops.Select(s => new Stopover {
                StopStation = s.StopStation,
                Departure   = s.Departure,
                Arrival     = s.Arrival
            }).ToList();

            return(Unit.routeFactory.CreateRoute().AddRoute(train, stopovers, selected));
        }
Exemple #14
0
        public Train DeMap(TrainDTO dto)
        {
            Train entity = repo.GetByID(dto.Id);

            routePropListEntity = new List <RoutePropereties>();
            if (entity == null)
            {
                foreach (RouteProperetiesDTO rpd in dto.RoutePropereties)
                {
                    routePropListEntity.Add(new RoutePropereties()
                    {
                        Id = rpd.Id, Price = rpd.Price, Place = rpd.Place, Date = rpd.Date
                    });
                }
                return(new Train()
                {
                    StationId = dto.StationId,
                    PlaceDeparture = dto.PlaceDeparture,
                    PlaceArrival = dto.PlaceArrival,
                    Name = dto.Name,
                    RoutePropereties = routePropListEntity,
                    Id = dto.Id
                });
            }
            entity.PlaceDeparture = dto.PlaceDeparture;
            entity.PlaceArrival   = dto.PlaceArrival;
            entity.Name           = dto.Name;
            entity.StationId      = dto.StationId;
            foreach (RouteProperetiesDTO rpd in dto.RoutePropereties)
            {
                entity.RoutePropereties.Add(new RoutePropereties()
                {
                    Id = rpd.Id, Price = rpd.Price, Place = rpd.Place, Date = rpd.Date
                });
            }
            entity.Id = dto.Id;
            return(entity);
        }
Exemple #15
0
        public string EditRoute(TrainDTO tr, List <StopoverDTO> stops, string selected)
        {
            var rt    = Unit.routeFactory.RoutesScaf().RoutesList().FirstOrDefault(r => r.RouteName == selected);
            var train = new Train {
                Number           = tr.Number,
                DepartureStation = tr.DepartureStation,
                ArrivalStation   = tr.ArrivalStation,
                Departure        = tr.Departure,
                Seats            = tr.Seats.Select(s => new Seat
                {
                    Type     = s.Type,
                    Quantity = s.Quantity,
                    Price    = s.Price
                }).ToList(),
                CurrentRoute = rt,
                Stops        = stops.Select(s => new Stopover {
                    StopStation = s.StopStation,
                    Departure   = s.Departure,
                    Arrival     = s.Arrival
                }).ToList()
            };

            return(Unit.routeFactory.RouteEditor().EditorRoute(train, selected));
        }
Exemple #16
0
        public ActionResult CheckJoinin(JoininModel model)
        {
            #region 数据验证
            if (model.TrainId <= 0)
            {
                return(Json(new AjaxResult {
                    Status = "0", ErrorMsg = "未知培训"
                }));
            }
            TrainDTO train = trainService.GetById(model.TrainId);
            if (train == null)
            {
                return(Json(new AjaxResult {
                    Status = "0", ErrorMsg = "未知培训"
                }));
            }
            if (train.StatusName == "已结束")
            {
                return(Json(new AjaxResult {
                    Status = "0", ErrorMsg = "活动已结束"
                }));
            }
            if (train.UpToOne != 0)
            {
                if (train.EntryCount >= train.UpToOne)
                {
                    return(Json(new AjaxResult {
                        Status = "0", ErrorMsg = "报名人数已满"
                    }));
                }
            }
            if (string.IsNullOrEmpty(model.Name))
            {
                return(Json(new AjaxResult {
                    Status = "0", ErrorMsg = "姓名不能为空"
                }));
            }
            if (model.Gender == 0)
            {
                return(Json(new AjaxResult {
                    Status = "0", ErrorMsg = "请选择性别"
                }));
            }
            if (string.IsNullOrEmpty(model.Mobile))
            {
                return(Json(new AjaxResult {
                    Status = "0", ErrorMsg = "手机号不能为空"
                }));
            }

            long phoneNum;
            if (!long.TryParse(model.Mobile, out phoneNum))
            {
                return(Json(new AjaxResult {
                    Status = "0", ErrorMsg = "手机号必须是数字"
                }));
            }
            if (model.Mobile.Length != 11)
            {
                return(Json(new AjaxResult {
                    Status = "0", ErrorMsg = "手机号必须是11位数字"
                }));
            }
            if (entryService.IsJoinined(model.TrainId, model.Mobile))
            {
                return(Json(new AjaxResult {
                    Status = "0", ErrorMsg = "该手机号已报过名"
                }));
            }
            if (string.IsNullOrEmpty(model.WorkUnits))
            {
                return(Json(new AjaxResult {
                    Status = "0", ErrorMsg = "工作单位不能为空"
                }));
            }
            if (string.IsNullOrEmpty(model.Duty))
            {
                return(Json(new AjaxResult {
                    Status = "0", ErrorMsg = "职务不能为空"
                }));
            }
            if (model.CityId == 0)
            {
                return(Json(new AjaxResult {
                    Status = "0", ErrorMsg = "请选择工作地"
                }));
            }
            if (model.StayId == 0)
            {
                return(Json(new AjaxResult {
                    Status = "0", ErrorMsg = "请选择住宿"
                }));
            }
            if (model.PayId == 0)
            {
                return(Json(new AjaxResult {
                    Status = "0", ErrorMsg = "请选择支付方式"
                }));
            }
            //if (string.IsNullOrEmpty(model.InvoiceUp))
            //{
            //    return Json(new AjaxResult { Status = "0", ErrorMsg = "发票不能为空" });
            //}
            //if (string.IsNullOrEmpty(model.Ein))
            //{
            //    return Json(new AjaxResult { Status = "0", ErrorMsg = "税号不能为空" });
            //}
            //if (string.IsNullOrEmpty(model.Address))
            //{
            //    return Json(new AjaxResult { Status = "0", ErrorMsg = "详细地址不能为空" });
            //}
            //if (string.IsNullOrEmpty(model.Contact))
            //{
            //    return Json(new AjaxResult { Status = "0", ErrorMsg = "联系方式不能为空" });
            //}
            //if (string.IsNullOrEmpty(model.OpenBank))
            //{
            //    return Json(new AjaxResult { Status = "0", ErrorMsg = "开户行不能为空" });
            //}
            //if (string.IsNullOrEmpty(model.BankAccount))
            //{
            //    return Json(new AjaxResult { Status = "0", ErrorMsg = "银行账号不能为空" });
            //}
            #endregion

            #region 报名添加数据
            EntryDTO dto = new EntryDTO();
            dto.Address        = model.Address;
            dto.BankAccount    = model.BankAccount;
            dto.CityId         = model.CityId;
            dto.Contact        = model.Contact;
            dto.Duty           = model.Duty;
            dto.Ein            = model.Ein;
            dto.EntryChannelId = 37;//微信公众号id=37,后台录入id=38
            dto.Gender         = model.Gender == 1;
            dto.InvoiceUp      = model.InvoiceUp;
            dto.Mobile         = model.Mobile;
            dto.Name           = model.Name;
            dto.OpenBank       = model.OpenBank;
            dto.PayId          = model.PayId;
            dto.StayId         = model.StayId;
            dto.TrainId        = model.TrainId;
            dto.WorkUnits      = model.WorkUnits;
            long id = entryService.Add(dto);
            if (id > 0)
            {
                return(Json(new AjaxResult {
                    Status = "1", Data = "/train/joinininfo?id=" + id + "&trainId=" + model.TrainId
                }));
            }
            else
            {
                return(Json(new AjaxResult {
                    Status = "0", ErrorMsg = "报名失败"
                }));
            }
            #endregion
        }
Exemple #17
0
        //按钮:输入征状信息
        private void InputSymptomInformation(object sender, RoutedEventArgs e)
        {
            Object   o        = record.Content;
            TrainDTO trainDto = null;
            User     user     = (User)UsersInfo.SelectedItem;

            if (o is TrainingRecord_Frame)
            {
                TrainingRecord_Frame trainingRecordFrame = (TrainingRecord_Frame)o;
                int index = trainingRecordFrame.TabControl1.SelectedIndex;
                switch (index)
                {
                case 0:
                    trainDto = (TrainDTO)trainingRecordFrame.TrainingRecord1.SelectedItem;
                    break;

                case 1:
                    trainDto = (TrainDTO)trainingRecordFrame.TrainingRecord2.SelectedItem;
                    break;

                case 2:
                    trainDto = (TrainDTO)trainingRecordFrame.TrainingRecord3.SelectedItem;
                    break;

                case 3:
                    trainDto = (TrainDTO)trainingRecordFrame.TrainingRecord4.SelectedItem;
                    break;

                case 4:
                    trainDto = (TrainDTO)trainingRecordFrame.TrainingRecord5.SelectedItem;
                    break;

                case 5:
                    trainDto = (TrainDTO)trainingRecordFrame.TrainingRecord6.SelectedItem;
                    break;
                }
            }

            if (user == null)
            {
                MessageBoxX.Warning(LanguageUtils.ConvertLanguage("请选择用户再进行操作!", "Please Select A Subject!"));
                return;
            }
            //if (trainDto == null)
            //{
            //    //判断是否选择了训练信息
            //    MessageBox.Show(LanguageUtils.ConvertLanguage("请选择训练信息再进行操作!", "Please Select A Train Info!"));
            //    return;
            //}

            InputSymptomInformation w2 = new InputSymptomInformation
            {
                Owner                 = Window.GetWindow(this),
                ShowActivated         = true,
                ShowInTaskbar         = false,
                WindowStartupLocation = WindowStartupLocation.CenterScreen
            };
            Dictionary <string, Object> dic = new Dictionary <string, object>();

            dic.Add("user", user);
            //dic.Add("trainDto", trainDto);
            w2.DataContext = dic;
            w2.ShowDialog();
            Refresh_RecordFrame_Action();
        }
Exemple #18
0
        //按钮:查看详细信息
        private void ViewDetails(object sender, RoutedEventArgs e)
        {
            //查看征状详细信息
            if (is_signinformationrecord.IsChecked == true)
            {
                ViewSymptomInformation viewSymptomInformation = new ViewSymptomInformation
                {
                    Owner                 = Window.GetWindow(this),
                    ShowActivated         = true,
                    ShowInTaskbar         = false,
                    WindowStartupLocation = WindowStartupLocation.CenterScreen
                };
                List <TrainInfo> list      = new List <TrainInfo>();
                TrainInfo        trainInfo = new TrainInfo
                {
                    Gmt_Create = new DateTime(2012, 01, 02)
                };
                list.Add(trainInfo);
                Console.WriteLine(trainInfo.Gmt_Create);
                list.Add(trainInfo);

                if (record.Content == null)
                {
                    MessageBoxX.Warning(LanguageUtils.ConvertLanguage("请选择症状信息再进行操作!", "Please Select A Symptom Info!"));
                    return;
                }

                DataGrid dataGrid = ((SignInformationRecord_Frame)record.Content).SignInformationRecord;

                SymptomInfoDTO symptomInfoDto = (SymptomInfoDTO)dataGrid.SelectedItem;
                User           user           = (User)UsersInfo.SelectedItem;
                if (user == null)
                {
                    MessageBoxX.Warning(LanguageUtils.ConvertLanguage("请选择用户再进行操作!", "Please Select A Subject!"));
                    return;
                }

                if (symptomInfoDto == null)
                {
                    MessageBoxX.Warning(LanguageUtils.ConvertLanguage("请选择症状信息再进行操作!", "Please Select A Symptom Info!"));
                    return;
                }

                Dictionary <string, Object> dictionary = new Dictionary <string, object>();
                dictionary.Add("user", user);
                dictionary.Add("symptomInfoDto", symptomInfoDto);
                viewSymptomInformation.DataContext = dictionary;
                viewSymptomInformation.ShowDialog();
            }
            //打开训练详细信息
            else if (is_trainingrecord.IsChecked == true)
            {
                ViewTrainingResults viewTrainingResults = new ViewTrainingResults
                {
                    Owner                 = Window.GetWindow(this),
                    ShowActivated         = true,
                    ShowInTaskbar         = false,
                    WindowStartupLocation = WindowStartupLocation.CenterScreen
                };

                Object   o        = record.Content;
                TrainDTO trainDto = null;
                User     user     = (User)UsersInfo.SelectedItem;
                if (o is TrainingRecord_Frame)
                {
                    TrainingRecord_Frame trainingRecordFrame = (TrainingRecord_Frame)o;
                    int index = trainingRecordFrame.TabControl1.SelectedIndex;
                    switch (index)
                    {
                    case 0:
                        trainDto = (TrainDTO)trainingRecordFrame.TrainingRecord1.SelectedItem;
                        break;

                    case 1:
                        trainDto = (TrainDTO)trainingRecordFrame.TrainingRecord2.SelectedItem;
                        break;

                    case 2:
                        trainDto = (TrainDTO)trainingRecordFrame.TrainingRecord3.SelectedItem;
                        break;

                    case 3:
                        trainDto = (TrainDTO)trainingRecordFrame.TrainingRecord4.SelectedItem;
                        break;

                    case 4:
                        trainDto = (TrainDTO)trainingRecordFrame.TrainingRecord5.SelectedItem;
                        break;

                    case 5:
                        trainDto = (TrainDTO)trainingRecordFrame.TrainingRecord6.SelectedItem;
                        break;
                    }
                }

                if (user == null)
                {
                    MessageBoxX.Warning(LanguageUtils.ConvertLanguage("请选择用户再进行操作!", "Please Select A Subject!"));
                    return;
                }
                if (trainDto == null)
                {//判断是否选择了训练信息
                    MessageBoxX.Warning(LanguageUtils.ConvertLanguage("请选择训练信息再进行操作!", "Please Select A Train Info!"));
                    return;
                }
                Dictionary <string, Object> dic = new Dictionary <string, object>();
                dic.Add("user", user);
                dic.Add("trainDto", trainDto);
                viewTrainingResults.DataContext = dic;
                viewTrainingResults.ShowDialog();
            }
            //打开体力评价详细信息
            else if (is_physicalevaluation.IsChecked == true)
            {
                ViewManualMvaluation viewManualMvaluation = new ViewManualMvaluation
                {
                    Owner                 = Window.GetWindow(this),
                    ShowActivated         = true,
                    ShowInTaskbar         = false,
                    WindowStartupLocation = WindowStartupLocation.CenterScreen
                };

                Object       o            = record.Content;
                PhysicaleDTO physicaleDto = null;
                User         user         = (User)UsersInfo.SelectedItem;
                if (o is PhysicaleValuation_Frame)
                {
                    PhysicaleValuation_Frame physicaleValuationFrame = (PhysicaleValuation_Frame)o;
                    physicaleDto = (PhysicaleDTO)physicaleValuationFrame.PhysicaleValuation.SelectedItem;
                }

                if (user == null)
                {
                    MessageBoxX.Warning(LanguageUtils.ConvertLanguage("请选择用户再进行操作!", "Please Select A Subject!"));
                    return;
                }
                if (physicaleDto == null)
                {//判断是否选择了训练信息
                    MessageBoxX.Warning(LanguageUtils.ConvertLanguage("请选择体力评价再进行操作!", "Please Select A Physical Evalution!"));
                    return;
                }
                Dictionary <string, Object> dic = new Dictionary <string, object>();
                dic.Add("user", user);
                dic.Add("physicaleDto", physicaleDto);
                viewManualMvaluation.DataContext = dic;
                viewManualMvaluation.ShowDialog();
            }
        }
Exemple #19
0
        public ActionResult EntryImport(EntryImportModel model)
        {
            if (model.Id <= 0)
            {
                return(Json(new AjaxResult {
                    Status = "0", ErrorMsg = "参数错误"
                }));
            }
            if (model.CityId <= 0)
            {
                return(Json(new AjaxResult {
                    Status = "0", ErrorMsg = "请选择导入市级"
                }));
            }
            if (model.File == null || model.File.ContentLength < 0)
            {
                return(Json(new AjaxResult {
                    Status = "0", ErrorMsg = "请选择要上传的文件"
                }));
            }
            long     id    = Convert.ToInt64(Session["AdminUserId"]);
            TrainDTO train = trainService.GetById(model.Id);

            if (train.UpToOne != 0)
            {
                return(Json(new AjaxResult {
                    Status = "0", ErrorMsg = "该培训活动有报名人数上限,导入可能会导致数据溢出,请将活动报名上限设为不限再导入"
                }));
            }
            string roleName = roleService.GetByAdminUserId(id).First().Name;

            string[] roleCities = new[] { "南宁市", "柳州市", "桂林市", "梧州市", "北海市", "防城港市", "钦州市", "玉林市", "贵港市", "百色市", "河池市", "贺州市", "来宾市", "崇左市", "厅机关处室、直属单位" };
            string   roleCity   = roleName.Split('-')[0];

            if (roleCities.Contains(roleCity))
            {
                if (idNameService.GetById(model.CityId).Name != roleCity)
                {
                    return(Json(new AjaxResult {
                        Status = "0", ErrorMsg = "你是" + roleCity + "的管理员,只能导入" + roleCity + "的数据"
                    }));
                }
            }

            string[] excelFormats = { ".xlsx", ".xls", ".XLSX", ".XLS" };
            string   md5          = CommonHelper.GetMD5(model.File.InputStream);
            string   ext          = Path.GetExtension(model.File.FileName);

            if (!excelFormats.Contains(ext))
            {
                return(Json(new AjaxResult {
                    Status = "0", ErrorMsg = "请上传excel文件"
                }));
            }
            string path     = "/upload/" + DateTime.Now.ToString("yyyy/MM/dd") + "/" + md5 + ext;
            string fullPath = HttpContext.Server.MapPath("~" + path);

            new FileInfo(fullPath).Directory.Create();
            model.File.SaveAs(fullPath);

            DataTable dt = ExcelHelper.GetDataTable(fullPath);

            if (!entryService.EntryImport(model.Id, model.CityId, idNameService.GetByName("后台录入").Id, dt))
            {
                return(Json(new AjaxResult {
                    Status = "0", ErrorMsg = "报名导入失败"
                }));
            }
            return(Json(new AjaxResult {
                Status = "1", Data = "/train/entrylist?id=" + model.Id
            }));
        }
Exemple #20
0
        public ActionResult EntryEdit(EntryEditModel model)
        {
            #region 数据验证
            if (model.Id <= 0)
            {
                return(Json(new AjaxResult {
                    Status = "0", ErrorMsg = "报名用户不存在"
                }));
            }
            if (model.TrainId <= 0)
            {
                return(Json(new AjaxResult {
                    Status = "0", ErrorMsg = "未知培训"
                }));
            }
            TrainDTO train = trainService.GetById(model.TrainId);
            if (train == null)
            {
                return(Json(new AjaxResult {
                    Status = "0", ErrorMsg = "未知培训"
                }));
            }
            if (string.IsNullOrEmpty(model.Name))
            {
                return(Json(new AjaxResult {
                    Status = "0", ErrorMsg = "姓名不能为空"
                }));
            }
            if (model.Gender == null)
            {
                return(Json(new AjaxResult {
                    Status = "0", ErrorMsg = "请选择性别"
                }));
            }
            if (string.IsNullOrEmpty(model.Mobile))
            {
                return(Json(new AjaxResult {
                    Status = "0", ErrorMsg = "手机号不能为空"
                }));
            }

            long phoneNum;
            if (!long.TryParse(model.Mobile, out phoneNum))
            {
                return(Json(new AjaxResult {
                    Status = "0", ErrorMsg = "手机号必须是数字"
                }));
            }
            if (model.Mobile.Length != 11)
            {
                return(Json(new AjaxResult {
                    Status = "0", ErrorMsg = "手机号必须是11位数字"
                }));
            }
            //if (entryService.IsJoinined(model.TrainId, model.Mobile))
            //{
            //    return Json(new AjaxResult { Status = "0", ErrorMsg = "该手机号已报过名" });
            //}
            if (model.CityId == 0)
            {
                return(Json(new AjaxResult {
                    Status = "0", ErrorMsg = "请选择工作地"
                }));
            }
            if (string.IsNullOrEmpty(model.WorkUnits))
            {
                return(Json(new AjaxResult {
                    Status = "0", ErrorMsg = "工作单位不能为空"
                }));
            }
            if (string.IsNullOrEmpty(model.Duty))
            {
                return(Json(new AjaxResult {
                    Status = "0", ErrorMsg = "职务不能为空"
                }));
            }
            if (model.StayId == 0)
            {
                return(Json(new AjaxResult {
                    Status = "0", ErrorMsg = "请选择住宿"
                }));
            }
            if (model.PayId == 0)
            {
                return(Json(new AjaxResult {
                    Status = "0", ErrorMsg = "请选择支付方式"
                }));
            }
            if (string.IsNullOrEmpty(model.InvoiceUp))
            {
                return(Json(new AjaxResult {
                    Status = "0", ErrorMsg = "发票不能为空"
                }));
            }
            if (string.IsNullOrEmpty(model.Ein))
            {
                return(Json(new AjaxResult {
                    Status = "0", ErrorMsg = "税号不能为空"
                }));
            }
            if (string.IsNullOrEmpty(model.Address))
            {
                return(Json(new AjaxResult {
                    Status = "0", ErrorMsg = "详细地址不能为空"
                }));
            }
            if (string.IsNullOrEmpty(model.Contact))
            {
                return(Json(new AjaxResult {
                    Status = "0", ErrorMsg = "联系方式不能为空"
                }));
            }
            if (string.IsNullOrEmpty(model.OpenBank))
            {
                return(Json(new AjaxResult {
                    Status = "0", ErrorMsg = "开户行不能为空"
                }));
            }
            if (string.IsNullOrEmpty(model.BankAccount))
            {
                return(Json(new AjaxResult {
                    Status = "0", ErrorMsg = "银行账号不能为空"
                }));
            }
            #endregion

            EntryDTO dto = new EntryDTO();
            dto.Id          = model.Id;
            dto.Address     = model.Address;
            dto.BankAccount = model.BankAccount;
            dto.CityId      = model.CityId;
            dto.Contact     = model.Contact;
            dto.Duty        = model.Duty;
            dto.Ein         = model.Ein;
            dto.Gender      = (bool)model.Gender;
            dto.InvoiceUp   = model.InvoiceUp;
            dto.Mobile      = model.Mobile;
            dto.Name        = model.Name;
            dto.OpenBank    = model.OpenBank;
            dto.PayId       = model.PayId;
            dto.StayId      = model.StayId;
            dto.WorkUnits   = model.WorkUnits;
            if (!entryService.Update(dto))
            {
                return(Json(new AjaxResult {
                    Status = "0", ErrorMsg = "编辑报名用户失败"
                }));
            }
            return(Json(new AjaxResult {
                Status = "1", Data = "/train/entrylist?id=" + model.TrainId
            }));
        }
Exemple #21
0
        public ActionResult Edit(long id)
        {
            TrainDTO dto = trainService.GetById(id);

            return(View(dto));
        }