Exemple #1
0
        //private FlowDocument m_doc;
        private void bt_printClick(object sender, RoutedEventArgs e)
        {
            try
            {
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load("Result/config.xml");
                XmlNode xn = xmlDoc.SelectSingleNode("items/szdy");

                if (xn.InnerXml == "1")
                {
                    if (this.dg_ShowUserinfor.SelectedItem != null)
                    {
                        User user = this.dg_ShowUserinfor.SelectedItem as User;
                        str_userID = user.id;
                        string sql = "select * from EHR_Arch_OldHerb where ID = '" + str_userID + "'";
                        DBhelp.writelog(sql);
                        DataSet datat = DBhelp.GetDataSet(sql);

                        int i = 0;

                        string ID                 = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ID"]);
                        string ARCHIVEID          = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ARCHIVEID"]);
                        string IDENTITYNO         = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["IDENTITYNO"]);
                        string SERVICEID          = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["SERVICEID"]);
                        string SERVICENAME        = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["SERVICENAME"]);
                        string FULLNAME           = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["FULLNAME"]);
                        string ISENERGETI         = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISENERGETI"]));
                        string ISTIRED            = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISTIRED"]));
                        string ISLOSEHEART        = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISLOSEHEART"]));
                        string ISDEEPVOICE        = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISDEEPVOICE"]));
                        string ISLISTLESS         = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISLISTLESS"]));
                        string ISJITTER           = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISJITTER"]));
                        string ISALONE            = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISALONE"]));
                        string ISSCARE            = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISSCARE"]));
                        string ISHEAVY            = strTosnum34(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISHEAVY"]));
                        string ISEYEDRY           = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISEYEDRY"]));
                        string ISEXTRECOLD        = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISEXTRECOLD"]));
                        string ISAFAIDCOLD        = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISAFAIDCOLD"]));
                        string ISRESISTCOLD       = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISRESISTCOLD"]));
                        string ISCATCHCOLD        = strTosnum35(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISCATCHCOLD"]));
                        string ISSNORTY           = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISSNORTY"]));
                        string ISSTERTOROUS       = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISSTERTOROUS"]));
                        string ISALLERGIC         = strTosnum36(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISALLERGIC"]));
                        string ISHIVES            = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISHIVES"]));
                        string ISENDERMICBLOOD    = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISENDERMICBLOOD"]));
                        string ISSCORE            = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISSCORE"]));
                        string ISFEVERDRY         = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISFEVERDRY"]));
                        string ISBODYPAIN         = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISBODYPAIN"]));
                        string ISFACELIGHT        = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISFACELIGHT"]));
                        string ISFLECK            = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISFLECK"]));
                        string ISTETTER           = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISTETTER"]));
                        string ISLIKEDRINK        = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISLIKEDRINK"]));
                        string ISMOUTHBITTER      = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISMOUTHBITTER"]));
                        string IFFAT              = strTosnum37(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["IFFAT"]));
                        string ISSCARECOLDFOOD    = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISSCARECOLDFOOD"]));
                        string ISSTOOLSTICK       = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISSTOOLSTICK"]));
                        string ISSTOOLDRY         = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISSTOOLDRY"]));
                        string ISLINGUAMASSIN     = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISLINGUAMASSIN"]));
                        string ISLINGUAVEIN       = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISLINGUAVEIN"]));
                        string PHYSIQUE_QXZ       = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["PHYSIQUE_QXZ"]);
                        string PHYSIQUE_YANGXZ    = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["PHYSIQUE_YANGXZ"]);
                        string PHYSIQUE_YINXZ     = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["PHYSIQUE_YINXZ"]);
                        string PHYSIQUE_TSZ       = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["PHYSIQUE_TSZ"]);
                        string PHYSIQUE_SRZ       = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["PHYSIQUE_SRZ"]);
                        string PHYSIQUE_XYZ       = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["PHYSIQUE_XYZ"]);
                        string PHYSIQUE_QYZ       = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["PHYSIQUE_QYZ"]);
                        string PHYSIQUE_TBZ       = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["PHYSIQUE_TBZ"]);
                        string PHYSIQUE_PHZ       = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["PHYSIQUE_PHZ"]);
                        string REPORTDATE         = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["REPORTDATE"]);
                        string REPORTDOC          = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["REPORTDOC"]);
                        string STATUS             = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["STATUS"]);
                        string CREATED_BY         = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["CREATED_BY"]);
                        string CREATED_DATE       = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["CREATED_DATE"]);
                        string UPDATED_BY         = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["UPDATED_BY"]);
                        string UPDATED_DATE       = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["UPDATED_DATE"]);
                        string DISABLED_BY        = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["DISABLED_BY"]);
                        string DUNS               = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["DUNS"]);
                        string DISABLED_DATE      = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["DISABLED_DATE"]);
                        string QXZ_SCORE          = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["QXZ_SCORE"]);
                        string YANGXZ_SCORE       = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["YANGXZ_SCORE"]);
                        string YINXZ_SCORE        = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["YINXZ_SCORE"]);
                        string TSZ_SCORE          = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["TSZ_SCORE"]);
                        string SRZ_SCORE          = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["SRZ_SCORE"]);
                        string XYZ_SCORE          = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["XYZ_SCORE"]);
                        string QYZ_SCORE          = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["QYZ_SCORE"]);
                        string TBZ_SCORE          = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["TBZ_SCORE"]);
                        string PHZ_SCORE          = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["PHZ_SCORE"]);
                        string QXZ_GUIDE          = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["QXZ_GUIDE"]);
                        string YANGXZ_GUIDE       = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["YANGXZ_GUIDE"]);
                        string YINXZ_GUIDE        = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["YINXZ_GUIDE"]);
                        string TSZ_GUIDE          = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["TSZ_GUIDE"]);
                        string SRZ_GUIDE          = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["SRZ_GUIDE"]);
                        string XYZ_GUIDE          = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["XYZ_GUIDE"]);
                        string QYZ_GUIDE          = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["QYZ_GUIDE"]);
                        string TBZ_GUIDE          = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["TBZ_GUIDE"]);
                        string PHZ_GUIDE          = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["PHZ_GUIDE"]);
                        string QXZ_GUIDE_OTHER    = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["QXZ_GUIDE_OTHER"]);
                        string YANGXZ_GUIDE_OTHER = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["YANGXZ_GUIDE_OTHER"]);
                        string YINXZ_GUIDE_OTHER  = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["YINXZ_GUIDE_OTHER"]);
                        string TSZ_GUIDE_OTHER    = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["TSZ_GUIDE_OTHER"]);
                        string SRZ_GUIDE_OTHER    = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["SRZ_GUIDE_OTHER"]);
                        string XYZ_GUIDE_OTHER    = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["XYZ_GUIDE_OTHER"]);
                        string QYZ_GUIDE_OTHER    = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["QYZ_GUIDE_OTHER"]);
                        string TBZ_GUIDE_OTHER    = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["TBZ_GUIDE_OTHER"]);
                        string PHZ_GUIDE_OTHER    = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["PHZ_GUIDE_OTHER"]);

                        string  sql1    = "select docname from EHR_His_doc where card_id = '" + REPORTDOC + "'";
                        DataSet doc     = DBhelp.GetDataSet(sql1);
                        string  docname = DBhelp.ObjectToString(doc.Tables["Table"].Rows[0]["docname"]);
                        DBhelp.writelog(docname);

                        string str1 = ID + "$" + ARCHIVEID + "$" + IDENTITYNO + "$" + SERVICEID + "$" + SERVICENAME + "$" + FULLNAME + "$" + ISENERGETI + "$" + ISTIRED + "$" + ISLOSEHEART + "$" + ISDEEPVOICE + "$" + ISLISTLESS + "$" + ISJITTER + "$" + ISALONE + "$" + ISSCARE + "$" + ISHEAVY + "$" + ISEYEDRY + "$" + ISEXTRECOLD + "$" + ISAFAIDCOLD + "$" + ISRESISTCOLD + "$" + ISCATCHCOLD + "$" + ISSNORTY + "$" + ISSTERTOROUS + "$" + ISALLERGIC + "$" + ISHIVES + "$" + ISENDERMICBLOOD + "$" + ISSCORE + "$" + ISFEVERDRY + "$" + ISBODYPAIN + "$" + ISFACELIGHT;
                        string str2 = ISFLECK + "$" + ISTETTER + "$" + ISLIKEDRINK + "$" + ISMOUTHBITTER + "$" + IFFAT + "$" + ISSCARECOLDFOOD + "$" + ISSTOOLSTICK + "$" + ISSTOOLDRY + "$" + ISLINGUAMASSIN + "$" + ISLINGUAVEIN + "$" + QXZ_SCORE + "$" + YANGXZ_SCORE + "$" + YINXZ_SCORE + "$" + TSZ_SCORE + "$" + SRZ_SCORE + "$" + XYZ_SCORE + "$" + QYZ_SCORE + "$" + TBZ_SCORE + "$" + PHZ_SCORE + "$" + REPORTDATE + "$" + docname + "$" + PHYSIQUE_QXZ + "$" + PHYSIQUE_YANGXZ + "$" + PHYSIQUE_YINXZ + "$" + PHYSIQUE_TSZ + "$" + PHYSIQUE_SRZ + "$" + PHYSIQUE_XYZ + "$" + PHYSIQUE_QYZ + "$" + PHYSIQUE_TBZ + "$" + PHYSIQUE_PHZ;
                        ;

                        //DBhelp.writelog(str1);
                        //DBhelp.writelog(str2);
                        //  m_doc = LoadDocumentAndRender("OrderDocument.xaml", tabPage);
                        //OrderDocument orderDoc = (OrderDocument)m_doc;
                        //string strPath = FileHelper.SaveXPS(m_doc, false, "w2");
                        //XpsDocument xpsDocument = new XpsDocument(strPath, FileAccess.Read);

                        //FixedDocumentSequence fixedDocSeq = xpsDocument.GetFixedDocumentSequence();
                        System.Windows.Controls.PrintDialog dialog = new System.Windows.Controls.PrintDialog();
                        dialog.PrintQueue = LocalPrintServer.GetDefaultPrintQueue();

                        //dialog.PrintDocument(fixedDocSeq.DocumentPaginator, "Test print");
                        //xpsDocument.Close();

                        //string qustionstrs1 = "201605186110240000202$612525195001181417$58$男$15463216531$苗留成$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1";
                        H_Print_trouble h_pr = new H_Print_trouble(str1);

                        string      strPath1     = FileHelper.SaveXPS1(h_pr.printArea, false, "w2");
                        XpsDocument xpsDocument1 = new XpsDocument(strPath1, FileAccess.Read);

                        FixedDocumentSequence fixedDocSeq1 = xpsDocument1.GetFixedDocumentSequence();

                        System.Windows.Controls.PrintDialog dialog1 = new System.Windows.Controls.PrintDialog();
                        dialog1.PrintQueue = LocalPrintServer.GetDefaultPrintQueue();
                        dialog1.PrintDocument(fixedDocSeq1.DocumentPaginator, FULLNAME + "");
                        xpsDocument1.Close();



                        //string qustionstrs2 = "1$1$1$1$1$1$1$1$1$1$4$4$4$4$4$4$4$4$21$2017/4/17$612525195001181417$$$$$SX0088_1$$$$SX0401_1";
                        H_Print_trouble1      h_pr1                 = new H_Print_trouble1(str2);
                        string                strPath2              = FileHelper.SaveXPS1(h_pr1.p2, false, "w2");
                        XpsDocument           xpsDocument2          = new XpsDocument(strPath2, FileAccess.Read);
                        FixedDocumentSequence fixedDocSeq2          = xpsDocument2.GetFixedDocumentSequence();
                        System.Windows.Controls.PrintDialog dialog2 = new System.Windows.Controls.PrintDialog();
                        dialog2.PrintQueue = LocalPrintServer.GetDefaultPrintQueue();
                        dialog2.PrintDocument(fixedDocSeq2.DocumentPaginator, FULLNAME + "_2");
                        xpsDocument2.Close();



                        H_Print_trouble       arv          = new H_Print_trouble(str1);
                        string                strPath      = FileHelper.SaveXPS1(arv.printArea, false, "w2");
                        XpsDocument           xpsDocument  = new XpsDocument(strPath, FileAccess.Read);
                        FixedDocumentSequence fixedDocSeq  = xpsDocument.GetFixedDocumentSequence();
                        RenderTargetBitmap    targetBitmap = new RenderTargetBitmap(1240, 1750, 150d, 150d, PixelFormats.Pbgra32);
                        targetBitmap.Render(arv.printArea);
                        PngBitmapEncoder encoder = new PngBitmapEncoder();
                        encoder.Frames.Add(BitmapFrame.Create(targetBitmap));
                        FileStream fs = File.Open(System.AppDomain.CurrentDomain.BaseDirectory + @"\Result\" + FULLNAME + "_1.png", FileMode.Create);
                        encoder.Save(fs);
                        fs.Close();
                        xpsDocument.Close();

                        H_Print_trouble1 arv1 = new H_Print_trouble1(str2);
                        strPath      = FileHelper.SaveXPS1(arv1.p2, false, "w2");
                        xpsDocument  = new XpsDocument(strPath, FileAccess.Read);
                        fixedDocSeq  = xpsDocument.GetFixedDocumentSequence();
                        targetBitmap = new RenderTargetBitmap(1240, 1750, 150d, 150d, PixelFormats.Pbgra32);
                        targetBitmap.Render(arv1.p2);
                        encoder = new PngBitmapEncoder();
                        encoder.Frames.Add(BitmapFrame.Create(targetBitmap));
                        fs = File.Open(System.AppDomain.CurrentDomain.BaseDirectory + @"\Result\" + FULLNAME + "_2.png", FileMode.Create);
                        encoder.Save(fs);
                        fs.Close();
                        xpsDocument.Close();
                    }
                    else
                    {
                        MessageBox.Show("请选择要打印人员!!");
                    }
                }

                //IsUserInforShowPrint = false ;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }