//public void GetFTPSETUPByFTPCODE()
        //{
        //    patregister_Class CurPatregister = new patregister_Class(CurAccessno);
        //    CurFTPSETUP = new FTPSETUP_Class(CurPatregister.ftpcode);
        //    if (CurFTPSETUP.id == 0)
        //        CurFTPSETUP.GetDataByFTPStatus();
        //}
        //public void DownloadXML()
        //{
        //    string d_FTPOPEN = "";
        //    d_FTPOPEN = Public_Class.GetINI("setup", "FTPOPEN");
        //    if (d_FTPOPEN != "yes")
        //    {
        //        return;
        //    }
        //    GetFTPSETUPByFTPCODE();
        //    string d_FTPUserName, d_FTPPassword, d_FTPHost, d_FTPPort, d_FTPFileName;
        //    if (CurFTPSETUP.id == 0)
        //    {
        //        d_FTPUserName = Public_Class.GetINI("setup", "FTPUserName");
        //        d_FTPPassword = Public_Class.GetINI("setup", "FTPPassword");
        //        d_FTPHost = Public_Class.GetINI("setup", "FTPHost");
        //        d_FTPPort = Public_Class.GetINI("setup", "FTPPort");
        //        d_FTPFileName = Public_Class.GetINI("setup", "FTPFileName");
        //    }
        //    else
        //    {
        //        d_FTPUserName = CurFTPSETUP.FTPUserName;
        //        d_FTPPassword = CurFTPSETUP.FTPPassword;
        //        d_FTPHost = CurFTPSETUP.FTPHost;
        //        d_FTPPort = CurFTPSETUP.FTPPort;
        //        d_FTPFileName = CurFTPSETUP.FTPFileName;
        //    }
        //    RIS.Vedio.FtpClient ftp = new RIS.Vedio.FtpClient(d_FTPHost, Convert.ToInt32(d_FTPPort), d_FTPUserName, d_FTPPassword);
        //    string d_date = CurPatexam.checkdate.ToString("yyyyMMdd");
        //    // '设置本地和远程的路径 
        //    ftp.LocalDirectory = @"XML\" + d_date;
        //    if (Directory.Exists(ftp.LocalDirectory) == false)
        //    {
        //        Directory.CreateDirectory(ftp.LocalDirectory);
        //    }
        //    ftp.RemoteDirectory = d_FTPFileName + @"/XML/" + d_date;

        //    // '浏览目录,如果不存在,自动创建目录 
        //    try
        //    {
        //        List<string> files = ftp.ListDirectory(CurAccessno + ".xml");

        //        foreach (string file in files)
        //        {
        //            ftp.Download(file);
        //        }
        //    }
        //    catch (Exception ex)
        //    {

        //        Public_Class.WriteFlog(ex.Message, "错误"); //'将详细错误信息写入日志
        //    }
        //}
        private void GetXMLFile()
        {

            FillInputXMLByClass();
            ReportXml_Class reportxml = new ReportXml_Class(CurPatexam.accessno);
            if (reportxml.xmlfile != "")
            {
                myEditControl.LoadDocumentFromString(reportxml.xmlfile.ToString(), "xml");
            }
            else
            {
                //FillInputXMLByClass();
                //DataTable dt = new DataTable();
                //dt = ReportStyle_Class.GetStyle(CurPatexam.dep, CurPatexam.modality, CurPatexam.checktype, CurPatexam.checkpos, "");
                //if (dt != null)
                //{
                //    ReportStyle_Class d_style = new ReportStyle_Class(dt.Rows[0]);
                //    myEditControl.LoadDocumentFromString(d_style.xmltext, "xml");
                //}
                //else
                //{
                string fileName = "";
                try
                {
                    if (CurPatexam.dep == "XRAY")
                    {
                        fileName = Share_Class.Dir + @"\xmlStyle\XRAYreport.xml";
                    }
                    else if (CurPatexam.dep == "CT")
                    {
                        fileName = Share_Class.Dir + @"\xmlStyle\CTreport.xml";
                    }
                    else if (CurPatexam.dep == "MRI")
                    {
                        fileName = Share_Class.Dir + @"\xmlStyle\MRIreport.xml";
                    }
                    else if (CurPatexam.dep == "DSA")
                    {
                        fileName = Share_Class.Dir + @"\xmlStyle\DSAreport.xml";
                    }
                    else if (CurPatexam.dep == "内窥镜")
                    {
                        fileName = Share_Class.Dir + @"\xmlStyle\ESreport.xml";
                    }
                    else
                    {
                        fileName = Share_Class.Dir + @"\xmlStyle\" + CurPatexam.dep + "report.xml";
                    }
                }
                catch
                {
                    fileName = Share_Class.Dir + @"\xmlStyle\CTreport.xml";
                }
                myEditControl.ExecuteCommand("FileOpen", false, fileName);
                //}
                XTextDocument xdocument = myEditControl.Document;
                DCSoft.Writer.Dom.XTextElementList d_list = xdocument.Fields;
                for (int i = 0; i < d_list.Count; i++)
                {
                    if (d_list[i].TypeName == "XTextBarcodeFieldElement")
                    {
                        XTextBarcodeFieldElement Element = (XTextBarcodeFieldElement)d_list[i];
                        Element.Text = CurPatexam.accessno;
                    }
                }
                FillTemplate(CurPatexam.reportinfo, CurPatexam.reportend);
                myEditControl.ExecuteCommand("UpdateViewForDataSource", false, null);
            }
            //else
            //{
            //    //System.IO.Stream s = new System.IO.oryStream(System.Text.Encoding.Default.GetBytes(CurPatReport.xmltext));
            //    //System.IO.StreamReader reader = new System.IO.StreamReader(s, Encoding.Default, true);
            //    //myEditControl.ExecuteCommand("FileOpen", false, reader);
            //    //myEditControl.LoadDocumentFromString(CurPatReport.xmltext, "xml");
            //    myEditControl.ExecuteCommand("FileOpen", false, localfiles[0].ToString());
            //}

        }
        private void GetXMLFile()
        {


            FillInputXMLByClass();
            ReportXml_Class reportxml = new ReportXml_Class(CurPatexam.accessno);

            if (reportxml.xmlfile != "")
            {
                if (reportxml.stylename.Trim() != "")
                    d_reportform.ChangeReportStyle(reportxml.stylename.Trim());
                myEditControl.LoadDocumentFromString(reportxml.xmlfile.ToString(), "xml");
            }
            else
            {
                //FillInputXMLByClass();
                //DataTable dt = new DataTable();
                //dt = ReportStyle_Class.GetStyle(CurPatexam.dep, CurPatexam.modality, CurPatexam.checktype, CurPatexam.checkpos, "");
                //if (dt != null)
                //{
                //    ReportStyle_Class d_style = new ReportStyle_Class(dt.Rows[0]);
                //    myEditControl.LoadDocumentFromString(d_style.xmltext, "xml");
                //}
                //else
                //{
                string p_type = "";

                if ((CurPatexam.dep == "PETCT") || (CurPatexam.dep == "ECT") || (CurPatexam.dep == "体检放射"))
                    p_type = "image";
                string fileName = GetReportStyleFile(p_type);
                myEditControl.ExecuteCommand("FileOpen", false, fileName);
                //}
                XTextDocument xdocument = myEditControl.Document;
                DCSoft.Writer.Dom.XTextElementList d_list = xdocument.Fields;
                for (int i = 0; i < d_list.Count; i++)
                {
                    if (d_list[i].TypeName == "XTextBarcodeFieldElement")
                    {
                        XTextBarcodeFieldElement Element = (XTextBarcodeFieldElement)d_list[i];
                        Element.Text = CurPatexam.accessno;
                    }
                }
                FillTemplate(CurPatexam.reportinfo, CurPatexam.reportend);
                //try
                //{
                //    XTextInputFieldElement reportendtable = (XTextInputFieldElement)myEditControl.GetElementById("ReportType");
                //    reportendtable.Focus();
                //    myEditControl.ExecuteCommand("MovePageUp", false, MoveTarget.PageHome);
                //}
                //catch { }

                //myEditControl.ExecuteCommand("UpdateViewForDataSource", false, null);
                //myEditControl.ExecuteCommand("MovePageUp", false, null);
            }
            myEditControl.ExecuteCommand("UpdateViewForDataSource", false, null);
            ShowDoctorImage();
            try
            {
                XTextTableElement reportinfotable = (XTextTableElement)myEditControl.GetElementById("reportinfotable");
                XTextTableCellElement d_cell = reportinfotable.GetCell(0, 0, true);
                d_cell.Focus();
                myEditControl.ExecuteCommand("MoveTo", false, MoveTarget.CellHome);
            }
            catch { }
            //myEditControl.ExecuteCommand("MovePageUp", false, null);
            //else
            //{
            //    //System.IO.Stream s = new System.IO.MemoryStream(System.Text.Encoding.Default.GetBytes(CurPatReport.xmltext));
            //    //System.IO.StreamReader reader = new System.IO.StreamReader(s, Encoding.Default, true);
            //    //myEditControl.ExecuteCommand("FileOpen", false, reader);
            //    //myEditControl.LoadDocumentFromString(CurPatReport.xmltext, "xml");
            //    myEditControl.ExecuteCommand("FileOpen", false, localfiles[0].ToString());
            //}

        }
 private void SaveXmlFile()
 {
     ReportXml_Class reportxml = new ReportXml_Class(CurPatexam.accessno);
     reportxml.accessno = CurPatexam.accessno;
     reportxml.stylename = d_reportform.image_ComboBoxEdit.Text.Trim();
     reportxml.xmlfile = myEditControl.Document.XMLText;
     reportxml.Save();
 }
        public bool Save()
        {
            ReportXml_Class reportxml = new ReportXml_Class(straccessno);
            if (reportxml.accessno == "")
            {
                Insert();
            }
            return Update();


        }