/// <summary> /// 保存.表单打印模板 /// </summary> /// <param name="templateVo"></param> /// <param name="templateId"></param> /// <returns></returns> public int SaveFormPrintTemplate(EntityEmrPrintTemplate templateVo, out int templateId) { using (BizFormDesign biz = new BizFormDesign()) { return(biz.SaveFormPrintTemplate(templateVo, out templateId)); } }
/// <summary> /// Design /// </summary> internal void Design() { EntityEmrPrintTemplate rptVo = Viewer.txtTemplateCode.Tag as EntityEmrPrintTemplate; if (rptVo == null) { DialogBox.Msg("请保存打印模板。"); return; } if (Viewer.ValueChanged) { if (this.Save(false) == false) { return; } } rptVo.dataSource = GetDataSource(); using (frmReportDesigner frm = new frmReportDesigner(rptVo)) { frm.ShowDialog(); if (frm.IsSave) { int index = (Viewer.tvTemplate.DataSource as List <EntityEmrPrintTemplate>).FindIndex(t => t.templateId == rptVo.templateId); (Viewer.tvTemplate.DataSource as List <EntityEmrPrintTemplate>)[index] = rptVo; LoadTemplate(rptVo); } } }
/// <summary> /// 删除.表单打印模板 /// </summary> /// <param name="templateId"></param> /// <returns></returns> public int DelFormPrintTemplate(int templateId) { int affectRows = 0; SqlHelper svc = null; try { svc = new SqlHelper(EnumBiz.onlineDB); EntityEmrPrintTemplate vo = new EntityEmrPrintTemplate(); vo.templateId = templateId; DataTable dt = svc.SelectPk(vo); if (dt != null && dt.Rows.Count > 0) { DacParm para = svc.GetDelParmByPk(vo); affectRows = svc.Commit(para); } else { return(1); } } catch (Exception ex) { ExceptionLog.OutPutException(Function.GetExceptionCaption(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message)); affectRows = -1; } finally { svc = null; } return(affectRows); }
/// <summary> /// 获取.表单打印模板 /// </summary> /// <param name="templateId"></param> /// <returns></returns> public EntityEmrPrintTemplate GetFormPrintTemplate(int idType, string templateId) { SqlHelper svc = null; EntityEmrPrintTemplate vo = null; try { DataTable dt = null; svc = new SqlHelper(EnumBiz.onlineDB); vo = new EntityEmrPrintTemplate(); if (idType == 1) { vo.templateId = Function.Dec(templateId); dt = svc.SelectPk(vo); } else if (idType == 2) { vo.templateCode = templateId; dt = svc.Select(vo, EntityEmrPrintTemplate.Columns.templateCode); } if (dt != null && dt.Rows.Count > 0) { vo = EntityTools.ConvertToEntityList <EntityEmrPrintTemplate>(dt)[0]; } } catch (Exception ex) { ExceptionLog.OutPutException(Function.GetExceptionCaption(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message)); } finally { svc = null; } return(vo); }
/// <summary> /// Delete /// </summary> internal void Delete() { EntityEmrPrintTemplate templateVo = Viewer.txtTemplateCode.Tag as EntityEmrPrintTemplate; if (templateVo == null || templateVo.templateId == 0) { return; } if (DialogBox.Msg("是否删除当前打印模板?", MessageBoxIcon.Question) == DialogResult.Yes) { using (ProxyFormDesign proxy = new ProxyFormDesign()) { int ret = proxy.Service.DelFormPrintTemplate((int)templateVo.templateId); if (ret > 0) { New(); Viewer.tvTemplate.Nodes.Remove(Viewer.tvTemplate.FocusedNode); DialogBox.Msg("删除成功!"); } else { DialogBox.Msg("删除失败。"); } } } }
/// <summary> /// 更新.表单打印模板 /// </summary> /// <param name="vo"></param> /// <returns></returns> public int UpdateFormPrintTemplate(EntityEmrPrintTemplate vo) { int affectRows = 0; SqlHelper svc = null; try { svc = new SqlHelper(EnumBiz.onlineDB); affectRows = svc.Commit(svc.GetUpdateParm(vo, new List <string> { EntityEmrPrintTemplate.Columns.templateFile }, new List <string> { EntityEmrPrintTemplate.Columns.templateId })); } catch (Exception ex) { ExceptionLog.OutPutException(Function.GetExceptionCaption(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message)); affectRows = -1; } finally { svc = null; } return(affectRows); }
/// <summary> /// New /// </summary> internal void New() { EntityEmrPrintTemplate vo = null; LoadTemplate(vo); Viewer.txtTemplateCode.Focus(); }
/// <summary> /// GetXR /// </summary> /// <returns></returns> XtraReport GetXR(decimal rptId) { EntityOutpatientInterview Vo = null; using (ProxyAdverseEvent proxy = new ProxyAdverseEvent()) { Vo = proxy.Service.GetInterviewVo(rptId); } EntityFormDesign formVo = null; EntityEmrPrintTemplate printVo = null; using (ProxyFormDesign proxy = new ProxyFormDesign()) { proxy.Service.GetForm(64, out formVo); if (formVo == null) { return(null); } printVo = proxy.Service.GetFormPrintTemplate(1, formVo.Printtemplateid.ToString()); } DataTable printDataSource = FormTool.GetPrintDataTable(formVo.Layout, Vo.xmlData); if (printVo.templateFile != null && printVo.templateFile.Length > 0) { XtraReport xr = new XtraReport(); MemoryStream stream = new MemoryStream(printVo.templateFile); xr.LoadLayout(stream); xr.DataSource = printDataSource; return(xr); } else { return(null); } }
/// <summary> /// 更新.表单打印模板 /// </summary> /// <param name="vo"></param> /// <returns></returns> public int UpdateFormPrintTemplate(EntityEmrPrintTemplate templateVo) { using (BizFormDesign biz = new BizFormDesign()) { return(biz.UpdateFormPrintTemplate(templateVo)); } }
/// <summary> /// GetXR /// </summary> /// <returns></returns> XtraReport GetXR(decimal rptId) { EntityRptContagion contagionVo = null; using (ProxyContagion proxy = new ProxyContagion()) { contagionVo = proxy.Service.GetContagion(rptId); } EntityFormDesign formVo = null; EntityEmrPrintTemplate printVo = null; using (ProxyFormDesign proxy = new ProxyFormDesign()) { proxy.Service.GetForm((int)contagionVo.formId, out formVo); if (formVo == null) { return(null); } printVo = proxy.Service.GetFormPrintTemplate(1, formVo.Printtemplateid.ToString()); } DataTable printDataSource = FormTool.GetPrintDataTable(formVo.Layout, contagionVo.xmlData); if (printVo.templateFile != null && printVo.templateFile.Length > 0) { XtraReport xr = new XtraReport(); MemoryStream stream = new MemoryStream(printVo.templateFile); xr.LoadLayout(stream); xr.DataSource = printDataSource; return(xr); } else { return(null); } }
/// <summary> /// GetXR /// </summary> /// <returns></returns> XtraReport GetXR() { EntityFormDesign formVo = null; EntityEmrPrintTemplate printVo = null; using (ProxyFormDesign proxy = new ProxyFormDesign()) { proxy.Service.GetForm((int)this.formId, out formVo); if (formVo == null) { return(null); } printVo = proxy.Service.GetFormPrintTemplate(1, formVo.Printtemplateid.ToString()); } DataTable printDataSource = FormTool.GetPrintDataTable(formVo.Layout, Viewer.showPanelForm.XmlData()); if (printVo.templateFile != null && printVo.templateFile.Length > 0) { XtraReport xr = new XtraReport(); MemoryStream stream = new MemoryStream(printVo.templateFile); xr.LoadLayout(stream); xr.DataSource = printDataSource; return(xr); } else { return(null); } }
/// <summary> /// 查找模板 /// </summary> /// <param name="val"></param> /// <param name="isPrecise">是否精确定位</param> internal void FindTemplate(string val, bool isPrecise) { if (string.IsNullOrEmpty(val)) { return; } if (this.IsSaving) { this.findIndex = 0; } bool isFind = false; EntityEmrPrintTemplate templateVo = null; for (int i = this.findIndex; i < Viewer.tvTemplate.AllNodesCount; i++) { templateVo = (EntityEmrPrintTemplate)Viewer.tvTemplate.GetDataRecordByNode(Viewer.tvTemplate.GetNodeByVisibleIndex(i)); if (templateVo.isLeaf) { if (isPrecise) { isFind = (templateVo.templateId.ToString() == val) ? true : false; } else { isFind = ((templateVo.pyCode.StartsWith(val) || templateVo.wbCode.StartsWith(val) || templateVo.templateName.StartsWith(val) || templateVo.templateCode.Equals(val))) ? true : false; } if (isFind) { this.findIndex = i + 1; Viewer.tvTemplate.SetFocusedNode(Viewer.tvTemplate.GetNodeByVisibleIndex(i)); LoadTemplate(Viewer.tvTemplate.GetNodeByVisibleIndex(i)); break; } } } if (isFind) { if (isPrecise == false) { if (this.findIndex < Viewer.tvTemplate.AllNodesCount && DialogBox.Msg("是否继续查找?", MessageBoxIcon.Question) == DialogResult.Yes) { FindTemplate(val, isPrecise); } } } else { if (this.findIndex == 0) { DialogBox.Msg("没有找到匹配项。"); } else { DialogBox.Msg("已找到末尾."); } } }
public frmReportDesigner(EntityEmrPrintTemplate _reportVo) { InitializeComponent(); if (!DesignMode) { ((ctlReportDesigner)Controller).rptTypeId = 2; ((ctlReportDesigner)Controller).templateVo = _reportVo; } }
/// <summary> /// 加载模板 /// </summary> void LoadTemplate(TreeListNode node) { if (IsSaving) { return; } EntityEmrPrintTemplate templateVo = (EntityEmrPrintTemplate)Viewer.tvTemplate.GetDataRecordByNode(node); LoadTemplate(templateVo); }
/// <summary> /// 保存.表单打印模板 /// </summary> /// <param name="templateVo"></param> /// <param name="templateId"></param> /// <returns></returns> public int SaveFormPrintTemplate(EntityEmrPrintTemplate templateVo, out int templateId) { int affectRows = 0; string Sql = string.Empty; SqlHelper svc = null; templateId = 0; try { svc = new SqlHelper(EnumBiz.onlineDB); List <DacParm> lstPara = new List <DacParm>(); bool isExsit = true; if (templateVo.templateId <= 0) { isExsit = false; templateVo.templateId = svc.GetNextID(EntityTools.GetTableName(templateVo), EntityTools.GetFieldName(templateVo, EntityEmrPrintTemplate.Columns.templateId)); } lstPara.Add(svc.GetInsertParm(templateVo)); if (templateVo.templateId > 0) { using (TransactionScope scope = svc.TransactionScope) { if (DelFormPrintTemplate((int)templateVo.templateId) < 0) { return(-1); } affectRows = svc.Commit(lstPara); scope.Complete(); } } else { affectRows = svc.Commit(lstPara); } templateId = (int)templateVo.templateId; if (templateId > 0 && affectRows <= 0) { affectRows = 1; } } catch (Exception ex) { ExceptionLog.OutPutException(Function.GetExceptionCaption(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message)); affectRows = -1; } finally { svc = null; } return(affectRows); }
/// <summary> /// LoadDataSource /// </summary> internal void LoadDataSource(bool isFind) { this.isInit = true; using (ProxyEntityFactory proxy = new ProxyEntityFactory()) { DataTable dt = proxy.Service.SelectFullTable(new EntityEmrPrintTemplate()); DataSourcePrtTemplate = EntityTools.ConvertToEntityList <EntityEmrPrintTemplate>(dt); } if (DataSourcePrtTemplate == null) { DataSourcePrtTemplate = new List <EntityEmrPrintTemplate>(); } foreach (EntityEmrPrintTemplate item in DataSourcePrtTemplate) { if (string.IsNullOrEmpty(item.pyCode)) { item.pyCode = SpellCodeHelper.GetPyCode(item.templateName); } if (string.IsNullOrEmpty(item.wbCode)) { item.wbCode = SpellCodeHelper.GetWbCode(item.templateName); } item.imageIndex = 1; //item.parent = "999999999"; item.isLeaf = true; } EntityEmrPrintTemplate defaultVo = null; if (DataSourcePrtTemplate.Count > 0 && defaultVo == null) { defaultVo = DataSourcePrtTemplate[0]; } //EntityEmrPrintTemplate vo = new EntityEmrPrintTemplate(); //vo.templateId = 999999999; //vo.templateName = "全部模板"; //vo.imageIndex = 2; //DataSourcePrtTemplate.Add(vo); Viewer.tvTemplate.BeginUpdate(); Viewer.tvTemplate.DataSource = DataSourcePrtTemplate; Viewer.tvTemplate.ExpandAll(); Viewer.tvTemplate.EndUpdate(); if (defaultVo != null && isFind == false) { LoadTemplate(defaultVo); } Viewer.ValueChanged = false; this.isInit = false; }
/// <summary> /// GetDataSource /// </summary> /// <returns></returns> DataTable GetDataSource() { EntityEmrPrintTemplate rptVo = Viewer.txtTemplateCode.Tag as EntityEmrPrintTemplate; if (rptVo == null) { DialogBox.Msg("请保存报表。"); return(null); } if (rptVo.templateColumns != null && rptVo.templateColumns.Length > 0) { return(FillFields(System.Text.Encoding.Default.GetString(rptVo.templateColumns))); } else { return(null); } }
/// <summary> /// LoadTemplate /// </summary> /// <param name="tableVo"></param> void LoadTemplate(EntityEmrPrintTemplate templateVo) { if (isLoading || IsSaving) { return; } try { isLoading = true; uiHelper.BeginLoading(Viewer); Viewer.txtTemplateCode.Tag = templateVo; if (templateVo == null) { Viewer.txtTemplateCode.Text = string.Empty; Viewer.txtTemplateName.Text = string.Empty; Viewer.txtTemplateDesc.Text = string.Empty; Viewer.dteUseEndDate.EditValue = null; Viewer.txtTableCols.Text = "0"; Viewer.txtTableRows.Text = "0"; Viewer.txtVersion.Text = string.Empty;; Viewer.chkTemplateStyle1.Checked = false; Viewer.chkTemplateStyle2.Checked = false; Viewer.chkTemplateStyle3.Checked = false; Viewer.lstDataCols.ResetText(); xr = new XtraReport(); this.Viewer.ucPrintControl.PrintingSystem = xr.PrintingSystem; xr.CreateDocument(); } else { Viewer.txtTemplateCode.Text = templateVo.templateCode; Viewer.txtTemplateName.Text = templateVo.templateName; Viewer.txtTemplateDesc.Text = templateVo.templateRemark; Viewer.dteUseEndDate.EditValue = templateVo.useEndDate; Viewer.txtTableCols.Text = templateVo.acrossCols == null ? "0" : templateVo.acrossCols.Value.ToString(); Viewer.txtTableRows.Text = templateVo.vrows == null ? "0" : templateVo.vrows.Value.ToString(); Viewer.txtVersion.Text = templateVo.templateVersion.ToString(); if (Function.Int(templateVo.tableType) == 0) { Viewer.chkTemplateStyle1.Checked = true; } else if (Function.Int(templateVo.tableType) == 1) { Viewer.chkTemplateStyle2.Checked = true; } else if (Function.Int(templateVo.tableType) == 2) { Viewer.chkTemplateStyle3.Checked = true; } #region 数据列 Viewer.lstDataCols.ResetText(); if (templateVo.templateColumns != null && templateVo.templateColumns.Length > 0) { string colStr = System.Text.Encoding.Default.GetString(templateVo.templateColumns); char[] sep = new char[] { '\r', '\n' }; string[] cols = colStr.Split(sep, StringSplitOptions.RemoveEmptyEntries); string[] currCol = null; string fieldName = null; string displayName = null; StringBuilder sb = new StringBuilder(); foreach (string col in cols) { sb.AppendLine(col); } Viewer.lstDataCols.Text = sb.ToString(); } #endregion xr = new XtraReport(); if (templateVo.templateFile != null && templateVo.templateFile.Length > 0) { MemoryStream stream = new MemoryStream(templateVo.templateFile); xr.LoadLayout(stream); xr.DataSource = GetDataSource(); } this.Viewer.ucPrintControl.PrintingSystem = xr.PrintingSystem; xr.CreateDocument(); } Viewer.ValueChanged = false; } catch (System.Exception e) { DialogBox.Msg(e.Message); } finally { isLoading = false; uiHelper.CloseLoading(Viewer); } }
/// <summary> /// Save /// </summary> /// <param name="isExits"></param> /// <returns></returns> internal bool Save(bool isExits) { if (IsSaving) { return(false); } IsSaving = true; try { bool isNew = false; EntityEmrPrintTemplate templateVo = null; if (Viewer.txtTemplateCode.Tag == null) { templateVo = new EntityEmrPrintTemplate(); templateVo.templatCreator = GlobalLogin.objLogin.EmpNo; templateVo.templateDate = Common.Utils.Utils.ServerTime(); isNew = true; } else { templateVo = Viewer.txtTemplateCode.Tag as EntityEmrPrintTemplate; } templateVo.templateCode = Viewer.txtTemplateCode.Text.Trim(); if (templateVo.templateCode == string.Empty) { DialogBox.Msg("请输入模板编码。"); Viewer.txtTemplateCode.Focus(); return(false); } templateVo.templateName = Viewer.txtTemplateName.Text.Trim(); if (templateVo.templateName == string.Empty) { DialogBox.Msg("请输入模板名称。"); Viewer.txtTemplateName.Focus(); return(false); } templateVo.templateRemark = Viewer.txtTemplateDesc.Text.Trim(); templateVo.useEndDate = Function.Datetimenull(Viewer.dteUseEndDate.EditValue); templateVo.acrossCols = Function.Decnull(Viewer.txtTableCols.Text); templateVo.vrows = Function.Decnull(Viewer.txtTableRows.Text); templateVo.templateVersion = Function.Int(Viewer.txtVersion.Text); if (Viewer.chkTemplateStyle1.Checked) { templateVo.tableType = 0; } else if (Viewer.chkTemplateStyle2.Checked) { templateVo.tableType = 1; } else if (Viewer.chkTemplateStyle3.Checked) { templateVo.tableType = 2; } templateVo.pyCode = SpellCodeHelper.GetPyCode(templateVo.templateName); templateVo.wbCode = SpellCodeHelper.GetWbCode(templateVo.templateName); templateVo.status = 1; templateVo.templateColumns = System.Text.Encoding.Default.GetBytes(Viewer.lstDataCols.Text); using (ProxyFormDesign proxy = new ProxyFormDesign()) { int templateId = 0; if (proxy.Service.SaveFormPrintTemplate(templateVo, out templateId) > 0) { Viewer.txtTemplateCode.Tag = templateVo; if (isNew) { templateVo.imageIndex = 1; templateVo.isLeaf = true; (Viewer.tvTemplate.DataSource as List <EntityEmrPrintTemplate>).Add(templateVo); Viewer.tvTemplate.RefreshDataSource(); //Viewer.tvTemplate.FocusedNode = Viewer.tvTemplate.FindNodeByKeyID(templateId); FindTemplate(templateId.ToString(), true); } else { int index = (Viewer.tvTemplate.DataSource as List <EntityEmrPrintTemplate>).FindIndex(t => t.templateId == templateId); (Viewer.tvTemplate.DataSource as List <EntityEmrPrintTemplate>)[index] = templateVo; Viewer.tvTemplate.RefreshDataSource(); } DialogBox.Msg("保存打印模板成功!"); } else { DialogBox.Msg("保存打印模板失败。"); } } Viewer.ValueChanged = false; } catch (Exception ex) { DialogBox.Msg(ex.Message); return(false); } finally { IsSaving = false; } return(true); }