/// <summary> /// 新增关账日信息 /// </summary> /// <returns></returns> public bool AddAccountDate(AccountDateOperateDTO dto) { bool result = false; using (var tcdmse = new Entities.TCDMS_MasterDataEntities()) { var pp = tcdmse.master_AccountDateInfo.Where(p => p.AccountDateBelongModel == dto.AccountDateBelongModel && p.AccountDateYear == dto.AccountDateYear).FirstOrDefault(); if (pp != null) { throw new Exception("年份及模块不可重复!"); } var newitem = new master_AccountDateInfo(); newitem = Mapper.Map <AccountDateOperateDTO, master_AccountDateInfo>(dto); tcdmse.master_AccountDateInfo.Add(newitem); // 记录日志 this.AddLog(tcdmse, new LogData { CurrentLogType = LogType.ADD, LogDetails = "新增关账日" + dto.AccountDateName, OpratorName = dto.CreateUser }); result = tcdmse.SaveChanges() > 0; } return(result); }
/// <summary> /// //导入关帐日数据 /// </summary> /// <param name="impdtolst"></param> /// <returns></returns> public bool ImportData(List <ExcelImportDataDTO> impdtolst) { bool blResult = false; using (var tcdmse = new Entities.TCDMS_MasterDataEntities()) { foreach (var p in impdtolst) { if (p is ExclCloseDataDTO)//判断是否是关帐日信息 { ExclCloseDataDTO exrdt = p as ExclCloseDataDTO; exrdt.AccountDateBelongModellist.ForEach(f => { master_AccountDateInfo mprd = new master_AccountDateInfo(); mprd.AccountDateName = exrdt.AccountDateName; mprd.AccountDateYear = Convert.ToInt16(exrdt.AccountDateYear); mprd.AccountDatePlace = exrdt.AccountDatePlace; //判断每个字符串传过来的值是否为空,如果为空,则当月日期为空。 if (!string.IsNullOrEmpty(exrdt.MonthDate))//一月 { mprd.MonthDate = Convert.ToDateTime(exrdt.MonthDate); } else { mprd.MonthDate = null; } if (!string.IsNullOrEmpty(exrdt.FebDate))//二月 { mprd.FebDate = Convert.ToDateTime(exrdt.FebDate); } else { mprd.FebDate = null; } if (!string.IsNullOrEmpty(exrdt.MarchDate))//三月 { mprd.MarchDate = Convert.ToDateTime(exrdt.MarchDate); } else { mprd.MarchDate = null; } if (!string.IsNullOrEmpty(exrdt.AprilDate))//四月 { mprd.AprilDate = Convert.ToDateTime(exrdt.AprilDate); } else { mprd.AprilDate = null; } if (!string.IsNullOrEmpty(exrdt.MayDate))//五月 { mprd.MayDate = Convert.ToDateTime(exrdt.MayDate); } else { mprd.MayDate = null; } if (!string.IsNullOrEmpty(exrdt.JuneDate))//六月 { mprd.JuneDate = Convert.ToDateTime(exrdt.JuneDate); } else { mprd.JuneDate = null; } if (!string.IsNullOrEmpty(exrdt.JulyDate))//七月 { mprd.JulyDate = Convert.ToDateTime(exrdt.JulyDate); } else { mprd.JulyDate = null; } if (!string.IsNullOrEmpty(exrdt.AugustDate))//八月 { mprd.AugustDate = Convert.ToDateTime(exrdt.AugustDate); } else { mprd.AugustDate = null; } if (!string.IsNullOrEmpty(exrdt.SepDate))//九月 { mprd.SepDate = Convert.ToDateTime(exrdt.SepDate); } else { mprd.SepDate = null; } if (!string.IsNullOrEmpty(exrdt.OctDate))//十月 { mprd.OctDate = Convert.ToDateTime(exrdt.OctDate); } else { mprd.OctDate = null; } if (!string.IsNullOrEmpty(exrdt.NovDate))//十一月 { mprd.NovDate = Convert.ToDateTime(exrdt.NovDate); } else { mprd.NovDate = null; } if (!string.IsNullOrEmpty(exrdt.DecDate))//十二月 { mprd.DecDate = Convert.ToDateTime(exrdt.DecDate); } else { mprd.DecDate = null; } mprd.CreateUser = p.Importer; mprd.CreateTime = DateTime.Now; mprd.ModifyTime = DateTime.Now; mprd.ModifyUser = p.Importer; mprd.AccountDateBelongModel = f; tcdmse.master_AccountDateInfo.Add(mprd); }); } } blResult = tcdmse.SaveChanges() > 0; } return(blResult); }