Example #1
0
 /// <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);
     }
 }
Example #2
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);
     }
 }
Example #3
0
        /// <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);
            }
        }
Example #4
0
        /// <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);
            }
        }
Example #5
0
        /// <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);
            }
        }
Example #6
0
 /// <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);
     }
 }
Example #7
0
 /// <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);
     }
 }
Example #8
0
 /// <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);
     }
 }
Example #9
0
 /// <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);
     }
 }
Example #10
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);
     }
 }
Example #11
0
 /// <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);
     }
 }
Example #12
0
 /// <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);
     }
 }
Example #13
0
 /// <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);
     }
 }
Example #14
0
        /// <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);
            }
        }
Example #15
0
        /// <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);
            }
        }
Example #16
0
        /// <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);
            }
        }
Example #17
0
        /// <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);
            }
        }
Example #18
0
        /// <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);
            }
        }
Example #19
0
        /// <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);
            }
        }
Example #20
0
        /// <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);
            }
        }
Example #21
0
 /// <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);
     }
 }
Example #22
0
        /// <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);
            }
        }
Example #23
0
 /// <summary>
 /// 新增用户
 /// </summary>
 public static void Insert(SysUser user)
 {
     try
     {
         LDLLogisticsEntities context = new LDLLogisticsEntities();
         //查找该用户是否存在
         if (context.SysUser.FirstOrDefault(obj => obj.UserName.Trim().ToLower() == user.UserName.Trim().ToLower() && obj.Valid == true) != null)
             throw new FaultException(string.Format("用户名[{0}]已存在!", user.UserName));
         context.SysUser.AddObject(user);    //新增
         context.SysOperationLog.AddObject(SysOperationLogAdapter.GetOperationtLog("SysUserAdapter01", Define.Insert, user));   //记录日志
         context.SaveChanges();  //提交保存
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message);
     }
 }
Example #24
0
        /// <summary>
        /// 入库登记
        /// </summary>
        public static void InsertStockWaybillRegister(StockWaybillRegister objRegister)
        {
            try
            {
                LDLLogisticsEntities context = new LDLLogisticsEntities();
                //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));
                    objWaybill = new StockWaybill();
                    objWaybill.OwnerSite = objRegister.OwnerSite;
                    objWaybill.Code = currentCode;
                    objWaybill.State = "2";
                    objWaybill.Type = "库存";
                    objWaybill.Price = objRegister.Price;
                    context.StockWaybill.AddObject(objWaybill);
                }

                context.StockWaybillRegister.AddObject(objRegister);    //新增入库登记
                context.SysOperationLog.AddObject(SysOperationLogAdapter.GetOperationtLog("StockWaybillAdapter01", Define.Insert, objRegister));   //记录日志
                context.SaveChanges();  //提交保存
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.Message);
            }
        }
Example #25
0
        /// <summary>
        /// 运单发放
        /// </summary>
        public static void InsertStockWaybillProvide(StockWaybillProvide objProvide)
        {
            try
            {
                LDLLogisticsEntities context = new LDLLogisticsEntities();
                //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.SrcSite && obj.Code == currentCode);
                    if (objWaybill == null)
                        throw new Exception(string.Format("运单号[{0}]不存在", currentCode));
                    if (objWaybill.Type == "发放")
                        throw new Exception(string.Format("运单号[{0}]已发放", currentCode));
                    objWaybill.OwnerSite = objProvide.DestSite;
                    objWaybill.Type = "发放";
                    objWaybill.State = "2"; //以后要审核,先审核
                    objWaybill.Price = objProvide.Price;
                }

                context.StockWaybillProvide.AddObject(objProvide);    //新增物料发放记录
                context.SysOperationLog.AddObject(SysOperationLogAdapter.GetOperationtLog("StockWaybillAdapter03", Define.Insert, objProvide));   //记录日志
                context.SaveChanges();  //提交保存
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.Message);
            }
        }
Example #26
0
        /// <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);
            }
        }
Example #27
0
        /// <summary>
        /// 修改菜单
        /// </summary>
        public static void Update(SysFunction function)
        {
            try
            {
                LDLLogisticsEntities context = new LDLLogisticsEntities();
                //查找该用户是否存在
                SysFunction _function = context.SysFunction.FirstOrDefault(obj => obj.Code == function.Code);
                if (_function == null)
                    throw new FaultException(string.Format("菜单[{0}]不存在!", function.Name));
                EntityObjectHelper.Copyto(function, ref _function); //利用反射动态赋值

                context.SysOperationLog.AddObject(SysOperationLogAdapter.GetOperationtLog("SysFunctionAdapter03", Define.Update, _function));   //记录日志
                context.SaveChanges();  //提交保存
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.Message);
            }
        }
Example #28
0
 /// <summary>
 /// 修改报价信息
 /// </summary>
 public static void UpdateQuoteMain(QuoteMain quoteMain, List<QuoteMainRelation> quoteMainRelation, List<QuoteExpression> quoteExpression)
 {
     try
     {
         LDLLogisticsEntities context = new LDLLogisticsEntities();
         //查找该报价是否存在
         QuoteMain _quoteMain = context.QuoteMain.FirstOrDefault(obj => obj.Guid == quoteMain.Guid);
         if (_quoteMain == null)
             throw new FaultException(string.Format("报价[{0}]不存在!", quoteMain.Name));
         EntityObjectHelper.Copyto(quoteMain, ref _quoteMain); //利用反射动态赋值
         //清除报价关系表,插入新的关系表
         IQueryable<QuoteMainRelation> queryQuoteMainRelation = context.QuoteMainRelation.Where(obj => obj.SrcID == quoteMain.Guid);
         foreach (QuoteMainRelation obj in queryQuoteMainRelation)
             context.QuoteMainRelation.DeleteObject(obj);
         foreach (QuoteMainRelation obj in quoteMainRelation)
             context.QuoteMainRelation.AddObject(obj);
         //清除报价公式表,插入新的公式表
         IQueryable<QuoteExpression> queryQuoteExpression = context.QuoteExpression.Where(obj => obj.SrcID == quoteMain.Guid);
         foreach (QuoteExpression obj in queryQuoteExpression)
             context.QuoteExpression.DeleteObject(obj);
         foreach (QuoteExpression obj in quoteExpression)
             context.QuoteExpression.AddObject(obj);
         context.SysOperationLog.AddObject(SysOperationLogAdapter.GetOperationtLog("QuoteMainAdapter03", Define.Update, _quoteMain));   //记录日志
         context.SaveChanges();  //提交保存
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message);
     }
 }
Example #29
0
 /// <summary>
 /// 新增报价信息
 /// </summary>
 public static void InsertQuoteMain(QuoteMain quoteMain, List<QuoteMainRelation> quoteMainRelation, List<QuoteExpression> quoteExpression)
 {
     try
     {
         LDLLogisticsEntities context = new LDLLogisticsEntities();
         //查找该ID是否存在,防止重复插入
         if (context.QuoteMain.FirstOrDefault(obj => obj.Guid.Trim().ToLower() == quoteMain.Guid.Trim().ToLower()) != null)
             throw new FaultException(string.Format("报价已存在!"));
         //插入报价关系表
         foreach (QuoteMainRelation obj in quoteMainRelation)
             context.QuoteMainRelation.AddObject(obj);
         //插入报价公式表
         foreach (QuoteExpression obj in quoteExpression)
             context.QuoteExpression.AddObject(obj);
         context.QuoteMain.AddObject(quoteMain);    //新增
         context.SysOperationLog.AddObject(SysOperationLogAdapter.GetOperationtLog("QuoteMainAdapter01", Define.Insert, quoteMain));   //记录日志
         context.SaveChanges();  //提交保存
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message);
     }
 }
Example #30
0
        /// <summary>
        /// 登陆
        /// </summary>
        public static SysUser Login(string macAddress, string ipAddress, string hostName)
        {
            try
            {
                UserNamePasswordValidator validator = (UserNamePasswordValidator)OperationContext.Current.Host.Credentials.UserNameAuthentication.CustomUserNamePasswordValidator;
                LDLLogisticsEntities context = new LDLLogisticsEntities();
                SysUserLoginLog log = new SysUserLoginLog();
                log.MacAddress = macAddress;
                log.IPAddress = ipAddress;
                log.HostName = hostName;
                log.LoginTime = DateTime.Now;
                log.UserName = validator.CurrentUser.UserName;
                log.LoginState = "成功";
                context.SysUserLoginLog.AddObject(log);

                if (validator.CurrentUser.CheckComputer)
                {
                    string computerCode = SecurityHelper.MD5(macAddress + "|" + hostName);
                    if (!validator.CurrentUser.ComputerCode.Contains(computerCode))
                    {
                        log.LoginState = "失败";
                        context.SaveChanges();
                        throw new FaultException("请在指定的计算机上登陆!");
                    }
                }
                context.SaveChanges();
                return validator.CurrentUser;
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.Message);
            }
        }