private void btnBarcodePrint_Click(object sender, EventArgs e) { List <string> listBarcode = new List <string>(); DataTable barcode = m_findSellIn.GetBarcodeTable(dgv_Show.CurrentRow.Cells["DJH"].Value.ToString()); for (int i = 0; i < barcode.Rows.Count; i++) { if (i == 0 || barcode.Rows[i]["BoxNo"].ToString() != barcode.Rows[i - 1]["BoxNo"].ToString()) { listBarcode = new List <string>(); } listBarcode.Add(barcode.Rows[i]["ProductCode"].ToString()); if (barcode.Rows.Count - 1 == i || barcode.Rows[i]["BoxNo"].ToString() != barcode.Rows[i + 1]["BoxNo"].ToString()) { PrintPartBarcode.PrintBarcodeCVTNumberList(listBarcode); PrintPartBarcode.PrintBarcode_120X30(barcode.Rows[i]["BoxNo"].ToString()); } } }