public ActionResult GetForAutocomplete(string pid) { EmployeeModel Script = new EmployeeModel(); List <EmployeeModel> result = Script.GetEmpDataByStaffID(pid, "0", "0"); return(Json(result)); }
public ActionResult BatchCreate(OverSeaBatchCreateViewModel model) { ResultModel result = new ResultModel(); try { #region 驗證Model if (!ModelState.IsValid) { throw new Exception(ModelStateErrorClass.FormatToString(ModelState)); } #endregion #region 前端資料變後端用資料ViewModel時用 //驗證工號是否都正確 EmployeeModel script = new EmployeeModel(); List <EmployeeModel> employeelist = script.GetEmpDataByStaffID("", "0", "0"); string mCX_Create = UserModel.GetUserData().StaffID; DateTime mNow = DateTime.Now; List <OverSea> oversealist = new List <OverSea>(0); foreach (var item in model.Detail) { if (!string.IsNullOrEmpty(item.CX_PID)) { var employee = employeelist.Where(x => x.eID == item.CX_PID).FirstOrDefault(); if (employee == null) { throw new Exception(item.CX_PID + "MessageEmployeeSearchError".ToLocalized()); } OverSea oversea = new OverSea() { CX_PID = item.CX_PID, CX_Name = employee.eName, ID_Country = model.Master.ID_Country, ID_OverType = model.Master.ID_OverType, CX_From_Date = model.Master.CX_From_Date, CX_To_Date = model.Master.CX_To_Date, CX_Dept_Name = employee.DeptName, CX_Title = employee.TitleName, CX_OnBoard_Date = employee.OnBoard, CX_Birthday = employee.OBirthday, CX_Create = mCX_Create, DT_Create = mNow, CX_OverSea_Remark = model.Master.CX_OverSea_Remark, CX_Place_Remark = model.Master.CX_Place_Remark, FG_IsWorkCard = item.FG_IsWorkCard }; //算遇到幾天 oversea.NQ_MeetBirthday = DateHelper.GetBetweenBirthdayCount( DateTime.Parse(oversea.CX_From_Date), DateTime.Parse(oversea.CX_To_Date), DateTime.Parse(oversea.CX_Birthday)); oversealist.Add(oversea); } } #endregion #region Service資料庫 this._overseaService.BatchCreate(oversealist); #endregion #region 息頁面設定 result.Status = true; result.Message = "MessageComplete".ToLocalized(); #endregion } catch (Exception ex) { #region 錯誤時錯誤訊息 result.Status = false; result.Message = ex.Message.ToString(); #endregion } return(Json(result)); }