/// <summary>
        /// 赋值账务信息
        /// </summary>
        /// <param name="context">数据上下文</param>
        /// <param name="bill">单据信息</param>
        /// <param name="item">明细信息</param>
        /// <returns>返回账务信息</returns>
        public S_InDepotDetailBill AssignDetailInfo(DepotManagementDataContext context, S_MaterialRejectBill bill,
                                                    S_MaterialListRejectBill item)
        {
            IBillTypeServer server   = ServerModuleFactory.GetServerModule <IBillTypeServer>();
            BASE_BillType   billType = server.GetBillTypeFromName("采购退货单");

            if (billType == null)
            {
                throw new Exception("获取不到单据类型信息");
            }


            S_InDepotDetailBill detailBill = new S_InDepotDetailBill();

            detailBill.ID              = Guid.NewGuid();
            detailBill.BillTime        = (DateTime)bill.OutDepotDate;
            detailBill.FillInPersonnel = bill.FillInPersonnel;
            detailBill.Department      = UniversalFunction.GetDeptInfo(context, bill.Department).部门名称;
            detailBill.FactPrice       = -Math.Round(item.UnitPrice * item.Amount, 2);
            detailBill.FactUnitPrice   = item.UnitPrice;
            detailBill.GoodsID         = item.GoodsID;
            detailBill.BatchNo         = item.BatchNo;
            detailBill.Provider        = item.Provider;
            detailBill.InDepotBillID   = bill.Bill_ID;
            detailBill.InDepotCount    = -item.Amount;
            detailBill.UnitPrice       = item.UnitPrice;
            detailBill.Price           = -Math.Round(item.UnitPrice * item.Amount, 2);
            detailBill.OperationType   = (int)GlobalObject.CE_SubsidiaryOperationType.采购退货;
            detailBill.StorageID       = bill.StorageID;
            detailBill.Remark          = "退货原因:" + bill.Reason + " 备注:" + bill.Remark;
            detailBill.AffrimPersonnel = bill.DepotManager;
            detailBill.FillInDate      = bill.Bill_Time;

            return(detailBill);
        }
        /// <summary>
        /// 赋值账务信息
        /// </summary>
        /// <param name="context">数据上下文</param>
        /// <param name="bill">单据信息</param>
        /// <param name="item">明细信息</param>
        /// <returns>返回账务信息对象</returns>
        public S_FetchGoodsDetailBill AssignDetailInfo(DepotManagementDataContext context, S_MaterialReturnedInTheDepot bill,
                                                       S_MaterialListReturnedInTheDepot item)
        {
            IBillTypeServer server   = ServerModuleFactory.GetServerModule <IBillTypeServer>();
            BASE_BillType   billType = server.GetBillTypeFromName("领料退库单");

            if (billType == null)
            {
                throw new Exception("获取不到单据类型信息");
            }

            View_Department department = UniversalFunction.GetDeptInfo(context, bill.Department);

            //单价设置
            decimal dcStockUnitPrice = m_serverStore.GetGoodsUnitPrice(context, item.GoodsID, item.BatchNo, bill.StorageID);

            //S_FetchGoodsDetailBill用于存放每次领料、领料退库的明细信息
            S_FetchGoodsDetailBill detailBill = new S_FetchGoodsDetailBill();

            detailBill.ID               = Guid.NewGuid();
            detailBill.FetchBIllID      = bill.Bill_ID;
            detailBill.BillTime         = ServerTime.Time;
            detailBill.FetchCount       = -item.ReturnedAmount;
            detailBill.GoodsID          = item.GoodsID;
            detailBill.BatchNo          = item.BatchNo;
            detailBill.ProviderBatchNo  = item.ProviderBatchNo;
            detailBill.Provider         = item.Provider;
            detailBill.Price            = -dcStockUnitPrice * (decimal)item.ReturnedAmount;
            detailBill.UnitPrice        = dcStockUnitPrice;
            detailBill.Department       = department.部门名称;
            detailBill.FillInPersonnel  = bill.FillInPersonnel;
            detailBill.FinanceSignatory = null;
            detailBill.DepartDirector   = bill.DepartmentDirector;
            detailBill.DepotManager     = bill.DepotManager;
            detailBill.OperationType    = (int)CE_SubsidiaryOperationType.领料退库;
            detailBill.StorageID        = bill.StorageID;
            detailBill.Remark           = "退库原因:" + bill.ReturnReason + ";备注:" + item.Remark;
            detailBill.FillInDate       = bill.Bill_Time;

            IMaterialRequisitionPurposeServer purposeServer =
                ServerModuleFactory.GetServerModule <IMaterialRequisitionPurposeServer>();

            detailBill.Using = string.Format("领料退库,初始用途:{0}", purposeServer.GetBillPurpose(context, bill.PurposeCode).Purpose);

            return(detailBill);
        }
Example #3
0
        /// <summary>
        /// 赋值账务信息
        /// </summary>
        /// <param name="ctx">数据上下文</param>
        /// <param name="outSourcing">单据信息</param>
        /// <returns>返回账务信息</returns>
        S_InDepotDetailBill AssignDetailInfo(DepotManagementDataContext ctx, S_CheckOutInDepotForOutsourcingBill outSourcing)
        {
            S_InDepotDetailBill detailBill = new S_InDepotDetailBill();
            var varData = from a in ctx.S_InDepotDetailBill
                          where a.InDepotBillID == outSourcing.Bill_ID
                          select a;

            if (varData.Count() != 0)
            {
                throw new Exception("数据不唯一");
            }
            else
            {
                IBillTypeServer server   = ServerModuleFactory.GetServerModule <IBillTypeServer>();
                BASE_BillType   billType = server.GetBillTypeFromName("委外报检入库单");

                if (billType == null)
                {
                    throw new Exception("获取不到单据类型信息");
                }

                detailBill.ID              = Guid.NewGuid();
                detailBill.BillTime        = ServerTime.Time;
                detailBill.FillInPersonnel = outSourcing.DeclarePersonnel;
                detailBill.Department      = UniversalFunction.GetPersonnelInfo(ctx, outSourcing.DeclarePersonnel).部门名称;
                detailBill.FactPrice       = Math.Round(outSourcing.UnitPrice * outSourcing.InDepotCount, 2);
                detailBill.FactUnitPrice   = outSourcing.UnitPrice;
                detailBill.GoodsID         = outSourcing.GoodsID;
                detailBill.BatchNo         = outSourcing.BatchNo;
                detailBill.InDepotBillID   = outSourcing.Bill_ID;
                detailBill.InDepotCount    = outSourcing.InDepotCount;
                detailBill.Price           = Math.Round(outSourcing.UnitPrice * outSourcing.InDepotCount, 2);
                detailBill.UnitPrice       = outSourcing.UnitPrice;
                detailBill.OperationType   = (int)CE_SubsidiaryOperationType.委外报检入库;
                detailBill.Provider        = outSourcing.Provider;
                detailBill.StorageID       = outSourcing.StorageID;
                detailBill.AffrimPersonnel = outSourcing.ManagerPersonnel;
                detailBill.FillInDate      = outSourcing.DeclareTime;
            }

            return(detailBill);
        }
        /// <summary>
        /// 获取报检入库单信息
        /// </summary>
        /// <returns>返回是否成功获取库存信息</returns>
        public IQueryResult GetAllBill()
        {
            IAuthorization m_authorization = PlatformFactory.GetObject <IAuthorization>();
            IQueryResult   qr = null;

            try
            {
                if (QueryResultFilter == null)
                {
                    qr = m_authorization.Query("报检入库单查询", null);
                }
                else
                {
                    qr = m_authorization.Query("报检入库单查询", null, QueryResultFilter);
                }

                if (!qr.Succeeded)
                {
                    throw new Exception(qr.Error);
                }

                if (m_billUniqueID < 0)
                {
                    IBillTypeServer server   = ServerModuleFactory.GetServerModule <IBillTypeServer>();
                    BASE_BillType   billType = server.GetBillTypeFromName("报检入库单");

                    if (billType == null)
                    {
                        throw new Exception("获取不到单据类型信息");
                    }

                    m_billUniqueID = billType.UniqueID;
                }

                return(qr);
            }
            catch (Exception)
            {
                return(null);
            }
        }
        /// <summary>
        /// 获取普通入库单信息
        /// </summary>
        /// <param name="returnInfo">入库单</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>操作是否成功的标志</returns>
        public bool GetAllBill(out IQueryResult returnInfo, out string error)
        {
            returnInfo = null;
            error      = null;

            IAuthorization authorization = PlatformFactory.GetObject <IAuthorization>();
            IQueryResult   qr            = null;

            if (QueryResultFilter == null)
            {
                qr = authorization.Query("普通入库单查询", null);
            }
            else
            {
                qr = authorization.Query("普通入库单查询", null, QueryResultFilter);
            }

            if (!qr.Succeeded)
            {
                error = qr.Error;
                return(false);
            }

            if (m_billUniqueID < 0)
            {
                IBillTypeServer server   = ServerModuleFactory.GetServerModule <IBillTypeServer>();
                BASE_BillType   billType = server.GetBillTypeFromName("普通入库单");

                if (billType == null)
                {
                    error = "获取不到单据类型信息";
                    return(false);
                }

                m_billUniqueID = billType.UniqueID;
            }

            returnInfo = qr;
            return(true);
        }
        /// <summary>
        /// 获取员工合同信息
        /// </summary>
        /// <param name="returnInfo">员工合同信息</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>操作是否成功的标志</returns>
        public bool GetAllPersonnelContarct(out IQueryResult returnInfo, out string error)
        {
            returnInfo = null;
            error      = null;

            IAuthorization serverAuthorization = PlatformFactory.GetObject <IAuthorization>();
            IQueryResult   qr = null;

            if (QueryResultFilter == null)
            {
                qr = serverAuthorization.Query("员工合同管理", null);
            }
            else
            {
                qr = serverAuthorization.Query("员工合同管理", null, QueryResultFilter);
            }

            if (!qr.Succeeded)
            {
                error = qr.Error;
                return(false);
            }

            IBillTypeServer server      = BasicServerFactory.GetServerModule <IBillTypeServer>();
            BASE_BillType   lnqBillType = server.GetBillTypeFromName("员工合同管理");

            if (lnqBillType == null)
            {
                error = "获取不到单据类型信息";
                return(false);
            }

            int m_billUniqueID = lnqBillType.UniqueID;

            returnInfo = qr;
            return(true);
        }
Example #7
0
        /// <summary>
        /// 赋值账务信息
        /// </summary>
        /// <param name="context">数据上下文</param>
        /// <param name="bill">单据信息</param>
        /// <param name="item">明细信息</param>
        /// <returns>返回账务信息对象</returns>
        public S_FetchGoodsDetailBill AssignDetailInfo(DepotManagementDataContext context, S_MaterialRequisition bill,
                                                       S_MaterialRequisitionGoods item)
        {
            IBillTypeServer server   = ServerModuleFactory.GetServerModule <IBillTypeServer>();
            BASE_BillType   billType = server.GetBillTypeFromName("领料单");

            if (billType == null)
            {
                throw new Exception("获取不到单据类型信息");
            }

            View_Department           department       = UniversalFunction.GetDeptInfo(context, bill.Department);
            IStoreServer              storeServer      = ServerModuleFactory.GetServerModule <IStoreServer>();
            IProductLendReturnService serverLendReturn = ServerModuleFactory.GetServerModule <IProductLendReturnService>();
            F_GoodsPlanCost           basicGoods       = m_basicGoodsServer.GetGoodsInfo(context, item.GoodsID);

            if (basicGoods == null)
            {
                throw new Exception(string.Format("物品ID [{0}] 的物品在基础物品表中没有查到,请与系统管理员联系!", item.GoodsID));
            }

            StoreQueryCondition condition = new StoreQueryCondition();

            condition.GoodsID   = item.GoodsID;
            condition.Provider  = item.ProviderCode;
            condition.BatchNo   = item.BatchNo;
            condition.StorageID = bill.StorageID;

            S_Stock stock = storeServer.GetStockInfoOverLoad(context, condition);

            if (stock == null && GlobalObject.GeneralFunction.IsNullOrEmpty(basicGoods.GoodsType))
            {
                throw new Exception(string.Format("图号:{0}, 名称:{1}, 规格:{2}, 供应商:{3}, 批次号:{4} 的物品在库存中没有查到相关物品,请仓管员核实!",
                                                  basicGoods.GoodsCode, basicGoods.GoodsName, basicGoods.Spec, item.ProviderCode, item.BatchNo));
            }

            //S_FetchGoodsDetailBill用于存放每次领料、领料退库的明细信息
            decimal dcRealCount = item.RealCount;
            decimal dcSumCount  = 0;

            var varData = from a in context.View_S_MaterialRequisitionProductReturnList
                          where a.单据号 == item.Bill_ID &&
                          a.还账物品ID == item.GoodsID &&
                          a.还账物品批次号 == item.BatchNo &&
                          a.还账物品供应商 == item.ProviderCode
                          select a;

            if (varData.Count() > 0)
            {
                dcSumCount = varData.Sum(a => a.还账数量);

                if (dcRealCount < dcSumCount)
                {
                    throw new Exception("实际领用数量不能大于还货数量,请重新核对");
                }
            }

            S_FetchGoodsDetailBill detailBill = new S_FetchGoodsDetailBill();

            detailBill.ID                 = Guid.NewGuid();
            detailBill.FetchBIllID        = bill.Bill_ID;
            detailBill.BillTime           = (DateTime)bill.OutDepotDate;
            detailBill.AssociatedBillType = bill.AssociatedBillType;
            detailBill.AssociatedBillNo   = bill.AssociatedBillNo;
            detailBill.Department         = department.部门名称;
            detailBill.FetchCount         = item.RealCount;
            detailBill.GoodsID            = item.GoodsID;
            detailBill.StorageID          = bill.StorageID;
            detailBill.Price              = dcSumCount;
            detailBill.UnitPrice          = stock == null ? 0 : stock.UnitPrice;
            detailBill.OperationType      = (int)CE_SubsidiaryOperationType.领料;
            detailBill.Provider           = item.ProviderCode;

            if (stock != null)
            {
                detailBill.ProviderBatchNo = stock.ProviderBatchNo;
            }
            else
            {
                detailBill.ProviderBatchNo = "";
            }

            detailBill.BatchNo = item.BatchNo;

            detailBill.FillInPersonnel  = bill.FillInPersonnel;
            detailBill.FinanceSignatory = null;
            detailBill.DepartDirector   = bill.DepartmentDirector;
            detailBill.DepotManager     = bill.DepotManager;
            detailBill.Remark           = (bill.Remark == null ? "" : bill.Remark.Trim()) + (item.Remark == null ? "" : item.Remark.Trim());
            detailBill.FillInDate       = bill.Bill_Time;

            IMaterialRequisitionPurposeServer purposeServer =
                ServerModuleFactory.GetServerModule <IMaterialRequisitionPurposeServer>();

            detailBill.Using = purposeServer.GetBillPurpose(context, bill.PurposeCode).Purpose;

            return(detailBill);
        }
        /// <summary>
        /// 为指定类别的单据分配新号
        /// </summary>
        /// <param name="dataContxt">数据上下文</param>
        /// <param name="billServer">单据服务</param>
        /// <param name="billTypeName">单据类别名称, 如:领料单</param>
        /// <returns>返回获取到的新单据号</returns>
        public string AssignNewNo(DepotManagementDataContext dataContxt, IBasicBillServer billServer, string billTypeName)
        {
            BASE_BillType billType = m_billTypeServer.GetBillTypeFromName(billTypeName);

            string billNo = null;

            if (billType == null)
            {
                throw new Exception("不存在的单据类型名称:" + billTypeName);
            }

            m_billServer = billServer;

            BASE_AssignBillNo billInfo = null;

            #region 检查是否有放弃的编号

            var result = from r in dataContxt.BASE_AssignBillNo
                         where r.Bill_TypeCode == billType.TypeCode && r.AlreadyUse == false &&
                         r.IsAbandoned == true && r.AssignedDate.Year == ServerTime.Time.Year
                         select r;

            if (result.Count() > 0)
            {
                // 是否发现异常单据
                bool findExceptionBill = false;

                foreach (var item in result)
                {
                    if (!billServer.IsExist(dataContxt, item.Bill_No))
                    {
                        billInfo = item;
                        break;
                    }
                    else
                    {
                        findExceptionBill = true;
                        item.IsAbandoned  = false;
                    }
                }

                if (findExceptionBill)
                {
                    dataContxt.SubmitChanges();
                }

                if (billInfo != null)
                {
                    Console.WriteLine("使用放弃的单据号:{0}", billInfo.Bill_No);

                    billInfo.IsAbandoned  = false;
                    billInfo.AssignedDate = ServerModule.ServerTime.Time;

                    dataContxt.SubmitChanges();

                    return(billInfo.Bill_No);
                }
            }

            #endregion

            // 生成新编号
            int maxValue = 1;

            result = from r in dataContxt.BASE_AssignBillNo
                     where r.Bill_TypeCode == billType.TypeCode && r.AssignedDate.Year == ServerTime.Time.Year
                     select r;

            if (result.Count() > 0)
            {
                maxValue += (from c in dataContxt.BASE_AssignBillNo
                             where c.Bill_TypeCode == billType.TypeCode && c.AssignedDate.Year == ServerTime.Time.Year
                             select Convert.ToInt32(c.Bill_No.Substring(billType.TypeCode.Length + 6))).Max();
            }

            //string prefix = GlobalObject.PinYin.GetFirstPYLetter(billTypeName).Substring(0, 3).ToUpper();

            DateTime dt = ServerTime.Time;

            billNo = string.Format("{0}{1:D4}{2:D2}{3:D6}", billType.TypeCode, dt.Year, dt.Month, maxValue);

            Console.WriteLine("使用新分配的单据号:{0}", billNo);

            billInfo = new BASE_AssignBillNo();

            billInfo.AlreadyUse    = false;
            billInfo.AssignedDate  = ServerModule.ServerTime.Time;
            billInfo.Bill_No       = billNo;
            billInfo.Bill_TypeCode = billType.TypeCode;
            billInfo.IsAbandoned   = false;

            dataContxt.BASE_AssignBillNo.InsertOnSubmit(billInfo);

            dataContxt.SubmitChanges();

            return(billNo);
        }