コード例 #1
0
ファイル: CoEmployeeAdapter.cs プロジェクト: haiming929/LDL
 /// <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
ファイル: StockWaybillAdapter.cs プロジェクト: hjqcan/LDL
        /// <summary>
        /// 运单发放删除
        /// </summary>
        public static void DeleteStockWaybillProvide(int id)
        {
            try
            {
                LDLLogisticsEntities context = new LDLLogisticsEntities();
                StockWaybillProvide objProvide = context.StockWaybillProvide.FirstOrDefault(obj => obj.ID == id && obj.Valid == true);
                if (objProvide == null)
                    throw new Exception("运单发放记录不存在");
                //StockWaybill State 0:已报损报废 1:已使用 2:未使用 3:审核中
                long startCode = long.Parse(objProvide.StartCode);
                long endCode = long.Parse(objProvide.EndCode);
                for (long i = startCode; i <= endCode; i++)
                {
                    string currentCode = i.ToString();
                    StockWaybill objWaybill = context.StockWaybill.FirstOrDefault(obj => obj.OwnerSite == objProvide.DestSite && obj.Code == currentCode);
                    if (objWaybill == null)
                        throw new Exception(string.Format("运单号[{0}]不存在", currentCode));
                    objWaybill.OwnerSite = objProvide.SrcSite;
                    objWaybill.Type = "库存";
                    objWaybill.State = "2";
                }

                //设置物料发放记录无效
                objProvide.Valid = false;
                context.SysOperationLog.AddObject(SysOperationLogAdapter.GetOperationtLog("StockWaybillAdapter04", Define.Delete, objProvide));   //记录日志
                context.SaveChanges();  //提交保存
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.Message);
            }
        }
コード例 #3
0
ファイル: StockWaybillAdapter.cs プロジェクト: hjqcan/LDL
        /// <summary>
        /// 删除入库登记
        /// </summary>
        public static void DeleteStockWaybillRegister(int id)
        {
            try
            {
                LDLLogisticsEntities context = new LDLLogisticsEntities();
                StockWaybillRegister objRegister = context.StockWaybillRegister.FirstOrDefault(obj => obj.ID == id && obj.Valid == true);
                if (objRegister == null)
                    throw new Exception("该入库登记记录不存在");
                //StockWaybill State 0:已报损报废 1:已使用 2:未使用 3:审核中
                long startCode = long.Parse(objRegister.StartCode);
                long endCode = long.Parse(objRegister.EndCode);
                for (long i = startCode; i <= endCode; i++)
                {
                    string currentCode = i.ToString();
                    StockWaybill objWaybill = context.StockWaybill.FirstOrDefault(obj => obj.Code == currentCode);
                    if (objWaybill == null)
                        throw new Exception(string.Format("运单号[{0}]不存在", currentCode));
                    else if (objWaybill.Type == "发放")
                        throw new Exception(string.Format("运单号[{0}]已发放", currentCode));
                    else if (objWaybill.OwnerSite != objWaybill.OwnerSite)
                        throw new Exception(string.Format("运单号[{0}]不属于该站点", currentCode));
                    context.StockWaybill.DeleteObject(objWaybill);
                }

                //设置入库登记记录无效
                objRegister.Valid = false;

                context.SysOperationLog.AddObject(SysOperationLogAdapter.GetOperationtLog("StockWaybillAdapter02", Define.Delete, objRegister));   //记录日志
                context.SaveChanges();  //提交保存
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.Message);
            }
        }
コード例 #4
0
ファイル: StockGoodsAdapter.cs プロジェクト: hjqcan/LDL
        /// <summary>
        /// 删除入库登记
        /// </summary>
        public static void DeleteStockGoodsRegister(int id)
        {
            try
            {
                LDLLogisticsEntities context = new LDLLogisticsEntities();
                StockGoodsRegister objRegister = context.StockGoodsRegister.FirstOrDefault(obj => obj.ID == id && obj.Valid == true);
                if (objRegister == null)
                    throw new Exception("该入库登记记录不存在");

                StockGoods objGoods = context.StockGoods.FirstOrDefault(obj => obj.OwnerSite == objRegister.OwnerSite && obj.Goods == objRegister.Goods);
                if (objGoods == null)
                    throw new Exception("库存记录不存在");
                if (objRegister.ActionType == "入库")
                {
                    if (objGoods.Number < objRegister.Number)
                        throw new Exception(string.Format("库存数量({0})低于入库登记的数量({1})", objGoods.Number, objRegister.Number));
                    objGoods.Number -= objRegister.Number;
                }
                else
                {
                    objGoods.Number += objRegister.Number;
                }
                //设置入库登记记录无效
                objRegister.Valid = false;

                context.SysOperationLog.AddObject(SysOperationLogAdapter.GetOperationtLog("StockGoodsAdapter02", Define.Delete, objRegister));   //记录日志
                context.SaveChanges();  //提交保存
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.Message);
            }
        }
コード例 #5
0
ファイル: SysFunctionAdapter.cs プロジェクト: haiming929/LDL
 /// <summary>
 /// 获取菜单列表
 /// </summary>
 //public static List<SysFunction> GetFunctionByUserName(string userName)
 //{
 //    LDLLogisticsEntities context = new LDLLogisticsEntities();
 //    List<string> lstUserFunction = context.SysUserFunction.Where(obj => obj.UserName == userName).ToList().
 //        ConvertAll<string>(obj => obj.FunctionCode);
 //    return context.SysFunction.Where(obj => obj.Valid && lstUserFunction.Contains(obj.Code)).ToList();
 //}
 /// <summary>
 /// 获取菜单列表
 /// </summary>
 public static List<SysFunction> GetFunctionByRole(string roleCode)
 {
     LDLLogisticsEntities context = new LDLLogisticsEntities();
     List<string> lstUserFunction = context.SysRoleFunction.Where(obj => obj.RoleCode.Trim().ToLower() == roleCode.Trim().ToLower()).ToList().
         ConvertAll<string>(obj => obj.FunctionCode);
     return context.SysFunction.Where(obj => obj.Valid && lstUserFunction.Contains(obj.Code)).OrderBy(obj => obj.OrderID).ToList();
 }
コード例 #6
0
ファイル: QuoteMainAdapter.cs プロジェクト: hjqcan/LDL
 /// <summary>
 /// 删除报价
 /// </summary>
 public static void DeleteQuoteMain(string guid)
 {
     try
     {
         LDLLogisticsEntities context = new LDLLogisticsEntities();
         //查找该站点是否存在
         QuoteMain quoteMain = context.QuoteMain.FirstOrDefault(obj => obj.Guid == guid);
         if (quoteMain == null)
             throw new FaultException(string.Format("报价不存在!"));
         quoteMain.Valid = false;
         //context.QuoteMain.DeleteObject(quoteMain); //删除
         //删除报价关系表
         //IQueryable<QuoteMainRelation> queryQuoteMainRelation = context.QuoteMainRelation.Where(obj => obj.SrcID == quoteMain.Guid);
         //foreach (QuoteMainRelation obj in queryQuoteMainRelation)
         //    context.QuoteMainRelation.DeleteObject(obj);
         //删除报价公式表
         //IQueryable<QuoteExpression> queryQuoteExpression = context.QuoteExpression.Where(obj => obj.SrcID == quoteMain.Guid);
         //foreach (QuoteExpression obj in queryQuoteExpression)
         //    context.QuoteExpression.DeleteObject(obj);
         context.SysOperationLog.AddObject(SysOperationLogAdapter.GetOperationtLog("QuoteMainAdapter02", Define.Delete, quoteMain));   //记录日志
         context.SaveChanges();  //提交保存
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message);
     }
 }
コード例 #7
0
ファイル: StockGoodsAdapter.cs プロジェクト: hjqcan/LDL
 /// <summary>
 /// 获取库存记录
 /// </summary>
 public static List<StockGoods> GetStockGoodsBySite(string siteCode)
 {
     LDLLogisticsEntities context = new LDLLogisticsEntities();
     if (string.IsNullOrEmpty(siteCode))
         return context.StockGoods.ToList();
     else
         return context.StockGoods.Where(obj => obj.OwnerSite == siteCode).ToList();
 }
コード例 #8
0
ファイル: SysVersionAdapter.cs プロジェクト: haiming929/LDL
 public static int GetVersion(string type)
 {
     LDLLogisticsEntities context = new LDLLogisticsEntities();
     SysVersion version = context.SysVersion.FirstOrDefault(obj => obj.Type.ToLower().Trim() == type.ToLower().Trim());
     if (version == null)
         return -1;
     else
         return version.Version;
 }
コード例 #9
0
ファイル: SysUserAdapter.cs プロジェクト: haiming929/LDL
        /// <summary>
        /// 获取用户
        /// </summary>
        public static SysUser GetUser(string userName)
        {
            LDLLogisticsEntities context = new LDLLogisticsEntities();
            //查找该用户是否存在
            SysUser user = context.SysUser.FirstOrDefault(obj => obj.UserName.Trim().ToLower() == userName.Trim().ToLower() && obj.Valid == true);
            if (user == null)
                throw new FaultException(string.Format("用户[{0}]不存在!", user.UserName));

            return user;
        }
コード例 #10
0
ファイル: WaybillInfoAdapter.cs プロジェクト: hjqcan/LDL
 /// <summary>
 /// 获取号码最低的可用运单编号
 /// </summary>
 public static string GetFirstWaybillCodeBySite(string siteID)
 {
     LDLLogisticsEntities context = new LDLLogisticsEntities();
     //获取最后一个运单
     StockWaybill lastStockWaybill = context.StockWaybill.OrderByDescending(obj => obj.Code).FirstOrDefault(obj => obj.OwnerSite == siteID && obj.State == "1" && obj.Type == "发放");
     string lastCode = lastStockWaybill == null ? "0" : lastStockWaybill.Code;
     //获取最新的一个可用的运单编号
     StockWaybill newStockWaybill = context.StockWaybill.OrderBy(obj => obj.Code).FirstOrDefault(obj => obj.OwnerSite == siteID && obj.Code.CompareTo(lastCode) > 0 && obj.State == "2" && obj.Type == "发放");
     if (newStockWaybill == null)
         return null;
     else
         return newStockWaybill.Code;
 }
コード例 #11
0
ファイル: CoEmployeeAdapter.cs プロジェクト: haiming929/LDL
 /// <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);
     }
 }
コード例 #12
0
ファイル: SysRoleAdapter.cs プロジェクト: haiming929/LDL
 /// <summary>
 /// 新增角色
 /// </summary>
 public static void Insert(SysRole role)
 {
     try
     {
         LDLLogisticsEntities context = new LDLLogisticsEntities();
         //查找该角色是否存在
         if (context.SysRole.FirstOrDefault(obj => obj.RoleCode.ToLower().Trim() == role.RoleCode.ToLower().Trim()) != null)
             throw new FaultException(string.Format("角色编码[{0}]已存在!", role.RoleCode));
         context.SysRole.AddObject(role);    //新增
         context.SysOperationLog.AddObject(SysOperationLogAdapter.GetOperationtLog("SysRoleAdapter01", Define.Insert, role));   //记录日志
         context.SaveChanges();  //提交保存
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message);
     }
 }
コード例 #13
0
ファイル: CoCustomersAdapter.cs プロジェクト: hjqcan/LDL
 /// <summary>
 /// 新增客户
 /// </summary>
 public static void Insert(CoCustomers customers)
 {
     try
     {
         LDLLogisticsEntities context = new LDLLogisticsEntities();
         //查找该客户是否存在
         if (context.CoCustomers.Any(obj => obj.Code.Trim().ToLower() == customers.Code.Trim().ToLower() && obj.Valid == true))
             throw new FaultException(string.Format("客户编码[{0}]已存在!", customers.Code));
         context.CoCustomers.AddObject(customers);    //新增
         context.SysOperationLog.AddObject(SysOperationLogAdapter.GetOperationtLog("CoCustomersAdapter01", Define.Insert, customers));   //记录日志
         context.SaveChanges();  //提交保存
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message);
     }
 }
コード例 #14
0
ファイル: CoDriverAdapter.cs プロジェクト: hjqcan/LDL
 /// <summary>
 /// 新增司机
 /// </summary>
 public static void Insert(CoDriver driver)
 {
     try
     {
         LDLLogisticsEntities context = new LDLLogisticsEntities();
         //查找该司机是否存在
         if (context.CoDriver.Any(obj => obj.Code == driver.Code && obj.Valid == true) )
             throw new FaultException(string.Format("司机编码[{0}]已存在!", driver.Code));
         context.CoDriver.AddObject(driver);    //新增
         context.SysOperationLog.AddObject(SysOperationLogAdapter.GetOperationtLog("CoDriverAdapter01", Define.Insert, driver));   //记录日志
         context.SaveChanges();  //提交保存
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message);
     }
 }
コード例 #15
0
ファイル: SysFunctionAdapter.cs プロジェクト: haiming929/LDL
 /// <summary>
 /// 新增菜单
 /// </summary>
 public static void Insert(SysFunction function)
 {
     try
     {
         LDLLogisticsEntities context = new LDLLogisticsEntities();
         //查找该菜单是否存在
         if (context.SysFunction.FirstOrDefault(obj => obj.Code == function.Code) != null)
             throw new FaultException(string.Format("菜单编码[{0}]已存在!", function.Code));
         context.SysFunction.AddObject(function);    //新增
         context.SysOperationLog.AddObject(SysOperationLogAdapter.GetOperationtLog("SysFunctionAdapter01", Define.Insert, function));   //记录日志
         context.SaveChanges();  //提交保存
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message);
     }
 }
コード例 #16
0
ファイル: CoCustomersAdapter.cs プロジェクト: hjqcan/LDL
 /// <summary>
 /// 删除客户
 /// </summary>
 public static void Delete(int id)
 {
     try
     {
         LDLLogisticsEntities context = new LDLLogisticsEntities();
         //查找该客户是否存在
         CoCustomers customers = context.CoCustomers.FirstOrDefault(obj => obj.ID == id);
         if (customers == null)
             throw new FaultException(string.Format("客户不存在!"));
         context.CoCustomers.DeleteObject(customers); //删除
         context.SysOperationLog.AddObject(SysOperationLogAdapter.GetOperationtLog("CoCustomersAdapter02", Define.Delete, customers));   //记录日志
         context.SaveChanges();  //提交保存
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message);
     }
 }
コード例 #17
0
ファイル: SysFunctionAdapter.cs プロジェクト: haiming929/LDL
 /// <summary>
 /// 删除菜单
 /// </summary>
 /// <param name="userName"></param>
 public static void Delete(string code)
 {
     try
     {
         LDLLogisticsEntities context = new LDLLogisticsEntities();
         //查找该用户是否存在
         SysFunction function = context.SysFunction.FirstOrDefault(obj => obj.Code == code);
         if (function == null)
             throw new FaultException(string.Format("菜单[{0}]不存在!", code));
         context.SysFunction.DeleteObject(function); //删除
         context.SysOperationLog.AddObject(SysOperationLogAdapter.GetOperationtLog("SysFunctionAdapter02", Define.Delete, function));   //记录日志
         context.SaveChanges();  //提交保存
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message);
     }
 }
コード例 #18
0
ファイル: CoDriverAdapter.cs プロジェクト: hjqcan/LDL
 /// <summary>
 /// 删除司机
 /// </summary>
 public static void Delete(int id)
 {
     try
     {
         LDLLogisticsEntities context = new LDLLogisticsEntities();
         //查找该司机是否存在
         CoDriver driver = context.CoDriver.FirstOrDefault(obj => obj.ID == id);
         if (driver == null)
             throw new FaultException(string.Format("司机不存在!"));
         context.CoDriver.DeleteObject(driver); //删除
         context.SysOperationLog.AddObject(SysOperationLogAdapter.GetOperationtLog("CoDriverAdapter02", Define.Delete, driver));   //记录日志
         context.SaveChanges();  //提交保存
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message);
     }
 }
コード例 #19
0
ファイル: CoDepartmentAdapter.cs プロジェクト: hjqcan/LDL
        /// <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);
            }
        }
コード例 #20
0
ファイル: CoCustomersAdapter.cs プロジェクト: hjqcan/LDL
        /// <summary>
        /// 修改客户
        /// </summary>
        public static void Update(CoCustomers customers)
        {
            try
            {
                LDLLogisticsEntities context = new LDLLogisticsEntities();
                //查找该客户是否存在
                CoCustomers _customers = context.CoCustomers.FirstOrDefault(obj => obj.ID == customers.ID);
                if (_customers == null)
                    throw new FaultException(string.Format("该客户[{0}]不存在!", customers.Name));
                EntityObjectHelper.Copyto(customers, ref _customers); //利用反射动态赋值

                context.SysOperationLog.AddObject(SysOperationLogAdapter.GetOperationtLog("CoCustomersAdapter03", Define.Update, _customers));   //记录日志
                context.SaveChanges();  //提交保存
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.Message);
            }
        }
コード例 #21
0
ファイル: CoDriverAdapter.cs プロジェクト: hjqcan/LDL
        /// <summary>
        /// 修改司机
        /// </summary>
        public static void Update(CoDriver driver)
        {
            try
            {
                LDLLogisticsEntities context = new LDLLogisticsEntities();
                //查找该司机是否存在
                CoDriver _driver = context.CoDriver.FirstOrDefault(obj => obj.ID == driver.ID);
                if (_driver == null)
                    throw new FaultException(string.Format("该司机[{0}]不存在!", driver.Name));
                EntityObjectHelper.Copyto(driver, ref _driver); //利用反射动态赋值

                context.SysOperationLog.AddObject(SysOperationLogAdapter.GetOperationtLog("CoDriverAdapter03", Define.Update, _driver));   //记录日志
                context.SaveChanges();  //提交保存
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.Message);
            }
        }
コード例 #22
0
ファイル: SysParameterAdapter.cs プロジェクト: hjqcan/LDL
        /// <summary>
        /// 修改参数
        /// </summary>
        public static void Update(SysParameter parameter)
        {
            try
            {
                LDLLogisticsEntities context = new LDLLogisticsEntities();
                //查找该用户是否存在
                SysParameter _parameter = context.SysParameter.FirstOrDefault(obj => obj.ID == parameter.ID);
                if (_parameter == null)
                    throw new FaultException(string.Format("参数不存在!"));
                EntityObjectHelper.Copyto(parameter, ref _parameter); //利用反射动态赋值

                context.SysOperationLog.AddObject(SysOperationLogAdapter.GetOperationtLog("SysParameterAdapter03", Define.Update, _parameter));   //记录日志
                context.SaveChanges();  //提交保存
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.Message);
            }
        }
コード例 #23
0
ファイル: CoCarAdapter.cs プロジェクト: haiming929/LDL
        /// <summary>
        /// 修改车辆
        /// </summary>
        public static void Update(CoCar car)
        {
            try
            {
                LDLLogisticsEntities context = new LDLLogisticsEntities();
                //查找该车辆是否存在
                CoCar _car = context.CoCar.FirstOrDefault(obj => obj.ID == car.ID);
                if (_car == null)
                    throw new FaultException(string.Format("该车辆[{0}]不存在!", car.LicenseNumber));
                EntityObjectHelper.Copyto(car, ref _car); //利用反射动态赋值

                context.SysOperationLog.AddObject(SysOperationLogAdapter.GetOperationtLog("CoCarAdapter03", Define.Update, _car));   //记录日志
                context.SaveChanges();  //提交保存
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.Message);
            }
        }
コード例 #24
0
ファイル: CoSiteAdapter.cs プロジェクト: haiming929/LDL
        /// <summary>
        /// 删除站点
        /// </summary>
        public static void Delete(string id)
        {
            try
            {
                LDLLogisticsEntities context = new LDLLogisticsEntities();
                //查找该站点是否存在
                CoSite site = context.CoSite.FirstOrDefault(obj => obj.ID == id);
                if (site == null)
                    throw new FaultException(string.Format("站点不存在!"));

                context.CoSite.DeleteObject(site);
                context.SysOperationLog.AddObject(SysOperationLogAdapter.GetOperationtLog("CoSiteAdapter02", Define.Delete, site));   //记录日志
                context.SaveChanges();  //提交保存
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.Message);
            }
        }
コード例 #25
0
ファイル: SysRoleAdapter.cs プロジェクト: haiming929/LDL
        /// <summary>
        /// 删除角色
        /// </summary>
        public static void Delete(string roleCode)
        {
            try
            {
                LDLLogisticsEntities context = new LDLLogisticsEntities();
                //查找该角色是否存在
                SysRole role = context.SysRole.FirstOrDefault(obj => obj.RoleCode.ToLower().Trim() == roleCode.ToLower().Trim());
                if (role == null)
                    throw new FaultException(string.Format("角色编码[{0}]不存在!", roleCode));
                IQueryable<SysRoleFunction> delRoleFunctionList = context.SysRoleFunction.Where(obj => obj.RoleCode.ToLower().Trim() == roleCode.ToLower().Trim());
                foreach (SysRoleFunction roleFuction in delRoleFunctionList)
                    context.SysRoleFunction.DeleteObject(roleFuction);
                context.SysRole.DeleteObject(role); //删除

                context.SysOperationLog.AddObject(SysOperationLogAdapter.GetOperationtLog("SysRoleAdapter02", Define.Delete, role));   //记录日志
                context.SaveChanges();  //提交保存
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.Message);
            }
        }
コード例 #26
0
ファイル: CoSiteAdapter.cs プロジェクト: haiming929/LDL
        /// <summary>
        /// 修改站点
        /// </summary>
        public static void Update(CoSite site)
        {
            try
            {
                LDLLogisticsEntities context = new LDLLogisticsEntities();
                //查找该站点是否存在
                CoSite _site = context.CoSite.FirstOrDefault(obj => obj.ID == site.ID);
                if (_site == null)
                    throw new FaultException(string.Format("该站点[{0}]不存在!", site.Name));
                if (_site.Code != site.Code && context.CoSite.Any(obj => obj.Code == site.Code && obj.Valid == true))
                    throw new FaultException(string.Format("站点编码[{0}]已存在!", site.Code));

                    EntityObjectHelper.Copyto(site, ref _site); //利用反射动态赋值

                context.SysOperationLog.AddObject(SysOperationLogAdapter.GetOperationtLog("CoSiteAdapter03", Define.Update, _site));   //记录日志
                context.SaveChanges();  //提交保存
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.Message);
            }
        }
コード例 #27
0
ファイル: CoSiteAdapter.cs プロジェクト: haiming929/LDL
        /// <summary>
        /// 新增站点
        /// </summary>
        public static void Insert(CoSite site)
        {
            try
            {
                LDLLogisticsEntities context = new LDLLogisticsEntities();
                //查找该站点是否存在
                if (context.CoSite.Any(obj => obj.Code == site.Code && obj.Valid == true))
                    throw new FaultException(string.Format("站点编码[{0}]已存在!", site.Code));
                //主键
                string maxID = site.ParentID + "00";
                if (context.CoSite.Count(obj => obj.ParentID == site.ParentID) > 0)
                    maxID = context.CoSite.Where(obj => obj.ParentID == site.ParentID).Max(obj => obj.ID);
                site.ID = (int.Parse(maxID) + 1).ToString();

                context.CoSite.AddObject(site);    //新增
                context.SysOperationLog.AddObject(SysOperationLogAdapter.GetOperationtLog("CoSiteAdapter01", Define.Insert, site));   //记录日志
                context.SaveChanges();  //提交保存
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.Message);
            }
        }
コード例 #28
0
ファイル: WaybillInfoAdapter.cs プロジェクト: hjqcan/LDL
 /// <summary>
 /// 新增
 /// </summary>
 public static void InsertWaybillInfo(WaybillInfo waybillInfo, List<WaybillGoods> lstWaybillGoods)
 {
     try
     {
         LDLLogisticsEntities context = new LDLLogisticsEntities();
         //查找运单号是否可用
         StockWaybill waybill = context.StockWaybill.FirstOrDefault(obj => obj.OwnerSite == waybillInfo.ConsignorSite && obj.Code == waybillInfo.Code && obj.Type == "发放");
         if (waybill == null || waybill.State != "2")
             throw new FaultException(string.Format("运单号[{0}]{1}!", waybillInfo.Code, waybill != null && waybill.State == "1" ? "已使用" : "未使用"));
         //运单号设为已使用
         waybill.State = "1";
         //保存
         context.WaybillInfo.AddObject(waybillInfo);
         foreach (WaybillGoods goods in lstWaybillGoods)
             context.WaybillGoods.AddObject(goods);
         context.SysOperationLog.AddObject(SysOperationLogAdapter.GetOperationtLog("WaybillInfoAdapter01", Define.Insert, waybillInfo));   //记录日志
         context.SaveChanges();  //提交保存
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message);
     }
 }
コード例 #29
0
ファイル: StockGoodsAdapter.cs プロジェクト: hjqcan/LDL
        /// <summary>
        /// 物料发放删除
        /// </summary>
        public static void DeleteStockGoodsProvide(int id)
        {
            try
            {
                LDLLogisticsEntities context = new LDLLogisticsEntities();
                StockGoodsProvide objProvide = context.StockGoodsProvide.FirstOrDefault(obj => obj.ID == id && obj.Valid == true);
                if (objProvide == null)
                    throw new Exception("物料发放记录不存在");
                StockGoods objGoods = context.StockGoods.FirstOrDefault(obj => obj.OwnerSite == objProvide.SrcSite && obj.Goods == objProvide.Goods);
                if (objGoods == null)
                    throw new Exception("库存记录不存在");
                //更新库存总量
                objGoods.Number += objProvide.Number;
                //设置物料发放记录无效
                objProvide.Valid = false;

                context.SysOperationLog.AddObject(SysOperationLogAdapter.GetOperationtLog("StockGoodsAdapter04", Define.Delete, objProvide));   //记录日志
                context.SaveChanges();  //提交保存
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.Message);
            }
        }
コード例 #30
0
ファイル: StockWaybillAdapter.cs プロジェクト: hjqcan/LDL
 //State 0:已报损报废 1:已使用 2:未使用 3:审核中
 /// <summary>
 /// 获取库存记录 
 /// </summary>
 public static List<StockWaybill> GetStockWaybillBySite(string siteCode)
 {
     LDLLogisticsEntities context = new LDLLogisticsEntities();
     if (string.IsNullOrEmpty(siteCode))
         return context.StockWaybill.Where(obj => obj.Type == "库存" && obj.State == "2").ToList();
     else
         return context.StockWaybill.Where(obj => obj.OwnerSite == siteCode && obj.Type == "库存" && obj.State == "2").ToList();
 }