public void stockSearchView_RemainSearchStockEvent(object sender, StockSearchEventArgs e)
        {
            var criteria = new ObjectCriteria();
            criteria.AddEqCriteria("DelFlg", (long)0);
            criteria.AddLesserOrEqualsCriteria("CreateDate", e.FromDate);
            IList deptStockInDetailFromList = DepartmentStockInDetailLogic.FindAll(criteria);

            criteria.AddNotEqualsCriteria("StockInType", (long)1);
            IList stockInDetailFromList = StockInDetailLogic.FindAll(criteria);

            criteria = new ObjectCriteria();
            criteria.AddEqCriteria("DelFlg", (long)0);
            criteria.AddLesserOrEqualsCriteria("CreateDate", e.ToDate);

            IList deptStockInDetailToList = DepartmentStockInDetailLogic.FindAll(criteria);
            criteria.AddNotEqualsCriteria("StockInType", (long)1);
            IList stockInDetailToList = StockInDetailLogic.FindAll(criteria);

            //            IList stockHistoryList = StockHistoryLogic.FindByMaxDate(criteria);
            var reportList = new List<UniversalStockReportObject>();

            // calculate dau` ton`
            foreach (StockInDetail stockInDetail in stockInDetailFromList)
            {
                UniversalStockReportObject report = null;
                foreach (var reportObject in reportList)
                {
                    if (stockInDetail.Product.ProductMaster.ProductMasterId.Equals(reportObject.ProductMaster.ProductMasterId))
                    {
                        report = reportObject;
                        break;
                    }
                }

                if (report != null)
                {
                    report.StockStartQuantity += stockInDetail.Quantity;
                    report.StockInStartQuantity += stockInDetail.Quantity;

                }
                else
                {
                    report = new UniversalStockReportObject();
                    reportList.Add(report);
                    report.StockStartQuantity = stockInDetail.Quantity;
                    report.StockInStartQuantity = stockInDetail.Quantity;
                }

                report.ProductMaster = stockInDetail.Product.ProductMaster;
                foreach (DepartmentStockInDetail deptStockInDetail in deptStockInDetailFromList)
                {
                    if (report.ProductMaster.ProductMasterId.Equals(deptStockInDetail.Product.ProductMaster.ProductMasterId))
                    {
                        report.StockStartQuantity -= deptStockInDetail.Quantity;
                        report.DepartmentStockInStartQuantity += deptStockInDetail.Quantity;
                    }
                }
                reportList.Add(report);
            }

            // calculate cuoi ton
            foreach (StockInDetail stockInDetail in stockInDetailToList)
            {
                UniversalStockReportObject report = null;
                foreach (var reportObject in reportList)
                {
                    if (stockInDetail.Product.ProductMaster.ProductMasterId.Equals(reportObject.ProductMaster.ProductMasterId))
                    {
                        report = reportObject;
                        break;
                    }
                }
                if (report != null)
                {
                    report.StockEndQuantity += stockInDetail.Quantity;
                    report.StockInEndQuantity += stockInDetail.Quantity;

                }
                else
                {
                    report = new UniversalStockReportObject();
                    report.ProductMaster = stockInDetail.Product.ProductMaster;
                    reportList.Add(report);
                    report.StockEndQuantity = stockInDetail.Quantity;
                    report.StockInEndQuantity = stockInDetail.Quantity;
                }

                foreach (DepartmentStockInDetail deptStockInDetail in deptStockInDetailToList)
                {
                    if (report.ProductMaster.ProductMasterId.Equals(deptStockInDetail.Product.ProductMaster.ProductMasterId))
                    {
                        report.StockEndQuantity -= deptStockInDetail.Quantity;
                        report.DepartmentStockInEndQuantity += deptStockInDetail.Quantity;
                    }
                }
            //                foreach (StockHistory stockHistory in stockHistoryList)
            //                {
            //                    if (report.ProductMaster.ProductMasterId.Equals(stockHistory.Product.ProductMaster.ProductMasterId))
            //                    {
            //                        report.LostCount += stockHistory.LostCount;
            //                        report.GoodCount += stockHistory.GoodCount;
            //                        report.ErrorCount += stockHistory.ErrorCount;
            //                        report.DamageCount += stockHistory.DamageCount;
            //                    }
            //                }
            }
            e.ReportList = reportList;
        }