Пример #1
0
        public void print(BarEntity entity)
        {
            this.entity = entity;

            printDocument.DefaultPageSettings.Landscape = true;



            printDocument.PrinterSettings.Copies = 1;


            int width = PrinterUnitConvert.Convert(100, PrinterUnit.TenthsOfAMillimeter, PrinterUnit.ThousandthsOfAnInch);

            pwidth = width;
            int height = PrinterUnitConvert.Convert(36, PrinterUnit.TenthsOfAMillimeter, PrinterUnit.ThousandthsOfAnInch);



            // System.Windows.Forms.MessageBox.Show(height + "" + width);
            // printDocument.PrinterSettings.DefaultPageSettings.PaperSize.Width = width;


            // printDocument.PrinterSettings.DefaultPageSettings.PaperSize.Height = height;

            printDocument.PrintPage += new PrintPageEventHandler(printHandler);


            printDocument.Print();
        }
Пример #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            setPrinter("SATO CL4NX 305dpi (副本 1)");

            //setPrinter("Brother PT-P900");

            BarEntity bar = new BarEntity();

            bar.aTitle = Str2Hex("国国国国国国");
            bar.aName  = Str2Hex("电脑键盘");
            bar.aDept  = Str2Hex("人事部门");
            bar.aDate  = Str2Hex("2112-21-23");
            bar.aArea  = Str2Hex("9691");

            bar.aNo = "00020170612102124309";

            // sato.print(bar);
            string data = "[{'aTitle':'宁波法师学院','aNo':'00020170703113638471','aName':'电脑','aDept':'会议室','aDate':'2017-12-26','aArea':'很隐蔽的地方','aBrand':'品牌联想','aSpec':'T1234567890'}]";

            preview(data);
        }
Пример #3
0
        public void print(BarEntity entity)
        {
            string aTitle = Str2Hex(entity.aTitle);
            string aName  = Str2Hex(entity.aName);
            string aDept  = Str2Hex(entity.aDept);
            string aDate  = Str2Hex(entity.aDate);
            string aArea  = Str2Hex(entity.aArea);
            string aBrand = Str2Hex(entity.aBrand);
            string aSpec  = Str2Hex(entity.aSpec);

            if (labelType == 0)
            {
                sendData1(entity.aNo, aTitle, aName, aDept, aDate, aArea, aBrand, aSpec);
            }
            else if (labelType == 1)
            {
                sendData(entity.aNo, aTitle, aName, aDept, aDate, aArea, aBrand, aSpec);
            }
            else if (labelType == 2 || labelType == 3)
            {
                System.Windows.Forms.MessageBox.Show("当前打印机不能打印该类型标签模板!");
            }
        }
Пример #4
0
        public Preview(OnclickPrintListener printListener, BarEntity entity)
        {
            InitializeComponent();


            this.listener = printListener;



            //公司名称==标题
            this.labelTitle.Text     = entity.aTitle.ToString();
            this.textTitle.Text      = entity.aTitle.ToString();
            this.labelTitle5024.Text = entity.aTitle.ToString();



            //资产名称
            this.labelName.Text     = entity.aName.ToString();
            this.textName.Text      = "资产名称:" + entity.aName.ToString();
            this.labelName5024.Text = "资产名称:" + entity.aName.ToString();



            //根据字数重新设置部门位置
            int tLen = System.Text.Encoding.Default.GetBytes(entity.aDept.ToString()).Length / 2;
            int x    = this.labelDept.Location.X - (tLen * 8);

            this.labelDept.Location = new Point(x, this.labelDept.Location.Y);
            this.labelDept.Text     = entity.aDept.ToString();



            this.labelDate.Text     = entity.aDate.ToString();
            this.textDate.Text      = "购置日期:" + entity.aDate.ToString();
            this.labelDate5024.Text = "购置日期:" + entity.aDate.ToString();



            tLen = System.Text.Encoding.Default.GetBytes(entity.aArea.ToString()).Length / 2;


            x = this.labelArea.Location.X - (tLen * 8);

            this.labelArea.Location = new Point(x, this.labelArea.Location.Y);

            this.labelArea.Text = entity.aArea.ToString();
            this.textArea.Text  = "区域:" + entity.aArea.ToString();



            this.labelArea5024.Text = "区    域:" + entity.aArea.ToString();



            this.labelNo.Text = entity.aNo.ToString();

            this.textNo.Text = "资产编号:" + entity.aNo.ToString();

            this.textBrand.Text = "品牌:" + entity.aBrand.ToString();

            this.textSpec.Text = "规格:" + entity.aSpec.ToString();

            this.labelSpec5024.Text = "规    格:" + entity.aSpec.ToString();

            this.cbxLabel.SelectedIndex = 0;
            // this.cbxLabel.SelectedIndex = 0;
        }