/// <summary> /// 新增部门 /// </summary> public static void Insert(CoDepartment dept) { try { LDLLogisticsEntities context = new LDLLogisticsEntities(); //查找该部门是否存在 if (context.CoDepartment.Any(obj => obj.DeptCode == dept.DeptCode && obj.Valid == true)) throw new FaultException(string.Format("部门编码[{0}]已存在!", dept.DeptCode)); context.CoDepartment.AddObject(dept); //新增 context.SysOperationLog.AddObject(SysOperationLogAdapter.GetOperationtLog("CoDepartmentAdapter01", Define.Insert, dept)); //记录日志 context.SaveChanges(); //提交保存 } catch (Exception ex) { throw new FaultException(ex.Message); } }
/// <summary> /// 修改部门 /// </summary> public static void Update(CoDepartment dept) { try { LDLLogisticsEntities context = new LDLLogisticsEntities(); //查找该部门是否存在 CoDepartment _dept = context.CoDepartment.FirstOrDefault(obj => obj.ID == dept.ID); if (_dept == null) throw new FaultException(string.Format("该部门不存在!")); EntityObjectHelper.Copyto(dept, ref _dept); //利用反射动态赋值 context.SysOperationLog.AddObject(SysOperationLogAdapter.GetOperationtLog("CoDepartmentAdapter03", Define.Update, _dept)); //记录日志 context.SaveChanges(); //提交保存 } catch (Exception ex) { throw new FaultException(ex.Message); } }
/// <summary> /// 用于向 CoDepartment EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet<T> 属性的 .Add 方法。 /// </summary> public void AddToCoDepartment(CoDepartment coDepartment) { base.AddObject("CoDepartment", coDepartment); }
/// <summary> /// 创建新的 CoDepartment 对象。 /// </summary> /// <param name="id">ID 属性的初始值。</param> /// <param name="parentID">ParentID 属性的初始值。</param> /// <param name="deptCode">DeptCode 属性的初始值。</param> /// <param name="deptName">DeptName 属性的初始值。</param> /// <param name="orderID">OrderID 属性的初始值。</param> /// <param name="valid">Valid 属性的初始值。</param> public static CoDepartment CreateCoDepartment(global::System.Int32 id, global::System.Int32 parentID, global::System.String deptCode, global::System.String deptName, global::System.Int32 orderID, global::System.Boolean valid) { CoDepartment coDepartment = new CoDepartment(); coDepartment.ID = id; coDepartment.ParentID = parentID; coDepartment.DeptCode = deptCode; coDepartment.DeptName = deptName; coDepartment.OrderID = orderID; coDepartment.Valid = valid; return coDepartment; }
public void UpdateDepartment(CoDepartment dept) { CoDepartmentAdapter.Update(dept); }
public void InsertDepartment(CoDepartment dept) { CoDepartmentAdapter.Insert(dept); }