示例#1
0
        private void button2_Click_1(object sender, EventArgs e)
        {
            /*打印标贴的程序如下*/

            string PhoneName = "hello world";

            //打开打印端口
            TSCLIB_DLL.openport("Deli DL-888F(NEW)");
            //设计打印纸的大小与间距
            TSCLIB_DLL.setup("30", "20", "3", "10", "0", "2", "0");    //宽度、高度、速度寸/秒、浓度0-15、。 长度30 20 OK,倒数间距2 OK
            //清空下缓存
            TSCLIB_DLL.clearbuffer();
            //打印文字
            TSCLIB_DLL.windowsfont(1, 15, 23, 0, 2, 0, "標楷體", PhoneName);  //用windowsTTF字型列印文字 X、Y、字体高度、角度、字体外形、有无底线、字体名称、打印内容
            TSCLIB_DLL.windowsfont(1, 40, 23, 0, 2, 0, "標楷體", PhoneName);  //用windowsTTF字型列印文字 X、Y、字体高度、角度、字体外形、有无底线、字体名称、打印内容
            TSCLIB_DLL.windowsfont(1, 65, 23, 0, 2, 0, "標楷體", PhoneName);  //用windowsTTF字型列印文字 X、Y、字体高度、角度、字体外形、有无底线、字体名称、打印内容
            TSCLIB_DLL.windowsfont(1, 90, 22, 0, 2, 0, "標楷體", PhoneName);  //用windowsTTF字型列印文字 X、Y、字体高度、角度、字体外形、有无底线、字体名称、打印内容
            TSCLIB_DLL.windowsfont(1, 115, 23, 0, 2, 0, "標楷體", PhoneName); //用windowsTTF字型列印文字 X、Y、字体高度、角度、字体外形、有无底线、字体名称、打印内容
            TSCLIB_DLL.windowsfont(1, 138, 23, 0, 2, 0, "標楷體", PhoneName); //用windowsTTF字型列印文字 X、Y、字体高度、角度、字体外形、有无底线、字体名称、打印内容


            //打印份数
            TSCLIB_DLL.printlabel("1", "1");
            //关闭打印端口
            TSCLIB_DLL.closeport();
            MessageBox.Show("hello");
        }
示例#2
0
        private void price4030(string price, string price_cur, string item_code, string item_name, string label_count, int point_number, int ribon, string item_unit)
        {
            try
            {
                string point_number_s = "";

                TSCLIB_DLL.openport(printer);
                TSCLIB_DLL.sendcommand("SIZE 40 mm, 30 mm");
                TSCLIB_DLL.sendcommand("SPEED 4");
                TSCLIB_DLL.sendcommand("GAP 4.2 mm,0 mm");
                if (ribon == 1)
                {
                    TSCLIB_DLL.sendcommand("SET RIBBON ON");
                }
                else
                {
                    TSCLIB_DLL.sendcommand("SET RIBBON OFF");
                }
                TSCLIB_DLL.sendcommand("DENSITY 8");
                TSCLIB_DLL.sendcommand("DIRECTION 1");
                TSCLIB_DLL.sendcommand("SET TEAR ON");
                TSCLIB_DLL.sendcommand("CODEPAGE UTF-8");

                if (point_number > 0)
                {
                    point_number_s = ".";
                    for (int j = 0; j < point_number; j++)
                    {
                        point_number_s += "0";
                    }
                }
                price = String.Format("{0:### ### ### ##0" + point_number_s + "}", float.Parse(price));
                TSCLIB_DLL.clearbuffer();

                TSCLIB_DLL.windowsfont(16, 0, 100, 0, 2, 0, "Agency FB", CenterString(price, 10));
                TSCLIB_DLL.windowsfont(230, 81, 35, 0, 1, 0, "Century Gothic", price_cur);

                TSCLIB_DLL.windowsfont(16, 118, 26, 0, 2, 0, "Century Gothic", CenterString(item_code, 30));
                if (item_name.Length > 28)
                {
                    TSCLIB_DLL.windowsfont(16, 145, 20, 0, 2, 0, "Century Gothic", item_name.Substring(0, 26) + "-");
                    TSCLIB_DLL.windowsfont(16, 162, 20, 0, 2, 0, "Century Gothic", item_name.Substring(26, item_name.Length - 26));
                }
                else
                {
                    TSCLIB_DLL.windowsfont(8, 149, 20, 0, 2, 0, "Century Gothic", CenterString(item_name, 32));
                }

                TSCLIB_DLL.windowsfont(235, 175, 20, 0, 3, 0, "Century Gothic", item_unit);

                TSCLIB_DLL.printlabel("1", label_count);

                TSCLIB_DLL.closeport();
            }

            catch (Exception e)
            {
                Log.set("HATA: PriceForm>4030 print()\nEXCEPTION:" + e.ToString());
            }
        }
示例#3
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "msg", "alert('Hello TSCLIB.DLL')", true);
            //TSCLIB_DLL.about();                                                                 //Show the DLL version
            TSCLIB_DLL.openport("TSC TTP-243 Plus");                                           //Open specified printer driver
            TSCLIB_DLL.setup("52", "28.5", "4", "5", "0", "0", "0");

            /*
             * width    設定標籤寬度   單位mm
             * height   設定標籤高度   單位mm
             * speed    設定列印速度   單位sec 間距1~10
             * density  設定列印濃度   單位    間距0~15
             * sensor   設定使用感應器類別 0 表示使用垂直間距感測器(gap sensor) 1 表示使用黑標感測器(black mark sensor)
             * vertical 字串型別,設定gap/black mark 垂直間距高度,單位:mm
             * offset   字串型別,設定gap/black mark 偏移距離,單位: mm,此參數若使用一般標籤時設為0
             */
            TSCLIB_DLL.clearbuffer();                                                           //Clear image buffer
            TSCLIB_DLL.barcode("80", "60", "128", "90", "1", "0", "4", "4", "3680302001393");

            /*
             * x        字串型別,條碼X方向起始點,以點(point)表示。
             * y        字串型別,條碼Y方向起始點,以點(point)表示。
             * type     字串型別
             * height   字串型別,設定條碼高度,高度以點來表示。
             * readable 字串型別,設定是否列印條碼碼文 0: 不列印碼文 1: 列印碼文
             * rotation 字串型別,設定條碼旋轉角度
             * narrow   字串型別,設定條碼窄bar 比例因子,請參考TSPL使用手冊(也會調整條滿寬度)
             * wide     字串型別,設定條碼寬bar 比例因子,請參考TSPL使用手冊(也會調整條滿寬度)
             * code     要列印的條碼
             */
            TSCLIB_DLL.printerfont("100", "200", "4", "0", "1", "2", "Bg04-11");

            /*
             * x:        字串型別,文字X方向起始點,以點(point)表示。
             * y:        字串型別,文字Y方向起始點,以點(point)表示。
             * fonttype: 字串型別,內建字型名稱,共12種。1~5
             * rotaiton: 字串型別,設定文字旋轉角度
             * xmul:     字串型別,設定文字X方向放大倍率,1~8
             * ymul:     字串型別,設定文字y方向放大倍率,1~8
             * text:     字串型別,列印文字內容
             *
             */
            TSCLIB_DLL.windowsfont(50, 270, 30, 0, 0, 0, "標楷體", "MPU-6050三軸加速度傳感器-送排針");

            /*
             * x:        整數型別,文字X方向起始點,以點(point)表示。
             * y:        整數型別,文字y方向起始點,以點(point)表示。
             * fonthigrt:整數型別,字體高度,以點(point)表示。
             * rotation :整數型別,旋轉角度,逆時鐘方向旋轉
             * fontstyle:整數型別,字體外形 0-> 標準(Normal)1-> 斜體(Italic)2-> 粗體(Bold)3-> 粗斜體(Bold and Italic)
             * fontline :整數型別,底線0-> 無底線1-> 加底線
             * szface   :字串型別,字體名稱。如: Arial, Times new Roman, 細名體, 標楷體
             * content  :字串型別,列印文字內容。
             */
            //TSCLIB_DLL.downloadpcx("C:\\ASP.NET_in_VCsharp_2008\\ASP.NET_in_VCsharp_2008\\UL.PCX", "UL.PCX");                                         //Download PCX file into printer
            //TSCLIB_DLL.downloadpcx("UL.PCX", "UL.PCX");                                         //Download PCX file into printer
            //TSCLIB_DLL.sendcommand("PUTPCX 100,400,\"UL.PCX\"");                                //Drawing PCX graphic
            TSCLIB_DLL.printlabel("1", "1");                                                    //set: 字串型別,設定列印標籤式數(set)copy: 字串型別,設定列印標籤份數(copy)
            TSCLIB_DLL.closeport();
        }
示例#4
0
        private static void DataReceivedHandler(
            object sender,
            SerialDataReceivedEventArgs e)
        {
            SerialPort sp     = (SerialPort)sender;
            string     indata = sp.ReadExisting();

            // If received "Detected!" from arduino Port
            if (indata.Contains("D"))
            {
                //MessageBox.Show("Is Dot Net Perls awesome?", "Important Question", MessageBoxButtons.YesNo);
                // Setup printer to print something
                TSCLIB_DLL.openport("TSC TDP-225");                                           //Open specified printer driver
                TSCLIB_DLL.setup("25", "220", "1", "8", "1", "6", "0");                       //Setup the media size and sensor type info
                TSCLIB_DLL.clearbuffer();                                                     //Clear image buffer
                //TSCLIB_DLL.barcode("100", "100", "128", "100", "1", "270", "2", "2", "Barcode Test"); //Drawing barcode
                //TSCLIB_DLL.printerfont("100", "250", "3", "0", "1", "1", "Print Font Test");        //Drawing printer font
                //TSCLIB_DLL.windowsfont(100, 300, 24, 270, 0, 0, "ARIAL", "Windows Arial Font Test");  //Draw windows font
                //TSCLIB_DLL.downloadpcx("UL.PCX", "UL.PCX");                                         //Download PCX file into printer
                TSCLIB_DLL.sendcommand("QRCODE 30,30,M,6,0,M2,\"BRADY123\"");
                //TSCLIB_DLL.sendcommand("PUTPCX 100,400,\"UL.PCX\"");
                //Drawing PCX graphic
                TSCLIB_DLL.printlabel("1", "1");                                                    //Print labels
                TSCLIB_DLL.closeport();
            }
        }
示例#5
0
        // Function to perform printing module!
        private void PrintDemoLabel(bool reprint)
        {
            // Read from DB to get counter. return 1 if db not found.
            // append the string with time,gate and counter
            // write time, gate, count and reprint to DB.
            // Print out ticket accordingly.
            // Update the label for counter.
            // if reprtint, do not increment the counter.
            String printformat = UpdateDB(reprint);

            // Update the counter at here
            LABEL_COUNT.Invoke(new EventHandler(delegate
            {
                LABEL_COUNT.Text = printformat.Split('/').Last();
            }));
            String gatePrint  = "Gate: " + printformat.Split('/')[1];
            String CountPrint = "Counter: " + printformat.Split('/').Last();

            TSCLIB_DLL.openport("TSC TDP-225");                                                 //Open specified printer driver
            TSCLIB_DLL.setup("40", "450", "12", "8", "1", "6", "300");                          //Setup the media size and sensor type info
            TSCLIB_DLL.clearbuffer();                                                           //Clear image buffer
            TSCLIB_DLL.barcode("100", "470", "128", "100", "0", "270", "2", "2", printformat);  //Drawing barcode
            TSCLIB_DLL.printerfont("140", "480", "5", "90", "1", "1", gatePrint);               //Print Gate number
            TSCLIB_DLL.printerfont("210", "480", "5", "90", "1", "1", CountPrint);              //Print Ticket Counter
            TSCLIB_DLL.sendcommand($"QRCODE 80,0,M,7,M,0,M2,S1,\"A{printformat}\"");            //Draw QR Code
            TSCLIB_DLL.printlabel("1", "1");                                                    //Print labels
            TSCLIB_DLL.closeport();                                                             //Close specified printer driver
        }
示例#6
0
        private void BtnPrnSticker_Click(object sender, EventArgs e)
        {
            //throw new NotImplementedException();
            string WT1 = txtName.Text.Trim();
            string B1  = txtBarcode.Text.Trim();

            byte[] result_unicode = System.Text.Encoding.GetEncoding("utf-16").GetBytes("unicode test");
            byte[] result_utf8    = System.Text.Encoding.UTF8.GetBytes("TEXT 40,620,\"ARIAL.TTF\",0,12,12,\"utf8 test Wörter auf Deutsch\"");

            //TSCLIB_DLL.about();
            byte status = TSCLIB_DLL.usbportqueryprinter();     //0 = idle, 1 = head open, 16 = pause, following <ESC>!? command of TSPL manual

            TSCLIB_DLL.openport("TSC TE210");
            TSCLIB_DLL.sendcommand("SIZE 100 mm, 120 mm");
            TSCLIB_DLL.sendcommand("SPEED 4");
            TSCLIB_DLL.sendcommand("DENSITY 12");
            TSCLIB_DLL.sendcommand("DIRECTION 1");
            TSCLIB_DLL.sendcommand("SET TEAR ON");
            TSCLIB_DLL.sendcommand("CODEPAGE UTF-8");
            TSCLIB_DLL.clearbuffer();
            //TSCLIB_DLL.downloadpcx("UL.PCX", "UL.PCX");
            TSCLIB_DLL.windowsfont(40, 490, 48, 0, 0, 0, "Arial", "Windows Font Test");
            TSCLIB_DLL.windowsfontUnicode(40, 550, 48, 0, 0, 0, "Arial", result_unicode);
            //TSCLIB_DLL.sendcommand("PUTPCX 40,40,\"UL.PCX\"");
            TSCLIB_DLL.sendBinaryData(result_utf8, result_utf8.Length);
            TSCLIB_DLL.barcode("40", "300", "128", "80", "1", "0", "2", "2", B1);
            TSCLIB_DLL.printerfont("40", "250", "0", "0", "15", "15", WT1);
            TSCLIB_DLL.printlabel("1", "1");
            TSCLIB_DLL.closeport();
        }
示例#7
0
        private void textBox1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                string text = textBox1.Text;

                TSCLIB_DLL.openport(printer);
                TSCLIB_DLL.sendcommand("SIZE 45 mm, 15 mm");
                TSCLIB_DLL.sendcommand("SPEED 4");
                TSCLIB_DLL.sendcommand("GAP 3 mm,0 mm");
                if (label_style == "Ribonlı yazdırım")
                {
                    TSCLIB_DLL.sendcommand("SET RIBBON ON");
                }
                else
                {
                    TSCLIB_DLL.sendcommand("SET RIBBON OFF");
                }
                TSCLIB_DLL.sendcommand("DENSITY 8");
                TSCLIB_DLL.sendcommand("DIRECTION 1");
                TSCLIB_DLL.sendcommand("SET TEAR ON");
                TSCLIB_DLL.clearbuffer();



                TSCLIB_DLL.sendcommand("CODEPAGE UTF-8");
                TSCLIB_DLL.windowsfont(16, 34, 40, 0, 3, 0, "Century Gothic", CenterString(text, 22));



                TSCLIB_DLL.printlabel("1", numericUpDown1.Value.ToString());
                TSCLIB_DLL.closeport();
                this.Close();
            }
        }
        public void Print(ExportDetail itm)
        {
            if (Export.SourceTransaction != "Sales Order")
            {
                return;
            }
            try
            {
                for (int i = 0; i < Quantity; i++)
                {
                    const int    VerticalSpace   = 150;
                    const int    HorizontalSpace = 100;
                    const string LabelFontSize   = "2.5";

                    TSCLIB_DLL.openport(Settings.Default.TSCPrinter);                                  //Open specified printer driver
                    TSCLIB_DLL.setup("101", "150", "6", "8", "0", "5", "0");                           //Setup the media size and sensor type info
                    TSCLIB_DLL.clearbuffer();                                                          //Clear image buffer
                    TSCLIB_DLL.downloadpcx("box.pcx", "box.pcx");                                      //Download PCX file into printer

                    TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * .5).ToString(), "3", "0", "4", "4", "M.N.I.B.");
                    TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 1.25).ToString(), "3", "0", "1.75", "1.75", "Young Street, St. George's, Grenada");

                    TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 2.5).ToString(), "3", "0", LabelFontSize, LabelFontSize, Instance.Info.Substring(0, Instance.Info.IndexOf(" - ")));
                    TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 3).ToString(), "3", "0", "1.75", "1.75", Instance.Info.Substring(Instance.Info.IndexOf(" - ") + 1));


                    TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 4).ToString(), "3", "0", "2", "2", DateTime.Today.ToString("yyyy-MMM-dd"));        //Drawing printer font


                    TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 4.5).ToString(), "3", "0", LabelFontSize, LabelFontSize, itm.Barcode);


                    TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 5).ToString(), "3", "0", LabelFontSize, LabelFontSize, Export.ProductDescription);

                    TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 5.75).ToString(), "3", "0", "2", "2", Box.Description);

                    TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 6.5).ToString(), "3", "0", "2", "2", itm.Weight.ToString());
                    TSCLIB_DLL.printerfont((HorizontalSpace * 1.5).ToString(), (VerticalSpace * 6.5).ToString(), "3", "0", "2", "2", "LBS.");

                    TSCLIB_DLL.barcode((HorizontalSpace * .5).ToString(), (VerticalSpace * 7).ToString(), "128", "125", "1", "0", "8", "8", itm.Barcode); //Drawing barcode



                    TSCLIB_DLL.printlabel("1", "1");                                                    //Print labels
                    TSCLIB_DLL.closeport();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#9
0
 private void btn_print_Click(object sender, EventArgs e)
 {
     TSCLIB_DLL.openport("TSC TDP-225");                                               //Open specified printer driver
     TSCLIB_DLL.setup("25", "220", "1", "8", "1", "6", "0");                           //Setup the media size and sensor type info
     TSCLIB_DLL.clearbuffer();                                                         //Clear image buffer
     //TSCLIB_DLL.barcode("150", "600", "128", "100", "1", "270", "2", "2", "Barcode Test"); //Drawing barcode
     //TSCLIB_DLL.printerfont("100", "350", "3", "270", "1", "1", "Print Font Test");        //Drawing printer font
     //TSCLIB_DLL.windowsfont(100, 400, 24, 90, 0, 0, "ARIAL", "Windows Arial Font Test");  //Draw windows font
     //TSCLIB_DLL.downloadpcx("UL.PCX", "UL.PCX");                                         //Download PCX file into printer
     TSCLIB_DLL.sendcommand("QRCODE 30,30,M,6,0,M2,\"BRADY123\"");                //Drawing PCX graphic
     TSCLIB_DLL.printlabel("1", "1");                                             //Print labels
     TSCLIB_DLL.closeport();                                                      //Close specified printer driver
 }
示例#10
0
        //---------- price
        private void price4515(string price, string price_cur, string item_code, string item_name, string label_count, int point_number, int ribon)
        {
            try
            {
                string point_number_s = "";
                string price_with_cur = "";
                TSCLIB_DLL.openport(printer);
                TSCLIB_DLL.sendcommand("SIZE 45 mm, 15 mm");
                TSCLIB_DLL.sendcommand("SPEED 4");
                TSCLIB_DLL.sendcommand("GAP 3 mm,0 mm");
                if (ribon == 1)
                {
                    TSCLIB_DLL.sendcommand("SET RIBBON ON");
                }
                else
                {
                    TSCLIB_DLL.sendcommand("SET RIBBON OFF");
                }
                TSCLIB_DLL.sendcommand("DENSITY 8");
                TSCLIB_DLL.sendcommand("DIRECTION 1");
                TSCLIB_DLL.sendcommand("SET TEAR ON");
                TSCLIB_DLL.sendcommand("CODEPAGE UTF-8");

                if (point_number > 0)
                {
                    point_number_s = ".";
                    for (int j = 0; j < point_number; j++)
                    {
                        point_number_s += "0";
                    }
                }
                price          = String.Format("{0:### ### ### ##0" + point_number_s + "}", float.Parse(price));
                price_with_cur = price + " " + price_cur;
                if (item_name.Length > 30)
                {
                    item_name = item_name.Substring(0, 30) + "...";
                }
                TSCLIB_DLL.clearbuffer();
                TSCLIB_DLL.windowsfont(16, 10, 50, 0, 2, 0, "Century Gothic", CenterString(price_with_cur, 19));
                TSCLIB_DLL.windowsfont(16, 55, 25, 0, 3, 0, "Century Gothic", CenterString(item_code, 37));
                TSCLIB_DLL.windowsfont(16, 80, 18, 0, 3, 0, "Century Gothic", CenterString(item_name, 50));

                TSCLIB_DLL.printlabel("1", label_count);

                TSCLIB_DLL.closeport();
            }
            catch (Exception e)
            {
                Log.set("HATA: PriceForm>4515 print()\nEXCEPTION:" + e.ToString());
            }
        }
示例#11
0
 private void button1_Click(object sender, EventArgs e)
 {
     //TSCLIB_DLL.about();                                                                 //Show the DLL version
     TSCLIB_DLL.openport("TSC TTP-344M Plus");                                           //Open specified printer driver
     TSCLIB_DLL.setup("100", "63.5", "4", "8", "0", "0", "0");                           //Setup the media size and sensor type info
     TSCLIB_DLL.clearbuffer();                                                           //Clear image buffer
     TSCLIB_DLL.barcode("100", "100", "128", "100", "1", "0", "2", "2", "Barcode Test"); //Drawing barcode
     TSCLIB_DLL.printerfont("100", "250", "3", "0", "1", "1", "Print Font Test");        //Drawing printer font
     TSCLIB_DLL.windowsfont(100, 300, 24, 0, 0, 0, "ARIAL", "Windows Arial Font Test");  //Draw windows font
     TSCLIB_DLL.downloadpcx("UL.PCX", "UL.PCX");                                         //Download PCX file into printer
     TSCLIB_DLL.sendcommand("PUTPCX 100,400,\"UL.PCX\"");                                //Drawing PCX graphic
     TSCLIB_DLL.printlabel("1", "1");                                                    //Print labels
     TSCLIB_DLL.closeport();                                                             //Close specified printer driver
 }
        private void PrintMediumSizeLabel(PurchaseOrderDetail itm)
        {
            try
            {
                const int    VerticalSpace   = 75;
                const int    HorizontalSpace = 101;
                const string LabelFontSize   = "2.5";

                TSCLIB_DLL.openport(Settings.Default.TSCPrinter);                                   //Open specified printer driver
                TSCLIB_DLL.setup("101", "50.2", "6", "8", "0", "0", "0");                           //Setup the media size and sensor type info
                TSCLIB_DLL.clearbuffer();                                                           //Clear image buffer
                TSCLIB_DLL.downloadpcx("box.pcx", "box.pcx");                                       //Download PCX file into printer



                TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * .5).ToString(), "2", "0", LabelFontSize, LabelFontSize, PurchaseOrder.Vendor);

                TSCLIB_DLL.printerfont((HorizontalSpace * 5).ToString(), (VerticalSpace * 1.3).ToString(), "2", "0", LabelFontSize, LabelFontSize, PurchaseOrder.PODate.ToString("yyyy-MMM-dd"));        //Drawing printer font

                TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 1.3).ToString(), "3", "0", LabelFontSize, LabelFontSize, "Inv#");
                TSCLIB_DLL.printerfont((HorizontalSpace * 2).ToString(), (VerticalSpace * 1.3).ToString(), "3", "0", LabelFontSize, LabelFontSize, itm.PurchaseOrderNo);

                TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 2).ToString(), "3", "0", LabelFontSize, LabelFontSize, "Item:");
                TSCLIB_DLL.printerfont((HorizontalSpace * 2.3).ToString(), (VerticalSpace * 2).ToString(), "3", "0", LabelFontSize, LabelFontSize, itm.ItemDescription);

                TSCLIB_DLL.barcode((HorizontalSpace * .5).ToString(), (VerticalSpace * 3).ToString(), "128", "75", "0", "0", "9", "8", itm.Barcode); //Drawing barcode

                TSCLIB_DLL.printerfont((HorizontalSpace * 2).ToString(), (VerticalSpace * 4.1).ToString(), "2", "0", "5", "5", itm.Barcode);

                //TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 4.5).ToString(), "3", "0", LabelFontSize, LabelFontSize, "SORT");
                //TSCLIB_DLL.sendcommand(string.Format("BOX {0},{1},{2},{3},2,19.2", HorizontalSpace * 0, VerticalSpace * 4.5, HorizontalSpace * 2, VerticalSpace * 4.5 + 50));

                //TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 5.5).ToString(), "3", "0", LabelFontSize, LabelFontSize, "GRADED");
                //TSCLIB_DLL.sendcommand(string.Format("BOX {0},{1},{2},{3},2,19.2", HorizontalSpace * 4, VerticalSpace * 5.5, HorizontalSpace * 8, VerticalSpace * 5.5 + 50));

                //TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 6.5).ToString(), "3", "0", LabelFontSize, LabelFontSize, "WASH");
                //TSCLIB_DLL.sendcommand(string.Format("BOX {0},{1},{2},{3},2,19.2", HorizontalSpace * 4, VerticalSpace * 6.5, HorizontalSpace * 8, VerticalSpace * 6.5 + 50));

                //TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 7.5).ToString(), "3", "0", LabelFontSize, LabelFontSize, "CHILLER#");
                //TSCLIB_DLL.sendcommand(string.Format("BOX {0},{1},{2},{3},2,19.2", HorizontalSpace * 4, VerticalSpace * 7.5, HorizontalSpace * 8, VerticalSpace * 7.5 + 49));


                TSCLIB_DLL.printlabel("1", itm.LabelQty.ToString());                                                    //Print labels
                TSCLIB_DLL.closeport();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#13
0
 private void btn_test_Click(object sender, EventArgs e)//测试按钮
 {
     //TSCLIB_DLL.about();                                                                //Show the DLL version
     TSCLIB_DLL.openport("TSC TDP-245");                                                 //Open specified printer driver
     TSCLIB_DLL.setup("100", "63.5", "4", "8", "0", "0", "0");                           //Setup the media size and sensor type info
     TSCLIB_DLL.clearbuffer();                                                           //Clear image buffer
     TSCLIB_DLL.about();
     TSCLIB_DLL.barcode("100", "100", "128", "100", "1", "0", "2", "2", "Barcode Test"); //Drawing barcode
     TSCLIB_DLL.printerfont("100", "250", "TSS24.BF2", "0", "1", "1", "Print Font 测试");  //Drawing printer font
     // TSCLIB_DLL.windowsfont(100, 300, 24, 0, 0, 0, "GBK", "测试"); //Draw windows font
     // TSCLIB_DLL.downloadpcx("UL.PCX", "UL.PCX");                                         //Download PCX file into printer
     TSCLIB_DLL.sendcommand("PUTPCXL.PC 100,400,\"UL.PCX\"");                           //Drawing PCX graphic
     TSCLIB_DLL.printlabel("1", "1");                                                   //Print labels
     TSCLIB_DLL.closeport();                                                            //Close specified printer driver
 }
示例#14
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "msg", "alert('Hello TSCLIB.DLL')", true);
     //TSCLIB_DLL.about();                                                                 //Show the DLL version
     TSCLIB_DLL.openport("TSC TTP-245C");                                                //Open specified printer driver
     TSCLIB_DLL.setup("100", "63.5", "4", "8", "0", "0", "0");                           //Setup the media size and sensor type info
     TSCLIB_DLL.clearbuffer();                                                           //Clear image buffer
     TSCLIB_DLL.barcode("100", "100", "128", "100", "1", "0", "2", "2", "Barcode Test"); //Drawing barcode
     TSCLIB_DLL.printerfont("100", "250", "3", "0", "1", "1", "Print Font Test");        //Drawing printer font
     TSCLIB_DLL.windowsfont(100, 300, 24, 0, 0, 0, "ARIAL", "Windows Arial Font Test");  //Draw windows font
     //TSCLIB_DLL.downloadpcx("C:\\ASP.NET_in_VCsharp_2008\\ASP.NET_in_VCsharp_2008\\UL.PCX", "UL.PCX");                                         //Download PCX file into printer
     TSCLIB_DLL.downloadpcx("UL.PCX", "UL.PCX");                                         //Download PCX file into printer
     TSCLIB_DLL.sendcommand("PUTPCX 100,400,\"UL.PCX\"");                                //Drawing PCX graphic
     TSCLIB_DLL.printlabel("1", "1");                                                    //Print labels
     TSCLIB_DLL.closeport();
 }
示例#15
0
        /// <summary>
        /// 条码布局在下方
        /// </summary>
        /// <param name="m"></param>
        /// <param name="layout"></param>
        private void BarCode_BAPrint(InstrumentModel m)
        {
            // 设置标签 宽度、高度 等信息.
            // 宽 94mm  高 25mm
            // 速度为4
            // 字体浓度为8
            // 使用垂直間距感測器(gap sensor)
            // 两个标签之间的  间距为 3.5mm
            //TSCLIB_DLL.setup("35", "35", "1", "8", "1", "3.5", "0");
            // 清除缓冲信息
            TSCLIB_DLL.clearbuffer();
            // 打印条码.
            // 在 (176, 66) 的坐标上
            // 以 Code39 的条码方式
            // 条码高度 130
            // 打印条码的同时,还打印条码的文本信息.
            // 旋转的角度为 0 度
            // 条码 宽 窄 比例因子为 7:12
            // 条码内容为:barCode "200", "5", "128", "65", "1", "0", "2", "2"
            // 发送 TSPL 指令.
            // 设置 打印的方向.
            // 打印文本信息.
            // 在 (176, 16) 的坐标上
            // 字体高度为34
            // 旋转的角度为 0 度
            // 2 表示 粗体.
            // 文字没有下划线.
            // 字体为 黑体.
            // 打印的内容为:title

            TSCLIB_DLL.windowsfont(200, 10, 23, 0, 2, 0, "宋体", "名称:" + m.InstrumentName);

            TSCLIB_DLL.windowsfont(200, 50, 23, 0, 2, 0, "宋体", "仪器型号:" + m.Specification);
            TSCLIB_DLL.windowsfont(200, 90, 23, 0, 2, 0, "宋体", "资产编号:" + m.AssetsNo);
            TSCLIB_DLL.windowsfont(200, 130, 23, 0, 2, 0, "宋体", "出厂编号:" + m.SerialNo);
            TSCLIB_DLL.windowsfont(200, 170, 23, 0, 2, 0, "宋体", "管理编号:" + m.ManageNo);
            TSCLIB_DLL.barcode("280", "220", "128", "65", "1", "0", "2", "2", m.BarCode);


            // 打印.
            TSCLIB_DLL.printlabel("1", "1");
            // 关闭 打印机 端口
            TSCLIB_DLL.closeport();
        }
        public void PrintOverTSC(string model, List <LabelData> labelList)
        {
            if (labelList.Count == 0)
            {
                return;
            }

            try
            {
                TSCLIB_DLL.openport(model);

                foreach (LabelData l in labelList)
                {
                    TSCLIB_DLL.setup("75", "30", "4", "8", "0", "2", "0");
                    TSCLIB_DLL.clearbuffer();
                    TSCLIB_DLL.printerfont("24", "24", "4", "0", "1", "1", l.Device);
                    TSCLIB_DLL.windowsfont(24, 60, 32, 0, 0, 0, "Arial", l.Drawer);
                    TSCLIB_DLL.windowsfont(336, 24, 32, 0, 0, 0, "Arial", currentTime);

                    if (l.MedName.Length <= 43)
                    {
                        TSCLIB_DLL.windowsfont(16, 96, 32, 0, 0, 0, "Arial", l.MedName);
                    }
                    else
                    {
                        TSCLIB_DLL.windowsfont(16, 96, 32, 0, 0, 0, "Arial", l.MedName.Substring(0, 43));
                        TSCLIB_DLL.windowsfont(16, 128, 32, 0, 0, 0, "Arial", l.MedName.Substring(43));
                    }

                    TSCLIB_DLL.windowsfont(24, 182, 48, 0, 0, 0, "標楷體", $"數量: {l.Amount}");
                    TSCLIB_DLL.barcode("264", "166", "128", "56", "1", "0", "2", "1", l.MedID);
                    TSCLIB_DLL.printlabel("1", "1");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
            finally
            {
                TSCLIB_DLL.closeport();
            }
        }
示例#17
0
        private void button1_Click(object sender, EventArgs e)
        {
            byte[] result = System.Text.Encoding.GetEncoding("utf-16").GetBytes("unicode test");

            //TSCLIB_DLL.about();
            TSCLIB_DLL.openport("TSC TA210");
            TSCLIB_DLL.sendcommand("SIZE 76 mm, 20 mm");
            TSCLIB_DLL.sendcommand("SPEED 4");
            TSCLIB_DLL.sendcommand("DENSITY 12");
            TSCLIB_DLL.sendcommand("DIRECTION 1");
            TSCLIB_DLL.sendcommand("SET TEAR ON");
            TSCLIB_DLL.clearbuffer();
            TSCLIB_DLL.barcode("335", "30", "128", "100", "1", "0", "2", "2", "3410156300419176");
            TSCLIB_DLL.barcode("35", "30", "128", "100", "1", "0", "2", "2", "3410156300419176");
            //TSCLIB_DLL.printerfont("100", "250", "3", "0", "1", "1", "Print Font Test");
            //TSCLIB_DLL.windowsfont(100, 300, 24, 0, 0, 0, "ARIAL", "Windows Arial Font Test");
            //TSCLIB_DLL.windowsfontUnicode(100, 350, 24, 0, 0, 0, "ARIAL", result);
            TSCLIB_DLL.downloadpcx("UL.PCX", "UL.PCX");
            TSCLIB_DLL.sendcommand("PUTPCX 100,400,\"UL.PCX\"");
            TSCLIB_DLL.printlabel("4", "4");
            TSCLIB_DLL.closeport();
        }
示例#18
0
        public void Print(ExportDetail itm)
        {
            if (Export.SourceTransaction != "Sales Order")
            {
                return;
            }
            try
            {
                const int    VerticalSpace   = 150;
                const int    HorizontalSpace = 100;
                const string LabelFontSize   = "2.5";

                TSCLIB_DLL.openport(Settings.Default.TSCPrinter);                              //Open specified printer driver
                TSCLIB_DLL.setup("101", "150", "6", "8", "0", "5", "0");                       //Setup the media size and sensor type info
                TSCLIB_DLL.clearbuffer();                                                      //Clear image buffer
                TSCLIB_DLL.downloadpcx("box.pcx", "box.pcx");                                  //Download PCX file into printer

                TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * .5).ToString(), "3", "0", "4", "4", "M.N.I.B.");
                TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 1.25).ToString(), "3", "0", "1.75", "1.75", "Young Street, St. George's, Grenada");

                TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 2.5).ToString(), "3", "0", LabelFontSize, LabelFontSize, Customer.CustomerName);
                TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 3).ToString(), "3", "0", "1.75", "1.75", Customer.CustomerAddress);


                TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 4).ToString(), "3", "0", "2", "2", DateTime.Today.ToString("yyyy-MMM-dd"));         //Drawing printer font


                TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 4.5).ToString(), "3", "0", LabelFontSize, LabelFontSize, itm.Barcode);


                TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 5).ToString(), "3", "0", LabelFontSize, LabelFontSize, Export.ProductDescription);

                TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 5.75).ToString(), "3", "0", "2", "2", Box.Description);

                TSCLIB_DLL.printerfont((HorizontalSpace * 3).ToString(), (VerticalSpace * 5.75).ToString(), "3", "0", "2", "2", itm.Weight.ToString());
                TSCLIB_DLL.printerfont((HorizontalSpace * 4).ToString(), (VerticalSpace * 5.75).ToString(), "3", "0", "2", "2", "LBS.");

                TSCLIB_DLL.barcode((HorizontalSpace * .5).ToString(), (VerticalSpace * 7).ToString(), "128", "125", "1", "0", "8", "8", itm.Barcode); //Drawing barcode

                //  TSCLIB_DLL.printerfont((HorizontalSpace * 2.3).ToString(), (VerticalSpace * 8.5).ToString(), "3", "0", "2", "2", Box.Description);

                //TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 4).ToString(), "3", "0", LabelFontSize, LabelFontSize, "SORT");
                //TSCLIB_DLL.sendcommand(string.Format("BOX {0},{1},{2},{3},4,19.2", HorizontalSpace * 4,VerticalSpace * 4,HorizontalSpace * 8,VerticalSpace * 4 + 100));

                //TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 5).ToString(), "3", "0", LabelFontSize, LabelFontSize, "GRADED");
                //TSCLIB_DLL.sendcommand(string.Format("BOX {0},{1},{2},{3},4,19.2", HorizontalSpace * 4, VerticalSpace * 5, HorizontalSpace * 8, VerticalSpace * 5 + 100));

                //TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 6).ToString(), "3", "0", LabelFontSize, LabelFontSize, "WASH");
                //TSCLIB_DLL.sendcommand(string.Format("BOX {0},{1},{2},{3},4,19.2", HorizontalSpace * 4, VerticalSpace * 6, HorizontalSpace * 8, VerticalSpace * 6 + 100));

                //TSCLIB_DLL.printerfont((HorizontalSpace * .5).ToString(), (VerticalSpace * 7).ToString(), "3", "0", LabelFontSize, LabelFontSize, "CHILLER#");
                //TSCLIB_DLL.sendcommand(string.Format("BOX {0},{1},{2},{3},4,19.2", HorizontalSpace * 4, VerticalSpace * 7, HorizontalSpace * 8, VerticalSpace * 7 + 100));


                TSCLIB_DLL.printlabel("1", "1");                                                    //Print labels
                TSCLIB_DLL.closeport();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 public void SendToPrint(double numberOfPrints)
 {
     TSCLIB_DLL.printlabel("1", numberOfPrints.ToString());
     TSCLIB_DLL.closeport();
 }
示例#20
0
        /// <summary>
        /// 条码布局在下方
        /// </summary>
        /// <param name="m"></param>
        /// <param name="layout"></param>
        private void MixCode_ABPrint(InstrumentModel m)
        {
            // 设置标签 宽度、高度 等信息.
            // 宽 94mm  高 25mm
            // 速度为4
            // 字体浓度为8
            // 使用垂直間距感測器(gap sensor)
            // 两个标签之间的  间距为 3.5mm
            //TSCLIB_DLL.setup("35", "35", "1", "8", "1", "3.5", "0");
            // 清除缓冲信息
            TSCLIB_DLL.clearbuffer();
            // 发送 TSPL 指令.
            // 设置 打印的方向.
            TSCLIB_DLL.sendcommand("DIRECTION 0");
            string strP = "QRCODE 530,140,H,6,A,0,M2,S1,\"" + m.BarCode + "\"";

            TSCLIB_DLL.sendcommand(strP);
            TSCLIB_DLL.barcode("280", "7", "128", "65", "1", "0", "2", "2", m.BarCode);
            // 打印文本信息.
            // 在 (176, 16) 的坐标上
            // 字体高度为34
            // 旋转的角度为 0 度
            // 2 表示 粗体.
            // 文字没有下划线.
            // 字体为 黑体.
            // 打印的内容为:title
            //TSCLIB_DLL.barcode("280", "7", "128", "65", "1", "0", "2", "2", m.BarCode);
            //TSCLIB_DLL.windowsfont(340, 120, 23, 0, 2, 0, "宋体", "名称:" + m.InstrumentName);
            //TSCLIB_DLL.windowsfont(340, 160, 23, 0, 2, 0, "宋体", "仪器型号:" + m.Specification);
            //TSCLIB_DLL.windowsfont(340, 200, 23, 0, 2, 0, "宋体", "资产编号:" + m.AssetsNo);
            //TSCLIB_DLL.windowsfont(340, 240, 23, 0, 2, 0, "宋体", "出厂编号:" + m.SerialNo);
            //TSCLIB_DLL.windowsfont(340, 280, 23, 0, 2, 0, "宋体", "管理编号:" + m.ManageNo);
            int    Y    = 0;
            string name = m.InstrumentName;

            if (m.InstrumentName.Length > 10)
            {
                Y    = 40;
                name = m.InstrumentName.Substring(0, 10);
            }
            TSCLIB_DLL.windowsfont(200, 110, 23, 0, 2, 0, "宋体", "名称:" + name);
            if (m.InstrumentName.Length > 10)
            {
                TSCLIB_DLL.windowsfont(200, 110 + Y, 23, 0, 2, 0, "宋体", m.InstrumentName.Substring(10, m.InstrumentName.Length - 10));
            }
            TSCLIB_DLL.windowsfont(200, 140 + Y, 23, 0, 2, 0, "宋体", "仪器型号:" + m.Specification);
            TSCLIB_DLL.windowsfont(200, 170 + Y, 23, 0, 2, 0, "宋体", "资产编号:" + m.AssetsNo);
            TSCLIB_DLL.windowsfont(200, 200 + Y, 23, 0, 2, 0, "宋体", "出厂编号:" + m.SerialNo);
            TSCLIB_DLL.windowsfont(200, 230 + Y, 23, 0, 2, 0, "宋体", "管理编号:" + m.ManageNo);
            // 打印条码.
            // 在 (176, 66) 的坐标上
            // 以 Code39 的条码方式
            // 条码高度 130
            // 打印条码的同时,还打印条码的文本信息.
            // 旋转的角度为 0 度
            // 条码 宽 窄 比例因子为 7:12
            // 条码内容为:barCode
            //TSCLIB_DLL.barcode("176", "66", "39", "130", "1", "0", "7", "12", barCode);
            // 打印.
            TSCLIB_DLL.printlabel("1", "1");
            // 关闭 打印机 端口
            TSCLIB_DLL.closeport();
        }
示例#21
0
        private void price10338()
        {
            try
            {
                int select_count = dgv_malzeme.SelectedRows.Count;
                if (select_count > 0)
                {
                    List <DataGridViewRow> rows =
                        (from DataGridViewRow row in dgv_malzeme.SelectedRows
                         where !row.IsNewRow
                         orderby row.Index
                         select row).ToList <DataGridViewRow>();
                    string price;
                    string price_cur;
                    string item_code;
                    string item_name;
                    string item_unit;
                    string printer_name = cmb_printer.Text;
                    string label_count  = labelCount.Value.ToString();
                    string price_with_cur;
                    int    point_number;
                    string point_number_s = "";

                    TSCLIB_DLL.openport(printer_name);
                    TSCLIB_DLL.sendcommand("SIZE 103 mm, 38 mm");
                    TSCLIB_DLL.sendcommand("SPEED 4");
                    TSCLIB_DLL.sendcommand("GAP 0 mm, 0 mm");
                    if (cmb_priceStyle.Text == "Ribonlı yazdırım")
                    {
                        TSCLIB_DLL.sendcommand("SET RIBBON ON");
                    }
                    else
                    {
                        TSCLIB_DLL.sendcommand("SET RIBBON OFF");
                    }
                    TSCLIB_DLL.sendcommand("DENSITY 8");
                    TSCLIB_DLL.sendcommand("DIRECTION 1");
                    TSCLIB_DLL.sendcommand("SET TEAR ON");
                    TSCLIB_DLL.sendcommand("CODEPAGE UTF-8");

                    for (int i = 0; i < select_count; i++)
                    {
                        price        = rows[i].Cells[3].Value.ToString();
                        price_cur    = rows[i].Cells[4].Value.ToString();
                        item_name    = rows[i].Cells[2].Value.ToString();
                        item_code    = rows[i].Cells[1].Value.ToString();
                        item_unit    = rows[i].Cells[5].Value.ToString();
                        point_number = Int32.Parse(rows[i].Cells[7].Value.ToString());
                        if (point_number > 0)
                        {
                            point_number_s = ".";
                            for (int j = 0; j < point_number; j++)
                            {
                                point_number_s += "0";
                            }
                        }
                        price = String.Format("{0:### ### ### ##0" + point_number_s + "}", float.Parse(price.Replace(".", System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.CurrencyDecimalSeparator.ToString()).Replace(",", System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.CurrencyDecimalSeparator.ToString())));

                        //MessageBox.Show(price);
                        // todo: orat suyshurmeli bolmasa page bellap bilenok
                        TSCLIB_DLL.clearbuffer();
                        switch (price.Length)

                        {
                        case 3:
                            TSCLIB_DLL.windowsfont(36, 15, 180, 0, 2, 0, "Agency FB", CenterString(price, 12));
                            TSCLIB_DLL.windowsfont(450, 75, 85, 0, 3, 0, "Century Gothic", price_cur);
                            break;

                        case 4:
                            TSCLIB_DLL.windowsfont(36, 15, 180, 0, 2, 0, "Agency FB", CenterString(price, 12));
                            TSCLIB_DLL.windowsfont(450, 75, 85, 0, 3, 0, "Century Gothic", price_cur);
                            break;

                        case 5:
                            TSCLIB_DLL.windowsfont(36, 15, 180, 0, 2, 0, "Agency FB", CenterString(price, 12));
                            TSCLIB_DLL.windowsfont(500, 75, 85, 0, 3, 0, "Century Gothic", price_cur);
                            break;

                        case 6:
                            TSCLIB_DLL.windowsfont(36, 15, 180, 0, 2, 0, "Agency FB", CenterString(price, 10));
                            TSCLIB_DLL.windowsfont(550, 88, 60, 0, 3, 0, "Century Gothic", price_cur);
                            break;

                        case 7:
                            TSCLIB_DLL.windowsfont(45, 15, 180, 0, 2, 0, "Agency FB", price);
                            TSCLIB_DLL.windowsfont(580, 88, 60, 0, 3, 0, "Century Gothic", price_cur);
                            break;

                        case 8:
                            TSCLIB_DLL.windowsfont(46, 15, 180, 0, 2, 0, "Agency FB", price);
                            TSCLIB_DLL.windowsfont(600, 88, 60, 0, 3, 0, "Century Gothic", price_cur);
                            break;

                        case 9:
                            TSCLIB_DLL.windowsfont(36, 15, 170, 0, 2, 0, "Agency FB", price);
                            TSCLIB_DLL.windowsfont(610, 78, 60, 0, 3, 0, "Century Gothic", price_cur);
                            break;

                        case 10:
                            TSCLIB_DLL.windowsfont(36, 15, 160, 0, 2, 0, "Agency FB", price);
                            TSCLIB_DLL.windowsfont(610, 88, 60, 0, 3, 0, "Century Gothic", price_cur);
                            break;

                        default:
                            TSCLIB_DLL.windowsfont(36, 15, 160, 0, 2, 0, "Agency FB", price);
                            TSCLIB_DLL.windowsfont(610, 88, 60, 0, 3, 0, "Century Gothic", price_cur);
                            break;
                        }

                        TSCLIB_DLL.windowsfont(30, 170, 48, 0, 2, 0, "Century Gothic", CenterString(item_code, 32));
                        if (item_name.Length > 40)
                        {
                            TSCLIB_DLL.windowsfont(30, 230, 32, 0, 2, 0, "Century Gothic", CenterString(item_name, 55));
                        }
                        else if (item_name.Length > 30)
                        {
                            TSCLIB_DLL.windowsfont(30, 230, 35, 0, 2, 0, "Century Gothic", CenterString(item_name, 45));
                        }
                        else
                        {
                            TSCLIB_DLL.windowsfont(24, 230, 38, 0, 2, 0, "Century Gothic", CenterString(item_name, 50));
                        }
                        TSCLIB_DLL.windowsfont(650, 270, 35, 0, 3, 0, "Century Gothic", item_unit);

                        TSCLIB_DLL.printlabel("1", label_count);
                    }
                    TSCLIB_DLL.closeport();
                }
            }
            catch (Exception e)
            {
                Log.set("HATA: PriceForm>8035 print()\nEXCEPTION:" + e.ToString());
            }
        }
示例#22
0
        private void price3825()
        {
            try
            {
                int select_count = dgv_malzeme.SelectedRows.Count;
                if (select_count > 0)
                {
                    List <DataGridViewRow> rows =
                        (from DataGridViewRow row in dgv_malzeme.SelectedRows
                         where !row.IsNewRow
                         orderby row.Index
                         select row).ToList <DataGridViewRow>();
                    string price;
                    string price_cur;
                    string item_code;
                    string item_name;
                    string item_unit;
                    string printer_name = cmb_printer.Text;
                    string label_count  = labelCount.Value.ToString();
                    int    point_number;
                    string point_number_s = "";

                    TSCLIB_DLL.openport(printer_name);
                    TSCLIB_DLL.sendcommand("SIZE 38 mm, 25 mm");
                    TSCLIB_DLL.sendcommand("SPEED 4");
                    TSCLIB_DLL.sendcommand("GAP 3 mm,0 mm");
                    if (cmb_priceStyle.Text == "Ribonlı yazdırım")
                    {
                        TSCLIB_DLL.sendcommand("SET RIBBON ON");
                    }
                    else
                    {
                        TSCLIB_DLL.sendcommand("SET RIBBON OFF");
                    }
                    TSCLIB_DLL.sendcommand("DENSITY 8");
                    TSCLIB_DLL.sendcommand("DIRECTION 1");
                    TSCLIB_DLL.sendcommand("SET TEAR ON");
                    TSCLIB_DLL.sendcommand("CODEPAGE UTF-8");
                    for (int i = 0; i < select_count; i++)
                    {
                        price        = rows[i].Cells[3].Value.ToString();
                        price_cur    = rows[i].Cells[4].Value.ToString();
                        item_name    = rows[i].Cells[2].Value.ToString();
                        item_code    = rows[i].Cells[1].Value.ToString();
                        item_unit    = rows[i].Cells[5].Value.ToString();
                        point_number = Int32.Parse(rows[i].Cells[7].Value.ToString());
                        if (point_number > 0)
                        {
                            point_number_s = ".";
                            for (int j = 0; j < point_number; j++)
                            {
                                point_number_s += "0";
                            }
                        }
                        price = String.Format("{0:### ### ### ##0" + point_number_s + "}", float.Parse(price.Replace(".", System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.CurrencyDecimalSeparator.ToString()).Replace(",", System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.CurrencyDecimalSeparator.ToString())));
                        TSCLIB_DLL.clearbuffer();

                        TSCLIB_DLL.windowsfont(16, -5, 100, 0, 2, 0, "Agency FB", CenterString(price, 10));
                        TSCLIB_DLL.windowsfont(230, 75, 35, 0, 1, 0, "Century Gothic", price_cur);

                        TSCLIB_DLL.windowsfont(16, 115, 26, 0, 2, 0, "Century Gothic", CenterString(item_code, 30));
                        if (item_name.Length > 30)
                        {
                            TSCLIB_DLL.windowsfont(16, 140, 20, 0, 2, 0, "Century Gothic", item_name.Substring(0, 26) + "-");
                            TSCLIB_DLL.windowsfont(16, 155, 20, 0, 2, 0, "Century Gothic", item_name.Substring(26, item_name.Length - 26));
                        }
                        else
                        {
                            TSCLIB_DLL.windowsfont(14, 140, 20, 0, 2, 0, "Century Gothic", CenterString(item_name, 32));
                        }

                        TSCLIB_DLL.windowsfont(235, 168, 20, 0, 3, 0, "Century Gothic", item_unit);

                        TSCLIB_DLL.printlabel("1", label_count);
                    }
                    TSCLIB_DLL.closeport();
                }
            }
            catch (Exception e)
            {
                Log.set("HATA: PriceForm>3825 print()\nEXCEPTION:" + e.ToString());
            }
        }
示例#23
0
        private void price10338(string price, string price_cur, string item_code, string item_name, string label_count, int point_number, int ribon, string item_unit)
        {
            try
            {
                string price_with_cur;
                string point_number_s = "";

                TSCLIB_DLL.openport(printer);
                TSCLIB_DLL.sendcommand("SIZE 103 mm, 38 mm");
                TSCLIB_DLL.sendcommand("SPEED 4");
                TSCLIB_DLL.sendcommand("GAP 0 mm, 0 mm");
                if (ribon == 1)
                {
                    TSCLIB_DLL.sendcommand("SET RIBBON ON");
                }
                else
                {
                    TSCLIB_DLL.sendcommand("SET RIBBON OFF");
                }
                TSCLIB_DLL.sendcommand("DENSITY 8");
                TSCLIB_DLL.sendcommand("DIRECTION 1");
                TSCLIB_DLL.sendcommand("SET TEAR ON");
                TSCLIB_DLL.sendcommand("CODEPAGE UTF-8");


                if (point_number > 0)
                {
                    point_number_s = ".";
                    for (int j = 0; j < point_number; j++)
                    {
                        point_number_s += "0";
                    }
                }
                price = String.Format("{0:### ### ### ##0" + point_number_s + "}", float.Parse(price)); //.ToString("### ### ### ###.##");

                //MessageBox.Show(price);
                // todo: orat suyshurmeli bolmasa page bellap bilenok
                TSCLIB_DLL.clearbuffer();
                switch (price.Length)
                {
                case 3:
                    TSCLIB_DLL.windowsfont(36, 15, 180, 0, 2, 0, "Agency FB", CenterString(price, 12));
                    TSCLIB_DLL.windowsfont(450, 75, 85, 0, 3, 0, "Century Gothic", price_cur);
                    break;

                case 4:
                    TSCLIB_DLL.windowsfont(36, 15, 180, 0, 2, 0, "Agency FB", CenterString(price, 12));
                    TSCLIB_DLL.windowsfont(450, 75, 85, 0, 3, 0, "Century Gothic", price_cur);
                    break;

                case 5:
                    TSCLIB_DLL.windowsfont(36, 15, 180, 0, 2, 0, "Agency FB", CenterString(price, 12));
                    TSCLIB_DLL.windowsfont(500, 75, 85, 0, 3, 0, "Century Gothic", price_cur);
                    break;

                case 6:
                    TSCLIB_DLL.windowsfont(36, 15, 180, 0, 2, 0, "Agency FB", CenterString(price, 10));
                    TSCLIB_DLL.windowsfont(550, 88, 60, 0, 3, 0, "Century Gothic", price_cur);
                    break;

                case 7:
                    TSCLIB_DLL.windowsfont(45, 15, 180, 0, 2, 0, "Agency FB", price);
                    TSCLIB_DLL.windowsfont(580, 88, 60, 0, 3, 0, "Century Gothic", price_cur);
                    break;

                case 8:
                    TSCLIB_DLL.windowsfont(46, 15, 180, 0, 2, 0, "Agency FB", price);
                    TSCLIB_DLL.windowsfont(600, 88, 60, 0, 3, 0, "Century Gothic", price_cur);
                    break;

                case 9:
                    TSCLIB_DLL.windowsfont(36, 15, 170, 0, 2, 0, "Agency FB", price);
                    TSCLIB_DLL.windowsfont(610, 78, 60, 0, 3, 0, "Century Gothic", price_cur);
                    break;

                case 10:
                    TSCLIB_DLL.windowsfont(36, 15, 160, 0, 2, 0, "Agency FB", price);
                    TSCLIB_DLL.windowsfont(610, 88, 60, 0, 3, 0, "Century Gothic", price_cur);
                    break;

                default:
                    TSCLIB_DLL.windowsfont(36, 15, 160, 0, 2, 0, "Agency FB", price);
                    TSCLIB_DLL.windowsfont(610, 88, 60, 0, 3, 0, "Century Gothic", price_cur);
                    break;
                }

                TSCLIB_DLL.windowsfont(30, 170, 48, 0, 2, 0, "Century Gothic", CenterString(item_code, 32));
                if (item_name.Length > 40)
                {
                    TSCLIB_DLL.windowsfont(30, 230, 32, 0, 2, 0, "Century Gothic", CenterString(item_name, 55));
                }
                else if (item_name.Length > 30)
                {
                    TSCLIB_DLL.windowsfont(30, 230, 35, 0, 2, 0, "Century Gothic", CenterString(item_name, 45));
                }
                else
                {
                    TSCLIB_DLL.windowsfont(24, 230, 38, 0, 2, 0, "Century Gothic", CenterString(item_name, 50));
                }
                TSCLIB_DLL.windowsfont(650, 270, 35, 0, 3, 0, "Century Gothic", item_unit);

                TSCLIB_DLL.printlabel("1", label_count);

                TSCLIB_DLL.closeport();
            }
            catch (Exception e)
            {
                Log.set("HATA: PriceForm>8035 print()\nEXCEPTION:" + e.ToString());
            }
        }
示例#24
0
        private void price8030(string price, string price_cur, string item_code, string item_name, string label_count, int point_number, int ribon, string item_unit)
        {
            try
            {
                string point_number_s = "";
                TSCLIB_DLL.openport(printer);
                TSCLIB_DLL.sendcommand("SIZE 80 mm, 30 mm");
                TSCLIB_DLL.sendcommand("SPEED 4");
                TSCLIB_DLL.sendcommand("GAP 3 mm,0 mm");
                if (ribon == 1)
                {
                    TSCLIB_DLL.sendcommand("SET RIBBON ON");
                }
                else
                {
                    TSCLIB_DLL.sendcommand("SET RIBBON OFF");
                }
                TSCLIB_DLL.sendcommand("DENSITY 8");
                TSCLIB_DLL.sendcommand("DIRECTION 1");
                TSCLIB_DLL.sendcommand("SET TEAR ON");
                TSCLIB_DLL.sendcommand("CODEPAGE UTF-8");

                if (point_number > 0)
                {
                    point_number_s = ".";
                    for (int j = 0; j < point_number; j++)
                    {
                        point_number_s += "0";
                    }
                }
                price = String.Format("{0:### ### ### ##0" + point_number_s + "}", float.Parse(price)); //.ToString("### ### ### ###.##");
                TSCLIB_DLL.clearbuffer();
                switch (price.Length)
                {
                case 3:
                    TSCLIB_DLL.windowsfont(16, -10, 170, 0, 2, 0, "Agency FB", CenterString(price, 12));
                    TSCLIB_DLL.windowsfont(350, 65, 75, 0, 3, 0, "Century Gothic", price_cur);
                    break;

                case 4:
                    TSCLIB_DLL.windowsfont(16, -10, 170, 0, 2, 0, "Agency FB", CenterString(price, 12));
                    TSCLIB_DLL.windowsfont(400, 65, 75, 0, 3, 0, "Century Gothic", price_cur);
                    break;

                case 5:
                    TSCLIB_DLL.windowsfont(16, -10, 170, 0, 2, 0, "Agency FB", CenterString(price, 12));
                    TSCLIB_DLL.windowsfont(440, 65, 75, 0, 3, 0, "Century Gothic", price_cur);
                    break;

                case 6:
                    TSCLIB_DLL.windowsfont(16, -10, 170, 0, 2, 0, "Agency FB", CenterString(price, 10));
                    TSCLIB_DLL.windowsfont(500, 78, 50, 0, 3, 0, "Century Gothic", price_cur);
                    break;

                case 7:
                    TSCLIB_DLL.windowsfont(25, -10, 170, 0, 2, 0, "Agency FB", price);
                    TSCLIB_DLL.windowsfont(510, 78, 50, 0, 3, 0, "Century Gothic", price_cur);
                    break;

                case 8:
                    TSCLIB_DLL.windowsfont(16, -10, 170, 0, 2, 0, "Agency FB", price);
                    TSCLIB_DLL.windowsfont(510, 78, 50, 0, 3, 0, "Century Gothic", price_cur);
                    break;

                case 9:
                    TSCLIB_DLL.windowsfont(16, -10, 160, 0, 2, 0, "Agency FB", price);
                    TSCLIB_DLL.windowsfont(510, 78, 50, 0, 3, 0, "Century Gothic", price_cur);
                    break;

                case 10:
                    TSCLIB_DLL.windowsfont(16, -10, 150, 0, 2, 0, "Agency FB", price);
                    TSCLIB_DLL.windowsfont(510, 78, 50, 0, 3, 0, "Century Gothic", price_cur);
                    break;

                default:
                    TSCLIB_DLL.windowsfont(16, -10, 150, 0, 2, 0, "Agency FB", price);
                    TSCLIB_DLL.windowsfont(510, 78, 50, 0, 3, 0, "Century Gothic", price_cur);
                    break;
                }

                TSCLIB_DLL.windowsfont(16, 140, 38, 0, 2, 0, "Century Gothic", CenterString(item_code, 32));
                if (item_name.Length > 40)
                {
                    TSCLIB_DLL.windowsfont(24, 175, 22, 0, 2, 0, "Century Gothic", CenterString(item_name, 55));
                }
                else if (item_name.Length > 30)
                {
                    TSCLIB_DLL.windowsfont(24, 175, 25, 0, 2, 0, "Century Gothic", CenterString(item_name, 45));
                }
                else
                {
                    TSCLIB_DLL.windowsfont(14, 175, 28, 0, 2, 0, "Century Gothic", CenterString(item_name, 50));
                }
                TSCLIB_DLL.windowsfont(550, 200, 25, 0, 3, 0, "Century Gothic", item_unit);

                TSCLIB_DLL.printlabel("1", label_count);

                TSCLIB_DLL.closeport();
            }
            catch (Exception e)
            {
                Log.set("HATA: PriceForm>8035 print()\nEXCEPTION:" + e.ToString());
            }
        }
示例#25
0
        private void eXCEL打印ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string excelFilePath = "";
            //excelFilePath = @"C:\Users\user\Desktop\EXCEL\TRY.xlsx";

            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Title       = "请选择文件";
            dialog.Filter      = "Excel(*.xlsm)|*.xlsm|Excel(*.xlsx)|*.xlsx|Excel(*.xls)|*.xls";
            dialog.Multiselect = false;      //确定是否可以选择多个文件
            //dialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            //dialog.InitialDirectory = Application.StartupPath ;
            dialog.InitialDirectory = @"\\version1\测试二所\样机管理系统\样机信息";


            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                excelFilePath = dialog.FileName;
            }
            else
            {
                return;
            }


            MExcel.Application app = new MExcel.Application();
            MExcel.Sheets      sheets;
            MExcel.Workbook    workbook = null;
            object             oMissing = System.Reflection.Missing.Value;
            //app.Visible = true;
            DataTable dt = new DataTable();

            //查询产线数据库需要
            //IMEI信息 无线功检工位数据库
            SqlConnection connSql  = new SqlConnection(GetConn.sqlConn); //连接对象
            List <string> IMEIList = new List <string>();                //IMEI号列表


            try
            {
                workbook = app.Workbooks.Open(excelFilePath, oMissing, oMissing, oMissing, oMissing, oMissing,
                                              oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing);
                sheets = workbook.Worksheets;
                MExcel.Worksheet worksheet = (MExcel.Worksheet)sheets.get_Item(1);          //用的是 worksheets 这一大类的
                //MExcel.Worksheet worksheet = (MExcel.Worksheet)workbook.Worksheets[1];

                int iRowCount = worksheet.get_Range("B65535", oMissing).get_End(MExcel.XlDirection.xlUp).Row;
                int iColCount = worksheet.UsedRange.Columns.Count;

                if (iRowCount < 4)
                {
                    MessageBox.Show("请在文档中输入样机信息!");
                    return;
                }


                //查询产线数据库,使用的sql命令. IMEI号获取
                //string strSqlTest;
                //SqlCommand cmdTest = null;
                //SqlDataReader dr = null;
                string IMEIPrint = "";

                string PhoneCode;                                                                          //PhoneID作为主键,可以在程序中自动生成,此处无需添加
                string PhoneName;
                string PhoneStage;
                string PhoneStagePrint;
                string PhoneNum;
                //string PhoneStatus = "在库";
                //string PhoneNoteAll;
                string PhoneNote;
                string PhoneNote1;
                string PhoneNote2;
                string PhoneNote3;
                string PhoneNote4;
                //string PhoneNote5;

                string PhoneOwner;

                string log1, log2, log3, log4;

                MExcel.Range rngName  = (MExcel.Range)worksheet.Cells[1, 2];
                MExcel.Range rngStage = (MExcel.Range)worksheet.Cells[2, 2];
                //MExcel.Range rngNoteAll = (MExcel.Range)worksheet.Cells[3, 2];
                PhoneName  = Convert.ToString(rngName.Value2);                                         //STRING 用来将内容变为字符串
                PhoneStage = Convert.ToString(rngStage.Value2);
                //PhoneNoteAll = Convert.ToString(rngNoteAll.Value2);

                MExcel.Range log1R = (MExcel.Range)worksheet.Cells[3, 1];
                MExcel.Range log2R = (MExcel.Range)worksheet.Cells[3, 5];
                MExcel.Range log3R = (MExcel.Range)worksheet.Cells[3, 6];
                MExcel.Range log4R = (MExcel.Range)worksheet.Cells[3, 7];

                log1 = Convert.ToString(log1R.Value2);                                          //STRING 用来将内容变为字符串
                log2 = Convert.ToString(log2R.Value2);
                log3 = Convert.ToString(log3R.Value2);
                log4 = Convert.ToString(log4R.Value2);

                if (PhoneName == null || PhoneStage == null || log1 == null || log2 == null || log3 == null || log4 == null)
                {
                    MessageBox.Show("'型号' 与 '测试阶段' 是必填内容 或 使用最新模板");
                    return;
                }


                PhoneBLL phonebll = new PhoneBLL();

                //循环打印开始
                for (int i = 4; i <= iRowCount; i++)
                {
                    MExcel.Range rngCode = (MExcel.Range)worksheet.Cells[i, 1];
                    MExcel.Range rngNum  = (MExcel.Range)worksheet.Cells[i, 2];
                    //MExcel.Range rngNote = (MExcel.Range)worksheet.Cells[i, 4];
                    MExcel.Range rngOwner = (MExcel.Range)worksheet.Cells[i, 3];
                    MExcel.Range rngNote1 = (MExcel.Range)worksheet.Cells[i, 4];
                    MExcel.Range rngNote2 = (MExcel.Range)worksheet.Cells[i, 5];
                    MExcel.Range rngNote3 = (MExcel.Range)worksheet.Cells[i, 6];
                    MExcel.Range rngNote4 = (MExcel.Range)worksheet.Cells[i, 7];
                    //MExcel.Range rngNote5 = (MExcel.Range)worksheet.Cells[i, 8];

                    PhoneCode = Convert.ToString(rngCode.Value2) + "";
                    PhoneNum  = Convert.ToString(rngNum.Value2) + "";

                    PhoneOwner = Convert.ToString(rngOwner.Value2) + "";
                    PhoneNote1 = Convert.ToString(rngNote1.Value2) + "";
                    PhoneNote2 = Convert.ToString(rngNote2.Value2) + "";
                    PhoneNote3 = Convert.ToString(rngNote3.Value2) + "";
                    PhoneNote4 = Convert.ToString(rngNote4.Value2) + "";
                    //PhoneNote5 = Convert.ToString(rngNote5.Value2) + "";
                    PhoneNote = PhoneNote1 + PhoneNote2 + PhoneNote3 + PhoneNote4;

                    PhoneStagePrint = PhoneStage + "_" + PhoneNum;

                    //如果没有PhoneCode时,就设为myname
                    //if (PhoneCode=="")
                    //{
                    //    PhoneCode = "xiechunhui";
                    //}

                    ////////////////////////////////////////////////////////连接产线数据库,查询是否有IMEI号,暂时不打印了。
                    //strSqlTest = "SELECT [dbo].[ESNRecord].IMEI FROM [dbo].[ESNRECORD] INNER JOIN [dbo].[TestReport] on [dbo].[TestReport].PhoneId=[dbo].[ESNRecord].PhoneId and [dbo].[TestReport].PhoneId = "
                    //               + "'" + PhoneCode + "'"; //样机名称combobox内容加载
                    ////打开连接
                    //connSql.Open();
                    ////新建mysql命令
                    //cmdTest = new SqlCommand(strSqlTest, connSql);
                    ////执行查寻; ExecuteReader() 方法的 CommandBehavior.CloseConnection 参数,会在DataReader对象关闭时也同时关闭Connection对象
                    //dr = cmdTest.ExecuteReader(CommandBehavior.CloseConnection);
                    //while (dr.Read())
                    //{
                    //    IMEIList.Add((dr.IsDBNull(0)) ? "" : dr.GetString(0));         //当PHONEID为NULL时的处理办法
                    //}
                    ////关闭DataReader对象
                    //dr.Close();
                    //dr.Dispose();
                    ////需要打印的IMEI号
                    ////当查询不到此PHONEID对应的IMEI号时列表中的值为空时,设其为空字符串
                    //if (IMEIList.Count == 0)
                    //{
                    //    IMEIPrint = "未写号";
                    //}
                    //else
                    //{
                    //    IMEIPrint = IMEIList[0];

                    //}

                    //打印开始******************************************************************************
                    //打开打印端口
                    TSCLIB_DLL.openport("Deli DL-888F(NEW)");
                    //设计打印纸的大小与间距
                    TSCLIB_DLL.setup("30", "20", "3", "10", "0", "2", "0");    //宽度、高度、速度寸/秒、浓度0-15、。 长度30 20 OK,倒数间距2 OK
                    //清空下缓存
                    TSCLIB_DLL.clearbuffer();
                    //打印文字
                    TSCLIB_DLL.windowsfont(1, 15, 22, 0, 0, 0, "標楷體", PhoneName);       //用windowsTTF字型列印文字 X、Y、字体高度、角度、字体外形、有无底线、字体名称、打印内容
                    TSCLIB_DLL.windowsfont(1, 38, 22, 0, 0, 0, "標楷體", PhoneStagePrint); //用windowsTTF字型列印文字 X、Y、字体高度、角度、字体外形、有无底线、字体名称、打印内容
                    TSCLIB_DLL.windowsfont(1, 61, 22, 0, 0, 0, "標楷體", PhoneNote1);      //用windowsTTF字型列印文字 X、Y、字体高度、角度、字体外形、有无底线、字体名称、打印内容
                    TSCLIB_DLL.windowsfont(1, 84, 22, 0, 0, 0, "標楷體", PhoneNote2);      //用windowsTTF字型列印文字 X、Y、字体高度、角度、字体外形、有无底线、字体名称、打印内容
                    TSCLIB_DLL.windowsfont(1, 107, 22, 0, 0, 0, "標楷體", PhoneNote3);     //用windowsTTF字型列印文字 X、Y、字体高度、角度、字体外形、有无底线、字体名称、打印内容
                    TSCLIB_DLL.windowsfont(1, 130, 15, 0, 0, 0, "標楷體", PhoneNote4);     //用windowsTTF字型列印文字 X、Y、字体高度、角度、字体外形、有无底线、字体名称、打印内容
                    //TSCLIB_DLL.windowsfont(1, 146, 15, 0, 0, 0, "標楷體", PhoneNote5);  //用windowsTTF字型列印文字 X、Y、字体高度、角度、字体外形、有无底线、字体名称、打印内容


                    //打印份数
                    TSCLIB_DLL.printlabel("1", "1");
                    //关闭打印端口
                    TSCLIB_DLL.closeport();
                    //打印结束********************************************************************************


                    //IMEIList.Clear();//IMEI查询时使用,在此不用
                }

                MessageBox.Show("样机信息打印成功^_^");
            }
            catch
            {
                MessageBox.Show("本机电脑可能不能访问产线数据库,有问题请联系 解chunhui");
            }
            finally
            {
                workbook.Close(false, oMissing, oMissing);                          //关闭 工作表
                System.Runtime.InteropServices.Marshal.ReleaseComObject(workbook);
                workbook = null;

                app.Workbooks.Close();                                              //关闭应用
                app.Quit();
                System.Runtime.InteropServices.Marshal.ReleaseComObject(app);
                app = null;


                //关闭连接
                connSql.Close();
            }
            //COM组件方式读取 EXCEL中的数值
        }
示例#26
0
        /*
         * barcode - Arassa barcode bermeli 240001, 2500001
         * item_code - haryt kody
         * item_name - haryt ady
         * birim_code - adet, packa
         * label_count - print count, yazdyryljak etiket sany
         * birim - 100 adet, 10.5 M
         * ek_sutun - goshamaca name maglumat bermeli bolsa,
         * unit_length - mukar beriljek wagty nace sany edip bermeli 55- lik bolsa 5, 46 bolsa 6
         * dev - 1000 lukmi yada 1 likmi
         * kapak - egerde kapak adyny cykarmaly bolsa kapak adynyn yazyp ugratmaly
         * galyndy - 1 bolsa yazgy gornushi uytgeyar, 0 bolsa galyndy dal digini anlatyar
         */

        private void birimBarcodePrint(string barcode, string item_code, string item_name, string birim_code, int label_count, float birim, string ek_sutun, int unit_length, int dev, string kapak, int galyndy, int ribon)
        {
            TSCLIB_DLL.openport(printer);
            TSCLIB_DLL.sendcommand("SIZE 45 mm, 15 mm");
            TSCLIB_DLL.sendcommand("SPEED 4");
            TSCLIB_DLL.sendcommand("GAP 3 mm, 0 mm");
            if (ribon == 1)
            {
                TSCLIB_DLL.sendcommand("SET RIBBON ON");
            }
            else
            {
                TSCLIB_DLL.sendcommand("SET RIBBON OFF");
            }

            TSCLIB_DLL.sendcommand("DENSITY 8");
            TSCLIB_DLL.sendcommand("DIRECTION 1");
            TSCLIB_DLL.sendcommand("DIRECTION 1");
            TSCLIB_DLL.sendcommand("SET TEAR ON");
            TSCLIB_DLL.sendcommand("CODEPAGE UTF-8");

            if (birim != 1)
            {
                string nollar = "";
                for (int j = 0; j < (int)unit_length; j++)
                {
                    nollar += "0";
                }
                barcode += ((int)dev * (float)birim).ToString(nollar);
                barcode  = makeControl(barcode);
            }

            TSCLIB_DLL.clearbuffer();
            if (kapak != "")
            {
                //TSCLIB_DLL.sendcommand("TEXT 300, 60,\"2\",0,1,1,2,\"" + kapak + "\"");
                //TSCLIB_DLL.sendcommand("BOX 260, 45, 340, 100, 2");
                TSCLIB_DLL.windowsfont(300, 10, 17, 0, 2, 0, "Century Gothic", kapak);
            }
            TSCLIB_DLL.sendcommand("BOX 40, 45, 120, 100, 2");

            /*
             * TSCLIB_DLL.windowsfont(30, 40, 28, 0, 2, 0, "Century Gothic", CenterString(birim.ToString(), 9));
             * TSCLIB_DLL.windowsfont(30, 60, 20, 0, 2, 0, "Century Gothic", CenterString(birim_code, 14));
             * TSCLIB_DLL.windowsfont(30, 75, 17, 0, 2, 0, "Century Gothic", "GALYNDY");*/
            TSCLIB_DLL.sendcommand("TEXT 80, 50,\"2\",0,1,1,2,\"" + birim.ToString() + "\"");
            TSCLIB_DLL.sendcommand("TEXT 80, 70,\"2\",0,1,1,2,\"" + birim_code + "\"");
            // TSCLIB_DLL.sendcommand("TEXT 30, 70,\"1\",90,1,1,2,\"" + DateTime.Now.ToString("yy.MM.dd") + "\"");
            if (galyndy == 1)
            {
                TSCLIB_DLL.windowsfont(20, 105, 17, 90, 2, 0, "Century Gothic", DateTime.Now.ToString("dd.MM.yy HH:mm"));
            }


            TSCLIB_DLL.windowsfont(42, 10, 20, 0, 2, 0, "Century Gothic", item_code);
            TSCLIB_DLL.windowsfont(42, 25, 16, 0, 2, 0, "Century Gothic", item_name);
            TSCLIB_DLL.barcode("130", "43", "128", "40", "0", "0", "1.4", "1", barcode);
            TSCLIB_DLL.windowsfont(130, 83, 14, 0, 2, 0, "Century Gothic", barcode);
            TSCLIB_DLL.windowsfont(130, 95, 16, 0, 2, 0, "Century Gothic", ek_sutun);
            TSCLIB_DLL.printlabel("1", label_count.ToString());

            TSCLIB_DLL.closeport();
        }
示例#27
0
        private void BtnPrt_Click(object sender, EventArgs e)           //打印按钮
        {
            string PhoneCode       = this.txtPhoneCode.Text;            //PhoneID作为主键,可以在程序中自动生成,此处无需添加
            string PhoneName       = this.txtPhoneName.Text;
            string PhoneNum        = this.txtPhoneNum.Value.ToString();
            string PhoneStage      = this.cbbPhoneStage.Text;
            string PhoneInf1       = this.cbbInf1.Text;
            string PhoneInf2       = this.cbbInf2.Text;
            string PhoneInf3       = this.cbbInf3.Text;
            string PhoneInf4       = this.cbbInf4.Text;
            string PhoneStagePrint = PhoneStage + "_" + PhoneNum;
            //要打印的IMEI号
            string IMEIPrint = txtPhoneid.Text;

            try
            {
                ////IMEI信息 无线功检工位数据库,因已经自动产生了,所以这一步可以省略.
                //SqlConnection connSql = new SqlConnection(GetConn.sqlConn);     //连接对象
                //List<string> IMEIList = new List<string>();       //IMEI号列表

                //string strSqlTest = "SELECT [dbo].[ESNRecord].IMEI FROM [dbo].[ESNRECORD] INNER JOIN [dbo].[TestReport] on [dbo].[TestReport].PhoneId=[dbo].[ESNRecord].PhoneId and [dbo].[TestReport].PhoneId = "
                //    + "'" + PhoneCode + "'"; //样机名称combobox内容加载
                ////打开连接
                //connSql.Open();
                ////新建mysql命令
                //SqlCommand cmdTest = new SqlCommand(strSqlTest, connSql);
                ////执行查寻; ExecuteReader() 方法的 CommandBehavior.CloseConnection 参数,会在DataReader对象关闭时也同时关闭Connection对象
                //SqlDataReader dr = cmdTest.ExecuteReader(CommandBehavior.CloseConnection);
                //while (dr.Read())
                //{
                //    IMEIList.Add((dr.IsDBNull(0)) ? "" : dr.GetString(0));         //当PHONEID为NULL时的处理办法
                //}
                ////关闭DataReader对象
                //dr.Close();
                //dr.Dispose();


                ////需要打印的IMEI号
                ////当查询不到此PHONEID对应的IMEI号时列表中的值为空时,设其为空字符串
                //if (IMEIList.Count == 0)
                //{
                //    IMEIPrint = "未写号";
                //}
                //else
                //{
                //    IMEIPrint = IMEIList[0];
                //}


                /*打印标贴的程序如下*/

                //打开打印端口
                TSCLIB_DLL.openport("Deli DL-888F(NEW)");
                //设计打印纸的大小与间距
                TSCLIB_DLL.setup("30", "20", "3", "10", "0", "2", "0");    //宽度、高度、速度寸/秒、浓度0-15、。 长度30 20 OK,倒数间距2 OK
                //清空下缓存
                TSCLIB_DLL.clearbuffer();
                //打印文字
                TSCLIB_DLL.windowsfont(1, 15, 23, 0, 2, 0, "標楷體", PhoneName);       //用windowsTTF字型列印文字 X、Y、字体高度、角度、字体外形、有无底线、字体名称、打印内容
                TSCLIB_DLL.windowsfont(1, 40, 23, 0, 2, 0, "標楷體", PhoneStagePrint); //用windowsTTF字型列印文字 X、Y、字体高度、角度、字体外形、有无底线、字体名称、打印内容
                TSCLIB_DLL.windowsfont(1, 65, 23, 0, 2, 0, "標楷體", PhoneInf1);       //用windowsTTF字型列印文字 X、Y、字体高度、角度、字体外形、有无底线、字体名称、打印内容
                TSCLIB_DLL.windowsfont(1, 90, 22, 0, 2, 0, "標楷體", PhoneInf2);       //用windowsTTF字型列印文字 X、Y、字体高度、角度、字体外形、有无底线、字体名称、打印内容
                TSCLIB_DLL.windowsfont(1, 115, 23, 0, 2, 0, "標楷體", PhoneInf3);      //用windowsTTF字型列印文字 X、Y、字体高度、角度、字体外形、有无底线、字体名称、打印内容
                TSCLIB_DLL.windowsfont(1, 138, 23, 0, 2, 0, "標楷體", PhoneInf4);      //用windowsTTF字型列印文字 X、Y、字体高度、角度、字体外形、有无底线、字体名称、打印内容

                //打印份数
                TSCLIB_DLL.printlabel("1", "1");
                //关闭打印端口
                TSCLIB_DLL.closeport();

                //样机编号,自动加1
                this.txtPhoneNum.Value++;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                //MessageBox.Show("something is wrong, please contact 解chunhui");
            }
            finally
            {
            }

            this.txtPhoneCode.Clear();
            //this.txtPhoneName.Clear();
            //this.txtPhoneNum.Clear();
            //this.cbbPhoneStage.Text = "";
            //this.cbbInf1.Text = "";
            //this.cbbInf2.Text = "";
            //this.cbbInf3.Text = "";
            //this.cbbInf4.Text = "";
            //this.cbbPhoneOwner.Text = "";
        }
示例#28
0
        public bool PrintAppointmentDetails(AppointmentDetails appointmentDetails)
        {
            try
            {
                // validate
                if (!appointmentDetails.IsValid())
                {
                    return(false);
                }

                //Open specified printer driver
                TSCLIB_DLL.openport(_printerName);

                int    startX        = 0;
                int    startX_Detail = startX + 100;
                int    startY        = 0;
                int    fontHeight    = 30;
                int    space         = 30;
                string fontName      = "ARIAL";

                //Setup the media size and sensor type info
                // page size 2.8"x1.4"
                // actually 71.12mm x 42.5mm
                // TSCLIB_DLL.setup("71.12", "42.5", "4", "8", "0", "0", "0");
                TSCLIB_DLL.setup("71.12", "100", "4", "8", "0", "0", "0").ToString();

                //Clear image buffer
                TSCLIB_DLL.clearbuffer();

                //Draw windows font
                // Company name line
                TSCLIB_DLL.windowsfont(startX, startY, fontHeight + 20, 0, 2, 1, fontName, appointmentDetails.CompanyName);
                // Next appointment line
                TSCLIB_DLL.windowsfont(startX, startY += fontHeight + 20 + space, fontHeight + 10, 0, 2, 0, fontName, "Next Appointment");
                // Name line
                TSCLIB_DLL.windowsfont(startX, startY += fontHeight + 10 + space, fontHeight, 0, 0, 0, fontName, "Name");
                TSCLIB_DLL.windowsfont(startX_Detail, startY, fontHeight, 0, 0, 0, fontName, ": " + appointmentDetails.Name);
                // Date line
                TSCLIB_DLL.windowsfont(startX, startY += fontHeight, fontHeight, 0, 0, 0, fontName, "Date");
                TSCLIB_DLL.windowsfont(startX_Detail, startY, fontHeight, 0, 0, 0, fontName, ": " + appointmentDetails.Date.ToString("dd/MM/yyyy"));
                // Time line
                // Convert time to datetime first, then use formatting
                string timeFormatted = string.Empty;
                if (appointmentDetails.StartTime.HasValue)
                {
                    timeFormatted = new DateTime(appointmentDetails.StartTime.Value.Ticks).ToString("hh:mm tt");
                }
                TSCLIB_DLL.windowsfont(startX, startY += fontHeight, fontHeight, 0, 0, 0, fontName, "Time");
                TSCLIB_DLL.windowsfont(startX_Detail, startY, fontHeight, 0, 0, 0, fontName, ": " + timeFormatted);
                // Venue line
                TSCLIB_DLL.windowsfont(startX, startY += fontHeight, fontHeight, 0, 0, 0, fontName, "Venue");
                TSCLIB_DLL.windowsfont(startX_Detail, startY, fontHeight, 0, 0, 0, fontName, ": " + appointmentDetails.Venue);
                // Note line
                TSCLIB_DLL.windowsfont(startX, startY += fontHeight + space, fontHeight, 0, 2, 0, fontName, "Please be punctual to avoid cancellation");
                TSCLIB_DLL.windowsfont(startX, startY += fontHeight, fontHeight, 0, 2, 0, fontName, "of appointment.");
                // printed date line
                TSCLIB_DLL.windowsfont(startX + 272, startY += fontHeight + space + space, fontHeight - 4, 0, 1, 0, fontName, "Printed Date: " + DateTime.Now.ToString("dd/MM/yyyy"));
                // printed time line
                TSCLIB_DLL.windowsfont(startX + 272, startY += fontHeight, fontHeight - 4, 0, 1, 0, fontName, "Printed Time: " + DateTime.Now.ToString("hh:mm tt"));

                TSCLIB_DLL.printlabel("1", "1");
                TSCLIB_DLL.closeport();

                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return(false);
            }
        }
示例#29
0
        /// <summary>
        /// Not ready yet
        /// </summary>
        /// <param name="mubLabelInfo"></param>
        /// <returns></returns>
        public bool PrintMUBLabel(MUBLabelInfo mubLabelInfo)
        {
            lock (syncRoot)
            {
                try
                {
                    // validate
                    if (!mubLabelInfo.IsValid())
                    {
                        //LogManager.Debug("Model is not valid.");
                        return(false);
                    }

                    //Open specified printer driver
                    TSCLIB_DLL.openport(EnumDeviceNames.MUBLabelPrinter);

                    #region rotation 90 degrees
                    //Setup the media size and sensor type info
                    // page size 55mm x 100mm
                    // template size 55mm x 100mm (actually 56mm x 82mm)
                    //TSCLIB_DLL.setup("55", "82.5", "4", "8", "0", "0", "0");
                    //Clear image buffer
                    //TSCLIB_DLL.clearbuffer();
                    // DPI = 203 => 8px = 1 mm
                    //Draw windows font
                    int    startX       = 280;
                    int    startY       = 142;
                    int    startY_Value = startY + 160;
                    string fontName     = "ARIAL";
                    int    fontStyle    = 0; // Normal
                    int    fontHeight   = 30;
                    int    lineSpacing  = 10;
                    int    maxChar      = 17; // max char of name at first name line
                    int    rotation     = 270;

                    // send FEED command
                    //TSCLIB_DLL.sendcommand("FEED 80");

                    TSCLIB_DLL.sendcommand("SIZE 40mm, 80mm");
                    TSCLIB_DLL.sendcommand("GAP 3mm, 0mm");
                    //TSCLIB_DLL.sendcommand("SIZE 42.5mm, 80mm");
                    //TSCLIB_DLL.sendcommand("GAP 1.3mm, 0mm");
                    TSCLIB_DLL.sendcommand("DIRECTION 0");
                    TSCLIB_DLL.sendcommand("CLS");
                    //TSCLIB_DLL.sendcommand("BOX 0,0,312,624,4");
                    TSCLIB_DLL.sendcommand("TEXT 280,312,\"ROMAN.TTF\",90,12,12,2,\"CENTRAL NARCOTICS BUREAU\"");
                    //TSCLIB_DLL.windowsfont(startX, startY, fontHeight, rotation, fontStyle, 0, fontName, "Name");
                    // Title line
                    //TSCLIB_DLL.windowsfont(startX, 48, fontHeight + 8, rotation, 2, 0, fontName, "CENTRAL NARCOTICS BUREAU");
                    //TSCLIB_DLL.windowsfont(startX-54, 0, fontHeight + 8, rotation, fontStyle, 0, fontName, "| Start");
                    //TSCLIB_DLL.windowsfont(startX-54, 600, fontHeight + 6, rotation, fontStyle, 0, fontName, "| End");


                    // Name line
                    TSCLIB_DLL.windowsfont(startX -= 64, startY, fontHeight, rotation, fontStyle, 0, fontName, "Name");
                    if (mubLabelInfo.Name.Length > maxChar)
                    {
                        TSCLIB_DLL.windowsfont(startX, startY_Value, fontHeight, rotation, fontStyle, 0, fontName, " : " + mubLabelInfo.Name.Substring(0, maxChar));
                        // Addition line if name is too long. Need to improve (detech addition row by space char)
                        TSCLIB_DLL.windowsfont(startX -= (fontHeight + lineSpacing), startY_Value + 32, fontHeight, rotation, fontStyle, 0, fontName, mubLabelInfo.Name.Substring(maxChar, mubLabelInfo.Name.Length - maxChar));
                    }
                    else
                    {
                        TSCLIB_DLL.windowsfont(startX, startY_Value, fontHeight, rotation, fontStyle, 0, fontName, " : " + mubLabelInfo.Name);
                        startX -= (fontHeight + lineSpacing);
                    }

                    // ID line
                    TSCLIB_DLL.windowsfont(startX -= (fontHeight + lineSpacing), startY, fontHeight, rotation, fontStyle, 0, fontName, "ID No.");
                    TSCLIB_DLL.windowsfont(startX, startY_Value, fontHeight, rotation, fontStyle, 0, fontName, " : " + mubLabelInfo.ID);

                    // Date line
                    TSCLIB_DLL.windowsfont(startX -= (fontHeight + lineSpacing), startY, fontHeight, rotation, fontStyle, 0, fontName, "Date");
                    TSCLIB_DLL.windowsfont(startX, startY_Value, fontHeight, rotation, fontStyle, 0, fontName, " : " + DateTime.Now.ToString("dd/MM/yyyy"));

                    // Marking no
                    TSCLIB_DLL.windowsfont(startX -= (fontHeight + lineSpacing), startY, fontHeight, rotation, fontStyle, 0, fontName, "Marking No.");
                    TSCLIB_DLL.windowsfont(startX, startY_Value, fontHeight, rotation, fontStyle, 0, fontName, " : " + mubLabelInfo.MarkingNumber);

                    //Drawing barcode
                    //TSCLIB_DLL.sendcommand("DMATRIX 200,16,400,400,x3,r90, \"" + mubLabelInfo.QRCodeString + "\"");
                    TSCLIB_DLL.sendcommand("DMATRIX 100,40,400,400,x2, \"" + mubLabelInfo.QRCodeString + "\"");

                    //Print labels
                    TSCLIB_DLL.printlabel("1", "1");

                    // send FEED command
                    //TSCLIB_DLL.sendcommand("BACKFEED 80");
                    TSCLIB_DLL.closeport();
                    #endregion

                    #region rotation 270 degrees
                    //// Setup the media size and sensor type info
                    //// page size 55mm x 100mm
                    //// template size 55mm x 100mm (actually 56mm x 82mm)
                    //TSCLIB_DLL.setup("55", "82.5", "4", "8", "0", "0", "0");

                    ////Clear image buffer
                    //TSCLIB_DLL.clearbuffer();
                    //// DPI = 203 => 8px = 1 mm
                    ////Draw windows font
                    //int startX = 348;
                    //int startY = 134;
                    //int startY_Value = startY + 160;
                    //string fontName = "ARIAL";
                    //int fontStyle = 0; // Normal
                    //int fontHeight = 30;
                    //int lineSpacing = 10;
                    //int maxChar = 17;   // max char of name at first name line
                    //int rotation = 270;

                    //// Title line
                    //TSCLIB_DLL.windowsfont(startX, 48, fontHeight + 8, rotation, 2, 0, fontName, "CENTRAL NARCOTICS BUREAU");
                    ////TSCLIB_DLL.windowsfont(startX-54, 0, fontHeight + 8, rotation, fontStyle, 0, fontName, "| Start");
                    ////TSCLIB_DLL.windowsfont(startX-54, 600, fontHeight + 6, rotation, fontStyle, 0, fontName, "| End");


                    //// Name line
                    //TSCLIB_DLL.windowsfont(startX -= 64, startY, fontHeight, rotation, fontStyle, 0, fontName, "Name");
                    //if (mubLabelInfo.Name.Length > maxChar)
                    //{
                    //    TSCLIB_DLL.windowsfont(startX, startY_Value, fontHeight, rotation, fontStyle, 0, fontName, " : " + mubLabelInfo.Name.Substring(0, maxChar));
                    //    // Addition line if name is too long. Need to improve (detech addition row by space char)
                    //    TSCLIB_DLL.windowsfont(startX -= (fontHeight + lineSpacing), startY_Value + 32, fontHeight, rotation, fontStyle, 0, fontName, "-" + mubLabelInfo.Name.Substring(maxChar, mubLabelInfo.Name.Length - maxChar));
                    //}
                    //else
                    //{
                    //    TSCLIB_DLL.windowsfont(startX, startY_Value, fontHeight, rotation, fontStyle, 0, fontName, " : " + mubLabelInfo.Name);
                    //    startX -= (fontHeight + lineSpacing);
                    //}

                    //// ID line
                    //TSCLIB_DLL.windowsfont(startX -= (fontHeight + lineSpacing), startY, fontHeight, rotation, fontStyle, 0, fontName, "ID No.");
                    //TSCLIB_DLL.windowsfont(startX, startY_Value, fontHeight, rotation, fontStyle, 0, fontName, " : " + mubLabelInfo.ID);

                    //// Date line
                    //TSCLIB_DLL.windowsfont(startX -= (fontHeight + lineSpacing), startY, fontHeight, rotation, fontStyle, 0, fontName, "Date");
                    //TSCLIB_DLL.windowsfont(startX, startY_Value, fontHeight, rotation, fontStyle, 0, fontName, " : " + DateTime.Now.ToString("dd/MM/yyyy"));

                    //// Marking no
                    //TSCLIB_DLL.windowsfont(startX -= (fontHeight + lineSpacing), startY, fontHeight, rotation, fontStyle, 0, fontName, "Marking No.");
                    //TSCLIB_DLL.windowsfont(startX, startY_Value, fontHeight, rotation, fontStyle, 0, fontName, " : " + mubLabelInfo.MarkingNumber);

                    ////Drawing barcode
                    ////TSCLIB_DLL.barcode(startX.ToString(), (startY += fontHeight + 8).ToString(), "39", "72", "0", "0", "1", "3", mubLabelInfo.QRCodeString);
                    //TSCLIB_DLL.sendcommand("DMATRIX 144,8,400,400,x3, \"" + mubLabelInfo.QRCodeString + "\"");

                    ////Download PCX file into printer
                    ////TSCLIB_DLL.downloadpcx("UL.PCX", "UL.PCX");
                    ////Drawing PCX graphic
                    ////TSCLIB_DLL.sendcommand("PUTPCX 100,400,\"UL.PCX\"");
                    ////Print labels
                    //TSCLIB_DLL.printlabel("1", "1");
                    //TSCLIB_DLL.closeport();
                    #endregion

                    return(true);
                }
                catch (Exception ex)
                {
                    //Debug.WriteLine("Print exception: " + ex.ToString());
                    LogManager.Debug("Print exception: " + ex.ToString());
                    return(false);
                }
            }
        }
示例#30
0
        /// <summary>
        /// print TTLabel
        /// </summary>
        /// <param name="ttLabelInfo">Id, Name, MarkingNumber must not be null</param>
        /// <returns>successful</returns>
        public bool PrintTTLabel_Direction_0(TTLabelInfo ttLabelInfo)
        {
            lock (syncRoot)
            {
                try
                {
                    //LogManager.Debug("PrintTTLabel ");
                    // validate
                    if (!ttLabelInfo.IsValid())
                    {
                        LogManager.Debug("!ttLabelInfo.IsValid");
                        return(false);
                    }

                    //Open specified printer driver
                    TSCLIB_DLL.openport(EnumDeviceNames.TTLabelPrinter);

                    //Setup the media size and sensor type info
                    // page size 55mm x 30mm
                    // template size 45mm x 30mm (actually 55mm x 32.5mm)
                    //TSCLIB_DLL.setup("55", "32.5", "4", "8", "0", "0", "0");
                    TSCLIB_DLL.setup("50", "30", "4", "8", "0", "0", "0");
                    TSCLIB_DLL.sendcommand("GAP 3mm, 0mm");
                    //TSCLIB_DLL.setup("52.5", "30", "4", "8", "0", "0", "0");
                    //TSCLIB_DLL.sendcommand("GAP 1.3mm, 0mm");
                    TSCLIB_DLL.sendcommand("DIRECTION 0");
                    TSCLIB_DLL.sendcommand("CLS");

                    //Clear image buffer
                    //TSCLIB_DLL.clearbuffer();

                    // DPI = 203 => 8px = 1 mm
                    //Draw windows font
                    //int startX = 54;
                    //int startY = 32;
                    int startX = 48;
                    int startY = 16;
                    //int startX = 40;
                    //int startY = 0;
                    string fontName   = "ARIAL";
                    int    fontStyle  = 2;  // Bold
                    int    fontHeight = 30;
                    int    maxChar    = 17; // max char of name at first name line

                    // Name line
                    TSCLIB_DLL.windowsfont(startX, startY, fontHeight, 0, fontStyle, 0, fontName, "Name");
                    if (ttLabelInfo.Name.Length > maxChar)
                    {
                        TSCLIB_DLL.windowsfont(startX + 70, startY, fontHeight, 0, fontStyle, 0, fontName, " : " + ttLabelInfo.Name.Substring(0, maxChar));
                        // Add name line if name is too long. Need to improve (split name by space char)
                        TSCLIB_DLL.windowsfont(startX + 100, startY += fontHeight, fontHeight, 0, fontStyle, 0, fontName, ttLabelInfo.Name.Substring(maxChar, ttLabelInfo.Name.Length - maxChar));
                    }
                    else
                    {
                        TSCLIB_DLL.windowsfont(startX + 70, startY, fontHeight, 0, fontStyle, 0, fontName, " : " + ttLabelInfo.Name);
                        startY += fontHeight;
                    }

                    // ID line
                    TSCLIB_DLL.windowsfont(startX, startY += fontHeight, fontHeight, 0, fontStyle, 0, fontName, "ID");
                    TSCLIB_DLL.windowsfont(startX + 70, startY, fontHeight, 0, fontStyle, 0, fontName, " : " + ttLabelInfo.ID);

                    //Drawing barcode
                    TSCLIB_DLL.barcode(startX.ToString(), (startY += fontHeight + 8).ToString(), "39", "72", "0", "0", "1", "3", ttLabelInfo.MarkingNumber);

                    // Drawing barcode buildin function do not let us set text size of readable line, so we need to draw a line to display MarkingNumber
                    TSCLIB_DLL.windowsfont(startX, startY += 80, fontHeight, 0, fontStyle, 0, fontName, ttLabelInfo.MarkingNumber);

                    //Print labels
                    TSCLIB_DLL.printlabel("1", "1");
                    TSCLIB_DLL.closeport();

                    //LogManager.Debug("Print OK");
                    return(true);
                }
                catch (Exception ex)
                {
                    //Debug.WriteLine("Print exception: " + ex.ToString());
                    LogManager.Debug("Print exception: " + ex.ToString());
                    return(false);
                }
            }
        }