当前位置: 首页>>代码示例>>C#>>正文


C# ObjectCriteria.AddSearchInCriteria方法代码示例

本文整理汇总了C#中ObjectCriteria.AddSearchInCriteria方法的典型用法代码示例。如果您正苦于以下问题:C# ObjectCriteria.AddSearchInCriteria方法的具体用法?C# ObjectCriteria.AddSearchInCriteria怎么用?C# ObjectCriteria.AddSearchInCriteria使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ObjectCriteria的用法示例。


在下文中一共展示了ObjectCriteria.AddSearchInCriteria方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Add

        public void Add(DepartmentStockIn data)
        {
            string deptStr = string.Format("{0:000}", data.DepartmentId);
            string dateStr = data.StockInDate.ToString("yyMMdd");
            var criteria = new ObjectCriteria();
            criteria.AddGreaterCriteria("StockoutId", (long)0);

            var maxId = StockOutDAO.SelectSpecificType(criteria, Projections.Max("StockoutId"));
            var stockOutId = maxId == null ? 1 : Int64.Parse(maxId.ToString()) + 1;

            //var stockInPk = new DepartmentStockInPK { DepartmentId = data.DepartmentId, StockInId = stockOutId + "" };

            //data.DepartmentStockInPK = stockInPk;
            data.CreateDate = DateTime.Now;
            data.UpdateDate = DateTime.Now;
            data.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
            data.CreateId = ClientInfo.getInstance().LoggedUser.Name;

            StockOut stockOut = new StockOut();
            stockOut.StockoutId = stockOutId;
            stockOut.CreateDate = DateTime.Now;
            stockOut.UpdateDate = DateTime.Now;
            stockOut.StockOutDate = DateTime.Now;
            stockOut.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
            stockOut.CreateId = ClientInfo.getInstance().LoggedUser.Name;
            stockOut.NotUpdateMainStock = false;
            stockOut.DefectStatus = new StockDefectStatus { DefectStatusId = 0};
            stockOut.DelFlg = 0;
            stockOut.DepartmentId = data.DepartmentId;

            // we will get the stock to get the data
            IList productMasterIds = new ArrayList();
            foreach (DepartmentStockInDetail stockInDetail in data.DepartmentStockInDetails)
            {
                productMasterIds.Add(stockInDetail.Product.ProductMaster.ProductMasterId);
            }
            IList productIds = new ArrayList();
            foreach (DepartmentStockInDetail stockInDetail in data.DepartmentStockInDetails)
            {
                productIds.Add(stockInDetail.Product.ProductId);
            }

            criteria = new ObjectCriteria();
            criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
            criteria.AddGreaterCriteria("Quantity", (long)0);
            //criteria.AddSearchInCriteria("ProductMaster.ProductMasterId", productMasterIds);
            criteria.AddSearchInCriteria("Product.ProductId", productIds);
            //criteria.AddOrder("ProductMaster.ProductMasterId", true);
            criteria.AddOrder("Product.ProductId", true);
            IList stockList = StockDAO.FindAll(criteria);

            IList updateStockList = new ArrayList();
            IList stockOutDetailList = new ArrayList();

            var maxSODetailId = StockOutDetailDAO.SelectSpecificType(new ObjectCriteria(), Projections.Max("StockOutDetailId"));
            long stockOutDetailId = (maxSODetailId == null ? 1 : Int64.Parse(maxSODetailId.ToString()) + 1);

            foreach (DepartmentStockInDetail stockInDetail in data.DepartmentStockInDetails)
            {
                long quantity = stockInDetail.Quantity;
                foreach (Stock stock in stockList)
                {
                    long stockInQty = 0;
                    //if (stock.ProductMaster.ProductMasterId.Equals(stockInDetail.Product.ProductMaster.ProductMasterId) && stock.Quantity > 0)
                    if (stock.Product.ProductId.Equals(stockInDetail.Product.ProductId) && stock.Quantity > 0)
                    {
                        if (quantity > stock.GoodQuantity)
                        {
                            throw new BusinessException("Mặt hàng: " + stock.ProductMaster.ProductName
                                + " - mã vạch: " + stock.Product.ProductId
                                + " không đủ hàng! Tồn: " + stockInDetail.StockQuantity + " , cần xuất: " + quantity);

                            stockInQty = stock.GoodQuantity;
                            quantity -= stock.GoodQuantity;
                            stock.GoodQuantity = 0;
                        }
                        else
                        {
                            stockInQty = quantity;
                            stock.GoodQuantity -= quantity;
                            quantity = 0;
                        }
                        stock.Quantity = stock.GoodQuantity + stock.ErrorQuantity + stock.DamageQuantity +
                                         stock.LostQuantity + stock.UnconfirmQuantity;
                        stock.UpdateDate = DateTime.Now;
                        stock.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                        updateStockList.Add(stock);

                        /*var pk = new StockOutDetailPK
                        {
                            //DepartmentId = data.DepartmentId,
                            ProductId = stock.Product.ProductId,
                            StockOutId = stockOutId
                        };*/

                        var detail = new StockOutDetail
                                         {
                                             //StockOutDetailPK = pk,
                            StockOutDetailId = stockOutDetailId++,
                            StockOutId = stockOutId,
//.........这里部分代码省略.........
开发者ID:DelLitt,项目名称:opmscoral,代码行数:101,代码来源:StockOutLogicImpl.cs

示例2: Update

        public void Update(StockOut stockOut)
        {
            int listCount = stockOut.StockOutDetails.Count;
            int delCount = 0;
            if(stockOut.ConfirmFlg == 1)
            {
                stockOut.NotUpdateMainStock = true;
            }
            var maxStockOutDetailIdStr = StockOutDetailDAO.SelectSpecificType(null, Projections.Max("StockOutDetailId"));
            long maxStockOutDetailId = maxStockOutDetailIdStr != null ? Int64.Parse(maxStockOutDetailIdStr.ToString()) : 0;
            maxStockOutDetailId = maxStockOutDetailId + 1;
            IList productIds = new ArrayList();
            foreach (StockOutDetail stockOutDetail in stockOut.StockOutDetails)
            {
                productIds.Add(stockOutDetail.Product.ProductId);
            }
            var criteria = new ObjectCriteria();
            criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
            criteria.AddSearchInCriteria("Product.ProductId", productIds);

            IList stockList = StockDAO.FindAll(criteria);
            foreach (StockOutDetail stockOutDetail in stockOut.StockOutDetails)
            {
                if (stockOutDetail.StockOutDetailId != 0)
                {
                    // if delete then delete it
                    if(stockOutDetail.DelFlg == 1)
                    {
                        StockOutDetailDAO.Delete(stockOutDetail);
                        delCount++;
                        continue;
                    }
                    // check number
                    var objectCriteria = new ObjectCriteria();
                    objectCriteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
                    objectCriteria.AddEqCriteria("Product.ProductId", stockOutDetail.Product.ProductId);

                    Stock stock = GetStock(stockOutDetail.Product.ProductId, stockList);
                    if (stock == null)
                    {
                        throw new BusinessException("Mặt hàng " + stockOutDetail.Product.ProductId + ", " +
                                                    stockOutDetail.Product.ProductFullName + " không có trong kho");
                    }

                    stockOutDetail.LostQuantity = 0;
                    stockOutDetail.UnconfirmQuantity = 0;

                    // xuất ra cửa hàng khác
                    if (stockOut.DefectStatus != null && stockOut.DefectStatus.DefectStatusId == 7)
                    {
                        stockOutDetail.Quantity = stockOutDetail.GoodQuantity;
                        stock.Quantity -= stockOutDetail.Quantity;

                        stockOutDetail.ErrorQuantity = 0;
                        stockOutDetail.DamageQuantity = 0;
                        stockOutDetail.LostQuantity = 0;
                        stockOutDetail.UnconfirmQuantity = 0;

                    }// xuất tạm
                    else if (stockOut.DefectStatus != null && stockOut.DefectStatus.DefectStatusId == 4)
                    {
                        // check whether it's has temp stockout enough ?

                        long totaltempErrorStockOut = 0;
                        long totalReStockCount = 0;

                        ObjectCriteria crit = new ObjectCriteria();
                        crit.AddEqCriteria("Product.ProductId", stockOutDetail.Product.ProductId)
                            .AddEqCriteria("DefectStatus.DefectStatusId", (long) 4)
                            .AddEqCriteria("DelFlg", (long) 0);
                        IList tempStockedOutList = StockOutDetailDAO.FindAll(crit);
                        if (tempStockedOutList != null)
                        {

                            foreach (StockOutDetail outDetail in tempStockedOutList)
                            {
                                totaltempErrorStockOut += outDetail.Quantity;
                            }

                        }

                        IList reStockList = StockInDetailDAO.FindReStock(stockOutDetail.Product.ProductId);
                        if (reStockList != null)
                        {
                            foreach (StockInDetail stockInDetail in reStockList)
                            {
                                totalReStockCount += stockInDetail.Quantity;
                            }
                        }
                        totaltempErrorStockOut = totaltempErrorStockOut - totalReStockCount;
                        if (stockOutDetail.ErrorQuantity > stock.ErrorQuantity - totaltempErrorStockOut)
                        {
                            throw new BusinessException("Lỗi: Mặt hàng " + stockOutDetail.Product.ProductFullName +
                                                        ", mã vạch "
                                                        + stockOutDetail.Product.ProductId + " có tồn " +
                                                        stock.ErrorQuantity + ", đã xuất tạm " + totaltempErrorStockOut +
                                                        ", và đang xuất " + stockOutDetail.ErrorQuantity);
                        }

                        // update quantity
//.........这里部分代码省略.........
开发者ID:DelLitt,项目名称:opmscoral,代码行数:101,代码来源:StockOutLogicImpl.cs

示例3: SyncToMain

        public void SyncToMain(SyncFromDepartmentToMain sync)
        {
            // insert department stock temp
            if(sync.DepartmentStockTempList!=null && sync.DepartmentStockTempList.Count > 0)
            {
                foreach (DepartmentStockTemp departmentStockTemp in sync.DepartmentStockTempList)
                {
                    bool failed = false;
                    if (departmentStockTemp != null)
                    {
                        DepartmentStockTemp curDeptTemp = DepartmentStockTempDAO.FindById(departmentStockTemp.DepartmentStockTempPK);
                        if (curDeptTemp == null)
                        {
                            DepartmentStockTempDAO.Add(departmentStockTemp);
                        }
                        else
                        {
                            if(departmentStockTemp.Fixed == 1 && departmentStockTemp.DelFlg == 1)
                            {
                                curDeptTemp.Fixed = 1;
                                curDeptTemp.DelFlg = 1;
                                DepartmentStockTempDAO.Update(curDeptTemp);
                            }
                        }
                    }
                }
            }
            // insert timeline
            if (sync.DepartmentTimelineList != null && sync.DepartmentTimelineList.Count > 0)
            {
                foreach (DepartmentTimeline timeline in sync.DepartmentTimelineList)
                {
                    bool failed = false;
                    if (timeline != null)
                    {
                        DepartmentTimeline curTimeline = DepartmentTimelineDAO.FindById(timeline.DepartmentTimelinePK);
                        if (curTimeline == null)
                        {
                            DepartmentTimelineDAO.Add(timeline);
                        }
                        else
                        {
                            // error
                            //failed = true;
                        }
                    }
                }
            }

            // insert PO, PO Detail
            if (sync.PurchaseOrderList != null && sync.PurchaseOrderList.Count > 0)
            {
                foreach (PurchaseOrder po in sync.PurchaseOrderList)
                {
                    PurchaseOrder poTemp = PurchaseOrderDAO.FindById(po.PurchaseOrderPK);
                    if (poTemp == null)
                    {
                        PurchaseOrderDAO.Add(po);
                        foreach (PurchaseOrderDetail detail in po.PurchaseOrderDetails)
                        {
                            PurchaseOrderDetailDAO.Add(detail);
                        }
                    }
                    else
                    {
                        // Error
                        //failed = true;
                    }
                }
            }

            // insert dept stock out
            if (sync.DepartmentStockOutList != null && sync.DepartmentStockOutList.Count > 0)
            {
                IList productIds = new ArrayList();
                foreach (DepartmentStockOut po in sync.DepartmentStockOutList)
                {
                    if (po.DefectStatus.DefectStatusId == StockDefectStatus.SEND_BACK_TO_MAIN)
                    {
                        foreach (DepartmentStockOutDetail detail in po.DepartmentStockOutDetails)
                        {
                            if (NotInList(productIds, detail.Product.ProductId))
                            {
                                productIds.Add(detail.Product.ProductId);
                            }
                        }
                    }
                }
                IList stockList = new ArrayList();
                ObjectCriteria criteria = new ObjectCriteria();
                criteria.AddSearchInCriteria("Product.ProductId", productIds);
                stockList = StockDAO.FindAll(criteria);

                StockOutMapper mapper = new StockOutMapper();
                StockOutDetailMapper detailMapper = new StockOutDetailMapper();
                DeptRetProdStockInMapper drpsiMapper = new DeptRetProdStockInMapper();
                DeptRetProdStockInDetailMapper drpsiDetMapper = new DeptRetProdStockInDetailMapper();

                // save to main.
                string dateStr = DateTime.Now.ToString("yyMMdd");
//.........这里部分代码省略.........
开发者ID:DelLitt,项目名称:opmscoral,代码行数:101,代码来源:DepartmentStockOutLogicImpl.cs

示例4: Delete

        public void Delete(ProductMaster data)
        {
            long deptId = CurrentDepartment.Get().DepartmentId;
            // delete product master
            ProductMaster master = ProductMasterDAO.FindById(data.ProductMasterId);
            if (master != null)
            {
                master.UpdateDate = DateTime.Now;
                master.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                master.DelFlg = 1;
                ProductMasterDAO.Update(master);
            }

            // delete product
            var criteria = new ObjectCriteria();
            criteria.AddEqCriteria("ProductMaster.ProductMasterId", data.ProductMasterId);
            criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
            IList products = ProductDAO.FindAll(criteria);
            IList productIds = new ArrayList();
            foreach (Product product in products)
            {
                product.UpdateDate = DateTime.Now;
                product.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                product.DelFlg = 1;
                ProductDAO.Update(product);
                productIds.Add(product.ProductId);
            }

            if (productIds.Count > 0)
            {
                // delete stock in detail
                criteria = new ObjectCriteria();
                criteria.AddEqCriteria("DepartmentStockInDetailPK.DepartmentId", deptId);
                criteria.AddSearchInCriteria("DepartmentStockInDetailPK.ProductId", productIds);
                IList stockInDetails = DepartmentStockInDetailDAO.FindAll(criteria);
                IList stockInIds = new ArrayList();
                foreach (DepartmentStockInDetail detail in stockInDetails)
                {
                    detail.UpdateDate = DateTime.Now;
                    detail.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                    detail.DelFlg = 1;
                    DepartmentStockInDetailDAO.Update(detail);
                    stockInIds.Add(detail.DepartmentStockInDetailPK.StockInId);
                }

                // delete stock in
                if (stockInIds.Count > 0)
                {
                    criteria = new ObjectCriteria();
                    criteria.AddEqCriteria("DepartmentStockInPK.DepartmentId", deptId);
                    criteria.AddSearchInCriteria("DepartmentStockInPK.StockInId", stockInIds);
                    IList stockIns = DepartmentStockInDAO.FindAll(criteria);
                    foreach (DepartmentStockIn stockIn in stockIns)
                    {
                        stockIn.UpdateDate = DateTime.Now;
                        stockIn.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                        stockIn.DelFlg = 1;
                        DepartmentStockInDAO.Update(stockIn);
                    }
                }

                // delete stock
                criteria = new ObjectCriteria();
                criteria.AddEqCriteria("DepartmentStockPK.DepartmentId", deptId);
                criteria.AddSearchInCriteria("DepartmentStockPK.ProductId", productIds);
                IList stocks = DepartmentStockDAO.FindAll(criteria);
                foreach (DepartmentStock stock in stocks)
                {
                    stock.UpdateDate = DateTime.Now;
                    stock.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                    stock.DelFlg = 1;
                    DepartmentStockDAO.Update(stock);
                }

                // delete purchase order detail
                criteria = new ObjectCriteria();
                criteria.AddEqCriteria("PurchaseOrderDetailPK.DepartmentId", deptId);
                criteria.AddEqCriteria("ProductMaster.ProductMasterId", data.ProductMasterId);
                IList purchaseOrderDetails = PurchaseOrderDetailDAO.FindAll(criteria);
                IList purchaseOrderIds = new ArrayList();
                foreach (PurchaseOrderDetail detail in purchaseOrderDetails)
                {
                    detail.UpdateDate = DateTime.Now;
                    detail.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                    detail.DelFlg = 1;
                    PurchaseOrderDetailDAO.Update(detail);
                    purchaseOrderIds.Add(detail.PurchaseOrderDetailPK.PurchaseOrderId);
                }

                // delete purchase order
                if (purchaseOrderIds.Count > 0)
                {
                    criteria = new ObjectCriteria();
                    criteria.AddEqCriteria("PurchaseOrderPK.DepartmentId", deptId);
                    criteria.AddSearchInCriteria("PurchaseOrderPK.PurchaseOrderId", purchaseOrderIds);
                    IList purchaseOrders = PurchaseOrderDAO.FindAll(criteria);
                    foreach (PurchaseOrder po in purchaseOrders)
                    {
                        po.UpdateDate = DateTime.Now;
                        po.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
//.........这里部分代码省略.........
开发者ID:DelLitt,项目名称:opmscoral,代码行数:101,代码来源:ProductMasterLogicImpl.cs

示例5: Add


//.........这里部分代码省略.........

                detail.CreateDate = DateTime.Now;
                detail.UpdateDate = DateTime.Now;
                detail.CreateId = ClientInfo.getInstance().LoggedUser.Name;
                detail.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                var purchaseOrderDetailPk = new PurchaseOrderDetailPK{DepartmentId = CurrentDepartment.Get().DepartmentId, PurchaseOrderId = purchaseOrderId, PurchaseOrderDetailId = id++};
                detail.PurchaseOrderDetailPK = purchaseOrderDetailPk;
                detail.PurchaseOrder = data;
                PurchaseOrderDetailDAO.Add(detail);

                // create Receipt.
            }

            // if departmentstock needs update
            if(stockList.Keys.Count > 0)
            {
                IList departmentStockViewList = new ArrayList();
                // get stock by product master
                foreach (string productId in stockList.Keys)
                {
                    if(!InDepartmentStockViewList(departmentStockViewList,productId))
                    {
                        Product searchProduct = productList[productId];
                        ObjectCriteria pmCrit = new ObjectCriteria();
                        pmCrit.AddEqCriteria("ProductMaster.ProductMasterId", searchProduct.ProductMaster.ProductMasterId);
                        IList list = ProductDAO.FindAll(pmCrit);

                        IList searchPrdIds = new ArrayList();
                        foreach (Product product in list)
                        {
                            searchPrdIds.Add(product.ProductId);
                        }
                        ObjectCriteria crit = new ObjectCriteria();
                        crit.AddSearchInCriteria("DepartmentStockPK.ProductId", searchPrdIds);
                        IList deptStockList = DepartmentStockDAO.FindAll(crit);

                        DepartmentStockView stockView = new DepartmentStockView();
                        stockView.ProductMaster = searchProduct.ProductMaster;
                        SortByProductId(deptStockList);
                        stockView.DepartmentStocks = deptStockList;
                        departmentStockViewList.Add(stockView);
                    }
                }

                foreach (string productId in stockList.Keys)
                {
                    /*ObjectCriteria crit = new ObjectCriteria();
                    crit.AddEqCriteria("DepartmentStockPK.ProductId", productId);
                    IList list = DepartmentStockDAO.FindAll(crit);
                    if(list!=null && list.Count == 1)
                    {
                        DepartmentStock stock = (DepartmentStock) list[0];
                        stock.GoodQuantity += stockList[productId];
                        if (stock.GoodQuantity < 0)
                        {
                            // strange
                            throw new BusinessException("Số lượng trong kho không đáp ứng đủ số lượng bán cho sản phẩm có mã vạch: " + productId);
                        }
                        stock.Quantity += stockList[productId];
                        DepartmentStockDAO.Update(stock);
                    }
                    else
                    {
                        throw new DataLayerException(" Dữ liệu không đồng nhất");
                    }*/
                    if(InDepartmentStockViewList(departmentStockViewList,productId))
开发者ID:DelLitt,项目名称:opmscoral,代码行数:67,代码来源:PurchaseOrderLogicImpl.cs

示例6: Add

        public DepartmentStockOut Add(DepartmentStockOut stockOut)
        {
            stockOut.CreateDate = DateTime.Now;
            stockOut.CreateId = ClientInfo.getInstance().LoggedUser.Name;
            stockOut.UpdateDate = DateTime.Now;
            stockOut.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
            stockOut.DelFlg = 0;
            stockOut.StockOutDate = DateTime.Now;
            long maxStockOutId = this.FindMaxId();
            maxStockOutId = maxStockOutId + 1;

            stockOut.DepartmentStockOutPK = new DepartmentStockOutPK();
            stockOut.DepartmentStockOutPK.StockOutId = maxStockOutId;
            stockOut.DepartmentStockOutPK.DepartmentId = CurrentDepartment.Get().DepartmentId;

            DepartmentStockOutDAO.Add(stockOut);
            var maxStockOutDetailIdStr = DepartmentStockOutDetailDAO.SelectSpecificType(null, Projections.Max("DepartmentStockOutDetailPK.StockOutDetailId"));
            long maxStockOutDetailId = maxStockOutDetailIdStr != null ? Int64.Parse(maxStockOutDetailIdStr.ToString()) : 0;
            maxStockOutDetailId = maxStockOutDetailId + 1;
            IList productIds = new ArrayList();
            foreach (DepartmentStockOutDetail stockOutDetail in stockOut.DepartmentStockOutDetails)
            {
                productIds.Add(stockOutDetail.Product.ProductId);
            }

            var criteria = new ObjectCriteria();
            criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
            criteria.AddEqCriteria("DepartmentStockPK.DepartmentId", CurrentDepartment.Get().DepartmentId);
            criteria.AddSearchInCriteria("Product.ProductId", productIds);
            IList stockList = DepartmentStockDAO.FindAll(criteria);
            foreach (DepartmentStockOutDetail stockOutDetail in stockOut.DepartmentStockOutDetails)
            {
                // check number
                var objectCriteria = new ObjectCriteria();
                objectCriteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
                objectCriteria.AddEqCriteria("Product.ProductId", stockOutDetail.Product.ProductId);
                DepartmentStock stock = GetStock(stockOutDetail.Product.ProductId, stockList);
                stockOutDetail.LostQuantity = 0;
                stockOutDetail.UnconfirmQuantity = 0;
                if (stockOutDetail.DefectStatus != null)
                {
                    // xuất qua cửa hàng khác
                    if (stockOutDetail.DefectStatus.DefectStatusId == 7)
                    {
                        stockOutDetail.Quantity = stockOutDetail.GoodQuantity;
                        stock.Quantity -= stockOutDetail.Quantity;
                        stock.GoodQuantity -= stockOutDetail.GoodQuantity;

                        stockOutDetail.ErrorQuantity = 0;
                        stockOutDetail.DamageQuantity = 0;
                        stockOutDetail.UnconfirmQuantity = 0;
                        stockOutDetail.LostQuantity = 0;
                    }
                    // xuất tạm để sửa
                    else if (stockOutDetail.DefectStatus.DefectStatusId == 4)
                    {
                        stockOutDetail.Quantity = stockOutDetail.ErrorQuantity;

                        //stockOutDetail.ErrorQuantity = 0;
                        stockOutDetail.GoodQuantity = 0;
                        stockOutDetail.LostQuantity = 0;
                        stockOutDetail.UnconfirmQuantity = 0;

                        // check whether it's has temp stockout enough ?

                        long totaltempErrorStockOut = 0;
                        long totalReStockCount = 0;

                        ObjectCriteria crit = new ObjectCriteria();
                        crit.AddEqCriteria("Product.ProductId", stockOutDetail.Product.ProductId)
                            .AddEqCriteria("DefectStatus.DefectStatusId", (long)4)
                            .AddEqCriteria("DelFlg", (long)0);
                        IList tempStockedOutList = DepartmentStockOutDetailDAO.FindAll(crit);
                        if (tempStockedOutList != null)
                        {

                            foreach (DepartmentStockOutDetail outDetail in tempStockedOutList)
                            {
                                totaltempErrorStockOut += outDetail.Quantity;
                            }

                        }

                        IList reStockList = DepartmentStockInDetailDAO.FindReStock(stockOutDetail.Product.ProductId);
                        if (reStockList != null)
                        {
                            foreach (DepartmentStockInDetail stockInDetail in reStockList)
                            {
                                totalReStockCount += stockInDetail.Quantity;
                            }
                        }
                        totaltempErrorStockOut = totaltempErrorStockOut - totalReStockCount;
                        if (stockOutDetail.ErrorQuantity > stock.ErrorQuantity - totaltempErrorStockOut)
                        {
                            throw new BusinessException("Lỗi: Mặt hàng " + stockOutDetail.Product.ProductFullName + ", mã vạch "
                                           + stockOutDetail.Product.ProductId + " có tồn " + stock.ErrorQuantity + ", đã xuất tạm " + totaltempErrorStockOut +
                                           ", và đang xuất " + stockOutDetail.ErrorQuantity);
                        }
                    }
                    // xuất trả về kho chính
//.........这里部分代码省略.........
开发者ID:DelLitt,项目名称:opmscoral,代码行数:101,代码来源:DepartmentStockOutLogicImpl.cs

示例7: Sync


//.........这里部分代码省略.........
                    if (!productIds.Contains(detail.Product.ProductId))
                    {
                        productIds.Add(detail.Product.ProductId);
                        quantityList.Add(detail.Quantity);
                    }

                    DepartmentStockInDetail DepartmentStockInDetail =
                        DepartmentStockInDetailDAO.FindById(detail.DepartmentStockInDetailPK);
                    if (DepartmentStockInDetail == null)
                    {
                        DepartmentStockInDetailDAO.Add(detail);
                    }
                    else
                    {
                        DepartmentStockInDetail.UpdateDate = detail.UpdateDate;
                        DepartmentStockInDetail.UpdateId = detail.UpdateId;
                        DepartmentStockInDetail.CreateDate = detail.CreateDate;
                        DepartmentStockInDetail.CreateId = detail.CreateId;
                        DepartmentStockInDetail.Quantity = DepartmentStockInDetail.Quantity;
                        DepartmentStockInDetail.Price = DepartmentStockInDetail.Price;

                        DepartmentStockInDetailDAO.Update(DepartmentStockInDetail);
                    }
                }

                // update price
                if (productMasterIds.Count > 0)
                {
                    /*IList NotDupPMList = new ArrayList();
                    NotDupPMList = CreateNotDuplicateList(productMasterIds);*/
                    var objectCriteria = new ObjectCriteria();
                    objectCriteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
                    objectCriteria.AddEqCriteria("DepartmentPricePK.DepartmentId", (long)0);
                    objectCriteria.AddSearchInCriteria("DepartmentPricePK.ProductMasterId", productMasterIds);
                    IList deptPriceList = DepartmentPriceDAO.FindAll(objectCriteria);
                    int i = 0;
                    IList newPriceList = new ArrayList();
                    foreach (string productMasterId in productMasterIds)
                    {
                        DepartmentPrice price = null;
                        bool found = false;
                        foreach (DepartmentPrice price1 in deptPriceList)
                        {
                            if (price1.DepartmentPricePK.ProductMasterId.Equals(productMasterId))
                            {
                                //price = price1;
                                found = true;
                                price1.Price = (Int64)priceList[i];
                                price1.WholeSalePrice = (Int64) whosalePriceList[i];
                                break;
                            }
                        }
                        if (!found)
                        {
                            foreach (DepartmentPrice price1 in newPriceList)
                            {
                                if (price1.DepartmentPricePK.ProductMasterId.Equals(productMasterId))
                                {
                                    //price = price1;
                                    found = true;
                                    price1.Price = (Int64) priceList[i];
                                    price1.WholeSalePrice = (Int64) whosalePriceList[i];
                                    break;
                                }
                            }
                        }
开发者ID:DelLitt,项目名称:opmscoral,代码行数:67,代码来源:DepartmentStockInLogicImpl.cs

示例8: Add


//.........这里部分代码省略.........

                detail.CreateDate = DateTime.Now;
                detail.UpdateDate = DateTime.Now;
                detail.CreateId = ClientInfo.getInstance().LoggedUser.Name;
                detail.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                var purchaseOrderDetailPk = new PurchaseOrderDetailPK{DepartmentId = CurrentDepartment.Get().DepartmentId, PurchaseOrderId = purchaseOrderId, PurchaseOrderDetailId = id++};
                detail.PurchaseOrderDetailPK = purchaseOrderDetailPk;
                detail.PurchaseOrder = data;
                PurchaseOrderDetailDAO.Add(detail);

                // create Receipt.
            }

            // if departmentstock needs update
            if(stockList.Keys.Count > 0)
            {
                IList departmentStockViewList = new ArrayList();
                // get stock by product master
                foreach (string productId in stockList.Keys)
                {
                    if(!InDepartmentStockViewList(departmentStockViewList,productId))
                    {
                        Product searchProduct = productList[productId];
                        ObjectCriteria pmCrit = new ObjectCriteria();
                        pmCrit.AddEqCriteria("ProductMaster.ProductMasterId", searchProduct.ProductMaster.ProductMasterId);
                        IList list = ProductDAO.FindAll(pmCrit);

                        IList searchPrdIds = new ArrayList();
                        foreach (Product product in list)
                        {
                            searchPrdIds.Add(product.ProductId);
                        }
                        ObjectCriteria crit = new ObjectCriteria();
                        crit.AddSearchInCriteria("DepartmentStockPK.ProductId", searchPrdIds);
                        IList deptStockList = DepartmentStockDAO.FindAll(crit);

                        DepartmentStockView stockView = new DepartmentStockView();
                        stockView.ProductMaster = searchProduct.ProductMaster;
                        ((ArrayList)deptStockList).Sort();
                        stockView.DepartmentStocks = deptStockList;
                        departmentStockViewList.Add(stockView);
                    }
                }

                bool allowTempNegativeSelling = false;
                // slide id selling
                foreach (string productId in stockList.Keys)
                {

                    if(InDepartmentStockViewList(departmentStockViewList,productId))
                    {

                        // get origin product id and minus first
                        DepartmentStockView view = GetDepartmentStockViewList(departmentStockViewList, productId);
                        long updateQty = stockList[productId];
                        long originUpdateQty = updateQty;
                        DepartmentStock departmentStock = GetDepartmentStockFromView(view, productId);
                        // if stock has been negative
                        if (departmentStock.GoodQuantity <= 0)
                        {
                            // FIX : Using negative update setting
                            // accept negative quantity and process later
                            if (ClientSetting.NegativeSelling)
                            {
                                departmentStock.GoodQuantity += updateQty;
                                departmentStock.Quantity += updateQty;
开发者ID:DelLitt,项目名称:opmscoral,代码行数:67,代码来源:PurchaseOrderLogicImpl.cs

示例9: AddStockInBack

        public void AddStockInBack(DepartmentStockIn data)
        {
            long deptId = data.DepartmentStockInPK.DepartmentId;
            string deptStr = "000";
            if (deptId > 9999)
            {
                deptStr = deptId.ToString();
            }
            else
            {
                deptStr = string.Format("{0:000}", data.DepartmentStockInPK.DepartmentId);
            }
            string dateStr = data.StockInDate.ToString("yyMMdd");
            var criteria = new ObjectCriteria();
            string extraZero = "00000";
            if(deptId > 9999)
            {
                extraZero = "000";
            }
            criteria.AddGreaterCriteria("DepartmentStockInPK.StockInId", dateStr + deptStr + extraZero);
            var maxId = DepartmentStockInDAO.SelectSpecificType(criteria,
                                                                Projections.Max("DepartmentStockInPK.StockInId"));
            string startNum = "00001";
            if(deptId > 9999)
            {
                startNum = "001";
            }
            var stockInId = maxId == null
                                ? dateStr + deptStr + startNum
                                : string.Format("{0:00000000000000}", (Int64.Parse(maxId.ToString()) + 1));

            var stockInPk = new DepartmentStockInPK {DepartmentId = deptId, StockInId = stockInId + ""};

            data.DepartmentStockInPK = stockInPk;
            data.CreateDate = DateTime.Now;
            data.UpdateDate = DateTime.Now;
            data.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
            data.CreateId = ClientInfo.getInstance().LoggedUser.Name;
            DepartmentStockInDAO.Add(data);

            // we will get the stock to get the data
            IList productMasterIds = new ArrayList();
            IList productIds = new ArrayList();
            foreach (DepartmentStockInDetail stockInDetail in data.DepartmentStockInDetails)
            {
                productIds.Add(stockInDetail.Product.ProductId);
            }

            criteria = new ObjectCriteria();
            criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
            criteria.AddSearchInCriteria("DepartmentStockPK.ProductId", productIds);
            criteria.AddOrder("Product.ProductId", true);
            IList stockList = DepartmentStockDAO.FindAll(criteria);

            IList updateStockList = new ArrayList();
            IList stockInDetailList = new ArrayList();
            foreach (DepartmentStockInDetail stockInDetail in data.DepartmentStockInDetails)
            {
                long quantity = stockInDetail.Quantity;
                DepartmentStockPK stockPk = new DepartmentStockPK
                                                {
                                                    DepartmentId = deptId,
                                                    ProductId = stockInDetail.Product.ProductId
                                                };
                DepartmentStock departmentStock = DepartmentStockDAO.FindById(stockPk);

                if (departmentStock.DepartmentStockPK.ProductId.Equals(stockInDetail.Product.ProductId))
                {
                        departmentStock.GoodQuantity += stockInDetail.Quantity;
                        departmentStock.Quantity += stockInDetail.Quantity;
                        departmentStock.UpdateDate = DateTime.Now;
                        departmentStock.UpdateId = ClientInfo.getInstance().LoggedUser.Name;

                        DepartmentStockDAO.Update(departmentStock);

                        var pk = new DepartmentStockInDetailPK
                                     {
                                         DepartmentId = data.DepartmentStockInPK.DepartmentId,
                                         ProductId = departmentStock.Product.ProductId,
                                         StockInId = stockInId
                                     };
                        stockInDetail.DepartmentStockInDetailPK = pk;
                        DepartmentStockInDetailDAO.Add(stockInDetail);
                }
            }
        }
开发者ID:DelLitt,项目名称:opmscoral,代码行数:86,代码来源:DepartmentStockInLogicImpl.cs

示例10: Add

        public DepartmentStockIn Add(DepartmentStockIn data)
        {
            string deptStr = "";
            if(ClientSetting.IsSubStock())
            {
                deptStr = string.Format("{0:00000}", data.DepartmentStockInPK.DepartmentId);
            }
            else
            {
                deptStr = string.Format("{0:000}", data.DepartmentStockInPK.DepartmentId);
            }

            string dateStr = data.StockInDate.ToString("yyMMdd");
            var criteria = new ObjectCriteria();
            if(ClientSetting.IsSubStock())
            {
                criteria.AddGreaterCriteria("DepartmentStockInPK.StockInId", dateStr + deptStr + "000");
            }
            else
            {
                criteria.AddGreaterCriteria("DepartmentStockInPK.StockInId", dateStr + deptStr + "00000");
            }

            var maxId = DepartmentStockInDAO.SelectSpecificType(criteria, Projections.Max("DepartmentStockInPK.StockInId"));
            string stockInId = "";
            if(ClientSetting.IsSubStock())
            {
                stockInId = maxId == null ? dateStr + deptStr + "001" :   string.Format("{0:00000000000000}", (Int64.Parse(maxId.ToString()) + 1));
            }
            else
            {
                stockInId = maxId == null ? dateStr + deptStr + "00001" : string.Format("{0:00000000000000}", (Int64.Parse(maxId.ToString()) + 1));
            }

            var stockInPk = new DepartmentStockInPK {DepartmentId = data.DepartmentId, StockInId = stockInId + ""};

            data.DepartmentStockInPK = stockInPk;
            data.CreateDate = DateTime.Now;
            data.UpdateDate = DateTime.Now;
            data.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
            data.CreateId = ClientInfo.getInstance().LoggedUser.Name;
            DepartmentStockInDAO.Add(data);

            // we will get the stock to get the data
            IList productMasterIds = new ArrayList();
            foreach (DepartmentStockInDetail stockInDetail in data.DepartmentStockInDetails)
            {
                productMasterIds.Add(stockInDetail.Product.ProductMaster.ProductMasterId);
            }

            criteria = new ObjectCriteria();
            criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
            criteria.AddGreaterCriteria("Quantity", (long)0);
            criteria.AddSearchInCriteria("ProductMaster.ProductMasterId", productMasterIds);
            criteria.AddOrder("ProductMaster.ProductMasterId", true);
            criteria.AddOrder("Product.ProductId", true);
            IList stockList = DepartmentStockDAO.FindAll(criteria);

            IList updateStockList = new ArrayList();
            IList stockInDetailList = new ArrayList();
            foreach (DepartmentStockInDetail stockInDetail in data.DepartmentStockInDetails)
            {
                long quantity = stockInDetail.Quantity;
                foreach (DepartmentStock stock in stockList)
                {
                    long stockInQty = 0;
                   if (stock.Product.ProductId.Equals(stockInDetail.ProductId) && stock.Quantity >= 0)
                    {
                        /*if (quantity >= stock.Quantity)
                        {
                            stockInQty = stock.Quantity;
                            quantity -= stock.Quantity;
                            stock.Quantity = 0;
                        }
                        else
                        {
                            stockInQty = quantity;
                            stock.Quantity -= quantity;
                            quantity = 0;
                        }*/
                        if (quantity >= stock.GoodQuantity)
                        {
                            stockInQty = stock.GoodQuantity;
                            quantity -= stock.GoodQuantity;
                            stock.GoodQuantity = 0;
                        }
                        else
                        {
                            stockInQty = quantity;
                            stock.GoodQuantity -= quantity;
                            quantity = 0;
                        }
                        stock.Quantity = stock.GoodQuantity + stock.ErrorQuantity + stock.DamageQuantity +
                                         stock.LostQuantity + stock.UnconfirmQuantity;
                        stock.UpdateDate = DateTime.Now;
                        stock.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                        updateStockList.Add(stock);
                        var pk = new DepartmentStockInDetailPK
                                   {
                                       DepartmentId = data.DepartmentId,
//.........这里部分代码省略.........
开发者ID:DelLitt,项目名称:opmscoral,代码行数:101,代码来源:DepartmentStockInLogicImpl.cs

示例11: SyncFromSubStock


//.........这里部分代码省略.........
                        ProductDAO.Update(Product);*/
                    }

                    if (!productIds.Contains(detail.Product.ProductId))
                    {
                        productIds.Add(detail.Product.ProductId);
                        quantityList.Add(detail.Quantity);
                    }

                    DepartmentStockInDetail DepartmentStockInDetail =
                        DepartmentStockInDetailDAO.FindById(detail.DepartmentStockInDetailPK);
                    if (DepartmentStockInDetail == null)
                    {
                        DepartmentStockInDetailDAO.Add(detail);
                    }
                    else
                    {
                        /*DepartmentStockInDetail.UpdateDate = detail.UpdateDate;
                        DepartmentStockInDetail.UpdateId = detail.UpdateId;
                        DepartmentStockInDetail.CreateDate = detail.CreateDate;
                        DepartmentStockInDetail.CreateId = detail.CreateId;
                        DepartmentStockInDetail.Quantity = DepartmentStockInDetail.Quantity;
                        DepartmentStockInDetail.Price = DepartmentStockInDetail.Price;
                        DepartmentStockInDetailDAO.Update(DepartmentStockInDetail);*/
                    }
                }

                // update price
                if (productMasterIds.Count > 0)
                {
                    var criteria = new ObjectCriteria();
                    criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
                    criteria.AddEqCriteria("DepartmentPricePK.DepartmentId", (long)0);
                    criteria.AddSearchInCriteria("DepartmentPricePK.ProductMasterId", productMasterIds);
                    IList deptPriceList = DepartmentPriceDAO.FindAll(criteria);
                    int i = 0;
                    foreach (string productMasterId in productMasterIds)
                    {
                        DepartmentPrice price = null;
                        foreach (DepartmentPrice price1 in deptPriceList)
                        {
                            if (price1.DepartmentPricePK.ProductMasterId.Equals(productMasterId))
                            {
                                price = price1;
                                price.Price = (Int64)priceList[i];
                                break;
                            }
                        }
                        if (price == null)
                        {
                            price = new DepartmentPrice
                            {
                                DepartmentPricePK = new DepartmentPricePK { DepartmentId = 0, ProductMasterId = productMasterId },
                                Price = (Int64)priceList[i],
                                CreateDate = DateTime.Now,
                                CreateId = ClientInfo.getInstance().LoggedUser.Name,
                                UpdateDate = DateTime.Now,
                                UpdateId = ClientInfo.getInstance().LoggedUser.Name
                            };
                            DepartmentPriceDAO.Add(price);
                        }
                        else
                        {
                            price.UpdateDate = DateTime.Now;
                            price.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                            DepartmentPriceDAO.Update(price);
开发者ID:DelLitt,项目名称:opmscoral,代码行数:67,代码来源:DepartmentStockInLogicImpl.cs

示例12: SyncToMain

        public void SyncToMain(SyncFromDepartmentToMain sync)
        {
            // insert department stock temp
            if(sync.DepartmentStockTempList!=null && sync.DepartmentStockTempList.Count > 0)
            {
                foreach (DepartmentStockTemp departmentStockTemp in sync.DepartmentStockTempList)
                {
                    bool failed = false;
                    if (departmentStockTemp != null)
                    {
                        DepartmentStockTemp curDeptTemp = DepartmentStockTempDAO.FindById(departmentStockTemp.DepartmentStockTempPK);
                        if (curDeptTemp == null)
                        {
                            DepartmentStockTempDAO.Add(departmentStockTemp);
                        }
                        else
                        {
                            if(departmentStockTemp.Fixed == 1 && departmentStockTemp.DelFlg == 1)
                            {
                                curDeptTemp.Fixed = 1;
                                curDeptTemp.DelFlg = 1;
                                DepartmentStockTempDAO.Update(curDeptTemp);
                            }
                        }
                    }
                }
            }
            // insert timeline
            if (sync.DepartmentTimelineList != null && sync.DepartmentTimelineList.Count > 0)
            {
                foreach (DepartmentTimeline timeline in sync.DepartmentTimelineList)
                {
                    bool failed = false;
                    if (timeline != null)
                    {
                        DepartmentTimeline curTimeline = DepartmentTimelineDAO.FindById(timeline.DepartmentTimelinePK);
                        if (curTimeline == null)
                        {
                            DepartmentTimelineDAO.Add(timeline);
                        }
                        else
                        {
                            // error
                            //failed = true;
                        }
                    }
                }
            }

            // insert PO, PO Detail
            if (sync.PurchaseOrderList != null && sync.PurchaseOrderList.Count > 0)
            {
                foreach (PurchaseOrder po in sync.PurchaseOrderList)
                {
                    PurchaseOrder poTemp = PurchaseOrderDAO.FindById(po.PurchaseOrderPK);
                    if (poTemp == null)
                    {
                        PurchaseOrderDAO.Add(po);
                        foreach (PurchaseOrderDetail detail in po.PurchaseOrderDetails)
                        {
                            PurchaseOrderDetailDAO.Add(detail);
                        }
                    }
                    else
                    {
                        // Error
                        //failed = true;
                    }
                }
            }

            // insert dept stock out
            if (sync.DepartemntStockOutList != null && sync.DepartemntStockOutList.Count > 0)
            {
                foreach (DepartmentStockOut po in sync.DepartemntStockOutList)
                {
                    IList productIds = new ArrayList();
                    IList stockList = null;
                    if (po.DefectStatus.DefectStatusId == StockDefectStatus.SEND_BACK_TO_MAIN)
                    {
                        foreach (DepartmentStockOutDetail detail in po.DepartmentStockOutDetails)
                        {
                            productIds.Add(detail.Product.ProductId);
                        }
                        ObjectCriteria criteria = new ObjectCriteria();
                        criteria.AddSearchInCriteria("Product.ProductId", productIds);
                        stockList = StockDAO.FindAll(criteria);
                    }
                    DepartmentStockOut poTemp = DepartmentStockOutDAO.FindById(po.DepartmentStockOutPK);
                    if (poTemp == null)
                    {
                        po.StockOutDate = DateTime.Now;
                        DepartmentStockOutDAO.Add(po);

                        foreach (DepartmentStockOutDetail detail in po.DepartmentStockOutDetails)
                        {
                            DepartmentStockOutDetailDAO.Add(detail);

                            // update stock if it's a dept stock out return to main ( defectstatus = 6 )
                            if (po.DefectStatus.DefectStatusId == StockDefectStatus.SEND_BACK_TO_MAIN
//.........这里部分代码省略.........
开发者ID:DelLitt,项目名称:opmscoral,代码行数:101,代码来源:DepartmentStockOutLogicImpl.cs

示例13: Sync


//.........这里部分代码省略.........
                    }

                    if (!productIds.Contains(detail.Product.ProductId))
                    {
                        productIds.Add(detail.Product.ProductId);
                        quantityList.Add(detail.Quantity);
                    }

                    DepartmentStockInDetail DepartmentStockInDetail =
                        DepartmentStockInDetailDAO.FindById(detail.DepartmentStockInDetailPK);
                    if (DepartmentStockInDetail == null)
                    {
                        DepartmentStockInDetailDAO.Add(detail);
                    }
                    else
                    {
                        DepartmentStockInDetail.UpdateDate = detail.UpdateDate;
                        DepartmentStockInDetail.UpdateId = detail.UpdateId;
                        DepartmentStockInDetail.CreateDate = detail.CreateDate;
                        DepartmentStockInDetail.CreateId = detail.CreateId;
                        DepartmentStockInDetail.Quantity = DepartmentStockInDetail.Quantity;
                        DepartmentStockInDetail.Price = DepartmentStockInDetail.Price;

                        DepartmentStockInDetailDAO.Update(DepartmentStockInDetail);
                    }
                }

                // update price
                if (productMasterIds.Count > 0)
                {
                    var objectCriteria = new ObjectCriteria();
                    objectCriteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
                    objectCriteria.AddEqCriteria("DepartmentPricePK.DepartmentId", (long)0);
                    objectCriteria.AddSearchInCriteria("DepartmentPricePK.ProductMasterId", productMasterIds);
                    IList deptPriceList = DepartmentPriceDAO.FindAll(objectCriteria);
                    int i = 0;
                    foreach (string productMasterId in productMasterIds)
                    {
                        DepartmentPrice price = null;
                        foreach (DepartmentPrice price1 in deptPriceList)
                        {
                            if (price1.DepartmentPricePK.ProductMasterId.Equals(productMasterId))
                            {
                                price = price1;
                                price.Price = (Int64)priceList[i];
                                break;
                            }
                        }
                        if (price == null)
                        {
                            price = new DepartmentPrice
                            {
                                DepartmentPricePK = new DepartmentPricePK { DepartmentId = 0, ProductMasterId = productMasterId },
                                Price = (Int64)priceList[i],
                                CreateDate = DateTime.Now,
                                CreateId = ClientInfo.getInstance().LoggedUser.Name,
                                UpdateDate = DateTime.Now,
                                UpdateId = ClientInfo.getInstance().LoggedUser.Name
                            };
                            DepartmentPriceDAO.Add(price);
                        }
                        else
                        {
                            price.UpdateDate = DateTime.Now;
                            price.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                            DepartmentPriceDAO.Update(price);
开发者ID:DelLitt,项目名称:opmscoral,代码行数:67,代码来源:DepartmentStockInLogicImpl.cs

示例14: Add

        public void Add(DepartmentStockIn data)
        {
            string deptStr = string.Format("{0:000}", data.DepartmentId);
            string dateStr = data.StockInDate.ToString("yyMMdd");
            var criteria = new ObjectCriteria();
            criteria.AddGreaterCriteria("StockoutId", (long)0);

            var maxId = StockOutDAO.SelectSpecificType(criteria, Projections.Max("StockoutId"));
            var stockOutId = maxId == null ? 1 : Int64.Parse(maxId.ToString()) + 1;

            //var stockInPk = new DepartmentStockInPK { DepartmentId = data.DepartmentId, StockInId = stockOutId + "" };

            //data.DepartmentStockInPK = stockInPk;
            data.CreateDate = DateTime.Now;
            data.UpdateDate = DateTime.Now;
            data.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
            data.CreateId = ClientInfo.getInstance().LoggedUser.Name;

            StockOut stockOut = new StockOut();
            stockOut.StockoutId = stockOutId;
            stockOut.CreateDate = DateTime.Now;
            stockOut.UpdateDate = DateTime.Now;
            stockOut.StockOutDate = DateTime.Now;
            stockOut.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
            stockOut.CreateId = ClientInfo.getInstance().LoggedUser.Name;
            stockOut.NotUpdateMainStock = false;
            stockOut.DefectStatus = new StockDefectStatus { DefectStatusId = 0};
            stockOut.DelFlg = 0;
            stockOut.DepartmentId = data.DepartmentId;

            // we will get the stock to get the data
            IList productMasterIds = new ArrayList();
            foreach (DepartmentStockInDetail stockInDetail in data.DepartmentStockInDetails)
            {
                productMasterIds.Add(stockInDetail.Product.ProductMaster.ProductMasterId);
            }

            criteria = new ObjectCriteria();
            criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
            criteria.AddGreaterCriteria("Quantity", (long)0);
            criteria.AddSearchInCriteria("ProductMaster.ProductMasterId", productMasterIds);
            criteria.AddOrder("ProductMaster.ProductMasterId", true);
            criteria.AddOrder("Product.ProductId", true);
            IList stockList = StockDAO.FindAll(criteria);

            IList updateStockList = new ArrayList();
            IList stockOutDetailList = new ArrayList();

            var maxSODetailId = StockOutDetailDAO.SelectSpecificType(new ObjectCriteria(), Projections.Max("StockOutDetailId"));
            long stockOutDetailId = (maxSODetailId == null ? 1 : Int64.Parse(maxSODetailId.ToString()) + 1);

            /*if(stockOutIds!= null && ((long)stockOutIds) > 0)
            {
                stockOutDetailId = (long) stockOutIds + 1;
            }
            MessageBox.Show(stockOutDetailId)*/
            /*if (stockOutIds != null && 1 == ((IList)stockOutIds).Count)
            {
                stockOutDetailId = (long)((IList)stockOutIds)[0] + 1;
            }*/

            foreach (DepartmentStockInDetail stockInDetail in data.DepartmentStockInDetails)
            {
                long quantity = stockInDetail.Quantity;
                foreach (Stock stock in stockList)
                {
                    long stockInQty = 0;
                    if (stock.ProductMaster.ProductMasterId.Equals(stockInDetail.Product.ProductMaster.ProductMasterId) && stock.Quantity > 0)
                    {
                        if (quantity >= stock.GoodQuantity)
                        {
                            stockInQty = stock.GoodQuantity;
                            quantity -= stock.GoodQuantity;
                            stock.GoodQuantity = 0;
                        }
                        else
                        {
                            stockInQty = quantity;
                            stock.GoodQuantity -= quantity;
                            quantity = 0;
                        }
                        stock.Quantity = stock.GoodQuantity + stock.ErrorQuantity + stock.DamageQuantity +
                                         stock.LostQuantity + stock.UnconfirmQuantity;
                        stock.UpdateDate = DateTime.Now;
                        stock.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                        updateStockList.Add(stock);

                        /*var pk = new StockOutDetailPK
                        {
                            //DepartmentId = data.DepartmentId,
                            ProductId = stock.Product.ProductId,
                            StockOutId = stockOutId
                        };*/

                        var detail = new StockOutDetail
                                         {
                                             //StockOutDetailPK = pk,
                            StockOutDetailId = stockOutDetailId++,
                            StockOutId = stockOutId,
                            StockOut = stockOut,
//.........这里部分代码省略.........
开发者ID:DelLitt,项目名称:opmscoral,代码行数:101,代码来源:StockOutLogicImpl.cs


注:本文中的ObjectCriteria.AddSearchInCriteria方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。