public static void CreateCarItem(S_NodeInfo nodeInfo, string type) { var user = FormulaHelper.GetUserInfo(); var entities = FormulaHelper.GetEntities <DocConstEntities>(); if (nodeInfo.ConfigInfo == null) { throw new Formula.Exceptions.BusinessException("未能找到文件【" + nodeInfo.ID + "】的配置对象信息"); } var carInfo = entities.Set <S_CarInfo>().FirstOrDefault(d => d.NodeID == nodeInfo.ID && d.State == "New" && d.UserID == user.UserID && d.Type == type && d.DataType == nodeInfo.ConfigInfo.Name); if (carInfo == null) { carInfo = new S_CarInfo { ID = FormulaHelper.CreateGuid(), UserID = user.UserID, UserName = user.UserName, Name = nodeInfo.CreateCarName(), Code = nodeInfo.DataEntity.GetValue("DocumentCode"), DataType = nodeInfo.ConfigInfo.Name, Type = type, NodeID = nodeInfo.ID, NodeName = nodeInfo.Name, State = ItemState.New.ToString(), CreateDate = DateTime.Now, CreateUser = user.UserName, CreateUserID = user.UserID, ConfigID = nodeInfo.ConfigInfo.ID, SpaceID = nodeInfo.Space.ID }; entities.Set <S_CarInfo>().Add(carInfo); } }
public void applynodeborrow(List <Dictionary <string, object> > nodes) { var docConstEntities = FormulaHelper.GetEntities <DocConstEntities>(); var list = nodes; foreach (var item in list) { var space = DocConfigHelper.CreateConfigSpaceByID(item.GetValue("SpaceID")); // var FileInfo = docConstEntities.T_Borrow_FileInfo.FirstOrDefault(d => d.T_BorrowID == item.GetValue("BorrowID") && d.FileName == item.GetValue("Name")); S_NodeInfo nodeInfo = new S_NodeInfo(item.GetValue("RelateID"), space); if (nodeInfo == null) { continue; } if (nodeInfo.ConfigInfo == null) { throw new Formula.Exceptions.BusinessException("未能找到文件【" + nodeInfo.ID + "】的配置对象信息"); } var carInfo = docConstEntities.S_CarInfo.FirstOrDefault(d => d.UserID == this.CurrentUserInfo.UserID && d.NodeID == nodeInfo.ID && d.State == "New" && d.Type == "Borrow" && d.DataType == nodeInfo.ConfigInfo.Name); if (carInfo == null) { carInfo = new S_CarInfo(); carInfo.ID = FormulaHelper.CreateGuid();; carInfo.Name = nodeInfo.CreateCarName(); //nodeInfo.Name; carInfo.NodeID = nodeInfo.ID; carInfo.NodeName = nodeInfo.Name; carInfo.SpaceID = item.GetValue("SpaceID"); carInfo.State = "New"; carInfo.Type = ItemType.Borrow.ToString(); carInfo.UserID = this.CurrentUserInfo.UserID; carInfo.UserName = this.CurrentUserInfo.UserName; //carInfo.Code = nodeInfo.; carInfo.ConfigID = nodeInfo.ConfigInfo.ID; carInfo.CreateDate = DateTime.Now; carInfo.CreateUser = this.CurrentUserInfo.UserName; carInfo.CreateUserID = this.CurrentUserInfo.UserID; carInfo.DataType = nodeInfo.ConfigInfo.Name; docConstEntities.S_CarInfo.Add(carInfo); } else if (list.Count == 1) { throw new Formula.Exceptions.BusinessException("【" + nodeInfo.Name + "】已在借阅车中,请前往借阅车申请借阅"); } } docConstEntities.SaveChanges(); }
private void Lend(Dictionary <string, object> row) { var lendNumber = 0; int.TryParse(row.GetValue("LendNumber"), out lendNumber); var id = row.GetValue("ID"); var borrowDetail = this.entities.Set <S_BorrowDetail>().FirstOrDefault(a => a.ID == id); var isNew = false; if (lendNumber > 0) { #region 部分借阅 if (borrowDetail == null) { if (string.IsNullOrEmpty(id)) { id = FormulaHelper.CreateGuid(); } borrowDetail = new S_BorrowDetail { ID = id, SpaceID = row.GetValue("SpaceID"), SpaceName = row.GetValue("SpaceName"), DataType = row.GetValue("DataType"), DetailType = row.GetValue("DetailType"), RelateID = row.GetValue("RelateID"), ConfigID = row.GetValue("ConfigID"), Name = row.GetValue("Name"), Code = row.GetValue("Code"), LendUserID = row.GetValue("LendUserID"), LendUserName = row.GetValue("LendUserName"), LendDeptID = row.GetValue("LendDeptID"), LendDeptName = row.GetValue("LendDeptName"), ParentID = row.GetValue("ParentID") }; var applyNumber = 0; int.TryParse(row.GetValue("ApplyNumber"), out applyNumber); borrowDetail.ApplyNumber = applyNumber; this.entities.Set <S_BorrowDetail>().Add(borrowDetail); isNew = true; var parent = this.entities.Set <S_BorrowDetail>().FirstOrDefault(a => a.ID == borrowDetail.ParentID); if (parent != null) { parent.HasChild = TrueOrFalse.True.ToString(); } } #endregion borrowDetail.LendUserID = row.GetValue("LendUserID"); borrowDetail.LendUserName = row.GetValue("LendUserName"); borrowDetail.LendDeptID = row.GetValue("LendDeptID"); borrowDetail.LendDeptName = row.GetValue("LendDeptName"); borrowDetail.LendNumber = (borrowDetail.LendNumber ?? 0) + lendNumber; if (borrowDetail.LendDate == null) { borrowDetail.LendDate = Convert.ToDateTime(row.GetValue("LendDate")); borrowDetail.BorrowExpireDate = Convert.ToDateTime(row.GetValue("BorrowExpireDate")); } borrowDetail.BorrowState = BorrowDetailState.ToReturn.ToString(); if (borrowDetail.DetailType == NodeType.Node.ToString()) { var space = DocConfigHelper.CreateConfigSpaceByID(borrowDetail.SpaceID); var nodeInfo = new S_NodeInfo(borrowDetail.RelateID, space); InventoryFO.CreateInventoryLedger(nodeInfo, InventoryType.Lend, 0, (0 - lendNumber), borrowDetail.ID, borrowDetail.LendUserID, borrowDetail.LendUserName, EnumBaseHelper.GetEnumDescription(InventoryType.Lend.GetType(), InventoryType.Lend.ToString()) + "份数:" + lendNumber + "份"); nodeInfo.DataEntity.SetValue("BorrowState", BorrowReturnState.Borrow.ToString()); nodeInfo.Save(false); if (isNew) { borrowDetail.Name = nodeInfo.CreateCarName(); } } else { var space = DocConfigHelper.CreateConfigSpaceByID(borrowDetail.SpaceID); var fileInfo = new S_FileInfo(borrowDetail.RelateID, space); InventoryFO.CreateInventoryLedger(fileInfo, InventoryType.Lend, 0, (0 - lendNumber), borrowDetail.ID, borrowDetail.LendUserID, borrowDetail.LendUserName, EnumBaseHelper.GetEnumDescription(InventoryType.Lend.GetType(), InventoryType.Lend.ToString()) + "份数:" + lendNumber + "份"); fileInfo.DataEntity.SetValue("BorrowState", BorrowReturnState.Borrow.ToString()); fileInfo.Save(false); if (isNew) { borrowDetail.Name = fileInfo.CreateCarName(); } } } else if (borrowDetail != null) { if (borrowDetail.LendDate == null) { borrowDetail.LendDate = Convert.ToDateTime(row.GetValue("LendDate")); } if (borrowDetail.BorrowExpireDate == null) { borrowDetail.BorrowExpireDate = Convert.ToDateTime(row.GetValue("BorrowExpireDate")); } } }