private void SliptToMerger(ParkingParserItem parserItem)
        {
            PackingListItem packingItem;
            int             base_index = 0;

            double totalQunatity = 0;
            double numberItem    = 0;

            foreach (PackingListItem item in parserItem.GetListItem())
            {
                if (item.IsNeedMerger())
                {
                    totalQunatity += item.GetQuantity();
                    numberItem++;
                }
            }

            if (totalQunatity >= parserItem.GetDatabaseItem().GetMaxPacketSize())
            {
                double          sliptQuantity = 0;
                PackingListItem itemAdd       = null;

                for (int run = 0; run < parserItem.GetListItem().Count; run++)
                {
                    if (parserItem.GetListItem().ElementAt(run).IsNeedMerger())
                    {
                        base_index = run;
                        break;
                    }
                }

                //Need to slipt
                parserItem.GetListItem().ElementAt(base_index).SetNeedMerger(false);

                sliptQuantity = parserItem.GetDatabaseItem().GetMaxPacketSize() -
                                parserItem.GetListItem().ElementAt(base_index).GetQuantity();

                while (sliptQuantity > 0)
                {
                    bool found = false;

                    for (int run = base_index + 1; run < parserItem.GetListItem().Count; run++)
                    {
                        if (parserItem.GetListItem().ElementAt(run).IsNeedMerger())
                        {
                            if (parserItem.GetListItem().ElementAt(run).GetQuantity() > sliptQuantity)
                            {
                                found = true;

                                itemAdd = new PackingListItem();

                                itemAdd.SetColor1(parserItem.GetListItem().ElementAt(run).GetColor1());
                                itemAdd.SetColor2(parserItem.GetListItem().ElementAt(run).GetColor2());
                                itemAdd.SetNameProduct(parserItem.GetListItem().ElementAt(run).GetNameProduct());
                                itemAdd.SetNeedMerger(false);
                                itemAdd.SetProductSize(parserItem.GetListItem().ElementAt(run).GetProductSize());
                                itemAdd.SetQuantity(sliptQuantity);

                                parserItem.GetListItem().ElementAt(run).SetQuantity(parserItem.GetListItem().ElementAt(run).GetQuantity() - sliptQuantity);

                                sliptQuantity = 0;
                                parserItem.GetListItem().ElementAt(base_index).AddMergerItem(itemAdd);
                            }
                            else
                            {
                                found = true;

                                packingItem = parserItem.GetListItem().ElementAt(run);

                                packingItem.SetNeedMerger(false);

                                parserItem.GetListItem().RemoveAt(run);

                                parserItem.GetListItem().ElementAt(base_index).AddMergerItem(packingItem);

                                sliptQuantity -= packingItem.GetQuantity();
                            }

                            break;
                        }
                    }

                    if (!found)
                    {
                        break;
                    }
                }

                SliptToMerger(parserItem);
            }
            else /*less than*/ if (numberItem != 0)
            {
                for (int run = 0; run < parserItem.GetListItem().Count; run++)
                {
                    if (parserItem.GetListItem().ElementAt(run).IsNeedMerger())
                    {
                        parserItem.GetListItem().ElementAt(run).SetNeedMerger(false);
                        base_index = run;
                        break;
                    }
                }

                numberItem -= 1;

                while (numberItem > 0)
                {
                    packingItem = null;

                    if (base_index >= parserItem.GetListItem().Count)
                    {
                        break;
                    }

                    for (int run = base_index; run < parserItem.GetListItem().Count; run++)
                    {
                        if (parserItem.GetListItem().ElementAt(run).IsNeedMerger())
                        {
                            packingItem = parserItem.GetListItem().ElementAt(run);

                            packingItem.SetNeedMerger(false);

                            parserItem.GetListItem().RemoveAt(run);
                            break;
                        }
                    }

                    if (packingItem != null)
                    {
                        parserItem.GetListItem().ElementAt(base_index).AddMergerItem(packingItem);
                    }

                    numberItem -= 1;
                }
            }
        }
        private void CreateRowValueSheet_2(ParkingParserItem item)
        {
            NPOI.SS.UserModel.IRow row;
            ICell  cell;
            int    type;
            String nametype = "";

            int start_row, end_row;

            if (!(item != null && item.GetListItem() != null && item.GetListItem().Count > 0))
            {
                return;
            }

            //Clear header value
            row = sheet_2.CreateRow(sheet_2_rowIndex);
            sheet_2_rowIndex++;
            start_row = sheet_2_rowIndex + 1;

            if (CheckExistsSize_2(item.GetListItem().ElementAt(0).GetProductSize()) < 0)
            {
                type = 1;
            }
            else
            {
                type = 2;
            }

            for (int run = 0; run < Sheet_2_GetNumberOfColum(); run++)
            {
                cell = row.CreateCell(run);

                cell.SetCellValue(Sheet_2_GetHeaderString(type, run));

                if (item.GetNameProduct().StartsWith("R"))
                {
                    nametype = " - BRASSIERES";
                }
                else
                {
                    nametype = " - BRIEFS";
                }

                if (run == 0)
                {
                    cell.SetCellValue(item.GetNameProduct() + nametype);


                    cell.CellStyle = sheet_2_headerStyle_1;
                }
                else
                {
                    cell.CellStyle = sheet_2_headerStyle_2;
                }
            }

            NPOI.SS.Util.CellRangeAddress range = new NPOI.SS.Util.CellRangeAddress(sheet_2_rowIndex - 1, sheet_2_rowIndex - 1, 0, 4);
            sheet_2.AddMergedRegion(range);


            foreach (PackingListItem packItem in item.GetListItem())
            {
                if (packItem.GetMergerList() != null && packItem.GetMergerList().Count > 0)
                {
                    CreateMergerItem(type, item, packItem);
                }
                else
                {
                    CreateNotMergerItem(type, item, packItem);
                }
            }

            end_row = sheet_2_rowIndex;

            //sum row
            row = sheet_2.CreateRow(sheet_2_rowIndex);
            sheet_2_rowIndex++;

            for (int run = 0; run < Sheet_2_GetNumberOfColum(); run++)
            {
                cell = row.CreateCell(run);
                if (run == 2)
                {
                    cell.CellStyle = sheet_2_bottomStyle_2;
                }
                else
                {
                    cell.CellStyle = sheet_2_bottomStyle_1;
                }
                switch (run)
                {
                case 0:
                    cell.SetCellValue("P'KGS");
                    break;

                case 2:
                    cell.SetCellValue("SUB TOTAL:");
                    break;

                case 3:
                case 4:
                    break;

                default:
                {
                    String colum  = Sheet_2_GetStringOfColum(run + 1);
                    String fomula = "SUM(" + colum + start_row + ":" + colum + end_row + ")";
                    cell.SetCellFormula(fomula);
                    break;
                }
                }
            }
        }