public ActionResult EditModelLineHR(ModelLineHRDTO dto) { dto.Modified_Date = DateTime.Now; HttpResponseMessage responMessage = APIHelper.APIPostAsync(dto, "ElectricalBoard/EditModelLineHRAPI"); var result = responMessage.Content.ReadAsStringAsync().Result; return(Content(result, "application/json")); }
public string AddModelLineHR(ModelLineHRDTO dto) { var entity = AutoMapper.Mapper.Map <ModelLineHR>(dto); modelLineHRRepository.Add(entity); unitOfWork.Commit(); return("SUCCESS"); }
public string EditModelLineHR(ModelLineHRDTO dto) { var dtoDB = modelLineHRRepository.GetById(dto.ModelLineHR_UID); dtoDB.Station = dto.Station; dtoDB.Total = dto.Total; dtoDB.ShouldCome = dto.ShouldCome; dtoDB.ActualCome = dto.ActualCome; dtoDB.VacationLeave = dto.VacationLeave; dtoDB.PersonalLeave = dto.PersonalLeave; dtoDB.SickLeave = dto.SickLeave; dtoDB.AbsentLeave = dto.AbsentLeave; dtoDB.Modified_Date = DateTime.Now; modelLineHRRepository.Update(dtoDB); unitOfWork.Commit(); return("SUCCESS"); }
public PagedListModel <ModelLineHRDTO> QueryModelLineHRs() { var allData = AutoMapper.Mapper.Map <List <ModelLineHRDTO> >(modelLineHRRepository.GetAll().ToList()); var count = allData.Count; var sumData = new ModelLineHRDTO() { Station = "合计", Total = allData.Sum(m => m.Total), ShouldCome = allData.Sum(m => m.ShouldCome), ActualCome = allData.Sum(m => m.ActualCome), VacationLeave = allData.Sum(m => m.VacationLeave), PersonalLeave = allData.Sum(m => m.PersonalLeave), SickLeave = allData.Sum(m => m.SickLeave), AbsentLeave = allData.Sum(m => m.AbsentLeave), Created_Date = DateTime.Now, Modified_Date = DateTime.Now }; allData.Add(sumData); var result = new PagedListModel <ModelLineHRDTO>(count, allData); return(result); }
/// <summary> /// /// </summary> /// <param name="uploadName"></param> /// <returns></returns> public string ImportModelLineHR(HttpPostedFileBase uploadName) { string errorInfo = string.Empty; try { using (var xlPackage = new ExcelPackage(uploadName.InputStream)) { var worksheet = xlPackage.Workbook.Worksheets.FirstOrDefault(); int totalRows = worksheet.Dimension.End.Row; int totalColumns = worksheet.Dimension.End.Column; if (worksheet == null) { errorInfo = "没有worksheet内容"; return(errorInfo); } //头样式设置 var propertiesHead = new[] { "工站", "总人力", "应到", "实到", "休息", "事假", "病假", "旷工" }; bool isExcelError = false; for (int i = 1; i <= totalColumns; i++) { if (worksheet.Cells[1, i].Value != null && !string.IsNullOrWhiteSpace(worksheet.Cells[1, i].Value.ToString())) { var result = worksheet.Cells[1, i].Value.ToString(); var hasItem = propertiesHead.FirstOrDefault(m => m.Contains(result)); if (hasItem == null) { isExcelError = true; break; } } else { isExcelError = true; break; } } if (isExcelError) { errorInfo = "Excel格式不正确"; return(errorInfo); } var modelLineList = new List <ModelLineHRDTO>(); for (int i = 2; i <= totalRows; i++) { var workStationValue = ExcelHelper.ConvertColumnToString(worksheet.Cells[i, GetColumnIndex(propertiesHead, "工站")].Value); var totalValue = ExcelHelper.ConvertColumnToString(worksheet.Cells[i, GetColumnIndex(propertiesHead, "总人力")].Value); int?total = null; var shouldComeValue = ExcelHelper.ConvertColumnToString(worksheet.Cells[i, GetColumnIndex(propertiesHead, "应到")].Value); int?shouldCome = null; var actualComeValue = ExcelHelper.ConvertColumnToString(worksheet.Cells[i, GetColumnIndex(propertiesHead, "实到")].Value); int?actualCome = null; var vacationLeaveValue = ExcelHelper.ConvertColumnToString(worksheet.Cells[i, GetColumnIndex(propertiesHead, "休息")].Value); int?vacationLeave = null; var personalLeaveValue = ExcelHelper.ConvertColumnToString(worksheet.Cells[i, GetColumnIndex(propertiesHead, "事假")].Value); int?personalLeave = null; var sickLeaveValue = ExcelHelper.ConvertColumnToString(worksheet.Cells[i, GetColumnIndex(propertiesHead, "病假")].Value); int?sickLeave = null; var absentLeaveValue = ExcelHelper.ConvertColumnToString(worksheet.Cells[i, GetColumnIndex(propertiesHead, "旷工")].Value); int?absentLeave = null; if (string.IsNullOrWhiteSpace(workStationValue)) { isExcelError = true; errorInfo = string.Format("第{0}行工站没有值", i); return(errorInfo); } else { workStationValue = workStationValue.Trim(); if (workStationValue == "总计" || workStationValue == "合计") { continue; } } if (!string.IsNullOrWhiteSpace(totalValue)) { totalValue = totalValue.Trim(); try { total = int.Parse(totalValue); } catch (Exception) { } } if (!string.IsNullOrWhiteSpace(shouldComeValue)) { shouldComeValue = shouldComeValue.Trim(); try { shouldCome = int.Parse(shouldComeValue); } catch (Exception) { } } if (!string.IsNullOrWhiteSpace(actualComeValue)) { actualComeValue = actualComeValue.Trim(); try { actualCome = int.Parse(actualComeValue); } catch (Exception) { } } if (!string.IsNullOrWhiteSpace(vacationLeaveValue)) { vacationLeaveValue = vacationLeaveValue.Trim(); try { vacationLeave = int.Parse(vacationLeaveValue); } catch (Exception) { throw; } } if (!string.IsNullOrWhiteSpace(personalLeaveValue)) { personalLeaveValue = vacationLeaveValue.Trim(); try { personalLeave = int.Parse(personalLeaveValue); } catch (Exception) { throw; } } if (!string.IsNullOrWhiteSpace(sickLeaveValue)) { sickLeaveValue = sickLeaveValue.Trim(); try { sickLeave = int.Parse(sickLeaveValue); } catch (Exception) { throw; } } if (!string.IsNullOrWhiteSpace(absentLeaveValue)) { absentLeaveValue = absentLeaveValue.Trim(); try { absentLeave = int.Parse(absentLeaveValue); } catch (Exception) { throw; } } var modelLineHR = new ModelLineHRDTO() { Station = workStationValue, Total = total, ShouldCome = shouldCome, ActualCome = actualCome, VacationLeave = vacationLeave, PersonalLeave = personalLeave, SickLeave = sickLeave, AbsentLeave = absentLeave, Created_Date = DateTime.Now, Modified_Date = DateTime.Now }; modelLineList.Add(modelLineHR); } //插入表 var json = JsonConvert.SerializeObject(modelLineList); var apiInsertVendorInfoUrl = string.Format("ElectricalBoard/CoverModelLineHRAPI"); HttpResponseMessage responMessage = APIHelper.APIPostAsync(json, apiInsertVendorInfoUrl); errorInfo = responMessage.Content.ReadAsStringAsync().Result.Replace("\"", ""); } } catch (Exception e) { errorInfo = "导入Model Line 人力数据失败:" + e.ToString(); } return(errorInfo); }
public string EditModelLineHRAPI(ModelLineHRDTO dto) { var result = ElectricalBoardService.EditModelLineHR(dto); return(result); }