Beispiel #1
0
        public void PrintViewClient()
        {
            SystemConfig config = FT.Commons.Cache.StaticCacheManager.GetConfig<SystemConfig>();
            Code39 code39 = new Code39();
            code39.WidthCU = 2;
            code39.LineHeight = 20;
            try
            {
                this.Draw11String(name,new Point(config.LeftPoint+5,config.TopPoint));
                SizeF titleSize = MyGraphics.MeasureString("1", code39.titleFont);
                code39.Height = code39.topHeight + code39.LineHeight + (int)titleSize.Height;//定义图片高度
                Bitmap map = code39.CreateBarCode(this.idcard);
                string path = Application.StartupPath + "/tempcode39.jpg";
                ImageHelper.SaveCoderPic(map, path);
                Image imagetest2 = Image.FromFile(path);
                Image imagetmp2 = new System.Drawing.Bitmap(imagetest2);

                MyGraphics.DrawImage(imagetmp2,config.LeftPoint, config.TopPoint+20);
                imagetest2.Dispose();
                File.Delete(path);
                imagetmp2.Dispose();
            }
            catch (Exception ex)
            {
                //LogFactoryWrapper.Debug("由于证件号码有汉字,不支持code39编码!");
            }
        }
Beispiel #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            Code39 code = new Code39();
            Bitmap map=code.CreateBarCode(this.txtOrgCode.Text.Trim());

            this.panelCode39.CreateGraphics().DrawImage(map, 0, 0);
        }
Beispiel #3
0
        private void PrintApply()
        {
            ApplyPrinterConfig config = AllPrinterConfig.GetPrinterConfig().ApplyConfig;
            int height = (config.Down - config.Up) * BaseStudentPrinter.PixelUnit + 140;
            //int sep = 35;
            int sep = 31;
            // int width = 132;
            int width = (config.Right - config.Left) * BaseStudentPrinter.PixelUnit + 90;

            //16,2
            //MyGraphics.DrawImage(this.GetQRImage(this.GetQRString()),new Point(620,860));
            //14,2
            if (Student.LearnType == "��ѧ")
            {
                if (config.Allow2Dimension)
                {
                    string path = Application.StartupPath + "/temp.jpg";
                    //string path = Application.StartupPath + "/tempcode39.jpg";
                    log.Debug("Ҫ��ӡ�˵�������" + Student.Name);
                    log.Debug("Ҫ��ӡ�˵����֤���룺" + Student.IdCard);
                    log.Debug("Ҫ��ӡ�˵Ķ�ά������ϢΪ:" + Student.Dimension);
                    ImageHelper.SaveCoderPic(this.GetQRImage(Student.Dimension),path);
                   // MyGraphics.DrawImage(Image.FromFile(path), new Rectangle(new Point(516 + width, 720 + height), new Size(150, 150)));
                    Image imagetest = Image.FromFile(path);

                   Image imagetmp=new System.Drawing.Bitmap(imagetest);

                    MyGraphics.DrawImage(imagetest, new Rectangle(new Point(356 + width, 790 + height), new Size(130, 130)));
                   imagetest.Dispose();
                    File.Delete(path);
                    imagetmp.Dispose();

                }
            }
            DateTime regDate = System.DateTime.Now;
            if (config.PrintApplyDate)
            {
                this.Draw10String(regDate.Year + "   " + regDate.Month + "  " + regDate.Day, new Point(width + 567, height + 920));
            }

            //MyGraphics.DrawImage(this.GetQRImage(this.GetQRString()), new Point(320, 460));
            //���������
            //MyGraphics.DrawRectangle(blackPen, 600, 10, 680, 30);
            //this.DrawStringHor("��У��ƣ�" + Fm.Windows.Forms.CompanyInfoForm.Info.NickName,  new Point(605, 55));
            // this.Draw11String("��У��ƣ�" + Fm.Windows.Forms.CompanyInfoForm.Info.NickName, new Point(605,55));
            CompanyInfo comp = StaticCacheManager.GetConfig<CompanyInfo>();
            this.DrawStringHor("����" + comp.NickName, new Font("����", 15), new Point(480 + width - config.NameLeft * BaseStudentPrinter.PixelUnit, height - 120 + config.NameDown * BaseStudentPrinter.PixelUnit));
            // �������֤�������һά����

            Code39 code39 = new Code39();
            code39.WidthCU = 2;
            code39.LineHeight = 20;
            try
            {
                SizeF titleSize = MyGraphics.MeasureString("1", code39.titleFont);
                code39.Height = code39.topHeight + code39.LineHeight + (int)titleSize.Height;//����ͼƬ�߶�
                Bitmap map = code39.CreateBarCode(Student.IdCard);
                string path = Application.StartupPath + "/tempcode39.jpg";
                ImageHelper.SaveCoderPic(map, path);
                Image imagetest2 = Image.FromFile(path);
                Image imagetmp2 = new System.Drawing.Bitmap(imagetest2);

                MyGraphics.DrawImage(imagetmp2, new RectangleF(width - 40, height - 46, 240, 30));
                imagetest2.Dispose();
                File.Delete(path);
                imagetmp2.Dispose();
            }
            catch (Exception ex)
            {
                //LogFactoryWrapper.Debug("����֤�������к��֣���֧��code39���룡");
            }

            if (config.PrintProfile && Student.LearnType != "��ѧ")
            {
                this.Draw15String(Student.Profile, new Point(width + 555, height - 34));//+75
            }

            this.Draw15String(Student.Name, new Point(width, height));//+75
            this.Draw15String(Student.Sex, new Point(319 + width, height));
            this.Draw15String(Student.Birthday, new Point(width + 436, height));
            this.Draw15String(Student.Nation, new Point(606 + width, height));

            height += sep - 2;
            if (Student.IdCardType.Length < IdCardTypeMaxLen)
            {
                this.Draw15String(Student.IdCardType, new Point(width, height + 5));
            }
            else
            {
                this.Draw9String(Student.IdCardType, new Point(width, height + 5));
            }

            //�����֤����
            StringFormat stringFormat = new StringFormat();
            stringFormat.LineAlignment = StringAlignment.Center;
            stringFormat.Alignment = StringAlignment.Center;
            for (int i = 0; i < Student.IdCard.Length; i++)
            {
                //MyGraphics.DrawString(idCard[i].ToString(), body11Font, blackBrush, new RectangleF(332 + 17 * i+(i/2)*1, height - 7, 17, 35), stringFormat);

                MyGraphics.DrawString(Student.IdCard[i].ToString(), body15Font, blackBrush, new RectangleF(width + 165 + 22 * i + (i / 6) * 1, height - 7, 22, 35), stringFormat);
                // MyGraphics.DrawRectangle(blackPen, 332 + 17 * i + (i / 2) * 1, height - 7, 17, 36);
                // this.Draw11String(idCard[i].ToString(), new Point(334 + i * tempIdSep, height));
            }

            this.PrintSelfPhoto();
            height += sep - 3;
            //����ס֤��

            if (Student.TempId!=null&&Student.TempId != string.Empty)
            {
                 this.Draw15String("��ס֤", new Point(width, height + 5));

                for (int i = 0; i < Student.TempId.Length; i++)
                {
                    MyGraphics.DrawString(Student.TempId[i].ToString(), body15Font, blackBrush, new RectangleF(width + 165 + 21 * i + (i / 2) * 1, height - 5, 21, 35), stringFormat);
                }
               }
            height += sep + 5;
            //string connadd = this.GetConnAddress();
               // string connadd = Student.RegAddress;
            string connadd = Student.ConnAddress;
            if (connadd.Length < ConnAddressMaxLen)
            {
                this.Draw15String(connadd, new Point(width, height));
            }
            else
            {
                this.Draw12String(connadd, new Point(width, height));
            }
            //this.Draw15String(Student.RegAddress, new Point(width, height));

            height += sep + 5;
            this.Draw15String(Student.Phone, new Point(width, height));
            this.Draw15String(Student.Description, new Point(410 + 100, height));

            height += sep + 6;
            this.Draw15String(Student.Mobile, new Point(width, height));
            this.Draw15String(Student.PostCode, new Point(410 + 100, height));

            height += sep + 10;
            //this.Draw11String(this.allowCar, new Point(470, height));
            this.Draw15String(Student.NewCarType, new Point(width + 170 + (config.CarRight - config.CarLeft) * BaseStudentPrinter.PixelUnit, (config.CarDown - config.CarUp) * BaseStudentPrinter.PixelUnit + height + 50));
            //Ϊ���ݻ��߳�ѧ��
            Font check = new Font("����", 20);
            if (Student.LearnType == "��ѧ")
            {
                // this.Draw11String("��", new Point(width+18, height+2));
                this.DrawStringHor("��", check, new Point(width - 58 + (config.GouDown - config.GouUp) * BaseStudentPrinter.PixelUnit, height - 5+(config.GouRight - config.GouLeft) * BaseStudentPrinter.PixelUnit));
            }
            else
            {
                //this.Draw11String("��", new Point(width+18, height+sep-1));
                this.DrawStringHor("��", check, new Point(width - 58 + (config.GouDown - config.GouUp) * BaseStudentPrinter.PixelUnit, height + sep - 6 + (config.GouRight - config.GouLeft) * BaseStudentPrinter.PixelUnit));
                //this.Draw15String(Student.OldCarType, new Point(568 + width, height));
            }
        }
        /// <summary>
        /// ֱ�Ӵ�ӡ
        /// </summary>
        public void PrintExcel(bool saveInk)
        {
            GoldPrinter.ExcelAccess excel = new GoldPrinter.ExcelAccess();

            if (!saveInk)
            {

                string strExcelTemplateFile = Application.StartupPath + "/template/" + "��ʻ֤�����";
                strExcelTemplateFile += "-" + this.Student.LearnType + ".xlt";
                //System.IO.Path.GetFullPath(@"��ʻ֤�����.xlt");
                excel.Open(strExcelTemplateFile);
            }//��ģ���ļ�
            else
            {
                string strExcelTemplateFile = Application.StartupPath + "/template/" + "�״�-��ʻ֤�����";
                //System.IO.Path.GetFullPath(@"��ʻ֤�����.xlt");
                strExcelTemplateFile += "-" + this.Student.LearnType + ".xlt";
                excel.Open(strExcelTemplateFile);
                //excel.Open();
            }
            excel.IsVisibledExcel = false;

            Code39 code39 = new Code39();
            code39.WidthCU = 2;
            code39.LineHeight = 20;
            try
            {
                //SizeF titleSize = MyGraphics.MeasureString("1", code39.titleFont);
                code39.Height = code39.topHeight + code39.LineHeight + (int)20;//����ͼƬ�߶�
                Bitmap map = code39.CreateBarCode(Student.IdCard);
                string pathcode39 = Application.StartupPath + "/tempcode39.jpg";
                ImageHelper.SaveCoderPic(map, pathcode39);
               // map.Save(pathcode39, System.Drawing.Imaging.ImageFormat.Jpeg);
                excel.InsertPicture(3, 1, pathcode39, 155, 26, 0);
            }
            catch (Exception ex)
            {
                //LogFactoryWrapper.Debug("����֤�������к��֣���֧��code39���룡");
            }

            //excel.SetCellText(1, 24, 1, 30, "����" + Fm.Windows.Forms.CompanyInfoForm.Info.NickName);
            //excel.SetCellText(2, 24, 2, 30, "��У-" + Fm.Windows.Forms.CompanyInfoForm.Info.NickName);
            // excel.SetCellText(1, 1, "  " + this.name);
            // excel.SetCellText(1, 20, "  " + this.name);
            //excel.SetCellText(1, 21, "  " + this.name);
            CompanyInfo comp = StaticCacheManager.GetConfig<CompanyInfo>();
            excel.SetCellText(1, 22, "����" + comp.NickName);
            //excel.SetCellText(1, 23, "  " + this.name);
            // excel.SetCellText(2, 24, 2, 30, "  " + this.name);

            excel.SetCellText(4, 3, 4, 11, "  " + Student.Name);

            excel.SetCellText(4, 14, 4, 15, Student.Sex);
            excel.SetCellText(4, 19, 4, 24, Student.Birthday);
            excel.SetCellText(4, 27, 4, 30, Student.Nation);
            excel.SetCellText(5, 3, 5, 4, Student.IdCardType);
            if (Student.IdCardType.Length < IdCardTypeMaxLen)
            {
                excel.SetFont(5, 3, 6, 4, new Font("����", 15f));
            }

            for (int i = 0; i < Student.IdCard.Length; i++)
            {
                excel.SetCellText(5, 7 + i, Student.IdCard[i].ToString());
            }
            if (Student.TempId.Length > 0)
            {
                excel.SetCellText(6, 3, 6, 4, "��ס֤");

                for (int i = 0; i < Student.TempId.Length; i++)
                {
                    excel.SetCellText(6, 7 + i, Student.TempId[i].ToString());
                }
            }
            excel.SetCellText(7, 3, 7, 24, "  " + Student.RegAddress);
            string connadd=this.GetConnAddress();

            excel.SetCellText(8, 3, 8, 24, "  " + connadd);
            if(connadd.Length<ConnAddressMaxLen)
            {
                excel.SetFont(8, 3, 8, 24, new Font("����", 15f));
            }

            excel.SetCellText(9, 3, 9, 13, "  " + Student.Phone);
            excel.SetCellText(9, 18, 9, 24, Student.PostCode);
            excel.SetCellText(10, 11, 10, 17,Student.NewCarType);
            DateTime regDate = System.DateTime.Now;
            if (AllPrinterConfig.GetPrinterConfig().ApplyConfig.PrintApplyDate)
            {
                excel.SetCellText(35, 25, 36, 30, regDate.Year + " �� " + regDate.Month + " �� " + regDate.Day + "��");
            }
            string path = Application.StartupPath + "/temp.jpg";
            if (Student.LearnType == "��ѧ")
            {
                if (AllPrinterConfig.GetPrinterConfig().ApplyConfig.Allow2Dimension)
                {
                    //this.GetQRImage(Student.Dimension).Save(path, System.Drawing.Imaging.ImageFormat.Jpeg);
                    ImageHelper.SaveCoderPic(this.GetQRImage(Student.Dimension), path);
                    //excel.InsertPicture(25, 23, path, 110, 110, 5);
                    excel.InsertPicture(27, 16, path, 100, 100, 5);
                }
            }
            else
            {
                excel.SetCellText(10, 25, 10, 30, Student.OldCarType);
                if (AllPrinterConfig.GetPrinterConfig().ApplyConfig.PrintProfile)
                {
                    excel.SetCellText(3, 25, 3, 30, Student.Profile);
                }
            }

            /*if (this.LearnTypeString == "��ѧ")
            {
                if (!this.saveInk)
                {
                    excel.SetCellText(10, 3, "����������");
                }
                else
                {
                    excel.SetCellText(10, 3, "��");
                }

            }
            else
            {
                if (!this.saveInk)
                {
                    excel.SetCellText(11, 3, "������׼�ݳ���");
                }
                else
                {
                    excel.SetCellText(11, 3, "��");
                }
                excel.SetCellText(10, 25, 10, 30, this.HaveCarType);
            }
            */
            GlobalPrintSetting printSetting = StaticCacheManager.GetConfig<GlobalPrintSetting>();
            if (printSetting.PrintModel == "ֱ�Ӵ�")
            {
                excel.Print();
            }
            else
            {
                excel.PrintPreview();
            }

            excel.Close();
        }