public void RunCombineMergerListItem() { CombineItem main = new CombineItem(packItem.GetColor1(), packItem.GetColor2()); main.UpdateCombineElement(new CombineEle(packItem.GetProductSize(), packItem.GetQuantity())); listCombineItem.Add(main); if (packItem.GetMergerList() != null && packItem.GetMergerList().Count > 0) { foreach (MergerItem merger in packItem.GetMergerList()) { bool iscombine = false; foreach (CombineItem combine in listCombineItem) { if (combine.GetColor1() == merger.GetColor1()) { iscombine = true; combine.UpdateCombineElement(new CombineEle(merger.GetProductSize(), merger.GetQuantity())); break; } } if (!iscombine) { main = new CombineItem(merger.GetColor1(), merger.GetColor2()); main.UpdateCombineElement(new CombineEle(merger.GetProductSize(), merger.GetQuantity())); listCombineItem.Add(main); } } } }
public void AddNewItemInList(PackingListItem item) { if (listItem == null) { listItem = new List <PackingListItem>(); } if (item != null && this.databaseItem != null) { int phan_nguyen = (int)(item.GetQuantity() / databaseItem.GetMaxPacketSize()); int phan_du = (int)(item.GetQuantity()) - (int)(phan_nguyen * databaseItem.GetMaxPacketSize()); if (phan_du == 0 || phan_nguyen == 0) { if (phan_nguyen == 0) { item.SetNeedMerger(true); } else { item.SetNeedMerger(false); } listItem.Add(item); } else { //add phan nguyen item.SetQuantity(phan_nguyen * databaseItem.GetMaxPacketSize()); item.SetNeedMerger(false); listItem.Add(item); //add phan du PackingListItem item_du = new PackingListItem(); item_du.SetColor1(item.GetColor1()); item_du.SetColor2(item.GetColor2()); item_du.SetNameProduct(item.GetNameProduct()); item_du.SetProductSize(item.GetProductSize()); item_du.SetQuantity(phan_du); item_du.SetNeedMerger(true); listItem.Add(item_du); } } }
public ParkingParserItem(String name, PackingListItem item, DatabaseItem databaseItem) { this.nameProduct = name; this.databaseItem = databaseItem; this.listItem = new List <PackingListItem>(); if (item != null) { int phan_nguyen = (int)(item.GetQuantity() / databaseItem.GetMaxPacketSize()); int phan_du = (int)(item.GetQuantity()) - (int)(phan_nguyen * databaseItem.GetMaxPacketSize()); if (phan_du == 0 || phan_nguyen == 0) { if (phan_nguyen == 0) { item.SetNeedMerger(true); } else { item.SetNeedMerger(false); } listItem.Add(item); } else { //add phan nguyen item.SetQuantity(phan_nguyen * databaseItem.GetMaxPacketSize()); item.SetNeedMerger(false); listItem.Add(item); //add phan du PackingListItem item_du = new PackingListItem(); item_du.SetColor1(item.GetColor1()); item_du.SetColor2(item.GetColor2()); item_du.SetNameProduct(item.GetNameProduct()); item_du.SetProductSize(item.GetProductSize()); item_du.SetQuantity(phan_du); item_du.SetNeedMerger(true); listItem.Add(item_du); } } }
public void AddMergerItem(PackingListItem packingItem) { MergerItem item = new MergerItem(); item.SetColor1(packingItem.GetColor1()); item.SetColor2(packingItem.GetColor2()); item.SetNameProduct(packingItem.GetNameProduct()); item.SetProductSize(packingItem.GetProductSize()); item.SetQuantity(packingItem.GetQuantity()); if (this.mergerList == null) { this.mergerList = new List <MergerItem>(); } this.mergerList.Add(item); }
//////////////////////////////////////////////////////////////////// private void CreateRowValueSheet_1(PackingListItem item, DatabaseItem databaseItem) { NPOI.SS.UserModel.IRow r; if (item.GetQuantity() < databaseItem.GetMaxPacketSize()) { r = sheet_1.CreateRow(rowIndex_sheet_1); rowIndex_sheet_1++; numberPacket_sheet_1++; double valueMerger = item.GetQuantity(); if (item.GetMergerList() != null && item.GetMergerList().Count > 0) { foreach (MergerItem merger in item.GetMergerList()) { valueMerger += merger.GetQuantity(); } } for (int idex = 0; idex < Sheet_1_Header.Length; idex++) { ICell cell = r.CreateCell(idex); cell.CellStyle = sheet_1_headerStyle; switch (idex) { case 0: cell.SetCellValue(this.packingParser.GetDateTime()); break; case 1: cell.SetCellValue(item.GetNameProduct()); break; case 2: cell.SetCellValue(item.GetColor1()); break; case 3: cell.SetCellValue(item.GetColor2()); break; case 4: cell.SetCellValue(item.GetProductSize()); break; case 5: cell.SetCellValue(item.GetQuantity()); if (valueMerger > item.GetQuantity()) { cell.CellStyle = sheet_1_headerStyle_2; } break; case 6: cell.SetCellValue(1); break; case 7: cell.SetCellValue(numberPacket_sheet_1); break; case 8: if (valueMerger <= item.GetQuantity()) { cell.SetCellValue(valueMerger); } break; case 9: cell.SetCellValue(databaseItem.GetNetWeight()); break; case 10: cell.SetCellValue(databaseItem.GetAllWeight()); break; case 11: cell.SetCellValue(databaseItem.GetPacketInformation()); break; default: break; } } } else { for (int tmp = 0; tmp < (int)(item.GetQuantity() / databaseItem.GetMaxPacketSize()); tmp++) { numberPacket_sheet_1++; r = sheet_1.CreateRow(rowIndex_sheet_1); rowIndex_sheet_1++; for (int idex = 0; idex < Sheet_1_Header.Length; idex++) { ICell cell = r.CreateCell(idex); cell.CellStyle = sheet_1_headerStyle; switch (idex) { case 0: cell.SetCellValue(this.packingParser.GetDateTime()); break; case 1: cell.SetCellValue(item.GetNameProduct()); break; case 2: cell.SetCellValue(item.GetColor1()); break; case 3: cell.SetCellValue(item.GetColor2()); break; case 4: cell.SetCellValue(item.GetProductSize()); break; case 5: cell.SetCellValue(databaseItem.GetMaxPacketSize()); break; case 6: cell.SetCellValue(1); break; case 7: cell.SetCellValue(numberPacket_sheet_1); break; case 8: cell.SetCellValue(databaseItem.GetMaxPacketSize()); break; case 9: cell.SetCellValue(databaseItem.GetNetWeight()); break; case 10: cell.SetCellValue(databaseItem.GetAllWeight()); break; case 11: cell.SetCellValue(databaseItem.GetPacketInformation()); break; default: break; } } } } if (item.GetMergerList() != null && item.GetMergerList().Count > 0) { foreach (MergerItem merger in item.GetMergerList()) { r = sheet_1.CreateRow(rowIndex_sheet_1); rowIndex_sheet_1++; for (int idex = 0; idex < Sheet_1_Header.Length; idex++) { ICell cell = r.CreateCell(idex); cell.CellStyle = sheet_1_headerStyle; switch (idex) { case 0: cell.SetCellValue(this.packingParser.GetDateTime()); break; case 1: cell.SetCellValue(merger.GetNameProduct()); break; case 2: cell.SetCellValue(merger.GetColor1()); break; case 3: cell.SetCellValue(merger.GetColor2()); break; case 4: cell.SetCellValue(merger.GetProductSize()); break; case 5: cell.SetCellValue(merger.GetQuantity()); cell.CellStyle = sheet_1_headerStyle_2; break; case 6: break; case 7: cell.SetCellValue(numberPacket_sheet_1); break; case 8: break; case 9: //cell.SetCellValue(databaseItem.GetNetWeight()); break; case 10: //cell.SetCellValue(databaseItem.GetAllWeight()); break; case 11: //cell.SetCellValue(databaseItem.GetPacketInformation()); break; default: break; } } } r = sheet_1.GetRow(rowIndex_sheet_1 - (1 + item.GetMergerList().Count)); String fomular = "SUM(F" + (rowIndex_sheet_1 - item.GetMergerList().Count) + ":F" + rowIndex_sheet_1 + ")"; if (r.GetCell(8) != null) { r.GetCell(8).CellFormula = fomular; } NPOI.SS.Util.CellRangeAddress range_1 = new NPOI.SS.Util.CellRangeAddress(rowIndex_sheet_1 - (1 + item.GetMergerList().Count), rowIndex_sheet_1 - 1, 6, 6); NPOI.SS.Util.CellRangeAddress range_2 = new NPOI.SS.Util.CellRangeAddress(rowIndex_sheet_1 - (1 + item.GetMergerList().Count), rowIndex_sheet_1 - 1, 8, 8); sheet_1.AddMergedRegion(range_1); sheet_1.AddMergedRegion(range_2); } }
private void CreateNotMergerItem(int type, ParkingParserItem item, PackingListItem packItem) { ICell cell; NPOI.SS.UserModel.IRow row; //create new row row = sheet_2.CreateRow(sheet_2_rowIndex); sheet_2_rowIndex++; int phan_nguyen = (int)(packItem.GetQuantity() / item.GetDatabaseItem().GetMaxPacketSize()); int size_index = Sheet_2_GetColumIndex(type, packItem.GetProductSize()); for (int run = 0; run < Sheet_2_GetNumberOfColum(); run++) { cell = row.CreateCell(run); cell.CellStyle = sheet_2_mainStyle_2; switch (run) { case 0: if (phan_nguyen > 1) { double from = sheet_2_numberPacket + 1; double to = sheet_2_numberPacket + phan_nguyen; cell.SetCellValue(from + " - " + to); sheet_2_numberPacket += phan_nguyen; } else { sheet_2_numberPacket++; cell.SetCellValue(sheet_2_numberPacket + ""); } break; case 1: if (phan_nguyen > 0) { cell.SetCellValue(phan_nguyen); } else { cell.SetCellValue(1); } break; case 2: cell.SetCellValue(packItem.GetNameProduct()); break; case 3: cell.SetCellValue(packItem.GetColor1()); break; case 4: cell.SetCellValue(packItem.GetColor2()); break; default: if (run == size_index) { if (phan_nguyen > 0) { String formula = item.GetDatabaseItem().GetMaxPacketSize() + "*$B" + sheet_2_rowIndex; cell.SetCellFormula(formula); } else { cell.SetCellValue(packItem.GetQuantity()); } } else { int total = Sheet_2_GetNumberOfColum(); if ((total - 4) == run) { String columName = Sheet_2_GetStringOfColum(Sheet_2_GetNumberOfColum() - 4); String formula = "SUM(F" + sheet_2_rowIndex + ":" + columName + sheet_2_rowIndex + ")"; cell.SetCellFormula(formula); } else if ((total - 3) == run) { cell.SetCellValue("PCS"); } else if ((total - 2) == run) { String formula = item.GetDatabaseItem().GetNetWeight() + "*B" + sheet_2_rowIndex; cell.SetCellFormula(formula); } else if ((total - 1) == run) { String formula = item.GetDatabaseItem().GetAllWeight() + "*B" + sheet_2_rowIndex; cell.SetCellFormula(formula); } else { cell.SetCellValue(""); } } break; } } }