Exemplo n.º 1
0
        private string doString(ref string lString, ref ADODB.Recordset rs)
        {
            string functionReturnValue = null;
            string lString1 = null;
            string lString2 = null;
            string lText = null;
            if (Strings.Len(lString) > 15) {
                lText = Strings.Mid(lString, 16);
                if (Strings.InStr(lText, "NAME 1 CENTER")) {
                    lString1 = rs.Fields("PersonName").Value;
                    splitString(ref Strings.Len(lText), ref lString1, ref lString2);
                    functionReturnValue = Strings.Left(lString, 15) + doCenter(ref lText, ref lString1);
                    return functionReturnValue;
                }
                if (Strings.InStr(lText, "DATE")) {
                    lString1 = Strings.Format(DateAndTime.Now, "yymm");
                    functionReturnValue = Strings.Left(lString, 15) + Strings.Format(DateAndTime.Now, "yymm");
                    return functionReturnValue;
                }

                if (Strings.InStr(lText, "BARCODE")) {
                    if (doCheckSum(ref rs.Fields("Person_QuickAccess").Value)) {
                    } else {
                        functionReturnValue = Strings.Left(lString, 15) + rs.Fields("Person_QuickAccess").Value;
                    }
                    return functionReturnValue;
                }
                if (Strings.InStr(lText, "600106007141")) {
                    if (doCheckSum(ref rs.Fields("Person_QuickAccess").Value))
                        functionReturnValue = Strings.Left(lString, 15) + rs.Fields("Person_QuickAccess").Value;
                    return functionReturnValue;
                }
                functionReturnValue = lString;
            } else {
                functionReturnValue = lString;
            }
            return functionReturnValue;
        }
Exemplo n.º 2
0
        private void adoPrimaryRS_FieldChangeComplete(int cFields, object Fields, ADODB.Error pError, ref ADODB.EventStatusEnum adStatus, ADODB.Recordset pRecordset)
        {
            string sql = null;
            sql = "DELETE From PriceChannelLnk WHERE (((PriceChannelLnk.PriceChannelLnk_StockItemID)=" + adoPrimaryRS.Fields("CatalogueChannelLnk_StockItemID").Value + ") AND ((PriceChannelLnk.PriceChannelLnk_Quantity)=" + adoPrimaryRS.Fields("CatalogueChannelLnk_Quantity").Value + ") AND ((PriceChannelLnk.PriceChannelLnk_ChannelID)=" + adoPrimaryRS.Fields("CatalogueChannelLnk_ChannelID").Value + "));";
            modRecordSet.cnnDB.Execute(sql);

            sql = "INSERT INTO PriceChannelLnk ( PriceChannelLnk_StockItemID, PriceChannelLnk_Quantity, PriceChannelLnk_ChannelID, PriceChannelLnk_Price ) SELECT CatalogueChannelLnk.CatalogueChannelLnk_StockItemID, CatalogueChannelLnk.CatalogueChannelLnk_Quantity, CatalogueChannelLnk.CatalogueChannelLnk_ChannelID, " + pRecordset.Fields("CatalogueChannelLnk_Price").Value + " AS Price From CatalogueChannelLnk WHERE (((CatalogueChannelLnk.CatalogueChannelLnk_StockItemID)=" + pRecordset.Fields("CatalogueChannelLnk_StockItemID").Value + ") AND ((CatalogueChannelLnk.CatalogueChannelLnk_Quantity)=" + pRecordset.Fields("CatalogueChannelLnk_Quantity").Value + ") AND ((CatalogueChannelLnk.CatalogueChannelLnk_ChannelID)=" + pRecordset.Fields("CatalogueChannelLnk_ChannelID").Value + ") AND ((CatalogueChannelLnk.CatalogueChannelLnk_PriceSystem)<>" + pRecordset.Fields("CatalogueChannelLnk_Price").Value + "));";

            modRecordSet.cnnDB.Execute(sql);
        }
Exemplo n.º 3
0
        private string doString(ref string lString, ref ADODB.Recordset rs)
        {
            string functionReturnValue = null;
            short x = 0;
            string lString1 = null;
            string lString2 = null;
            string lText = null;
            ADODB.Recordset rsP = default(ADODB.Recordset);
            ADODB.Recordset rsShrink = default(ADODB.Recordset);

            if (Strings.Len(lString) > 15) {
                lText = Strings.Mid(lString, 16);
                if (Strings.InStr(lText, "COMPANY NAME CENTER")) {
                    functionReturnValue = Strings.Left(lString, 15) + doCenter(ref lText, ref rs.Fields("Company_Name").Value);
                    return functionReturnValue;
                }
                if (Strings.InStr(lText, "COMPANY NAME LEFT")) {
                    functionReturnValue = Strings.Left(lString, 15) + Strings.Left(rs.Fields("Company_Name").Value, Strings.Len(lText));
                    return functionReturnValue;
                }
                if (Strings.InStr(lText, "COMPANY NAME RIGHT")) {
                    functionReturnValue = Strings.Left(lString, 15) + Strings.Right(new string(" ", Strings.Len(lText)) + rs.Fields("Company_Name").Value, Strings.Len(lText));
                    return functionReturnValue;
                }
                if (Strings.InStr(lText, "TELEPHONE CENTER")) {
                    functionReturnValue = Strings.Left(lString, 15) + doCenter(ref lText, ref rs.Fields("Company_Telephone").Value);
                    return functionReturnValue;
                }
                if (Strings.InStr(lText, "TELEPHONE LEFT")) {
                    functionReturnValue = Strings.Left(lString, 15) + Strings.Left(rs.Fields("Company_Telephone").Value, Strings.Len(lText));
                    return functionReturnValue;
                }
                if (Strings.InStr(lText, "TELEPHONE RIGHT")) {
                    functionReturnValue = Strings.Left(lString, 15) + Strings.Right(new string(" ", Strings.Len(lText)) + rs.Fields("Company_Telephone").Value, Strings.Len(lText));
                    return functionReturnValue;
                }
                if (Strings.InStr(lText, "PRICEXXXXX")) {
                    functionReturnValue = Strings.Left(lString, 15) + Strings.Replace(lText, lText, Strings.Right(new string(" ", Strings.Len(lText)) + rs.Fields("Price").Value, Strings.Len(lText)));
                    return functionReturnValue;
                }
                if (Strings.InStr(lText, "PRICEX")) {
                    functionReturnValue = Strings.Left(lString, 15) + Strings.Replace(lText, lText, Strings.Right(new string(" ", Strings.Len(lText)) + Strings.Split(rs.Fields("Price").Value + ".00", ".")[0], Strings.Len(lText)));
                    return functionReturnValue;
                }

                if (Strings.InStr(lText, "PRIC4XXXXX")) {
                    functionReturnValue = Strings.Left(lString, 15) + Strings.Replace(lText, lText, Strings.Right(new string(" ", Strings.Len(lText)) + rs.Fields("Price").Value, Strings.Len(lText)));
                    return functionReturnValue;
                }
                if (Strings.InStr(lText, "PRIC1XXXXX")) {
                    rsShrink = modRecordSet.getRS(ref "SELECT StockItem.StockItemID, StockItem.StockItem_ShrinkID, Shrink.ShrinkID, ShrinkItem.ShrinkItem_ShrinkID, ShrinkItem.ShrinkItem_Quantity FROM (Shrink INNER JOIN StockItem ON Shrink.ShrinkID = StockItem.StockItem_ShrinkID) INNER JOIN ShrinkItem ON Shrink.ShrinkID = ShrinkItem.ShrinkItem_ShrinkID Where (((StockItem.stockitemID) = " + rs.Fields("StockItemID").Value + ")) ORDER BY StockItem.StockItemID, ShrinkItem.ShrinkItem_Quantity;");
                    x = 0;
                    if (rsShrink.RecordCount > 0) {

                        while (!(rsShrink.EOF)) {
                            if (rsShrink.Fields("ShrinkItem_Quantity").Value > 1) {
                                if (x == 0) {
                                    rsP = modRecordSet.getRS(ref "SELECT TOP 1 PriceChannelLnk.PriceChannelLnk_StockItemID, PriceChannelLnk.PriceChannelLnk_Quantity, PriceChannelLnk.PriceChannelLnk_ChannelID, PriceChannelLnk.PriceChannelLnk_Price From PriceChannelLnk Where (((PriceChannelLnk.PriceChannelLnk_StockItemID) = " + rsShrink.Fields("StockItemID").Value + ") And ((PriceChannelLnk.PriceChannelLnk_ChannelID) = 1) And ((PriceChannelLnk.PriceChannelLnk_Quantity) = " + rsShrink.Fields("ShrinkItem_Quantity").Value + ")) ORDER BY PriceChannelLnk.PriceChannelLnk_Quantity DESC;");
                                    if (rsP.RecordCount > 0) {
                                        functionReturnValue = Strings.Left(lString, 15) + Strings.Replace(lText, lText, Strings.Right(new string(" ", Strings.Len(lText)) + Strings.FormatNumber(rsP.Fields("PriceChannelLnk_Price").Value, 2) + " FOR  ", Strings.Len(lText)));
                                    } else {
                                        rsP = modRecordSet.getRS(ref "SELECT TOP 1 CatalogueChannelLnk.CatalogueChannelLnk_StockItemID, CatalogueChannelLnk.CatalogueChannelLnk_Quantity, CatalogueChannelLnk.CatalogueChannelLnk_ChannelID, CatalogueChannelLnk.CatalogueChannelLnk_Price From CatalogueChannelLnk Where (((CatalogueChannelLnk.CatalogueChannelLnk_StockItemID) = " + rsShrink.Fields("StockItemID").Value + ") And ((CatalogueChannelLnk.CatalogueChannelLnk_ChannelID) = 1) And ((CatalogueChannelLnk.CatalogueChannelLnk_Quantity) = " + rsShrink.Fields("ShrinkItem_Quantity").Value + ")) ORDER BY CatalogueChannelLnk.CatalogueChannelLnk_Quantity DESC;");
                                        if (rsP.RecordCount > 0) {
                                            functionReturnValue = Strings.Left(lString, 15) + Strings.Replace(lText, lText, Strings.Right(new string(" ", Strings.Len(lText)) + Strings.FormatNumber(rsP.Fields("CatalogueChannelLnk_Price").Value, 2) + " FOR  ", Strings.Len(lText)));
                                        } else {
                                            //doString = Left(lString, 15) & Replace(lText, lText, Right(String(Len(lText), " ") & Split(rs("Price") & ".00", ".")(0), Len(lText)))
                                        }
                                    }
                                    x = x + 1;

                                } else if (x == 1) {
                                    x = x + 1;

                                } else if (x == 2) {
                                    x = x + 1;
                                }

                            }

                            rsShrink.MoveNext();
                        }
                    }
                    return functionReturnValue;

                }
                if (Strings.InStr(lText, "PRIC2XXXXX")) {
                    rsShrink = modRecordSet.getRS(ref "SELECT StockItem.StockItemID, StockItem.StockItem_ShrinkID, Shrink.ShrinkID, ShrinkItem.ShrinkItem_ShrinkID, ShrinkItem.ShrinkItem_Quantity FROM (Shrink INNER JOIN StockItem ON Shrink.ShrinkID = StockItem.StockItem_ShrinkID) INNER JOIN ShrinkItem ON Shrink.ShrinkID = ShrinkItem.ShrinkItem_ShrinkID Where (((StockItem.stockitemID) = " + rs.Fields("StockItemID").Value + ")) ORDER BY StockItem.StockItemID, ShrinkItem.ShrinkItem_Quantity;");
                    x = 0;
                    if (rsShrink.RecordCount > 0) {

                        while (!(rsShrink.EOF)) {
                            if (rsShrink.Fields("ShrinkItem_Quantity").Value > 1) {

                                if (x == 0) {
                                    x = x + 1;
                                } else if (x == 1) {
                                    rsP = modRecordSet.getRS(ref "SELECT TOP 1 PriceChannelLnk.PriceChannelLnk_StockItemID, PriceChannelLnk.PriceChannelLnk_Quantity, PriceChannelLnk.PriceChannelLnk_ChannelID, PriceChannelLnk.PriceChannelLnk_Price From PriceChannelLnk Where (((PriceChannelLnk.PriceChannelLnk_StockItemID) = " + rsShrink.Fields("StockItemID").Value + ") And ((PriceChannelLnk.PriceChannelLnk_ChannelID) = 1) And ((PriceChannelLnk.PriceChannelLnk_Quantity) = " + rsShrink.Fields("ShrinkItem_Quantity").Value + ")) ORDER BY PriceChannelLnk.PriceChannelLnk_Quantity DESC;");
                                    if (rsP.RecordCount > 0) {
                                        functionReturnValue = Strings.Left(lString, 15) + Strings.Replace(lText, lText, Strings.Right(new string(" ", Strings.Len(lText)) + Strings.FormatNumber(rsP.Fields("PriceChannelLnk_Price").Value, 2) + " FOR  ", Strings.Len(lText)));
                                    } else {
                                        rsP = modRecordSet.getRS(ref "SELECT TOP 1 CatalogueChannelLnk.CatalogueChannelLnk_StockItemID, CatalogueChannelLnk.CatalogueChannelLnk_Quantity, CatalogueChannelLnk.CatalogueChannelLnk_ChannelID, CatalogueChannelLnk.CatalogueChannelLnk_Price From CatalogueChannelLnk Where (((CatalogueChannelLnk.CatalogueChannelLnk_StockItemID) = " + rsShrink.Fields("StockItemID").Value + ") And ((CatalogueChannelLnk.CatalogueChannelLnk_ChannelID) = 1) And ((CatalogueChannelLnk.CatalogueChannelLnk_Quantity) = " + rsShrink.Fields("ShrinkItem_Quantity").Value + ")) ORDER BY CatalogueChannelLnk.CatalogueChannelLnk_Quantity DESC;");
                                        if (rsP.RecordCount > 0) {
                                            functionReturnValue = Strings.Left(lString, 15) + Strings.Replace(lText, lText, Strings.Right(new string(" ", Strings.Len(lText)) + Strings.FormatNumber(rsP.Fields("CatalogueChannelLnk_Price").Value, 2) + " FOR  ", Strings.Len(lText)));
                                        } else {
                                            //doString = Left(lString, 15) & Replace(lText, lText, Right(String(Len(lText), " ") & Split(rs("Price") & ".00", ".")(0), Len(lText)))
                                        }
                                    }
                                    x = x + 1;

                                } else if (x == 2) {
                                    x = x + 1;
                                }

                            }

                            rsShrink.MoveNext();
                        }
                    }
                    return functionReturnValue;
                }
                if (Strings.InStr(lText, "PRIC3XXXXX")) {
                    rsShrink = modRecordSet.getRS(ref "SELECT StockItem.StockItemID, StockItem.StockItem_ShrinkID, Shrink.ShrinkID, ShrinkItem.ShrinkItem_ShrinkID, ShrinkItem.ShrinkItem_Quantity FROM (Shrink INNER JOIN StockItem ON Shrink.ShrinkID = StockItem.StockItem_ShrinkID) INNER JOIN ShrinkItem ON Shrink.ShrinkID = ShrinkItem.ShrinkItem_ShrinkID Where (((StockItem.stockitemID) = " + rs.Fields("StockItemID").Value + ")) ORDER BY StockItem.StockItemID, ShrinkItem.ShrinkItem_Quantity;");
                    x = 0;
                    if (rsShrink.RecordCount > 0) {

                        while (!(rsShrink.EOF)) {
                            if (rsShrink.Fields("ShrinkItem_Quantity").Value > 1) {

                                if (x == 0) {
                                    x = x + 1;

                                } else if (x == 1) {
                                    x = x + 1;
                                } else if (x == 2) {
                                    rsP = modRecordSet.getRS(ref "SELECT TOP 1 PriceChannelLnk.PriceChannelLnk_StockItemID, PriceChannelLnk.PriceChannelLnk_Quantity, PriceChannelLnk.PriceChannelLnk_ChannelID, PriceChannelLnk.PriceChannelLnk_Price From PriceChannelLnk Where (((PriceChannelLnk.PriceChannelLnk_StockItemID) = " + rsShrink.Fields("StockItemID").Value + ") And ((PriceChannelLnk.PriceChannelLnk_ChannelID) = 1) And ((PriceChannelLnk.PriceChannelLnk_Quantity) = " + rsShrink.Fields("ShrinkItem_Quantity").Value + ")) ORDER BY PriceChannelLnk.PriceChannelLnk_Quantity DESC;");
                                    if (rsP.RecordCount > 0) {
                                        functionReturnValue = Strings.Left(lString, 15) + Strings.Replace(lText, lText, Strings.Right(new string(" ", Strings.Len(lText)) + Strings.FormatNumber(rsP.Fields("PriceChannelLnk_Price").Value, 2) + " FOR  ", Strings.Len(lText)));
                                    } else {
                                        rsP = modRecordSet.getRS(ref "SELECT TOP 1 CatalogueChannelLnk.CatalogueChannelLnk_StockItemID, CatalogueChannelLnk.CatalogueChannelLnk_Quantity, CatalogueChannelLnk.CatalogueChannelLnk_ChannelID, CatalogueChannelLnk.CatalogueChannelLnk_Price From CatalogueChannelLnk Where (((CatalogueChannelLnk.CatalogueChannelLnk_StockItemID) = " + rsShrink.Fields("StockItemID").Value + ") And ((CatalogueChannelLnk.CatalogueChannelLnk_ChannelID) = 1) And ((CatalogueChannelLnk.CatalogueChannelLnk_Quantity) = " + rsShrink.Fields("ShrinkItem_Quantity").Value + ")) ORDER BY CatalogueChannelLnk.CatalogueChannelLnk_Quantity DESC;");
                                        if (rsP.RecordCount > 0) {
                                            functionReturnValue = Strings.Left(lString, 15) + Strings.Replace(lText, lText, Strings.Right(new string(" ", Strings.Len(lText)) + Strings.FormatNumber(rsP.Fields("CatalogueChannelLnk_Price").Value, 2) + " FOR  ", Strings.Len(lText)));
                                        } else {
                                            //doString = Left(lString, 15) & Replace(lText, lText, Right(String(Len(lText), " ") & Split(rs("Price") & ".00", ".")(0), Len(lText)))
                                        }
                                    }
                                    x = x + 1;
                                }

                            }

                            rsShrink.MoveNext();
                        }
                    }
                    return functionReturnValue;
                }

                if (lText == "S1") {
                    rsShrink = modRecordSet.getRS(ref "SELECT StockItem.StockItemID, StockItem.StockItem_ShrinkID, Shrink.ShrinkID, ShrinkItem.ShrinkItem_ShrinkID, ShrinkItem.ShrinkItem_Quantity FROM (Shrink INNER JOIN StockItem ON Shrink.ShrinkID = StockItem.StockItem_ShrinkID) INNER JOIN ShrinkItem ON Shrink.ShrinkID = ShrinkItem.ShrinkItem_ShrinkID Where (((StockItem.stockitemID) = " + rs.Fields("StockItemID").Value + ")) ORDER BY StockItem.StockItemID, ShrinkItem.ShrinkItem_Quantity;");
                    x = 0;
                    if (rsShrink.RecordCount > 0) {

                        while (!(rsShrink.EOF)) {
                            if (rsShrink.Fields("ShrinkItem_Quantity").Value > 1) {
                                if (x == 0) {
                                    rsP = modRecordSet.getRS(ref "SELECT TOP 1 PriceChannelLnk.PriceChannelLnk_StockItemID, PriceChannelLnk.PriceChannelLnk_Quantity, PriceChannelLnk.PriceChannelLnk_ChannelID, PriceChannelLnk.PriceChannelLnk_Price From PriceChannelLnk Where (((PriceChannelLnk.PriceChannelLnk_StockItemID) = " + rsShrink.Fields("StockItemID").Value + ") And ((PriceChannelLnk.PriceChannelLnk_ChannelID) = 1) And ((PriceChannelLnk.PriceChannelLnk_Quantity) = " + rsShrink.Fields("ShrinkItem_Quantity").Value + ")) ORDER BY PriceChannelLnk.PriceChannelLnk_Quantity DESC;");
                                    if (rsP.RecordCount > 0) {
                                        functionReturnValue = Strings.Left(lString, 15) + Strings.Right(new string(" ", Strings.Len(lText)) + rsP.Fields("PriceChannelLnk_Quantity").Value, Strings.Len(lText));
                                    } else {
                                        rsP = modRecordSet.getRS(ref "SELECT TOP 1 CatalogueChannelLnk.CatalogueChannelLnk_StockItemID, CatalogueChannelLnk.CatalogueChannelLnk_Quantity, CatalogueChannelLnk.CatalogueChannelLnk_ChannelID, CatalogueChannelLnk.CatalogueChannelLnk_Price From CatalogueChannelLnk Where (((CatalogueChannelLnk.CatalogueChannelLnk_StockItemID) = " + rsShrink.Fields("StockItemID").Value + ") And ((CatalogueChannelLnk.CatalogueChannelLnk_ChannelID) = 1) And ((CatalogueChannelLnk.CatalogueChannelLnk_Quantity) = " + rsShrink.Fields("ShrinkItem_Quantity").Value + ")) ORDER BY CatalogueChannelLnk.CatalogueChannelLnk_Quantity DESC;");
                                        if (rsP.RecordCount > 0) {
                                            functionReturnValue = Strings.Left(lString, 15) + Strings.Right(new string(" ", Strings.Len(lText)) + rsP.Fields("CatalogueChannelLnk_Quantity").Value, Strings.Len(lText));

                                        } else {
                                        }
                                    }
                                    x = x + 1;

                                } else if (x == 1) {
                                    x = x + 1;

                                } else if (x == 2) {
                                    x = x + 1;
                                }

                            }

                            rsShrink.MoveNext();
                        }
                    }
                    return functionReturnValue;

                }
                if (lText == "S2") {
                    rsShrink = modRecordSet.getRS(ref "SELECT StockItem.StockItemID, StockItem.StockItem_ShrinkID, Shrink.ShrinkID, ShrinkItem.ShrinkItem_ShrinkID, ShrinkItem.ShrinkItem_Quantity FROM (Shrink INNER JOIN StockItem ON Shrink.ShrinkID = StockItem.StockItem_ShrinkID) INNER JOIN ShrinkItem ON Shrink.ShrinkID = ShrinkItem.ShrinkItem_ShrinkID Where (((StockItem.stockitemID) = " + rs.Fields("StockItemID").Value + ")) ORDER BY StockItem.StockItemID, ShrinkItem.ShrinkItem_Quantity;");
                    x = 0;
                    if (rsShrink.RecordCount > 0) {

                        while (!(rsShrink.EOF)) {
                            if (rsShrink.Fields("ShrinkItem_Quantity").Value > 1) {

                                if (x == 0) {
                                    x = x + 1;
                                } else if (x == 1) {
                                    rsP = modRecordSet.getRS(ref "SELECT TOP 1 PriceChannelLnk.PriceChannelLnk_StockItemID, PriceChannelLnk.PriceChannelLnk_Quantity, PriceChannelLnk.PriceChannelLnk_ChannelID, PriceChannelLnk.PriceChannelLnk_Price From PriceChannelLnk Where (((PriceChannelLnk.PriceChannelLnk_StockItemID) = " + rsShrink.Fields("StockItemID").Value + ") And ((PriceChannelLnk.PriceChannelLnk_ChannelID) = 1) And ((PriceChannelLnk.PriceChannelLnk_Quantity) = " + rsShrink.Fields("ShrinkItem_Quantity").Value + ")) ORDER BY PriceChannelLnk.PriceChannelLnk_Quantity DESC;");
                                    if (rsP.RecordCount > 0) {
                                        functionReturnValue = Strings.Left(lString, 15) + Strings.Right(new string(" ", Strings.Len(lText)) + rsP.Fields("PriceChannelLnk_Quantity").Value, Strings.Len(lText));
                                    } else {
                                        rsP = modRecordSet.getRS(ref "SELECT TOP 1 CatalogueChannelLnk.CatalogueChannelLnk_StockItemID, CatalogueChannelLnk.CatalogueChannelLnk_Quantity, CatalogueChannelLnk.CatalogueChannelLnk_ChannelID, CatalogueChannelLnk.CatalogueChannelLnk_Price From CatalogueChannelLnk Where (((CatalogueChannelLnk.CatalogueChannelLnk_StockItemID) = " + rsShrink.Fields("StockItemID").Value + ") And ((CatalogueChannelLnk.CatalogueChannelLnk_ChannelID) = 1) And ((CatalogueChannelLnk.CatalogueChannelLnk_Quantity) = " + rsShrink.Fields("ShrinkItem_Quantity").Value + ")) ORDER BY CatalogueChannelLnk.CatalogueChannelLnk_Quantity DESC;");
                                        if (rsP.RecordCount > 0) {
                                            functionReturnValue = Strings.Left(lString, 15) + Strings.Right(new string(" ", Strings.Len(lText)) + rsP.Fields("CatalogueChannelLnk_Quantity").Value, Strings.Len(lText));

                                        } else {
                                        }
                                    }
                                    x = x + 1;

                                } else if (x == 2) {
                                    x = x + 1;
                                }

                            }

                            rsShrink.MoveNext();
                        }
                    }
                    return functionReturnValue;
                }
                if (lText == "S3") {
                    rsShrink = modRecordSet.getRS(ref "SELECT StockItem.StockItemID, StockItem.StockItem_ShrinkID, Shrink.ShrinkID, ShrinkItem.ShrinkItem_ShrinkID, ShrinkItem.ShrinkItem_Quantity FROM (Shrink INNER JOIN StockItem ON Shrink.ShrinkID = StockItem.StockItem_ShrinkID) INNER JOIN ShrinkItem ON Shrink.ShrinkID = ShrinkItem.ShrinkItem_ShrinkID Where (((StockItem.stockitemID) = " + rs.Fields("StockItemID").Value + ")) ORDER BY StockItem.StockItemID, ShrinkItem.ShrinkItem_Quantity;");
                    x = 0;
                    if (rsShrink.RecordCount > 0) {

                        while (!(rsShrink.EOF)) {
                            if (rsShrink.Fields("ShrinkItem_Quantity").Value > 1) {

                                if (x == 0) {
                                    x = x + 1;

                                } else if (x == 1) {
                                    x = x + 1;
                                } else if (x == 2) {
                                    rsP = modRecordSet.getRS(ref "SELECT TOP 1 PriceChannelLnk.PriceChannelLnk_StockItemID, PriceChannelLnk.PriceChannelLnk_Quantity, PriceChannelLnk.PriceChannelLnk_ChannelID, PriceChannelLnk.PriceChannelLnk_Price From PriceChannelLnk Where (((PriceChannelLnk.PriceChannelLnk_StockItemID) = " + rsShrink.Fields("StockItemID").Value + ") And ((PriceChannelLnk.PriceChannelLnk_ChannelID) = 1) And ((PriceChannelLnk.PriceChannelLnk_Quantity) = " + rsShrink.Fields("ShrinkItem_Quantity").Value + ")) ORDER BY PriceChannelLnk.PriceChannelLnk_Quantity DESC;");
                                    if (rsP.RecordCount > 0) {
                                        functionReturnValue = Strings.Left(lString, 15) + Strings.Right(new string(" ", Strings.Len(lText)) + rsP.Fields("PriceChannelLnk_Quantity").Value, Strings.Len(lText));
                                    } else {
                                        rsP = modRecordSet.getRS(ref "SELECT TOP 1 CatalogueChannelLnk.CatalogueChannelLnk_StockItemID, CatalogueChannelLnk.CatalogueChannelLnk_Quantity, CatalogueChannelLnk.CatalogueChannelLnk_ChannelID, CatalogueChannelLnk.CatalogueChannelLnk_Price From CatalogueChannelLnk Where (((CatalogueChannelLnk.CatalogueChannelLnk_StockItemID) = " + rsShrink.Fields("StockItemID").Value + ") And ((CatalogueChannelLnk.CatalogueChannelLnk_ChannelID) = 1) And ((CatalogueChannelLnk.CatalogueChannelLnk_Quantity) = " + rsShrink.Fields("ShrinkItem_Quantity").Value + ")) ORDER BY CatalogueChannelLnk.CatalogueChannelLnk_Quantity DESC;");
                                        if (rsP.RecordCount > 0) {
                                            functionReturnValue = Strings.Left(lString, 15) + Strings.Right(new string(" ", Strings.Len(lText)) + rsP.Fields("CatalogueChannelLnk_Quantity").Value, Strings.Len(lText));

                                        } else {
                                        }
                                    }
                                    x = x + 1;
                                }

                            }

                            rsShrink.MoveNext();
                        }
                    }
                    return functionReturnValue;
                }

                if (lText == "(P1 ea)") {
                    rsShrink = modRecordSet.getRS(ref "SELECT StockItem.StockItemID, StockItem.StockItem_ShrinkID, Shrink.ShrinkID, ShrinkItem.ShrinkItem_ShrinkID, ShrinkItem.ShrinkItem_Quantity FROM (Shrink INNER JOIN StockItem ON Shrink.ShrinkID = StockItem.StockItem_ShrinkID) INNER JOIN ShrinkItem ON Shrink.ShrinkID = ShrinkItem.ShrinkItem_ShrinkID Where (((StockItem.stockitemID) = " + rs.Fields("StockItemID").Value + ")) ORDER BY StockItem.StockItemID, ShrinkItem.ShrinkItem_Quantity;");
                    x = 0;
                    if (rsShrink.RecordCount > 0) {

                        while (!(rsShrink.EOF)) {
                            if (rsShrink.Fields("ShrinkItem_Quantity").Value > 1) {
                                if (x == 0) {
                                    rsP = modRecordSet.getRS(ref "SELECT TOP 1 PriceChannelLnk.PriceChannelLnk_StockItemID, PriceChannelLnk.PriceChannelLnk_Quantity, PriceChannelLnk.PriceChannelLnk_ChannelID, PriceChannelLnk.PriceChannelLnk_Price From PriceChannelLnk Where (((PriceChannelLnk.PriceChannelLnk_StockItemID) = " + rsShrink.Fields("StockItemID").Value + ") And ((PriceChannelLnk.PriceChannelLnk_ChannelID) = 1) And ((PriceChannelLnk.PriceChannelLnk_Quantity) = " + rsShrink.Fields("ShrinkItem_Quantity").Value + ")) ORDER BY PriceChannelLnk.PriceChannelLnk_Quantity DESC;");
                                    if (rsP.RecordCount > 0) {
                                        functionReturnValue = Strings.Left(lString, 15) + Strings.Left("(" + Strings.FormatNumber((rsP.Fields("PriceChannelLnk_Price").Value ? rsP.Fields("PriceChannelLnk_Price").Value : 1) / (rsP.Fields("PriceChannelLnk_Quantity").Value ? rsP.Fields("PriceChannelLnk_Quantity").Value : 1), 2) + " ea)", Strings.Len(" (" + Strings.FormatNumber((rsP.Fields("PriceChannelLnk_Price").Value ? rsP.Fields("PriceChannelLnk_Price").Value : 1) / (rsP.Fields("PriceChannelLnk_Quantity").Value ? rsP.Fields("PriceChannelLnk_Quantity").Value : 1), 2) + " ea)"));
                                    } else {
                                        rsP = modRecordSet.getRS(ref "SELECT TOP 1 CatalogueChannelLnk.CatalogueChannelLnk_StockItemID, CatalogueChannelLnk.CatalogueChannelLnk_Quantity, CatalogueChannelLnk.CatalogueChannelLnk_ChannelID, CatalogueChannelLnk.CatalogueChannelLnk_Price From CatalogueChannelLnk Where (((CatalogueChannelLnk.CatalogueChannelLnk_StockItemID) = " + rsShrink.Fields("StockItemID").Value + ") And ((CatalogueChannelLnk.CatalogueChannelLnk_ChannelID) = 1) And ((CatalogueChannelLnk.CatalogueChannelLnk_Quantity) = " + rsShrink.Fields("ShrinkItem_Quantity").Value + ")) ORDER BY CatalogueChannelLnk.CatalogueChannelLnk_Quantity DESC;");
                                        if (rsP.RecordCount > 0) {
                                            functionReturnValue = Strings.Left(lString, 15) + Strings.Left("(" + Strings.FormatNumber((rsP.Fields("CatalogueChannelLnk_Price").Value ? rsP.Fields("CatalogueChannelLnk_Price").Value : 1) / (rsP.Fields("CatalogueChannelLnk_Quantity").Value ? rsP.Fields("CatalogueChannelLnk_Quantity").Value : 1), 2) + " ea)", Strings.Len(" (" + Strings.FormatNumber((rsP.Fields("CatalogueChannelLnk_Price").Value ? rsP.Fields("CatalogueChannelLnk_Price").Value : 1) / (rsP.Fields("CatalogueChannelLnk_Quantity").Value ? rsP.Fields("CatalogueChannelLnk_Quantity").Value : 1), 2) + " ea)"));

                                        } else {
                                        }
                                    }
                                    x = x + 1;

                                } else if (x == 1) {
                                    x = x + 1;

                                } else if (x == 2) {
                                    x = x + 1;
                                }

                            }

                            rsShrink.MoveNext();
                        }
                    }
                    return functionReturnValue;

                }
                if (lText == "(P2 ea)") {
                    rsShrink = modRecordSet.getRS(ref "SELECT StockItem.StockItemID, StockItem.StockItem_ShrinkID, Shrink.ShrinkID, ShrinkItem.ShrinkItem_ShrinkID, ShrinkItem.ShrinkItem_Quantity FROM (Shrink INNER JOIN StockItem ON Shrink.ShrinkID = StockItem.StockItem_ShrinkID) INNER JOIN ShrinkItem ON Shrink.ShrinkID = ShrinkItem.ShrinkItem_ShrinkID Where (((StockItem.stockitemID) = " + rs.Fields("StockItemID").Value + ")) ORDER BY StockItem.StockItemID, ShrinkItem.ShrinkItem_Quantity;");
                    x = 0;
                    if (rsShrink.RecordCount > 0) {

                        while (!(rsShrink.EOF)) {
                            if (rsShrink.Fields("ShrinkItem_Quantity").Value > 1) {

                                if (x == 0) {
                                    x = x + 1;
                                } else if (x == 1) {
                                    rsP = modRecordSet.getRS(ref "SELECT TOP 1 PriceChannelLnk.PriceChannelLnk_StockItemID, PriceChannelLnk.PriceChannelLnk_Quantity, PriceChannelLnk.PriceChannelLnk_ChannelID, PriceChannelLnk.PriceChannelLnk_Price From PriceChannelLnk Where (((PriceChannelLnk.PriceChannelLnk_StockItemID) = " + rsShrink.Fields("StockItemID").Value + ") And ((PriceChannelLnk.PriceChannelLnk_ChannelID) = 1) And ((PriceChannelLnk.PriceChannelLnk_Quantity) = " + rsShrink.Fields("ShrinkItem_Quantity").Value + ")) ORDER BY PriceChannelLnk.PriceChannelLnk_Quantity DESC;");
                                    if (rsP.RecordCount > 0) {
                                        functionReturnValue = Strings.Left(lString, 15) + Strings.Left("(" + Strings.FormatNumber((rsP.Fields("PriceChannelLnk_Price").Value ? rsP.Fields("PriceChannelLnk_Price").Value : 1) / (rsP.Fields("PriceChannelLnk_Quantity").Value ? rsP.Fields("PriceChannelLnk_Quantity").Value : 1), 2) + " ea)", Strings.Len(" (" + Strings.FormatNumber((rsP.Fields("PriceChannelLnk_Price").Value ? rsP.Fields("PriceChannelLnk_Price").Value : 1) / (rsP.Fields("PriceChannelLnk_Quantity").Value ? rsP.Fields("PriceChannelLnk_Quantity").Value : 1), 2) + " ea)"));
                                    } else {
                                        rsP = modRecordSet.getRS(ref "SELECT TOP 1 CatalogueChannelLnk.CatalogueChannelLnk_StockItemID, CatalogueChannelLnk.CatalogueChannelLnk_Quantity, CatalogueChannelLnk.CatalogueChannelLnk_ChannelID, CatalogueChannelLnk.CatalogueChannelLnk_Price From CatalogueChannelLnk Where (((CatalogueChannelLnk.CatalogueChannelLnk_StockItemID) = " + rsShrink.Fields("StockItemID").Value + ") And ((CatalogueChannelLnk.CatalogueChannelLnk_ChannelID) = 1) And ((CatalogueChannelLnk.CatalogueChannelLnk_Quantity) = " + rsShrink.Fields("ShrinkItem_Quantity").Value + ")) ORDER BY CatalogueChannelLnk.CatalogueChannelLnk_Quantity DESC;");
                                        if (rsP.RecordCount > 0) {
                                            functionReturnValue = Strings.Left(lString, 15) + Strings.Left("(" + Strings.FormatNumber((rsP.Fields("CatalogueChannelLnk_Price").Value ? rsP.Fields("CatalogueChannelLnk_Price").Value : 1) / (rsP.Fields("CatalogueChannelLnk_Quantity").Value ? rsP.Fields("CatalogueChannelLnk_Quantity").Value : 1), 2) + " ea)", Strings.Len(" (" + Strings.FormatNumber((rsP.Fields("CatalogueChannelLnk_Price").Value ? rsP.Fields("CatalogueChannelLnk_Price").Value : 1) / (rsP.Fields("CatalogueChannelLnk_Quantity").Value ? rsP.Fields("CatalogueChannelLnk_Quantity").Value : 1), 2) + " ea)"));

                                        } else {
                                        }
                                    }
                                    x = x + 1;

                                } else if (x == 2) {
                                    x = x + 1;
                                }

                            }

                            rsShrink.MoveNext();
                        }
                    }
                    return functionReturnValue;
                }
                if (lText == "(P3 ea)") {
                    rsShrink = modRecordSet.getRS(ref "SELECT StockItem.StockItemID, StockItem.StockItem_ShrinkID, Shrink.ShrinkID, ShrinkItem.ShrinkItem_ShrinkID, ShrinkItem.ShrinkItem_Quantity FROM (Shrink INNER JOIN StockItem ON Shrink.ShrinkID = StockItem.StockItem_ShrinkID) INNER JOIN ShrinkItem ON Shrink.ShrinkID = ShrinkItem.ShrinkItem_ShrinkID Where (((StockItem.stockitemID) = " + rs.Fields("StockItemID").Value + ")) ORDER BY StockItem.StockItemID, ShrinkItem.ShrinkItem_Quantity;");
                    x = 0;
                    if (rsShrink.RecordCount > 0) {

                        while (!(rsShrink.EOF)) {
                            if (rsShrink.Fields("ShrinkItem_Quantity").Value > 1) {

                                if (x == 0) {
                                    x = x + 1;

                                } else if (x == 1) {
                                    x = x + 1;
                                } else if (x == 2) {
                                    rsP = modRecordSet.getRS(ref "SELECT TOP 1 PriceChannelLnk.PriceChannelLnk_StockItemID, PriceChannelLnk.PriceChannelLnk_Quantity, PriceChannelLnk.PriceChannelLnk_ChannelID, PriceChannelLnk.PriceChannelLnk_Price From PriceChannelLnk Where (((PriceChannelLnk.PriceChannelLnk_StockItemID) = " + rsShrink.Fields("StockItemID").Value + ") And ((PriceChannelLnk.PriceChannelLnk_ChannelID) = 1) And ((PriceChannelLnk.PriceChannelLnk_Quantity) = " + rsShrink.Fields("ShrinkItem_Quantity").Value + ")) ORDER BY PriceChannelLnk.PriceChannelLnk_Quantity DESC;");
                                    if (rsP.RecordCount > 0) {
                                        functionReturnValue = Strings.Left(lString, 15) + Strings.Left("(" + Strings.FormatNumber((rsP.Fields("PriceChannelLnk_Price").Value ? rsP.Fields("PriceChannelLnk_Price").Value : 1) / (rsP.Fields("PriceChannelLnk_Quantity").Value ? rsP.Fields("PriceChannelLnk_Quantity").Value : 1), 2) + " ea)", Strings.Len(" (" + Strings.FormatNumber((rsP.Fields("PriceChannelLnk_Price").Value ? rsP.Fields("PriceChannelLnk_Price").Value : 1) / (rsP.Fields("PriceChannelLnk_Quantity").Value ? rsP.Fields("PriceChannelLnk_Quantity").Value : 1), 2) + " ea)"));
                                    } else {
                                        rsP = modRecordSet.getRS(ref "SELECT TOP 1 CatalogueChannelLnk.CatalogueChannelLnk_StockItemID, CatalogueChannelLnk.CatalogueChannelLnk_Quantity, CatalogueChannelLnk.CatalogueChannelLnk_ChannelID, CatalogueChannelLnk.CatalogueChannelLnk_Price From CatalogueChannelLnk Where (((CatalogueChannelLnk.CatalogueChannelLnk_StockItemID) = " + rsShrink.Fields("StockItemID").Value + ") And ((CatalogueChannelLnk.CatalogueChannelLnk_ChannelID) = 1) And ((CatalogueChannelLnk.CatalogueChannelLnk_Quantity) = " + rsShrink.Fields("ShrinkItem_Quantity").Value + ")) ORDER BY CatalogueChannelLnk.CatalogueChannelLnk_Quantity DESC;");
                                        if (rsP.RecordCount > 0) {
                                            functionReturnValue = Strings.Left(lString, 15) + Strings.Left("(" + Strings.FormatNumber((rsP.Fields("CatalogueChannelLnk_Price").Value ? rsP.Fields("CatalogueChannelLnk_Price").Value : 1) / (rsP.Fields("CatalogueChannelLnk_Quantity").Value ? rsP.Fields("CatalogueChannelLnk_Quantity").Value : 1), 2) + " ea)", Strings.Len(" (" + Strings.FormatNumber((rsP.Fields("CatalogueChannelLnk_Price").Value ? rsP.Fields("CatalogueChannelLnk_Price").Value : 1) / (rsP.Fields("CatalogueChannelLnk_Quantity").Value ? rsP.Fields("CatalogueChannelLnk_Quantity").Value : 1), 2) + " ea)"));

                                        } else {
                                        }
                                    }
                                    x = x + 1;
                                }

                            }

                            rsShrink.MoveNext();
                        }
                    }
                    return functionReturnValue;
                }

                if (lText == "(P1 EA)") {
                    rsShrink = modRecordSet.getRS(ref "SELECT StockItem.StockItemID, StockItem.StockItem_ShrinkID, Shrink.ShrinkID, ShrinkItem.ShrinkItem_ShrinkID, ShrinkItem.ShrinkItem_Quantity FROM (Shrink INNER JOIN StockItem ON Shrink.ShrinkID = StockItem.StockItem_ShrinkID) INNER JOIN ShrinkItem ON Shrink.ShrinkID = ShrinkItem.ShrinkItem_ShrinkID Where (((StockItem.stockitemID) = " + rs.Fields("StockItemID").Value + ")) ORDER BY StockItem.StockItemID, ShrinkItem.ShrinkItem_Quantity;");
                    x = 0;
                    if (rsShrink.RecordCount > 0) {

                        while (!(rsShrink.EOF)) {
                            if (rsShrink.Fields("ShrinkItem_Quantity").Value > 1) {
                                if (x == 0) {
                                    rsP = modRecordSet.getRS(ref "SELECT TOP 1 PriceChannelLnk.PriceChannelLnk_StockItemID, PriceChannelLnk.PriceChannelLnk_Quantity, PriceChannelLnk.PriceChannelLnk_ChannelID, PriceChannelLnk.PriceChannelLnk_Price From PriceChannelLnk Where (((PriceChannelLnk.PriceChannelLnk_StockItemID) = " + rsShrink.Fields("StockItemID").Value + ") And ((PriceChannelLnk.PriceChannelLnk_ChannelID) = 1) And ((PriceChannelLnk.PriceChannelLnk_Quantity) = " + rsShrink.Fields("ShrinkItem_Quantity").Value + ")) ORDER BY PriceChannelLnk.PriceChannelLnk_Quantity DESC;");
                                    if (rsP.RecordCount > 0) {
                                        functionReturnValue = Strings.Left(lString, 15) + Strings.Left("(" + Strings.FormatNumber((rsP.Fields("PriceChannelLnk_Price").Value ? rsP.Fields("PriceChannelLnk_Price").Value : 1) / (rsP.Fields("PriceChannelLnk_Quantity").Value ? rsP.Fields("PriceChannelLnk_Quantity").Value : 1), 2) + " ea)", Strings.Len(" (" + Strings.FormatNumber((rsP.Fields("PriceChannelLnk_Price").Value ? rsP.Fields("PriceChannelLnk_Price").Value : 1) / (rsP.Fields("PriceChannelLnk_Quantity").Value ? rsP.Fields("PriceChannelLnk_Quantity").Value : 1), 2) + " EA)"));
                                    } else {
                                        rsP = modRecordSet.getRS(ref "SELECT TOP 1 CatalogueChannelLnk.CatalogueChannelLnk_StockItemID, CatalogueChannelLnk.CatalogueChannelLnk_Quantity, CatalogueChannelLnk.CatalogueChannelLnk_ChannelID, CatalogueChannelLnk.CatalogueChannelLnk_Price From CatalogueChannelLnk Where (((CatalogueChannelLnk.CatalogueChannelLnk_StockItemID) = " + rsShrink.Fields("StockItemID").Value + ") And ((CatalogueChannelLnk.CatalogueChannelLnk_ChannelID) = 1) And ((CatalogueChannelLnk.CatalogueChannelLnk_Quantity) = " + rsShrink.Fields("ShrinkItem_Quantity").Value + ")) ORDER BY CatalogueChannelLnk.CatalogueChannelLnk_Quantity DESC;");
                                        if (rsP.RecordCount > 0) {
                                            functionReturnValue = Strings.Left(lString, 15) + Strings.Left("(" + Strings.FormatNumber((rsP.Fields("CatalogueChannelLnk_Price").Value ? rsP.Fields("CatalogueChannelLnk_Price").Value : 1) / (rsP.Fields("CatalogueChannelLnk_Quantity").Value ? rsP.Fields("CatalogueChannelLnk_Quantity").Value : 1), 2) + " ea)", Strings.Len(" (" + Strings.FormatNumber((rsP.Fields("CatalogueChannelLnk_Price").Value ? rsP.Fields("CatalogueChannelLnk_Price").Value : 1) / (rsP.Fields("CatalogueChannelLnk_Quantity").Value ? rsP.Fields("CatalogueChannelLnk_Quantity").Value : 1), 2) + " EA)"));

                                        } else {
                                        }
                                    }
                                    x = x + 1;

                                } else if (x == 1) {
                                    x = x + 1;

                                } else if (x == 2) {
                                    x = x + 1;
                                }

                            }

                            rsShrink.MoveNext();
                        }
                    }
                    return functionReturnValue;

                }
                if (lText == "(P2 EA)") {
                    rsShrink = modRecordSet.getRS(ref "SELECT StockItem.StockItemID, StockItem.StockItem_ShrinkID, Shrink.ShrinkID, ShrinkItem.ShrinkItem_ShrinkID, ShrinkItem.ShrinkItem_Quantity FROM (Shrink INNER JOIN StockItem ON Shrink.ShrinkID = StockItem.StockItem_ShrinkID) INNER JOIN ShrinkItem ON Shrink.ShrinkID = ShrinkItem.ShrinkItem_ShrinkID Where (((StockItem.stockitemID) = " + rs.Fields("StockItemID").Value + ")) ORDER BY StockItem.StockItemID, ShrinkItem.ShrinkItem_Quantity;");
                    x = 0;
                    if (rsShrink.RecordCount > 0) {

                        while (!(rsShrink.EOF)) {
                            if (rsShrink.Fields("ShrinkItem_Quantity").Value > 1) {

                                if (x == 0) {
                                    x = x + 1;
                                } else if (x == 1) {
                                    rsP = modRecordSet.getRS(ref "SELECT TOP 1 PriceChannelLnk.PriceChannelLnk_StockItemID, PriceChannelLnk.PriceChannelLnk_Quantity, PriceChannelLnk.PriceChannelLnk_ChannelID, PriceChannelLnk.PriceChannelLnk_Price From PriceChannelLnk Where (((PriceChannelLnk.PriceChannelLnk_StockItemID) = " + rsShrink.Fields("StockItemID").Value + ") And ((PriceChannelLnk.PriceChannelLnk_ChannelID) = 1) And ((PriceChannelLnk.PriceChannelLnk_Quantity) = " + rsShrink.Fields("ShrinkItem_Quantity").Value + ")) ORDER BY PriceChannelLnk.PriceChannelLnk_Quantity DESC;");
                                    if (rsP.RecordCount > 0) {
                                        functionReturnValue = Strings.Left(lString, 15) + Strings.Left("(" + Strings.FormatNumber((rsP.Fields("PriceChannelLnk_Price").Value ? rsP.Fields("PriceChannelLnk_Price").Value : 1) / (rsP.Fields("PriceChannelLnk_Quantity").Value ? rsP.Fields("PriceChannelLnk_Quantity").Value : 1), 2) + " ea)", Strings.Len(" (" + Strings.FormatNumber((rsP.Fields("PriceChannelLnk_Price").Value ? rsP.Fields("PriceChannelLnk_Price").Value : 1) / (rsP.Fields("PriceChannelLnk_Quantity").Value ? rsP.Fields("PriceChannelLnk_Quantity").Value : 1), 2) + " EA)"));
                                    } else {
                                        rsP = modRecordSet.getRS(ref "SELECT TOP 1 CatalogueChannelLnk.CatalogueChannelLnk_StockItemID, CatalogueChannelLnk.CatalogueChannelLnk_Quantity, CatalogueChannelLnk.CatalogueChannelLnk_ChannelID, CatalogueChannelLnk.CatalogueChannelLnk_Price From CatalogueChannelLnk Where (((CatalogueChannelLnk.CatalogueChannelLnk_StockItemID) = " + rsShrink.Fields("StockItemID").Value + ") And ((CatalogueChannelLnk.CatalogueChannelLnk_ChannelID) = 1) And ((CatalogueChannelLnk.CatalogueChannelLnk_Quantity) = " + rsShrink.Fields("ShrinkItem_Quantity").Value + ")) ORDER BY CatalogueChannelLnk.CatalogueChannelLnk_Quantity DESC;");
                                        if (rsP.RecordCount > 0) {
                                            functionReturnValue = Strings.Left(lString, 15) + Strings.Left("(" + Strings.FormatNumber((rsP.Fields("CatalogueChannelLnk_Price").Value ? rsP.Fields("CatalogueChannelLnk_Price").Value : 1) / (rsP.Fields("CatalogueChannelLnk_Quantity").Value ? rsP.Fields("CatalogueChannelLnk_Quantity").Value : 1), 2) + " ea)", Strings.Len(" (" + Strings.FormatNumber((rsP.Fields("CatalogueChannelLnk_Price").Value ? rsP.Fields("CatalogueChannelLnk_Price").Value : 1) / (rsP.Fields("CatalogueChannelLnk_Quantity").Value ? rsP.Fields("CatalogueChannelLnk_Quantity").Value : 1), 2) + " EA)"));

                                        } else {
                                        }
                                    }
                                    x = x + 1;

                                } else if (x == 2) {
                                    x = x + 1;
                                }

                            }

                            rsShrink.MoveNext();
                        }
                    }
                    return functionReturnValue;
                }
                if (lText == "(P3 EA)") {
                    rsShrink = modRecordSet.getRS(ref "SELECT StockItem.StockItemID, StockItem.StockItem_ShrinkID, Shrink.ShrinkID, ShrinkItem.ShrinkItem_ShrinkID, ShrinkItem.ShrinkItem_Quantity FROM (Shrink INNER JOIN StockItem ON Shrink.ShrinkID = StockItem.StockItem_ShrinkID) INNER JOIN ShrinkItem ON Shrink.ShrinkID = ShrinkItem.ShrinkItem_ShrinkID Where (((StockItem.stockitemID) = " + rs.Fields("StockItemID").Value + ")) ORDER BY StockItem.StockItemID, ShrinkItem.ShrinkItem_Quantity;");
                    x = 0;
                    if (rsShrink.RecordCount > 0) {

                        while (!(rsShrink.EOF)) {
                            if (rsShrink.Fields("ShrinkItem_Quantity").Value > 1) {

                                if (x == 0) {
                                    x = x + 1;

                                } else if (x == 1) {
                                    x = x + 1;
                                } else if (x == 2) {
                                    rsP = modRecordSet.getRS(ref "SELECT TOP 1 PriceChannelLnk.PriceChannelLnk_StockItemID, PriceChannelLnk.PriceChannelLnk_Quantity, PriceChannelLnk.PriceChannelLnk_ChannelID, PriceChannelLnk.PriceChannelLnk_Price From PriceChannelLnk Where (((PriceChannelLnk.PriceChannelLnk_StockItemID) = " + rsShrink.Fields("StockItemID").Value + ") And ((PriceChannelLnk.PriceChannelLnk_ChannelID) = 1) And ((PriceChannelLnk.PriceChannelLnk_Quantity) = " + rsShrink.Fields("ShrinkItem_Quantity").Value + ")) ORDER BY PriceChannelLnk.PriceChannelLnk_Quantity DESC;");
                                    if (rsP.RecordCount > 0) {
                                        functionReturnValue = Strings.Left(lString, 15) + Strings.Left("(" + Strings.FormatNumber((rsP.Fields("PriceChannelLnk_Price").Value ? rsP.Fields("PriceChannelLnk_Price").Value : 1) / (rsP.Fields("PriceChannelLnk_Quantity").Value ? rsP.Fields("PriceChannelLnk_Quantity").Value : 1), 2) + " ea)", Strings.Len(" (" + Strings.FormatNumber((rsP.Fields("PriceChannelLnk_Price").Value ? rsP.Fields("PriceChannelLnk_Price").Value : 1) / (rsP.Fields("PriceChannelLnk_Quantity").Value ? rsP.Fields("PriceChannelLnk_Quantity").Value : 1), 2) + " EA)"));
                                    } else {
                                        rsP = modRecordSet.getRS(ref "SELECT TOP 1 CatalogueChannelLnk.CatalogueChannelLnk_StockItemID, CatalogueChannelLnk.CatalogueChannelLnk_Quantity, CatalogueChannelLnk.CatalogueChannelLnk_ChannelID, CatalogueChannelLnk.CatalogueChannelLnk_Price From CatalogueChannelLnk Where (((CatalogueChannelLnk.CatalogueChannelLnk_StockItemID) = " + rsShrink.Fields("StockItemID").Value + ") And ((CatalogueChannelLnk.CatalogueChannelLnk_ChannelID) = 1) And ((CatalogueChannelLnk.CatalogueChannelLnk_Quantity) = " + rsShrink.Fields("ShrinkItem_Quantity").Value + ")) ORDER BY CatalogueChannelLnk.CatalogueChannelLnk_Quantity DESC;");
                                        if (rsP.RecordCount > 0) {
                                            functionReturnValue = Strings.Left(lString, 15) + Strings.Left("(" + Strings.FormatNumber((rsP.Fields("CatalogueChannelLnk_Price").Value ? rsP.Fields("CatalogueChannelLnk_Price").Value : 1) / (rsP.Fields("CatalogueChannelLnk_Quantity").Value ? rsP.Fields("CatalogueChannelLnk_Quantity").Value : 1), 2) + " ea)", Strings.Len(" (" + Strings.FormatNumber((rsP.Fields("CatalogueChannelLnk_Price").Value ? rsP.Fields("CatalogueChannelLnk_Price").Value : 1) / (rsP.Fields("CatalogueChannelLnk_Quantity").Value ? rsP.Fields("CatalogueChannelLnk_Quantity").Value : 1), 2) + " EA)"));

                                        } else {
                                        }
                                    }
                                    x = x + 1;
                                }

                            }

                            rsShrink.MoveNext();
                        }
                    }
                    return functionReturnValue;
                }

                if (lText == "CCCC MM") {
                    //doString = Left(lString, 15) & Replace(lText, lText, Left(String(Len(lText), " ") & Year(Now) & " " & Month(Now), Len(lText)))
                    functionReturnValue = Strings.Left(lString, 15) + Strings.Left(DateAndTime.Year(DateAndTime.Now) + " " + DateAndTime.Month(DateAndTime.Now), Strings.Len(lText));
                    return functionReturnValue;
                }

                //If InStr(lText, "XX") Then
                if (lText == "XX") {
                    functionReturnValue = Strings.Left(lString, 15) + Strings.Replace(lText, lText, Strings.Right(new string(" ", Strings.Len(lText)) + Strings.Split(rs.Fields("Price").Value, ".")[1], Strings.Len(lText)));
                    return functionReturnValue;
                }
                if (Strings.InStr(lText, "DEPARTMENT CENTER")) {
                    functionReturnValue = Strings.Left(lString, 15) + doCenter(ref lText, ref rs.Fields("PricingGroup_Name").Value);
                    return functionReturnValue;
                }
                if (Strings.InStr(lText, "DEPARTMENT LEFT")) {
                    functionReturnValue = Strings.Left(lString, 15) + Strings.Left(rs.Fields("PricingGroup_Name").Value, Strings.Len(lText));
                    return functionReturnValue;
                }
                if (Strings.InStr(lText, "DEPARTMENT RIGHT")) {
                    functionReturnValue = Strings.Left(lString, 15) + Strings.Right(new string(" ", Strings.Len(lText)) + rs.Fields("PricingGroup_Name").Value, Strings.Len(lText));
                    return functionReturnValue;
                }
                if (Strings.InStr(lText, "BARREAD CENTER")) {
                    functionReturnValue = Strings.Left(lString, 15) + doCenter(ref lText, ref rs.Fields("Catalogue_Barcode").Value);
                    return functionReturnValue;
                }
                if (Strings.InStr(lText, "BARREAD LEFT")) {
                    functionReturnValue = Strings.Left(lString, 15) + Strings.Left(rs.Fields("Catalogue_Barcode").Value, Strings.Len(lText));
                    return functionReturnValue;
                }
                if (Strings.InStr(lText, "BARREAD RIGHT")) {
                    functionReturnValue = Strings.Left(lString, 15) + Strings.Right(new string(" ", Strings.Len(lText)) + rs.Fields("Catalogue_Barcode").Value, Strings.Len(lText));
                    return functionReturnValue;
                }

                if (Strings.InStr(lText, "BARCODEXXXXXX")) {
                    functionReturnValue = Strings.Left(lString, 15) + Strings.Right(new string(" ", Strings.Len(lText)) + rs.Fields("Catalogue_Barcode").Value, Strings.Len(lText));
                    return functionReturnValue;
                }

                if (Strings.InStr(lText, "NAME 1 CENTER")) {
                    lString1 = rs.Fields("Stockitem_Name").Value;
                    if (rs.Fields("Catalogue_Quantity").Value != 1)
                        lString1 = rs.Fields("Catalogue_Quantity").Value + "X" + lString1;
                    splitString(ref Strings.Len(lText), ref lString1, ref lString2);
                    functionReturnValue = Strings.Left(lString, 15) + doCenter(ref lText, ref lString1);
                    return functionReturnValue;
                }
                if (Strings.InStr(lText, "NAME 1 LEFT")) {
                    lString1 = rs.Fields("Stockitem_Name").Value;
                    if (rs.Fields("Catalogue_Quantity").Value != 1)
                        lString1 = rs.Fields("Catalogue_Quantity").Value + "X" + lString1;
                    splitString(ref Strings.Len(lText), ref lString1, ref lString2);
                    functionReturnValue = Strings.Left(lString, 15) + Strings.Left(lString1, Strings.Len(lText));
                    return functionReturnValue;
                }
                if (Strings.InStr(lText, "NAME 1 RIGHT")) {
                    lString1 = rs.Fields("Stockitem_Name").Value;
                    if (rs.Fields("Catalogue_Quantity").Value != 1)
                        lString1 = rs.Fields("Catalogue_Quantity").Value + "X" + lString1;
                    splitString(ref Strings.Len(lText), ref lString1, ref lString2);
                    functionReturnValue = Strings.Left(lString, 15) + Strings.Right(new string(" ", Strings.Len(lText)) + lString1, Strings.Len(lText));
                    return functionReturnValue;
                }

                if (Strings.InStr(lText, "NAME 2 CENTER")) {
                    lString1 = rs.Fields("Stockitem_Name").Value;
                    if (rs.Fields("Catalogue_Quantity").Value != 1)
                        lString1 = rs.Fields("Catalogue_Quantity").Value + "X" + lString1;
                    splitString(ref Strings.Len(lText), ref lString1, ref lString2);
                    functionReturnValue = Strings.Left(lString, 15) + doCenter(ref lText, ref lString2);
                    return functionReturnValue;
                }
                if (Strings.InStr(lText, "NAME 2 LEFT")) {
                    lString1 = rs.Fields("Stockitem_Name").Value;
                    if (rs.Fields("Catalogue_Quantity").Value != 1)
                        lString1 = rs.Fields("Catalogue_Quantity").Value + "X" + lString1;
                    splitString(ref Strings.Len(lText), ref lString1, ref lString2);
                    functionReturnValue = Strings.Left(lString, 15) + Strings.Left(lString2, Strings.Len(lText));
                    return functionReturnValue;
                }
                if (Strings.InStr(lText, "NAME 2 RIGHT")) {
                    lString1 = rs.Fields("Stockitem_Name").Value;
                    if (rs.Fields("Catalogue_Quantity").Value != 1)
                        lString1 = rs.Fields("Catalogue_Quantity").Value + "X" + lString1;
                    splitString(ref Strings.Len(lText), ref lString1, ref lString2);
                    functionReturnValue = Strings.Left(lString, 15) + Strings.Right(new string(" ", Strings.Len(lText)) + lString2, Strings.Len(lText));
                    return functionReturnValue;
                }
                if (Strings.InStr(lText, "DATE")) {
                    lString1 = Strings.Format(DateAndTime.Now, "yymm");
                    functionReturnValue = Strings.Left(lString, 15) + Strings.Format(DateAndTime.Now, "yymm");
                    return functionReturnValue;
                }

                //Expiry Date
                if (Strings.InStr(lText, "SELL BY")) {
                    //lString1 = Format((Now() + rs("StockItem_ExpiryDays")), "dd/mm/yy")
                    //doString = Left(lString, 15) & Format((Now() + rs("StockItem_ExpiryDays")), "dd/mm/yy")
                    lString1 = rs.Fields("StockItem_ExpiryDays").Value;
                    functionReturnValue = Strings.Left(lString, 15) + rs.Fields("StockItem_ExpiryDays").Value;
                    return functionReturnValue;
                }

                if (lText == "BARCODE") {
                    //If InStr(lText, "BARCODE") Then
                    if (doCheckSum(ref rs.Fields("Catalogue_Barcode").Value)) {
                    } else {
                        functionReturnValue = Strings.Left(lString, 15) + rs.Fields("Catalogue_Barcode").Value;
                    }
                    return functionReturnValue;
                }
                if (Strings.InStr(lText, "600106007141")) {
                    if (doCheckSum(ref rs.Fields("Catalogue_Barcode").Value)) {
                        functionReturnValue = Strings.Left(lString, 15) + Strings.Left(rs.Fields("Catalogue_Barcode").Value + "0000", 13);
                    }
                    return functionReturnValue;
                }
                functionReturnValue = lString;
            } else {
                if (lString == "Q0001") {
                    functionReturnValue = Strings.Replace(lString, "Q0001", "Q" + Strings.Right("0000" + rs.Fields("barcodePersonLnk_PrintQTY").Value, 4));
                } else {
                    functionReturnValue = lString;
                }
            }
            return functionReturnValue;
        }
Exemplo n.º 4
0
        public bool PrintBarcodeDatamax(ref ADODB.Recordset rs)
        {
            string sql = null;
            string mm = null;
            int i = 0;
            int lline = 0;
            int lTop = 0;
            int lHeight = 0;
            System.Drawing.Printing.PrintDocument Printer = new System.Drawing.Printing.PrintDocument();
            System.Drawing.Printing.PrintDocument lObject = new System.Drawing.Printing.PrintDocument();
            int y = 0;
            int x = 0;
            ADODB.Recordset rsData = default(ADODB.Recordset);
            int currentPic = 0;
            int twipsToMM = 0;
            int lLeft = 0;
            int lWidth = 0;
            short lCol = 0;
            short lCols = 0;
            short lRows = 0;
            short lrow = 0;

            ADODB.Recordset rsPrice = default(ADODB.Recordset);

            //Printer.ScaleMode = ScaleModeConstants.vbTwips 'twips
            //twipsToMM = Printer.ScaleWidth
            //Printer.ScaleMode = ScaleModeConstants.vbMillimeters 'mm
            //twipsToMM = twipsToMM / Printer.ScaleWidth
            //Printer.ScaleMode = ScaleModeConstants.vbTwips 'twips
            lObject = Printer;

            string lString1 = null;
            string lString2 = null;
            rsData = modRecordSet.getRS(ref "SELECT * FROM labelItem INNER JOIN label ON labelItem.labelItem_LabelID = label.labelID Where (((label.labelID) = " + rs.Fields("LabelID").Value + ")) ORDER BY label.labelID, labelItem.labelItem_Line;");
            //lLeft = (lObject.Width - (lWidth)) / 2 + (gOffsetLabel * twipsToMM)

            lLeft = 0;
            if (rsData.Fields("Label_Rotate").Value) {
                lWidth = rsData.Fields("label_Height").Value * twipsToMM;
                lHeight = rsData.Fields("label_Width").Value * twipsToMM;
            } else {
                lWidth = rsData.Fields("label_width").Value * twipsToMM;
                lHeight = rsData.Fields("label_Height").Value * twipsToMM;
            }
            lTop = rsData.Fields("label_Top").Value * twipsToMM;
            //lCols = CDec(Printer.Width / (lWidth + 60)) - 0.49999
            //lRows = CDec(Printer.Height / (lHeight + 60)) - 0.49999

            while (!(rs.EOF)) {
                rsData.MoveFirst();
                y = 0;

                //If y < 0 Then y = 0
                //lObject.FontName = "Tahoma"
                rsData.MoveFirst();
                if (rsData.RecordCount) {
                    lline = rsData.Fields("labelItem_Line").Value;

                    for (i = 1; i <= rs.Fields("barcodePersonLnk_PrintQTY").Value; i++) {
                        lLeft = (Information.IsDBNull(rsData.Fields("Label_Left").Value) ? 0 : rsData.Fields("Label_Left").Value) * twipsToMM;
                        //lObject.CurrentY = lrow * (lHeight + 60)
                        rsData.MoveFirst();
                        //y = lObject.CurrentY
                        //lObject.ForeColor = System.Drawing.ColorTranslator.ToOle(Me.BackColor)
                         // ERROR: Not supported in C#: OnErrorStatement

                        //lObject.Line((lLeft, y) - (lLeft, y + 100))
                        //lObject.Line((lLeft, y) - (lLeft + 100, y))
                        //lObject.Line((lLeft + lWidth, y) - (lLeft + lWidth - 100, y))
                        //lObject.Line((lLeft + lWidth, y) - (lLeft + lWidth, y + 100))
                        //lObject.Line((lLeft + lWidth, lHeight + y) - (lLeft + lWidth, lHeight + y - 100))
                        //lObject.Line((lLeft + lWidth, lHeight + y) - (lLeft + lWidth - 100, lHeight + y))
                        //lObject.Line((lLeft, lHeight + y) - (lLeft, lHeight + y - 100))
                        //lObject.Line((lLeft, lHeight + y) - (lLeft + 100, lHeight + y))
                        //lObject.CurrentY = lrow * (lHeight + 60) + lTop
                        //lObject.ForeColor = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Black)
                        //y = lObject.CurrentY + 10

                        while (!(rsData.EOF)) {
                            if (lline != rsData.Fields("labelItem_Line").Value) {
                                //y = lObject.CurrentY + 10

                                lline = rsData.Fields("labelItem_Line").Value;
                            }

                            switch (Strings.LCase(Strings.Trim(rsData.Fields("labelItem_Field").Value))) {
                                case "blank":
                                    break;
                                //lObject.FontSize = rsData.Fields("labelItem_Size").Value
                                //lObject.FontBold = rsData.Fields("labelItem_Bold").Value
                                //lObject.ForeColor = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.White)
                                //lObject.Print(" ")
                                case "line":
                                    break;
                                //lObject.Line((15 + lLeft, y) - (lLeft + lWidth, y), System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Black))

                                case "code":
                                    switch (rsData.Fields("labelItem_Align").Value) {
                                        case 1:
                                            break;
                                        //printBarcode(lObject, rs.Fields("Catalogue_Barcode").Value, lLeft + 90, y)
                                        case 2:
                                            break;
                                        //printBarcode(lObject, rs.Fields("Catalogue_Barcode").Value, lLeft + 90, y, lWidth + lWidth - 1440)
                                        default:
                                            break;
                                        //printBarcode(lObject, rs.Fields("Catalogue_Barcode").Value, lLeft, y, lWidth)
                                    }

                                    break;
                                default:
                                    //lObject.FontSize = rsData.Fields("labelItem_Size").Value
                                    //lObject.FontBold = rsData.Fields("labelItem_Bold").Value
                                    //lObject.ForeColor = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.White)
                                    mm = rsData.Fields("labelItem_Field").Value;
                                    //code for printing shrinks
                                    if (mm == "Price6") {
                                        sql = "SELECT StockItem.StockItemID, Format([CatalogueChannelLnk_Price],'Currency') AS Price ";
                                        sql = sql + "FROM (StockItem INNER JOIN Catalogue ON StockItem.StockItemID = Catalogue.Catalogue_StockItemID) INNER JOIN CatalogueChannelLnk ON StockItem.StockItemID = CatalogueChannelLnk.CatalogueChannelLnk_StockItemID ";
                                        sql = sql + "WHERE (((StockItem.StockItemID)=" + rs.Fields("StockItemID").Value + ") AND ((Catalogue.Catalogue_Quantity)=6) AND ((CatalogueChannelLnk.CatalogueChannelLnk_Quantity)=6) AND ((CatalogueChannelLnk.CatalogueChannelLnk_ChannelID)=1));";
                                        rsPrice = modRecordSet.getRS(ref sql);
                                        if (rsPrice.RecordCount) {
                                            lString1 = rsPrice.Fields("Price").Value + " FOR   6";
                                        } else {
                                            lString1 = " ";
                                        }

                                    } else if (mm == "Price12") {
                                        sql = "SELECT StockItem.StockItemID, Format([CatalogueChannelLnk_Price],'Currency') AS Price ";
                                        sql = sql + "FROM (StockItem INNER JOIN Catalogue ON StockItem.StockItemID = Catalogue.Catalogue_StockItemID) INNER JOIN CatalogueChannelLnk ON StockItem.StockItemID = CatalogueChannelLnk.CatalogueChannelLnk_StockItemID ";
                                        sql = sql + "WHERE (((StockItem.StockItemID)=" + rs.Fields("StockItemID").Value + ") AND ((Catalogue.Catalogue_Quantity)=12) AND ((CatalogueChannelLnk.CatalogueChannelLnk_Quantity)=12) AND ((CatalogueChannelLnk.CatalogueChannelLnk_ChannelID)=1));";
                                        rsPrice = modRecordSet.getRS(ref sql);
                                        if (rsPrice.RecordCount) {
                                            lString1 = rsPrice.Fields("Price").Value + " FOR  12";
                                        } else {
                                            lString1 = " ";
                                        }

                                    } else if (mm == "Price24") {
                                        sql = "SELECT StockItem.StockItemID, Format([CatalogueChannelLnk_Price],'Currency') AS Price ";
                                        sql = sql + "FROM (StockItem INNER JOIN Catalogue ON StockItem.StockItemID = Catalogue.Catalogue_StockItemID) INNER JOIN CatalogueChannelLnk ON StockItem.StockItemID = CatalogueChannelLnk.CatalogueChannelLnk_StockItemID ";
                                        sql = sql + "WHERE (((StockItem.StockItemID)=" + rs.Fields("StockItemID").Value + ") AND ((Catalogue.Catalogue_Quantity)=24) AND ((CatalogueChannelLnk.CatalogueChannelLnk_Quantity)=24) AND ((CatalogueChannelLnk.CatalogueChannelLnk_ChannelID)=1));";
                                        rsPrice = modRecordSet.getRS(ref sql);
                                        if (rsPrice.RecordCount) {
                                            lString1 = rsPrice.Fields("Price").Value + " FOR  24";
                                        } else {
                                            lString1 = " ";
                                        }
                                    } else {
                                        lString1 = rs.Fields(mm).Value;
                                    }
                                    //code for printing shrinks

                                    //lString1 = rs(mm)
                                    switch (rsData.Fields("labelItem_Align").Value) {
                                        case 1:

                                            break;
                                        //lObject.PSet(New Point[](lLeft + 90, y))
                                        //lObject.ForeColor = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Black)
                                        //lObject.Print(lString1)

                                        case 2:
                                            break;
                                        //lObject.PSet(New Point[](lLeft + lWidth - lObject.TextWidth(lString1) - 90, y))
                                        //lObject.ForeColor = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Black)
                                        //lObject.Print(lString1)
                                        case 3:
                                            //splitStringA4(lObject, lWidth, lString1, lString2)
                                            //lObject.PSet(New Point[](CShort(lLeft + (lWidth - lObject.TextWidth(lString1)) / 2), y))
                                            //lObject.ForeColor = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Black)
                                            //lObject.Print(lString1)
                                            //y = lObject.CurrentY + 10

                                            //lObject.ForeColor = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.White)
                                            lString1 = lString2;
                                            break;
                                        //lObject.PSet(New Point[](CShort(lLeft + (lWidth - lObject.TextWidth(lString1)) / 2), y))
                                        //lObject.ForeColor = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Black)
                                        //lObject.Print(lString1)

                                        default:
                                            break;
                                        //lObject.PSet(New Point[](CShort(lLeft + (lWidth - lObject.TextWidth(lString1)) / 2), y))

                                        // lObject.ForeColor = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Black)
                                        // lObject.Print(lString1)
                                    }
                                    break;
                            }
                            rsData.MoveNext();
                        }

                        //New code for tesing barcode printing

                        //Printer.NewPage()

                    }
                }
                rs.MoveNext();
            }
            //Printer.EndDoc()
        }
Exemplo n.º 5
0
        private void printStockBarcode(ref ADODB.Recordset rs)
        {
            Scripting.FileSystemObject fso = new Scripting.FileSystemObject();
            Scripting.TextStream lStream = default(Scripting.TextStream);
            string lString = null;
            string[] lArray = null;
            string lText = null;
            short x = 0;
            while (!(rs.EOF)) {
                lString = rs.Fields("label_textstream").Value;
                lArray = Strings.Split(lString, Constants.vbCrLf);
                lString = "";

                for (x = 0; x <= Information.UBound(lArray); x++) {
                    lText = lArray[x];
                    lString = lString + Constants.vbCrLf + doString(ref lText, ref rs);
                }
                lStream = fso.OpenTextFile("c:\\aa.txt", Scripting.IOMode.ForWriting, true);
                lStream.Write(lString);
                lStream.Close();
                lString = "C:\\AA.TXT";
                modSpool.SpoolFile(lString, (lblPrinter.Text));

                rs.MoveNext();
            }
        }
Exemplo n.º 6
0
        private void printStockA4(ref ADODB.Recordset rs)
        {
            decimal mm = default(decimal);
            int i = 0;
            int lline = 0;
            string bGroup = null;
            string sGroup = null;
            int lTop = 0;
            int lHeight = 0;
            int gOffsetLabel = 0;
            int dasd = 0;
            System.Drawing.Printing.PrintDocument Printer = new System.Drawing.Printing.PrintDocument();
            System.Drawing.Printing.PrintDocument lObject = new System.Drawing.Printing.PrintDocument();
            int y = 0;
            int x = 0;
            ADODB.Recordset rsData = default(ADODB.Recordset);
            int currentPic = 0;
            int twipsToMM = 0;
            int lLeft = 0;
            int lWidth = 0;
            short lCol = 0;
            short lCols = 0;
            short lRows = 0;
            short lrow = 0;
             // ERROR: Not supported in C#: OnErrorStatement

            dasd = Printer.PrinterSettings.DefaultPageSettings.PaperSize.Width;
            //Printer.PrinterSettings.DefaultPageSettings.ScaleMode = ScaleModeConstants.vbTwips 'twips
            //twipsToMM = Printer.ScaleWidth
            //Printer.ScaleMode = ScaleModeConstants.vbMillimeters 'mm
            //twipsToMM = twipsToMM / Printer.ScaleWidth
            //Printer.ScaleMode = ScaleModeConstants.vbTwips 'twips
            lObject = Printer;

            string lString1 = null;
            string lString2 = null;

            rsData = modRecordSet.getRS(ref "SELECT * FROM labelItem INNER JOIN label ON labelItem.labelItem_LabelID = label.labelID Where (((label.labelID) = " + rs.Fields("LabelID").Value + ")) ORDER BY label.labelID, labelItem.labelItem_Line;");

            lLeft = (lObject.PrinterSettings.DefaultPageSettings.PaperSize.Width - (lWidth)) / 2 + (gOffsetLabel * twipsToMM);
            lLeft = 0;
            if (rsData.Fields("Label_Rotate").Value) {
                lWidth = rsData.Fields("label_Height").Value * twipsToMM;
                lHeight = rsData.Fields("label_Width").Value * twipsToMM;
            } else {
                lWidth = rsData.Fields("label_width").Value * twipsToMM;
                lHeight = rsData.Fields("label_Height").Value * twipsToMM;
            }
            lTop = rsData.Fields("label_Top").Value * twipsToMM;
            lCols = Convert.ToDecimal(Printer.PrinterSettings.DefaultPageSettings.PaperSize.Width / (lWidth + 60)) - 0.49999;
            lRows = Convert.ToDecimal(Printer.PrinterSettings.DefaultPageSettings.PaperSize.Height / (lHeight + 60)) - 0.49999;

            sGroup = "1";
            if (Strings.InStr(Strings.LCase(rsData.Fields("Label_Name").Value), "nursery")) {
                bGroup = "Yes";
            } else {
                bGroup = "No";
                printStockA4(ref rs);
                return;
            }

            while (!(rs.EOF)) {
                rsData.MoveFirst();
                y = 0;

                if (y < 0)
                    y = 0;
                //lObject.FontName = "Tahoma"
                rsData.MoveFirst();
                if (rsData.RecordCount) {
                    lline = rsData.Fields("labelItem_Line").Value;
                    for (i = 1; i <= rs.Fields("barcodePersonLnk_PrintQTY").Value; i++) {
                        lLeft = (Information.IsDBNull(rsData.Fields("Label_Left").Value) ? 0 : rsData.Fields("Label_Left").Value) * twipsToMM;
                        //lLeft = 1200 'lCol * (lWidth + 60)

                        //lObject.CurrentY = lrow * (lHeight + 60)
                        rsData.MoveFirst();
                        //y = lObject.CurrentY
                        //lObject.ForeColor = System.Drawing.ColorTranslator.ToOle(Me.BackColor)
                         // ERROR: Not supported in C#: OnErrorStatement

                        //lObject.Line((lLeft, y) - (lLeft, y + 100))
                        //lObject.Line((lLeft, y) - (lLeft + 100, y))
                        //lObject.Line((lLeft + lWidth, y) - (lLeft + lWidth - 100, y))
                        //lObject.Line((lLeft + lWidth, y) - (lLeft + lWidth, y + 100))
                        //lObject.Line((lLeft + lWidth, lHeight + y) - (lLeft + lWidth, lHeight + y - 100))
                        //lObject.Line((lLeft + lWidth, lHeight + y) - (lLeft + lWidth - 100, lHeight + y))
                        //lObject.Line((lLeft, lHeight + y) - (lLeft, lHeight + y - 100))
                        //lObject.Line((lLeft, lHeight + y) - (lLeft + 100, lHeight + y))
                        //lObject.CurrentY = lrow * (lHeight + 60) + lTop
                        //lObject.ForeColor = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Black)
                        //y = lObject.CurrentY + 10
                        while (!(rsData.EOF)) {
                            if (lline != rsData.Fields("labelItem_Line").Value) {
                                //y = lObject.CurrentY + 10
                                lline = rsData.Fields("labelItem_Line").Value;
                            }

                            switch (Strings.LCase(Strings.Trim(rsData.Fields("labelItem_Field").Value))) {
                                case "blank":
                                    break;
                                //lObject.FontSize = rsData.Fields("labelItem_Size").Value
                                //lObject.FontBold = rsData.Fields("labelItem_Bold").Value
                                //lObject.ForeColor = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.White)
                                //lObject.Print(" ")
                                case "line":
                                    break;
                                //lObject.Line((15 + lLeft, y) - (lLeft + lWidth, y), System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Black))
                                case "code":
                                    switch (rsData.Fields("labelItem_Align").Value) {
                                        case 1:
                                            if (bGroup == "Yes") {
                                                //Barcode CodeType, txtData, Printer, 15, 700, 3000, 250
                                                //Barcode "128", rs("Catalogue_Barcode"), lObject, 15, 700, lLeft + 90, Y
                                                AllCodes.Barcode(ref "128", ref rs.Fields("Catalogue_Barcode").Value, ref lObject, ref 24, ref 500, ref 2400, ref Convert.ToSingle(y));
                                            } else {
                                                //printBarcode(lObject, rs.Fields("Catalogue_Barcode").Value, lLeft + 90, y)
                                            }
                                            break;
                                        case 2:
                                            if (bGroup == "Yes") {
                                                AllCodes.Barcode(ref "128", ref rs.Fields("Catalogue_Barcode").Value, ref lObject, ref 24, ref 500, ref 2400, ref Convert.ToSingle(y));
                                            } else {
                                                //old line before jonas   printBarcode lObject, rs("Catalogue_Barcode"), lLeft + 90, y
                                                //printBarcode(lObject, rs.Fields("Catalogue_Barcode").Value, lLeft + 90, y, lWidth + lWidth - 1440)
                                            }
                                            break;
                                        default:
                                            if (bGroup == "Yes") {
                                                //Barcode "128", rs("Catalogue_Barcode"), lObject, 15, 700, lLeft + 90, Y
                                                AllCodes.Barcode(ref "128", ref rs.Fields("Catalogue_Barcode").Value, ref lObject, ref 24, ref 500, ref 2400, ref Convert.ToSingle(y));
                                                //3600
                                                //Barcode "128", "tZst1234", lObject, 24, 700, 2500, 130
                                            } else {
                                                //printBarcode(lObject, rs.Fields("Catalogue_Barcode").Value, lLeft, y, lWidth)
                                            }
                                            break;
                                    }
                                    break;
                                default:
                                    //lObject.FontSize = rsData.Fields("labelItem_Size").Value
                                    //lObject.FontBold = rsData.Fields("labelItem_Bold").Value
                                    //lObject.ForeColor = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.White)
                                    mm = rsData.Fields("labelItem_Field").Value;
                                    //code for printing shrinks

                                    //code for printing shrinks
                                    lString1 = rs.Fields(mm).Value;
                                    switch (rsData.Fields("labelItem_Align").Value) {
                                        case 1:
                                            break;
                                        //lObject.PSet(New Point[](lLeft + 90, y))
                                        //lObject.ForeColor = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Black)
                                        //lObject.Print(lString1)

                                        case 2:
                                            break;
                                        //lObject.PSet(New Point[](lLeft + lWidth - lObject.TextWidth(lString1) - 90, y))
                                        //lObject.ForeColor = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Black)
                                        //lObject.Print(lString1)

                                        case 3:
                                            //splitStringA4(lObject, lWidth, lString1, lString2)
                                            //lObject.PSet(New Point[](CShort(lLeft + (lWidth - lObject.TextWidth(lString1)) / 2), y))
                                            //lObject.ForeColor = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Black)
                                            //lObject.Print(lString1)
                                            //y = lObject.CurrentY + 10
                                            //lObject.ForeColor = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.White)
                                            lString1 = lString2;
                                            break;
                                        //lObject.PSet(New Point[](CShort(lLeft + (lWidth - lObject.TextWidth(lString1)) / 2), y))
                                        //lObject.ForeColor = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Black)
                                        //lObject.Print(lString1)
                                        default:
                                            break;
                                        //lObject.PSet(New Point[](CShort(lLeft + (lWidth - lObject.TextWidth(lString1)) / 2), y))
                                        //lObject.ForeColor = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Black)
                                        //lObject.Print(lString1)
                                    }
                                    break;
                            }

                            if (bGroup == "Yes") {
                                //sGroup = "1"

                                //And rs("barcodePersonLnk_PrintQTY") = 1 Then
                                if (sGroup != rsData.Fields("labelItem_Sample").Value) {
                                    if (rs.Fields("barcodePersonLnk_PrintQTY").Value == 1) {
                                        rs.moveNext();
                                    } else if (rs.Fields("barcodePersonLnk_PrintQTY").Value >= 1) {
                                        if (i == rs.Fields("barcodePersonLnk_PrintQTY").Value & sGroup == "4") {
                                            sGroup = "1";
                                            break; // TODO: might not be correct. Was : Exit Do
                                        } else if (i == rs.Fields("barcodePersonLnk_PrintQTY").Value) {
                                            rs.moveNext();
                                            i = 0;
                                        }
                                        i = i + 1;
                                    }
                                    sGroup = rsData.Fields("labelItem_Sample").Value;
                                }

                                //i = i + 1
                                //If i >= rs("barcodePersonLnk_PrintQTY") Then
                                //    sGroup = rsData("labelItem_Sample")
                                //    'rs.moveNext
                                //   Exit Do
                                //End If
                                if (rs.EOF)
                                    break; // TODO: might not be correct. Was : Exit Do
                            }
                            rsData.moveNext();
                        }
                        lCol = lCol + 1;
                        if (lCol >= lCols) {
                            lCol = 0;
                            lrow = lrow + 1;
                            //If (lrow + 1) * lHeight > lObject.Height Then
                            // Printer.NewPage()
                            // If bGroup = "Yes" Then
                            // lrow = 0 '-1
                            //Else
                            //   lrow = -1
                            // End If
                            //End If
                        }
                        if (sGroup == "4")
                            sGroup = "1";
                    }
                }
                if (bGroup == "Yes") {
                    if (rs.EOF)
                        break; // TODO: might not be correct. Was : Exit Do
                    if (sGroup == "4")
                        sGroup = "1";
                }
                rs.moveNext();
            }
            //Printer.EndDoc()

            return;
            Err_printStockA4:
            //MsgBox Err.Description
             // ERROR: Not supported in C#: ResumeStatement
        }