Пример #1
0
        /// <summary>
        /// 创建新的tabItem
        /// </summary>
        /// <param name="tid">文书id</param>
        private void CreateTabItem(int tid, string strMark_id)
        {
            //验证重复打开,如已经打开则定位到该条注释
            if (IsSameTabItem(tid.ToString()) == true)
            {
                frmText text = tctlDoc.SelectedTab.AttachedControl.Controls[0] as frmText;
                if (text.MyDoc.Us.Tid.ToString() == tid.ToString())
                {
                    foreach (var ele in text.MyDoc.Elements)
                    {
                        if (ele is ZYTextBapfMark)
                        {
                            ZYTextBapfMark mark = (ZYTextBapfMark)ele;
                            if (mark.Value == strMark_id)
                            {
                                Point point = new Point(mark.RealLeft, mark.RealTop);
                                point = text.MyDoc.OwnerControl.ViewPointToClient(point.X, point.Y);
                                text.MyDoc.OwnerControl.AutoScrollPosition = new Point(text.MyDoc.OwnerControl.AutoScrollPosition.X / 2 + point.X / 2, point.Y - text.MyDoc.OwnerControl.AutoScrollPosition.Y);
                                text.MyDoc.Content.MoveSelectStart(text.MyDoc.Elements.IndexOf(mark));
                                text.MyDoc.OwnerControl.Focus();
                            }
                        }
                    }
                }
                return;
            }

            /*
             * 创建新的tabItem 的实现思路:
             * 1.当前选中的文书类别,如果是单例文书,就查出其内容。
             * 2.当前选中的是病人文书,根据文书id,查出其内容
             */
            // 获得当前时间,精确到分钟
            // string time = string.Format("{0:g}", DateTime.Now);
            DevComponents.DotNetBar.TabControlPanel tabctpnDoc = new DevComponents.DotNetBar.TabControlPanel();
            tabctpnDoc.AutoScroll = true;
            DevComponents.DotNetBar.TabItem page = new DevComponents.DotNetBar.TabItem();
            //tctlDoc.TabItemClose += new TabStrip.UserActionEventHandler(tctlDoc_TabItemClose);
            //page.Click += new EventHandler(page_Click);

            //if (tid == 0)
            //{
            //    Class_Text text = advFinishDoc.SelectedNode.Tag as Class_Text;
            //    //新建文书,page页的Name用分号隔开,第一位:代表文书类型ID;第二位:文书类型;第三位:代表新建文书;第四位:是否单例文书
            //    page.Name = advFinishDoc.SelectedNode.Name + ";" + advFinishDoc.SelectedNode.Tag.GetType().ToString() + ";0;" + text.Issimpleinstance;
            //}
            //else //修改文书,page页的Name用分号隔开,第一位:文书ID;第二位:文书类型
            //{
            //    page.Name = tid + ";" + advFinishDoc.SelectedNode.Tag.GetType().ToString();
            //}

            page.Text = dgvSubjective.SelectedRows[0].Cells["文书名称"].Value.ToString() + " " + " (" + inpat.Sick_Bed_Name + " 床)";

            //已写文书
            Patient_Doc doc = GetDoc(dgvSubjective.SelectedRows[0].Cells["docId"].Value.ToString());

            page.Tag = doc;
            if (page.Tag != null)
            {
                //string log_Tid = advFinishDoc.SelectedNode.Name;
                //isCustom = false;

                //是否忽略空行
                //bool NeglectLine = IsNeglectLine(advFinishDoc.SelectedNode);
                string textTitle = dgvSubjective.SelectedRows[0].Cells["文书名称"].Value.ToString();
                page.Tooltip = dgvSubjective.SelectedRows[0].Cells["文书类别"].Value.ToString();

                //打开单例文书
                if (inpat.Sick_Bed_Name != "")
                {
                    //tid = Convert.ToInt32(temptid);
                    frmText text = new frmText(Convert.ToInt32(dgvSubjective.SelectedRows[0].Cells["textkind_id"].Value.ToString()), 0, 0, textTitle, tid, inpat, true, false, "", "");
                    text.MyDoc.IgnoreLine = true;

                    //隐藏编辑器右键
                    text.MyDoc.OwnerControl.ContextMenuStrip.Visible = false;
                    //隐藏工具栏
                    text.MyDoc.Menus.PnlMenus.Visible = false;

                    XmlDocument tmpxml = new System.Xml.XmlDocument();
                    tmpxml.PreserveWhitespace = true;
                    string    sql = "select tid,Ishighersign,Havedoctorsign,Havehighersign,submitted,section_name from t_patients_doc where textkind_id='" + dgvSubjective.SelectedRows[0].Cells["textkind_id"].Value.ToString() + "' and patient_id=" + inpat.Id + "";
                    DataTable dt  = App.GetDataSet(sql).Tables[0];

                    string content = "";
                    content = App.ReadSqlVal("select * from T_PATIENT_DOC_COLB where tid=" + dt.Rows[0]["tid"].ToString() + "", 0, "CONTENT");
                    if (content == null || content == "")
                    {
                        content = App.DownLoadFtpPatientDoc(dt.Rows[0]["tid"].ToString() + ".xml", inpat.Id.ToString());//App.ReadSqlVal(sql, 0, "patients_doc");
                    }
                    //content = App.DownLoadFtpPatientDoc(dt.Rows[0]["tid"].ToString() + ".xml", currentPatient.Id.ToString()); //dt.Rows[0]["patients_doc"].ToString();
                    string ishighersign   = dt.Rows[0]["Ishighersign"].ToString();
                    string havedoctorsign = dt.Rows[0]["Havedoctorsign"].ToString();
                    string havehighersign = dt.Rows[0]["Havehighersign"].ToString();
                    text.MyDoc.Section_name = dt.Rows[0]["section_name"].ToString();
                    //修改文书,Ishighersign是否需要上级医师审签
                    text.MyDoc.TextSuperiorSignature = ishighersign;
                    text.MyDoc.HaveTubebedSign       = havedoctorsign; //经治医师是否审签
                    text.MyDoc.HaveSuperiorSignature = havehighersign; //是否已经有过上级医生签名
                    text.MyDoc.OnDrawPageHeader     += DataInit.EMRDoc_OnDrawPageHeader;
                    text.MyDoc.Locked = true;

                    ////病案评分-------------------------------------------------------
                    //if (this.OnComeFrmText != null)
                    //{
                    //    //触发事件
                    //    OnComeFrmText(text);
                    //}
                    ////--------------------------------------------------------


                    tmpxml.LoadXml(content);

                    text.MyDoc.FromXML(tmpxml.DocumentElement);

                    //注释定位
                    foreach (var ele in text.MyDoc.Elements)
                    {
                        if (ele is ZYTextBapfMark)
                        {
                            ZYTextBapfMark mark = (ZYTextBapfMark)ele;
                            if (mark.Value == strMark_id)
                            {
                                Point point = new Point(mark.RealLeft, mark.RealTop);
                                point = text.MyDoc.OwnerControl.ViewPointToClient(point.X, point.Y);
                                text.MyDoc.OwnerControl.AutoScrollPosition = new Point(text.MyDoc.OwnerControl.AutoScrollPosition.X / 2 + point.X / 2, point.Y - text.MyDoc.OwnerControl.AutoScrollPosition.Y);
                                text.MyDoc.Content.MoveSelectStart(text.MyDoc.Elements.IndexOf(mark));
                                //text.MyDoc.OwnerControl.Focus();
                            }
                        }
                    }

                    text.MyDoc.ContentChanged();
                    tabctpnDoc.Controls.Add(text);
                    text.Dock = DockStyle.Fill;
                }

                tabctpnDoc.TabItem   = page;
                tabctpnDoc.Dock      = DockStyle.Fill;
                page.AttachedControl = tabctpnDoc;
                this.tctlDoc.Controls.Add(tabctpnDoc);
                this.tctlDoc.Tabs.Add(page);
                this.tctlDoc.Refresh();
                this.tctlDoc.SelectedTab = page;
                //if (doc.Submitted == "Y")
                //{
                //    App.SetToolButtonByUser("tsbtnTempSave", false);
                //}
                //else
                //{
                //    App.SetToolButtonByUser("tsbtnTempSave", true);
                //}
            }
            else
            {
                App.Msg("打开文书异常!");
            }
            App.AddCurrentDocMsg(inpat.Id.ToString() + page.Text);
        }