public static void ApproveNEWEQRequest(NewEqRequestModel model) { using (var context = new BEMSContext()) { if (model.IsComplete == true) { var ticket = context.FlowNewEqRequests.SingleOrDefault(a => a.ID.Equals(model.ID)); if (ticket == null) { throw new NullReferenceException(string.Format("单据未找到。ID:{0}。", model.ID)); } ticket.IsComplete = true; } else { var ticketFlow = context.FlowProgress.SingleOrDefault(a => a.TicketID.Equals(model.ID)); ticketFlow.Assignee = model.Assignee; ticketFlow.AssignTime = DateTime.Now; ticketFlow.CurrentFlowStep = model.CurrentFlowIndex.Value; ticketFlow.Comments = model.Comments; ticketFlow.LastUpdateBy = model.LastModifyBy; ticketFlow.LastUpdateTime = model.LastModifyTime.Value; } context.SaveChanges(); } }
public static void CreateNewEqRequest(NewEqRequestModel model) { using (var context = new BEMSContext()) { model.ID = "NEWEQ_" + DateTime.Now.ToString("yyyyMMddHHmmss"); context.FlowNewEqRequests.Add(new EF.DBModels.FlowNewEqRequest() { ID = model.ID, Amount = model.Amount, EModel = model.EModel, EType = model.EType, Memo = model.Memo, Requester = model.Requester, RequestTime = model.RequestTime, IsComplete = model.IsComplete }); context.FlowProgress.Add(new EF.DBModels.FlowProgress { FlowType = "NEWEQ", Assignee = model.Assignee, AssignTime = model.RequestTime, Comments = string.Empty, CurrentFlowStep = model.CurrentFlowIndex.Value, TicketID = model.ID, LastUpdateBy = model.Requester, LastUpdateTime = model.RequestTime }); context.SaveChanges(); } }
public static void CreateUser(UserModel userData) { using (var context = new BEMSContext()) { var user = context.Users.SingleOrDefault(a => a.AccountName.Equals(userData.AccountName)); if (user != null) { throw new ArgumentException("账号已存在"); } context.Users.Add(new Users() { AccountName = userData.AccountName, Address = userData.Address, CreateBy = userData.CreateBy, CreateTime = userData.CreateTime, DisplayName = userData.DisplayName, LastModifyBy = userData.LastModifyBy, LastModifyTime = userData.LastModifyTime, Memo = userData.Memo, Password = userData.Password, Phone = userData.Phone, State = userData.State }); context.SaveChanges(); } }
public static void UpdateUser(UserModel userData) { using (var context = new BEMSContext()) { var user = context.Users.SingleOrDefault(a => a.ID == userData.ID); if (user != null) { user.Address = userData.Address; user.DisplayName = userData.DisplayName; user.LastModifyBy = userData.LastModifyBy; user.LastModifyTime = userData.LastModifyTime; user.Memo = userData.Memo; user.Phone = userData.Phone; } else { throw new NullReferenceException("用户不存在!"); } context.SaveChanges(); } }