private string getDelimeter(ref ADODB.Recordset rs) { string functionReturnValue = null; string lString1 = null; string lString2 = null; ADODB.Field lField = default(ADODB.Field); lString1 = ""; while (!(rs.EOF)) { lString2 = ""; foreach ( lField in rs.Fields) { if (Information.IsDBNull(lField.Value)) { lString2 = lString2 + Strings.Chr(254) + Strings.Chr(253); } else { switch (lField.Type) { case 7: lString2 = lString2 + Strings.Chr(254) + Strings.Format(lField.value, "yyyy/MM/dd"); break; case 202: lString2 = lString2 + Strings.Chr(254) + lField.value; break; default: lString2 = lString2 + Strings.Chr(254) + lField.value; break; } } } lString1 = lString1 + Strings.Chr(255) + Strings.Mid(lString2, 2); rs.moveNext(); } if (string.IsNullOrEmpty(lString1)) { functionReturnValue = ""; } else { functionReturnValue = Strings.Mid(lString1, 2); } return functionReturnValue; }
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 }