Пример #1
0
        private void 新建ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            RecordInfo vRecordInfo = null;
            int        vTemplateID = -1;

            frmTemplateList vFrmTempList = new frmTemplateList();

            vFrmTempList.ShowDialog();
            if (vFrmTempList.DialogResult == System.Windows.Forms.DialogResult.OK)
            {
                vTemplateID = vFrmTempList.TemplateID;

                vRecordInfo         = new RecordInfo();
                vRecordInfo.DesID   = vFrmTempList.DesID;
                vRecordInfo.RecName = vFrmTempList.RecordName;
                vRecordInfo.DT      = vFrmTempList.RecordDateTime;
            }
            else
            {
                return;
            }

            using (MemoryStream vSM = new MemoryStream())
            {
                emrMSDB.DB.GetTemplateContent(vTemplateID, vSM);  // 取模板内容

                TabPage   vPage      = null;
                frmRecord vFrmRecord = null;

                NewPageAndRecord(vRecordInfo, ref vPage, ref vFrmRecord);
                emrMSDB.DB.GetDataSetElement(vRecordInfo.DesID);

                if (vSM.Length > 0)
                {
                    PrepareSyncData(vRecordInfo.DesID);

                    vFrmRecord.EmrView.OnSyncDeItem = DoSyncDeItem;
                    try
                    {
                        vFrmRecord.EmrView.LoadFromStream(vSM);
                        SyncDeGroupByStruct(vFrmRecord.EmrView);
                        vFrmRecord.EmrView.FormatData();
                        vFrmRecord.EmrView.IsChanged = true;
                    }
                    finally
                    {
                        vFrmRecord.EmrView.OnSyncDeItem = null;
                    }
                }

                tabRecord.SelectedTab = vPage;
            }
        }
Пример #2
0
        private void 新建ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            RecordInfo vRecordInfo = null;
            int        vTemplateID = -1;

            frmTemplateList vFrmTempList = new frmTemplateList();

            vFrmTempList.ShowDialog();
            if (vFrmTempList.DialogResult == System.Windows.Forms.DialogResult.OK)
            {
                vTemplateID = vFrmTempList.TemplateID;

                vRecordInfo         = new RecordInfo();
                vRecordInfo.DesID   = vFrmTempList.DesID;
                vRecordInfo.RecName = vFrmTempList.RecordName;
                vRecordInfo.DT      = vFrmTempList.RecordDateTime;
            }
            else
            {
                return;
            }

            using (MemoryStream vSM = new MemoryStream())
            {
                emrMSDB.DB.GetTemplateContent(vTemplateID, vSM);  // 取模板内容(流)

                TabPage   vPage      = null;
                frmRecord vFrmRecord = null;

                NewPageAndRecord(vRecordInfo, ref vPage, ref vFrmRecord);
                emrMSDB.DB.GetDataSetElement(vRecordInfo.DesID);

                if (vSM.Length > 0)  // 模板内容不为空
                {
                    // 获取当前数据集有哪些数据可以被替换的数据
                    // 放到本地DataTable:FDataElementSetMacro中
                    PrepareSyncData(vRecordInfo.DesID);

                    // 赋值模板加载时替换数据元内容的方法
                    vFrmRecord.EmrView.OnSyncDeItem = DoSyncDeItem;
                    try
                    {
                        vFrmRecord.EmrView.BeginUpdate();
                        try
                        {
                            // 加载模板,加载过程会调用DoSyncDeItem
                            // 给每一个数据元到FDataElementSetMacro中找
                            // 自己要替换为什么内容的机会
                            vFrmRecord.EmrView.LoadFromStream(vSM);

                            // 替换数据组的内容
                            SyncDeGroupByStruct(vFrmRecord.EmrView);
                            vFrmRecord.EmrView.FormatData();
                            vFrmRecord.EmrView.IsChanged = true;
                        }
                        finally
                        {
                            vFrmRecord.EmrView.EndUpdate();
                        }
                    }
                    finally
                    {
                        vFrmRecord.EmrView.OnSyncDeItem = null;
                    }
                }

                tabRecord.SelectedTab = vPage;
            }
        }