/// <summary> /// 更新.电子申请单.打印 /// </summary> /// <param name="formVo"></param> /// <returns></returns> public int UpdateFormPrint(EntityFormDesign formVo) { using (BizFormDesign biz = new BizFormDesign()) { return(biz.UpdateFormPrint(formVo)); } }
/// <summary> /// 保存.电子申请单 /// </summary> /// <param name="formVo"></param> /// <param name="formId"></param> /// <returns></returns> public int SaveForm(EntityFormDesign formVo, out int formId) { using (BizFormDesign biz = new BizFormDesign()) { return(biz.SaveForm(formVo, out formId)); } }
/// <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> /// Delete /// </summary> internal void Delete() { EntityFormDesign formVo = Viewer.txtFormCode.Tag as EntityFormDesign; if (formVo == null || formVo.Formid <= 0) { New(); return; } else { if (DialogBox.Msg("是否删除当前表单信息?", MessageBoxIcon.Question) == DialogResult.Yes) { using (ProxyFormDesign proxy = new ProxyFormDesign()) { if (proxy.Service.DelForm(formVo.Formid, formVo.Version) > 0) { this.New(); LoadDataSource(); DialogBox.Msg("删除成功!!"); } else { DialogBox.Msg("删除失败。"); } } } } }
/// <summary> /// Design /// </summary> internal void Design() { EntityFormDesign formVo = Viewer.txtFormCode.Tag as EntityFormDesign; if (formVo == null || formVo.Formid <= 0) { DialogBox.Msg("请保存表单信息。"); return; } try { SuspendLayoutUc(); using (frmFormDesign frm = new frmFormDesign()) { frm.FormType = Function.Int(Viewer.FormType); frm.FormId = formVo.Formid; frm.ShowDialog(); if (frm.IsSave || frm.UpdateFlag) { LoadForm(frm.FormId); if (Viewer.txtFormCode.Tag != null) { (Viewer.txtFormCode.Tag as EntityFormDesign).Layout = Viewer.showPanelForm.LayoutXML(); } } } } finally { ResumeLayoutUc(); } }
/// <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> /// Init /// </summary> internal void Init() { try { Viewer.Location = new Point(Viewer.Location.X, 0); Viewer.Height = Screen.PrimaryScreen.WorkingArea.Height; uiHelper.BeginLoading(Viewer); #region 参数 using (ProxyEntityFactory proxy = new ProxyEntityFactory()) { ContagionParmData = EntityTools.ConvertToEntityList <EntityRptContagionParm>(proxy.Service.SelectFullTable(new EntityRptContagionParm())); } #endregion // 传染病报表 if (ContagionParmData != null) { if (ContagionParmData.Any(t => t.reportId == this.ContagionDisplayVo.reportId && t.keyId == "templateId")) { this.formId = Function.Dec(ContagionParmData.FirstOrDefault(t => t.reportId == this.ContagionDisplayVo.reportId && t.keyId == "templateId").keyValue); } } if (this.formId > 0) { using (ProxyFormDesign proxy = new ProxyFormDesign()) { proxy.Service.GetForm((int)this.formId, out FormDesignVo); } } if (FormDesignVo == null) { FormDesignVo = new EntityFormDesign(); } if (Function.Dec(this.ContagionDisplayVo.rptId) > 0) { using (ProxyContagion proxy = new ProxyContagion()) { EntityRptContagion vo = proxy.Service.GetContagion(Function.Dec(this.ContagionDisplayVo.rptId)); #region patientInfo Viewer.rdoFlag.SelectedIndex = vo.patType - 1; Viewer.rdoFlag.Properties.ReadOnly = true; Viewer.txtCardNo.Text = vo.patNo; #endregion LoadForm(FormDesignVo.Layout, vo.xmlData); GetPatient(); } } else { LoadForm(FormDesignVo.Layout, null); } } finally { uiHelper.CloseLoading(Viewer); } }
/// <summary> /// tvTemplate_FocusedNodeChanged /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tvForm_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e) { if (IsInit) { return; } try { if (isTreeDoing) { return; } isTreeDoing = true; EntityFormDesign formVoOld = (EntityFormDesign)Viewer.tvForm.GetDataRecordByNode(e.OldNode); if (formVoOld.isLeaf) { formVoOld.imageIndex = 2; } LoadForm(e.Node); } finally { isTreeDoing = false; } }
/// <summary> /// 获取.电子申请单 /// </summary> /// <param name="formId"></param> /// <param name="version"></param> /// <param name="formVo"></param> public void GetForm(int formId, int version, out EntityFormDesign formVo) { using (BizFormDesign biz = new BizFormDesign()) { biz.GetForm(formId, version, out formVo); } }
/// <summary> /// 查找模板 /// </summary> /// <param name="val"></param> /// <param name="isPrecise">是否精确定位</param> internal void FindForm(string val, bool isPrecise) { if (string.IsNullOrEmpty(val)) { return; } if (this.IsSaving) { this.FindIndex = 0; } bool isFind = false; EntityFormDesign formVo = null; for (int i = this.FindIndex; i < Viewer.tvForm.AllNodesCount; i++) { formVo = (EntityFormDesign)Viewer.tvForm.GetDataRecordByNode(Viewer.tvForm.GetNodeByVisibleIndex(i)); if (formVo.isLeaf) { if (isPrecise) { isFind = (formVo.Formid.ToString() == val) ? true : false; } else { isFind = ((formVo.Pycode.StartsWith(val) || formVo.Wbcode.StartsWith(val) || formVo.Formname.StartsWith(val) || formVo.Formcode.Equals(val))) ? true : false; } if (isFind) { this.FindIndex = i + 1; Viewer.tvForm.SetFocusedNode(Viewer.tvForm.GetNodeByVisibleIndex(i)); LoadForm(Viewer.tvForm.GetNodeByVisibleIndex(i)); break; } } } if (isFind) { if (isPrecise == false) { if (this.FindIndex < Viewer.tvForm.AllNodesCount && DialogBox.Msg("是否继续查找?", MessageBoxIcon.Question) == DialogResult.Yes) { FindForm(val, isPrecise); } } } else { if (this.FindIndex == 0) { DialogBox.Msg("没有找到匹配项。"); } else { DialogBox.Msg("已找到末尾."); } } }
/// <summary> /// Init /// </summary> internal void Init() { try { Viewer.Location = new System.Drawing.Point(Viewer.Location.X, 0); Viewer.Height = Screen.PrimaryScreen.WorkingArea.Height; uiHelper.BeginLoading(Viewer); #region 参数 using (ProxyAdverseEvent proxy = new ProxyAdverseEvent()) { InterviewParmData = proxy.Service.GetInterviewParm(); } #endregion this.formId = 64; if (this.formId > 0) { using (ProxyFormDesign proxy = new ProxyFormDesign()) { proxy.Service.GetForm((int)this.formId, out FormDesignVo); } } if (FormDesignVo == null) { FormDesignVo = new EntityFormDesign(); } using (ProxyAdverseEvent proxy = new ProxyAdverseEvent()) { EntityOutpatientInterview vo = proxy.Service.GetInterviewVo(Function.Dec(this.InterviewVo.rptId)); if (vo != null) { #region patientInfo Viewer.txtCardNo.Text = vo.patNo; GetPatient(); #endregion LoadForm(FormDesignVo.Layout, vo.xmlData); } else { Viewer.txtCardNo.Text = this.InterviewVo.patNo; GetPatient(); LoadForm(FormDesignVo.Layout, null); } } } finally { uiHelper.CloseLoading(Viewer); } }
/// <summary> /// 加载模板 /// </summary> void LoadForm(TreeListNode node) { EntityFormDesign formVo = (EntityFormDesign)Viewer.tvForm.GetDataRecordByNode(node); if (formVo.isLeaf) { formVo.imageIndex = 3; SetData(formVo); } }
void SetVersion(EntityFormDesign formVo) { this.cboVersion.Properties.Items.Clear(); if (formVo.lstVersion != null && formVo.lstVersion.Count > 0) { foreach (int no in formVo.lstVersion) { this.cboVersion.Properties.Items.Add(no.ToString()); } } }
void SetMainInfo(EntityFormDesign formVo) { SetVersion(formVo); this.txtEfCode.Text = formVo.Formcode; this.txtEfName.Text = formVo.Formname; isSelected = true; this.cboVersion.Text = formVo.Version.ToString(); isSelected = false; this.cboEfStatus.SelectedIndex = Function.Int(formVo.Status); this.pnlDesignPanel.Width = formVo.PanelWidth; this.pnlDesignPanel.Height = formVo.PanelHeight < this.Height ? this.Height - 80 : formVo.PanelHeight; }
/// <summary> /// Filter /// </summary> void Filter() { List <XmlField> dataSource = null; string layoutXml = string.Empty; string formId = this.lueForm.Properties.DBValue; List <EntityFormCtrl> formCtrls = null; EntityObjectList vo = DataSourceForm.FirstOrDefault(t => t.formId == formId); if (formId.StartsWith("a")) { using (ProxyFormDesign proxy = new ProxyFormDesign()) { EntityFormDesign vo1 = proxy.Service.GetForm(int.Parse(formId.Substring(1)), true)[0]; layoutXml = vo1.Layout; } formCtrls = FormTool.Entities(layoutXml).FindAll(t => t.ItemType == "1" || t.ItemType == "2" || t.ItemType == "6"); if (formCtrls != null) { dataSource = new List <XmlField>(); foreach (EntityFormCtrl item in formCtrls) { dataSource.Add(new XmlField() { check = 0, itemName = item.ItemName, itemCaption = item.ItemCaption }); } } } else if (formId.StartsWith("b")) { using (ProxyFormDesign proxy = new ProxyFormDesign()) { List <EntityEmrTableFieldInfo> tabFields = proxy.Service.GetTableFieldInfo(formId.Substring(1)); if (tabFields != null && tabFields.Count > 0) { dataSource = new List <XmlField>(); foreach (EntityEmrTableFieldInfo item in tabFields) { dataSource.Add(new XmlField() { check = 0, itemName = item.fieldName, itemCaption = item.fieldCaptain }); } } } } this.gcFields.DataSource = dataSource; }
/// <summary> /// LoadDataSource /// </summary> internal void LoadDataSource() { try { uiHelper.BeginLoading(Viewer); using (ProxyFormDesign proxy = new ProxyFormDesign()) { this.IsInit = true; DataSourceForm = proxy.Service.GetForm(0, false); if (DataSourceForm == null) { DataSourceForm = new List <EntityFormDesign>(); } foreach (EntityFormDesign item in DataSourceForm) { item.imageIndex = 2; item.parent = 99; item.isLeaf = true; } EntityFormDesign defaultVo = null; if (DataSourceForm.Count > 0) { defaultVo = DataSourceForm[0]; } EntityFormDesign vo = new EntityFormDesign(); vo.Formid = 99; vo.Formname = "全部表单"; vo.imageIndex = 1; DataSourceForm.Add(vo); Viewer.tvForm.BeginUpdate(); Viewer.tvForm.DataSource = DataSourceForm; Viewer.tvForm.ExpandAll(); Viewer.tvForm.EndUpdate(); if (defaultVo != null) { SetData(defaultVo); } this.IsInit = false; } } finally { uiHelper.CloseLoading(Viewer); } }
/// <summary> /// SetData /// </summary> /// <param name="formVo"></param> internal void SetData(EntityFormDesign formVo) { if (formVo == null) { Viewer.txtFormCode.Tag = null; Viewer.txtFormCode.Text = string.Empty; Viewer.txtFormName.Text = string.Empty; Viewer.cboType.SelectedIndex = 0; Viewer.rdoStatus.SelectedIndex = 1; Viewer.luePrint.Properties.DBValue = string.Empty; Viewer.luePrint.Text = string.Empty; Viewer.txtCreatDate.Text = string.Empty; Viewer.showPanelForm.ClearComponent(); Viewer.xtraScrollableControl.Tag = 0; } else { Viewer.txtFormCode.Tag = formVo; Viewer.txtFormCode.Text = formVo.Formcode; Viewer.txtFormName.Text = formVo.Formname; Viewer.cboType.SelectedIndex = 0; Viewer.rdoStatus.SelectedIndex = Function.Int(formVo.Status); Viewer.luePrint.Properties.DBValue = formVo.Printtemplateid.ToString(); if (DataSourcePrintTemplate != null) { if (DataSourcePrintTemplate.Any(t => t.templateId == formVo.Printtemplateid)) { Viewer.luePrint.Text = DataSourcePrintTemplate.FirstOrDefault(t => t.templateId == formVo.Printtemplateid).templateName; } else { Viewer.luePrint.Text = string.Empty; } } Viewer.txtCreatDate.Text = formVo.Recorddate.ToString("yyyy-MM-dd HH:mm"); LoadForm(formVo.Formid); } Viewer.ValueChanged = false; }
/// <summary> /// 删除.电子申请单 /// </summary> /// <param name="formId"></param> /// <returns></returns> public int DelForm(int formId, int version) { int affectRows = 0; SqlHelper svc = null; try { svc = new SqlHelper(EnumBiz.onlineDB); EntityFormDesign po = new EntityFormDesign(); po.Formid = formId; po.Version = version; DataTable dt = svc.Select(po, new List <string> { EntityFormDesign.Columns.Formid, EntityFormDesign.Columns.Version }); if (dt != null && dt.Rows.Count > 0) { DacParm para = svc.GetDelParm(po, new List <string>() { EntityFormDesign.Columns.Formid, EntityFormDesign.Columns.Version }); 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="formId"></param> /// <returns></returns> public int DelForm(int formId, int version) { int affectRows = 0; SqlHelper svc = null; try { svc = new SqlHelper(EnumBiz.onlineDB); EntityFormDesign po = new EntityFormDesign(); po.Formid = formId; po.Version = version; DataTable dt = svc.Select(po, new List <string> { EntityFormDesign.Columns.Formid, EntityFormDesign.Columns.Version }); if (dt != null && dt.Rows.Count > 0) { DacParm para = svc.GetDelParm(po, new List <string>() { EntityFormDesign.Columns.Formid, EntityFormDesign.Columns.Version }); affectRows = svc.Commit(para); } else { return(1); } } catch (Exception e) { ExceptionLog.OutPutException(e); affectRows = -1; } finally { svc = null; } return(affectRows); }
/// <summary> /// 更新.电子申请单.打印 /// </summary> /// <param name="formVo"></param> /// <returns></returns> public int UpdateFormPrint(EntityFormDesign formVo) { int affectRows = 0; //SqlHelper svc = null; //try //{ // svc = new SqlHelper(EnumBiz.onlineDB); // DacParm para = svc.GetUpdateParm(eForm, new List<string>() { EntityFormDesign.Columns.Printfilename, EntityFormDesign.Columns.Printfiledata }, // new List<string>() { EntityFormDesign.Columns.Formid }); // affectRows = svc.Commit(para); //} //catch (Exception e) //{ // ExceptionLog.OutPutException(e); // affectRows = -1; //} //finally //{ // svc = null; //} return(affectRows); }
/// <summary> /// 获取.电子申请单 /// </summary> /// <param name="formId"></param> /// <param name="version"></param> /// <param name="formVo"></param> public void GetForm(int formId, int version, out EntityFormDesign formVo) { string SQL = string.Empty; formVo = new EntityFormDesign(); List <EntityFormDesign> main = GetForm(formId, true); if (main != null && main.Count > 0) { List <int> lstVersion = new List <int>(); foreach (EntityFormDesign item in main) { lstVersion.Add((int)item.Version); } if (version > 0) { if (main.Exists(t => t.Version == version)) { formVo = main.FirstOrDefault(t => t.Version == version); } else { formVo = null; } } else { formVo = main[main.Count - 1]; } if (formVo != null) { formVo.lstVersion = lstVersion; } } }
/// <summary> /// SaveForm /// </summary> /// <returns></returns> public bool SaveForm() { try { this.Cursor = Cursors.WaitCursor; formCtrlData = this.loader.Save(); if (formCtrlData != null && formCtrlData.Count > 0) { string strFormCode = string.Empty; string strFormName = string.Empty; strFormCode = this.txtEfCode.Text.Trim(); if (string.IsNullOrEmpty(strFormCode)) { DialogBox.Msg("请输申请单编码。", MessageBoxIcon.Exclamation); this.txtEfCode.Focus(); return(false); } strFormName = this.txtEfName.Text.Trim(); if (string.IsNullOrEmpty(strFormName)) { DialogBox.Msg("请输入申请单名称。", MessageBoxIcon.Exclamation); this.txtEfName.Focus(); return(false); } int intVersion = Function.Int(this.cboVersion.Text); if (intVersion == 0) { DialogBox.Msg("请输入版本号。", MessageBoxIcon.Exclamation); this.cboVersion.Focus(); return(false); } int intStatus = this.cboEfStatus.SelectedIndex; List <string> lstCtrl = new List <string>(); foreach (EntityFormCtrl ctrl in formCtrlData) { if (!string.IsNullOrEmpty(ctrl.ItemName)) { if (lstCtrl.IndexOf(ctrl.ItemName) < 0) { lstCtrl.Add(ctrl.ItemName); } else { DialogBox.Msg("存在同名的控件名称:" + ctrl.ItemCaption + "(" + ctrl.ItemName + "),请修正。", MessageBoxIcon.Exclamation); return(false); } } else { if (Function.Int(ctrl.ItemType) > 0) { DialogBox.Msg("请录入项目代码:" + ctrl.ItemCaption, MessageBoxIcon.Exclamation); return(false); } } } try { // 1. EntityFormDesign formVo = new EntityFormDesign(); formVo.Formid = FormId; formVo.Formcode = strFormCode; formVo.Formname = strFormName; formVo.Formtype = this.FormType; formVo.Version = intVersion; formVo.Pycode = SpellCodeHelper.GetPyCode(strFormName); formVo.Wbcode = SpellCodeHelper.GetWbCode(strFormName); formVo.Recorderid = GlobalLogin.objLogin.EmpNo; formVo.RecorderName = GlobalLogin.objLogin.EmpName; formVo.Status = intStatus; formVo.Printtemplateid = this.PrintTemplateId; int heightCtrl = 0; foreach (EntityFormCtrl item in formCtrlData) { heightCtrl = Math.Max(item.Top, heightCtrl); } formVo.Panelsize = Convert.ToString(heightCtrl + 50) + "|" + pnlDesignPanel.Width.ToString(); // 2. formVo.Layout = FormTool.LayoutXml(formCtrlData); int intAppFid = 0; ProxyFormDesign proxy = new ProxyFormDesign(); formVo.Recorddate = Common.Utils.Utils.ServerTime(); #region 一般表单处理 if (proxy.Service.SaveForm(formVo, out intAppFid) > 0) { if (this.FormId <= 0) { NewFlag = true; } else { if (!NewFlag) { UpdateFlag = true; } } this.ValueChanged = false; this.FormId = intAppFid; if (wrapper != null) { wrapper.FormId = this.FormId; } bool isExsit = false; int count = this.cboVersion.Properties.Items.Count; for (int i = 0; i < count; i++) { if (this.cboVersion.Properties.Items[i].ToString() == formVo.Version.ToString()) { IsExists = true; break; } } if (!isExsit) { this.cboVersion.Properties.Items.Add(formVo.Version.ToString()); } this.IsSave = true; DialogBox.Msg("保存表单成功!", MessageBoxIcon.Exclamation); this.ValueChanged = false; return(true); } else { DialogBox.Msg("保存表单失败。", MessageBoxIcon.Exclamation); } #endregion } catch (Exception e) { DialogBox.Msg(e.Message); return(false); } } else { DialogBox.Msg("请制作表单。", MessageBoxIcon.Information); } } finally { this.Cursor = Cursors.Default; } return(false); }
/// <summary> /// Save /// </summary> /// <param name="isExsit"></param> /// <returns></returns> internal bool Save(bool isExsit) { EntityFormDesign formVoOri = null; EntityFormDesign formVo = new EntityFormDesign(); bool isNew = false; if (Viewer.txtFormCode.Tag != null) { formVoOri = Viewer.txtFormCode.Tag as EntityFormDesign; formVo.Formid = formVoOri.Formid; formVo.Version = formVoOri.Version; formVo.Panelsize = formVoOri.Panelsize; if (string.IsNullOrEmpty(formVoOri.Layout)) { using (ProxyFormDesign proxy = new ProxyFormDesign()) { EntityFormDesign vo1 = proxy.Service.GetForm(formVoOri.Formid, true)[0]; formVoOri.Layout = vo1.Layout; } } formVo.Layout = formVoOri.Layout; formVo.Recorderid = formVoOri.Recorderid; formVo.Recorddate = formVoOri.Recorddate; } else { formVo.Version = 1; formVo.Panelsize = "100|100"; formVo.Layout = "<XmlData></XmlData>"; formVo.Recorderid = GlobalLogin.objLogin.EmpNo; formVo.Recorddate = Common.Utils.Utils.ServerTime(); isNew = true; } formVo.Formtype = Function.Int(Viewer.FormType); formVo.Formcode = Viewer.txtFormCode.Text.Trim(); if (string.IsNullOrEmpty(formVo.Formcode)) { DialogBox.Msg("请输入表单编码。"); Viewer.txtFormCode.Focus(); return(false); } formVo.Formname = Viewer.txtFormName.Text.Trim(); if (string.IsNullOrEmpty(formVo.Formname)) { DialogBox.Msg("请输入表单名称。"); Viewer.txtFormName.Focus(); return(false); } formVo.Status = Viewer.rdoStatus.SelectedIndex; if (!string.IsNullOrEmpty(Viewer.luePrint.Properties.DBValue) && Viewer.luePrint.Properties.DBRow != null) { formVo.Printtemplateid = Function.Int(Viewer.luePrint.Properties.DBValue); } formVo.Pycode = SpellCodeHelper.GetPyCode(formVo.Formname); formVo.Wbcode = SpellCodeHelper.GetWbCode(formVo.Formname); try { uiHelper.BeginLoading(Viewer); using (ProxyFormDesign proxy = new ProxyFormDesign()) { int formId2 = 0; if (proxy.Service.SaveForm(formVo, out formId2) > 0) { formVo.Formid = formId2; formVo.imageIndex = 2; formVo.isLeaf = true; Viewer.txtFormCode.Tag = formVo; try { this.IsSaving = true; if (isNew) { LoadDataSource(); FindForm(formId2.ToString(), true); } } finally { this.IsSaving = false; } for (int i = 0; i < DataSourceForm.Count; i++) { if (DataSourceForm[i].Formid == formId2) { DataSourceForm[i] = formVo; break; } } Viewer.ValueChanged = false; DialogBox.Msg("保存成功!!"); } else { DialogBox.Msg("保存失败。"); return(false); } } } finally { uiHelper.CloseLoading(Viewer); } return(true); }
/// <summary> /// GetForm /// </summary> /// <param name="formId"></param> /// <returns></returns> public List <EntityFormDesign> GetForm(int formId, bool isShowLayout) { string SQL = string.Empty; List <EntityFormDesign> lstForm = new List <EntityFormDesign>(); EntityFormDesign vo = new EntityFormDesign(); DataTable dt = null; SqlHelper svc = new SqlHelper(EnumBiz.onlineDB); IDataParameter[] paramArr = null; try { SQL = @"select t.formid, t.formcode, t.formname, t.formtype, t.version, t.pycode, t.wbcode, t.panelsize, {0} t.printtemplateid, t.recorderid, t.recorddate, t.status, b.oper_name as empname from emrFormDesign t left join code_operator b on t.recorderid = b.oper_code "; if (isShowLayout) { SQL = string.Format(SQL, "t.layout,"); } else { SQL = string.Format(SQL, ""); } if (formId <= 0) { SQL += @"order by t.version asc"; dt = svc.GetDataTable(SQL); } else { SQL += @" where t.formid = ? order by t.version asc"; paramArr = svc.CreateParm(1); paramArr[0].Value = formId; dt = svc.GetDataTable(SQL, paramArr); } if (dt != null && dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { vo = new EntityFormDesign(); vo.Formid = Function.Int(dr["formid"]); vo.Formcode = dr["formcode"].ToString(); vo.Formname = dr["formname"].ToString(); vo.Formtype = Function.Int(dr["formtype"].ToString()); vo.Version = Function.Int(dr["version"]); vo.Pycode = dr["pycode"].ToString().ToUpper(); vo.Wbcode = dr["wbcode"].ToString().ToUpper(); vo.Panelsize = dr["panelsize"].ToString(); if (isShowLayout) { vo.Layout = dr["layout"].ToString(); } vo.Printtemplateid = Function.Int(dr["printtemplateid"].ToString()); vo.Recorderid = dr["recorderid"].ToString(); vo.RecorderName = dr["empname"].ToString(); vo.Recorddate = Convert.ToDateTime(dr["recorddate"].ToString()); vo.Status = Function.Int(dr["status"]); vo.StatusName = (vo.Status == 1 ? "启用" : "停用"); lstForm.Add(vo); } } } catch (Exception ex) { ExceptionLog.OutPutException(Function.GetExceptionCaption(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message)); } finally { svc = null; paramArr = null; } return(lstForm); }
/// <summary> /// InitDesigner /// </summary> /// <param name="formId"></param> /// <param name="version"></param> void InitDesigner(int formId, int version) { if (this.isSelected) { return; } this.Loading = true; try { SuspendLayoutUc(); this.Cursor = Cursors.WaitCursor; designSurface = new DesignSurface(); this.pnlDesignPanel.Controls.Clear(); //服务容器 IServiceContainer serviceContainer = designSurface.GetService(typeof(IServiceContainer)) as IServiceContainer; idh = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost)); _KeyStrokeMessageFilter.SetHostAndMDIForm(idh, designSurface); //工具箱服务 this.toolboxServiceXtraTree.host = idh; serviceContainer.AddService(typeof(IToolboxService), this.toolboxServiceXtraTree); PopulateToolbox(this.toolboxServiceXtraTree); this.toolboxServiceXtraTree.designPanel = this.pnlDesignPanel; //菜单命令服务 menuService = new MenuCommandServiceImpl(serviceContainer); serviceContainer.AddService(typeof(IMenuCommandService), menuService); //命名服务 serviceContainer.AddService(typeof(INameCreationService), new NameCreationService(idh)); //控件序列化反序列化服务 serviceContainer.AddService(typeof(IDesignerSerializationService), new DesignerSerializationServiceForm(idh)); //获取控件信息 EntityFormDesign formVo = new EntityFormDesign(); if (formId > 0) { this.IsExists = true; ProxyFormDesign proxy = new ProxyFormDesign(); proxy.Service.GetForm(formId, version, out formVo); proxy = null; this.PrintTemplateId = formVo.Printtemplateid; } if (formVo != null && formVo.Formid > 0) { SetMainInfo(formVo); if (!string.IsNullOrEmpty(formVo.Layout)) { formCtrlData = FormTool.Entities(formVo.Layout); } } else { this.cboEfStatus.SelectedIndex = 1; this.pnlDesignPanel.Height = this.Height - 80; } if ((this.FormType > 2 && formId <= 0 && (formVo == null || string.IsNullOrEmpty(formVo.Layout)))) { this.txtEfCode.Properties.ReadOnly = true; this.txtEfName.Properties.ReadOnly = true; } if (this.FormType > 2) { this.cboVersion.Text = "1"; this.cboVersion.Properties.ReadOnly = true; this.cboEfStatus.SelectedIndex = 1; this.cboEfStatus.Properties.ReadOnly = true; } if (this.FormType > 10) { this.txtEfCode.Properties.ReadOnly = true; this.txtEfName.Properties.ReadOnly = true; this.cboVersion.Text = "1"; this.cboVersion.Properties.ReadOnly = true; this.cboEfStatus.SelectedIndex = 1; this.cboEfStatus.Properties.ReadOnly = true; } //if (this.TemplateMainVo != null) //{ // this.txtEfCode.Text = this.TemplateMainVo.templateCode; // this.txtEfName.Text = this.TemplateMainVo.templateName; //} if (this.txtEfCode.Text.Trim() == string.Empty) { this.txtEfCode.Text = DateTime.Now.ToString("yyMMddHHmm"); } loader = new DesignLoaderForm(idh, formCtrlData); loader.InitWidth = this.pnlDesignPanel.Width - 30; loader.InitHeight = this.pnlDesignPanel.Height - 30; loader.FormFlag = true; //绑定事件 loader.ComponentAdded -= new ComponentEventHandler(loader_ComponentAdded); loader.ComponentAdded += new ComponentEventHandler(loader_ComponentAdded); loader.ComponentChanged -= new ComponentChangedEventHandler(loader_ComponentChanged); loader.ComponentChanged += new ComponentChangedEventHandler(loader_ComponentChanged); loader.ComponentRemoved -= new ComponentEventHandler(loader_ComponentRemoved); loader.ComponentRemoved += new ComponentEventHandler(loader_ComponentRemoved); designSurface.BeginLoad(loader); Control ctrl = designSurface.View as Control; ctrl.Parent = pnlDesignPanel; ctrl.Dock = DockStyle.Fill; ISelectionService selectionService = designSurface.GetService(typeof(ISelectionService)) as ISelectionService; selectionService.SelectionChanged -= new EventHandler(selectionService_SelectionChanged); selectionService.SelectionChanged += new EventHandler(selectionService_SelectionChanged); BehaviorService bhsvc = idh.GetService(typeof(BehaviorService)) as BehaviorService; //undo/redo服务 serializationService = new ComponentSerializationServiceImpl(idh); serviceContainer.AddService(typeof(ComponentSerializationService), serializationService); undoEngine = new UndoEngineImpl(idh); serviceContainer.AddService(typeof(UndoEngine), undoEngine); } catch (Exception ex) { throw ex; } finally { ResumeLayoutUc(); Loading = false; this.Cursor = Cursors.Default; } }
/// <summary> /// 保存.电子申请单 /// </summary> /// <param name="formVo"></param> /// <param name="formId"></param> /// <returns></returns> public int SaveForm(EntityFormDesign formVo, out int formId) { int affectRows = 0; string Sql = string.Empty; SqlHelper svc = null; formId = 0; try { svc = new SqlHelper(EnumBiz.onlineDB); List <DacParm> lstPara = new List <DacParm>(); bool isExsit = true; if (formVo.Formid <= 0) { isExsit = false; formVo.Formid = svc.GetNextID(EntityTools.GetTableName(formVo), EntityTools.GetFieldName(formVo, EntityFormDesign.Columns.Formid)); } lstPara.Add(svc.GetInsertParm(formVo)); if (Function.Int(formVo.Formtype) < 3) { if (isExsit == false) { string tbName = "emrFormRtf" + formVo.Formid.ToString(); // 自动生成 EntityEmrBasicInfo vo = new EntityEmrBasicInfo(); vo.typeId = 1; vo.formId = formVo.Formid; vo.caseName = formVo.Formname; vo.caseCode = formVo.Formid.ToString(); vo.pyCode = SpellCodeHelper.GetPyCode(formVo.Formname); vo.wbCode = SpellCodeHelper.GetWbCode(formVo.Formname); vo.tableName = tbName; vo.attribute = 0; vo.showType = 0; vo.caseStyle = 0; vo.catalogId = 23; // 其他类 vo.fieldXml = EmrTool.GetBasicFieldXml(formVo.Layout); vo.status = 1; lstPara.Add(svc.GetInsertParm(vo)); if (svc.enumDBMS == EnumDBMS.Oracle) { } else { Sql = @"if exists (select 1 from sysobjects where id = object_id('{0}') and type = 'U') drop table {1}"; lstPara.Add(svc.GetDacParm(EnumExecType.ExecSql, string.Format(Sql, tbName, tbName))); Sql = @"create table {0} ( registerid varchar(20) not null, recorddate datetime not null, fieldname varchar(50) not null, rowindex numeric(10,0) not null, tablecode varchar(100) null, contentrtf image null, printrtf image null, isprint numeric(1,0) not null, constraint pk_{0} primary key (registerid, recorddate, fieldname, rowindex) )"; } lstPara.Add(svc.GetDacParm(EnumExecType.ExecSql, string.Format(Sql, tbName, tbName))); } else { EntityEmrBasicInfo vo = new EntityEmrBasicInfo(); vo.formId = formVo.Formid; vo.caseName = formVo.Formname; vo.pyCode = SpellCodeHelper.GetPyCode(formVo.Formname); vo.wbCode = SpellCodeHelper.GetWbCode(formVo.Formname); vo.fieldXml = EmrTool.GetBasicFieldXml(formVo.Layout); DataTable dt = svc.Select(vo, new List <string>() { EntityEmrBasicInfo.Columns.formId }); if (dt != null && dt.Rows.Count > 0) { //lstPara.Add(svc.GetUpdateParm(vo, new List<string>() { EntityEmrBasicInfo.Columns.caseName, EntityEmrBasicInfo.Columns.pyCode, // EntityEmrBasicInfo.Columns.wbCode, EntityEmrBasicInfo.Columns.fieldXml }, // new List<string>() { EntityEmrBasicInfo.Columns.formId })); Sql = @"update emrBasicInfo set caseName = ?, pyCode = ?, wbCode = ?, fieldXml = ? where formId = ?"; IDataParameter[] parms = svc.CreateParm(5); parms[0].Value = vo.caseName; parms[1].Value = vo.pyCode; parms[2].Value = vo.wbCode; parms[3].Value = vo.fieldXml; if (!string.IsNullOrEmpty(vo.fieldXml) && vo.fieldXml.Trim() != null) { parms[3].ParameterName = "xmltype"; } parms[4].Value = vo.formId; lstPara.Add(svc.GetDacParm(EnumExecType.ExecSql, Sql, parms)); } } } if (formVo.Formid > 0) { using (TransactionScope scope = svc.TransactionScope) { if (DelForm((int)formVo.Formid, (int)formVo.Version) < 0) { return(-1); } affectRows = svc.Commit(lstPara); scope.Complete(); } } else { affectRows = svc.Commit(lstPara); } formId = (int)formVo.Formid; if (formId > 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> /// 获取.电子申请单 /// </summary> /// <param name="formId"></param> /// <param name="formVo"></param> public void GetForm(int formId, out EntityFormDesign formVo) { GetForm(formId, -1, out formVo); }
/// <summary> /// Load /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ShowPanelEF_Load(object sender, EventArgs e) { if (DesignMode) { return; } try { this.SuspendLayout(); if (!string.IsNullOrEmpty(this.FormLayout)) { FormCtrls = FormTool.Entities(this.FormLayout); } else { if (Formid > 0) { EntityFormDesign vo = null; ProxyFormDesign proxy = new ProxyFormDesign(); proxy.Service.GetForm(Formid, out vo); FormCtrls = FormTool.Entities(vo.Layout); } } #region 用下面代码设定:宽*高 //if (!string.IsNullOrEmpty(eafMain.PanelSize)) //{ // string[] size = eafMain.PanelSize.Split('|'); // if (size.Length == 2) // { // int height = HopeBridge.FrameWork.Utils.Function.Int(size[0]); // if (height > 0) // { // this.Height = height + 8; // } // int width = HopeBridge.FrameWork.Utils.Function.Int(size[1]); // if (width > 0) // { // this.Width = width + 8; // } // } //} #endregion #region Controls int intMaxTop = 0; int intMaxLeft = 0; if (FormCtrls != null) { int diffTableHeight = 0; object obj = null; Control ctrl = null; EntityCtrlPoint point = null; IRuntimeDesignControl ICtrl = null; List <EntityCtrlPoint> lstCtrlPoint = new List <EntityCtrlPoint>(); FormTool.SetParentObject(this, ControlContainer); FormCtrls.Sort(); foreach (EntityFormCtrl node in FormCtrls) { if (!string.IsNullOrEmpty(node.Parent)) { continue; } obj = FormTool.CreateControl(node, FormCtrls); if (obj == null) { continue; } if (obj is Control) { ctrl = obj as Control; ctrl.Name = node.ControlName; ControlContainer.Controls.Add(ctrl); if (ctrl is IRuntimeDesignControl) { if (diffTableHeight > 0 && intMaxTop > node.Top) { node.Top += diffTableHeight; } ICtrl = ctrl as IRuntimeDesignControl; ICtrl.Location = new System.Drawing.Point(node.Left, node.Top); ICtrl.Width = node.Width; ICtrl.Height = node.Height; if (ctrl is IRtfEditor) { } else { ICtrl.Text = node.Text; } ICtrl.ForeColor = node.ForeColor; if (!string.IsNullOrEmpty(node.TextFont)) { ((Control)ctrl).Font = FontSerializationService.Deserialize(node.TextFont); } if (ctrl is ICheckBox && node.Checked == "1") { ctrl.ForeColor = Color.Blue; } if (ctrl is IFormCtrl) { ((Control)ctrl).Tag = node; } } else if (ctrl is ctlTableCase) { node.Top += diffTableHeight; ctrl.Location = new System.Drawing.Point(node.Left, node.Top); diffTableHeight = ctrl.Height - node.Height; node.Width = ctrl.Width; node.Height = ctrl.Height; ctrl.Width = node.Width; ctrl.Height = node.Height; } else { if (diffTableHeight > 0 && intMaxTop > node.Top) { node.Top += diffTableHeight; } ctrl.Location = new System.Drawing.Point(node.Left, node.Top); ctrl.Width = node.Width; ctrl.Height = node.Height; } point = new EntityCtrlPoint(); point.CtrlName = node.ControlName; point.X = node.Left; point.Y = node.Top; lstCtrlPoint.Add(point); intMaxTop = Math.Max(node.Top + node.Height, intMaxTop); intMaxLeft = Math.Max(node.Left + node.Width, intMaxLeft); } } ButtonItemClick(ControlContainer); this.Width = intMaxLeft + 20; this.Height = intMaxTop + 20; FormTool.maxHeight = this.Height; #region 多个表格时,有时需要重整坐标 if (diffTableHeight > 0) { foreach (Control ctrl1 in ControlContainer.Controls) { EntityCtrlPoint point1 = lstCtrlPoint.FirstOrDefault(t => t.CtrlName == ctrl1.Name); ctrl1.Location = new Point(point1.X, point1.Y); } } #endregion } #endregion } finally { this.ResumeLayout(); } }
/// <summary> /// 保存.电子申请单 /// </summary> /// <param name="formVo"></param> /// <param name="formId"></param> /// <returns></returns> public int SaveForm(EntityFormDesign formVo, out int formId) { int affectRows = 0; string Sql = string.Empty; SqlHelper svc = null; formId = 0; try { svc = new SqlHelper(EnumBiz.onlineDB); List <DacParm> lstPara = new List <DacParm>(); bool isExsit = true; if (formVo.Formid <= 0) { isExsit = false; formVo.Formid = svc.GetNextID(EntityTools.GetTableName(formVo), EntityTools.GetFieldName(formVo, EntityFormDesign.Columns.Formid)); } lstPara.Add(svc.GetInsertParm(formVo)); if (isExsit == false) { string tbName = "emrFormRtf" + formVo.Formid.ToString(); // 自动生成 EntityEmrBasicInfo vo = new EntityEmrBasicInfo(); vo.typeId = 1; vo.formId = formVo.Formid; vo.formName = formVo.Formname; vo.caseCode = formVo.Formid.ToString(); vo.pyCode = SpellCodeHelper.GetPyCode(formVo.Formname); vo.wbCode = SpellCodeHelper.GetWbCode(formVo.Formname); vo.tableName = tbName; vo.attribute = 0; vo.showType = 0; vo.caseStyle = 0; vo.catalogId = 23; // 其他类 vo.fieldXml = EmrTool.GetBasicFieldXml(formVo.Layout); vo.status = 1; lstPara.Add(svc.GetInsertParm(vo)); Sql = @"if exists (select 1 from sysobjects where id = object_id('{0}') and type = 'U') drop table {1}"; lstPara.Add(svc.GetDacParm(EnumExecType.ExecSql, string.Format(Sql, tbName, tbName))); Sql = @"create table {0} ( registerid varchar(20) not null, recorddate datetime not null, fieldname varchar(50) not null, rowindex numeric(10,0) not null, tablecode varchar(100) null, contentrtf image null, printrtf image null, isprint numeric(1,0) not null, constraint pk_{0} primary key (registerid, recorddate, fieldname, rowindex) )"; lstPara.Add(svc.GetDacParm(EnumExecType.ExecSql, string.Format(Sql, tbName, tbName))); } else { EntityEmrBasicInfo vo = new EntityEmrBasicInfo(); vo.formId = formVo.Formid; vo.formName = formVo.Formname; vo.pyCode = SpellCodeHelper.GetPyCode(formVo.Formname); vo.wbCode = SpellCodeHelper.GetWbCode(formVo.Formname); vo.fieldXml = EmrTool.GetBasicFieldXml(formVo.Layout); DataTable dt = svc.Select(vo, new List <string>() { EntityEmrBasicInfo.Columns.formId }); if (dt != null && dt.Rows.Count > 0) { lstPara.Add(svc.GetUpdateParm(vo, new List <string>() { EntityEmrBasicInfo.Columns.formName, EntityEmrBasicInfo.Columns.pyCode, EntityEmrBasicInfo.Columns.wbCode, EntityEmrBasicInfo.Columns.fieldXml }, new List <string>() { EntityEmrBasicInfo.Columns.formId })); } } if (formVo.Formid > 0) { using (TransactionScope scope = svc.TransactionScope) { if (DelForm((int)formVo.Formid, (int)formVo.Version) < 0) { return(-1); } affectRows = svc.Commit(lstPara); scope.Complete(); } } else { affectRows = svc.Commit(lstPara); } formId = (int)formVo.Formid; if (formId > 0 && affectRows <= 0) { affectRows = 1; } } catch (Exception e) { ExceptionLog.OutPutException(e); affectRows = -1; } finally { svc = null; } return(affectRows); }