Example #1
0
        public static void Update_ADODB_from_ADO(DataTable inTable, ref ADODB.Recordset adoRs)
        {
            // ADODB.Recordset result = adoRs.Clone(ADODB.LockTypeEnum.adLockOptimistic);
            ADODB.Fields adoFields = adoRs.Fields;
            System.Data.DataColumnCollection inColumns = inTable.Columns;
            //Delete
            adoRs.MoveFirst();
            while (!adoRs.EOF)
            {
                adoRs.Delete();
                adoRs.MoveNext();

            }
            //Add
            foreach (DataRow dr in inTable.Rows)
            {
                adoRs.AddNew(System.Reflection.Missing.Value,
                                System.Reflection.Missing.Value);

                for (int columnIndex = 0; columnIndex < inColumns.Count; columnIndex++)
                {
                    adoFields[columnIndex].Value = dr[columnIndex];
                }
            }
        }
        private void UpdateADODBRecordset_from_ADODataTable(DataTable inTable, ref ADODB.Recordset adoRs)
        {
            ADODB.Fields adoFields = adoRs.Fields;
            System.Data.DataColumnCollection inColumns = inTable.Columns;
            //Delete
            if (adoRs.RecordCount > 0) {
                adoRs.MoveFirst();
            }
            while (!adoRs.EOF)
            {
                adoRs.Delete();
                adoRs.MoveNext();

            }
            //Add
            foreach (DataRow dr in inTable.Rows)
            {
                // Proceso las que no estan borradas
                if (dr.RowState != DataRowState.Deleted)
                {
                    adoRs.AddNew(System.Reflection.Missing.Value,
                                    System.Reflection.Missing.Value);

                    for (int columnIndex = 0; columnIndex < inColumns.Count; columnIndex++)
                    {
                        adoFields[columnIndex].Value = dr[columnIndex];
                    }
                }
            }
        }
Example #3
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()
        }
Example #4
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();
            }
        }