예제 #1
0
 /// <summary>
 /// 删除员工
 /// </summary>
 public static void Delete(CoEmployee employee, bool delUser)
 {
     try
     {
         LDLLogisticsEntities context = new LDLLogisticsEntities();
         //查找该员工是否存在
         CoEmployee _employee = context.CoEmployee.FirstOrDefault(obj => obj.ID == employee.ID);
         if (_employee == null)
             throw new FaultException(string.Format("该员工[{0}]不存在!", employee.Name));
         EntityObjectHelper.Copyto(employee, ref _employee); //利用反射动态赋值
         if (delUser)
         {
             SysUser user = context.SysUser.FirstOrDefault(obj => obj.EmployeeID == employee.ID);
             if (user != null)
                 context.SysUser.DeleteObject(user);
             context.SysOperationLog.AddObject(SysOperationLogAdapter.GetOperationtLog("CoEmployeeAdapter04", Define.Delete, user));   //记录日志
         }
         context.SysOperationLog.AddObject(SysOperationLogAdapter.GetOperationtLog("CoEmployeeAdapter05", Define.Delete, employee));   //记录日志
         context.SaveChanges();  //提交保存
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message);
     }
 }
예제 #2
0
 /// <summary>
 /// 新增员工
 /// </summary>
 public static void Insert(CoEmployee employee)
 {
     try
     {
         LDLLogisticsEntities context = new LDLLogisticsEntities();
         //查找该员工是否存在
         if (context.CoEmployee.FirstOrDefault(obj => obj.Code.Trim().ToLower() == employee.Code.Trim().ToLower() && obj.Valid == true) != null)
             throw new FaultException(string.Format("员工编号[{0}]已存在!", employee.Code));
         context.CoEmployee.AddObject(employee);    //新增
         context.SysOperationLog.AddObject(SysOperationLogAdapter.GetOperationtLog("CoEmployeeAdapter01", Define.Insert, employee));   //记录日志
         context.SaveChanges();  //提交保存
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message);
     }
 }
예제 #3
0
 /// <summary>
 /// 用于向 CoEmployee EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddToCoEmployee(CoEmployee coEmployee)
 {
     base.AddObject("CoEmployee", coEmployee);
 }
예제 #4
0
 /// <summary>
 /// 创建新的 CoEmployee 对象。
 /// </summary>
 /// <param name="id">ID 属性的初始值。</param>
 /// <param name="code">Code 属性的初始值。</param>
 /// <param name="name">Name 属性的初始值。</param>
 /// <param name="deptID">DeptID 属性的初始值。</param>
 /// <param name="siteID">SiteID 属性的初始值。</param>
 /// <param name="valid">Valid 属性的初始值。</param>
 public static CoEmployee CreateCoEmployee(global::System.Int32 id, global::System.String code, global::System.String name, global::System.Int32 deptID, global::System.String siteID, global::System.Boolean valid)
 {
     CoEmployee coEmployee = new CoEmployee();
     coEmployee.ID = id;
     coEmployee.Code = code;
     coEmployee.Name = name;
     coEmployee.DeptID = deptID;
     coEmployee.SiteID = siteID;
     coEmployee.Valid = valid;
     return coEmployee;
 }
예제 #5
0
 public void UpdateEmployee(CoEmployee employee)
 {
     CoEmployeeAdapter.Update(employee);
 }
예제 #6
0
 public void DeleteEmployee(CoEmployee employee, bool delUser)
 {
     CoEmployeeAdapter.Delete(employee, delUser);
 }
예제 #7
0
 public void InsertEmployeeWithUser(CoEmployee employee, SysUser user)
 {
     CoEmployeeAdapter.InsertWithUser(employee, user);
 }
예제 #8
0
 public void InsertEmployee(CoEmployee employee)
 {
     CoEmployeeAdapter.Insert(employee);
 }
예제 #9
0
        /// <summary>
        /// 修改员工
        /// </summary>
        public static void Update(CoEmployee employee)
        {
            try
            {
                LDLLogisticsEntities context = new LDLLogisticsEntities();
                //查找该员工是否存在
                CoEmployee _employee = context.CoEmployee.FirstOrDefault(obj => obj.ID == employee.ID);
                if (_employee == null)
                    throw new FaultException(string.Format("该员工[{0}]不存在!", employee.Name));
                EntityObjectHelper.Copyto(employee, ref _employee); //利用反射动态赋值

                context.SysOperationLog.AddObject(SysOperationLogAdapter.GetOperationtLog("CoEmployeeAdapter06", Define.Update, _employee));   //记录日志
                context.SaveChanges();  //提交保存
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.Message);
            }
        }