protected void Btn_Save_Click(object sender, EventArgs e) { try { if (this.FK_MapData.Replace("ND", "") == this.FK_Node.ToString()) { this.SaveNode(); return; } MapData md = new MapData(this.FK_MapData); GEEntity en = md.HisGEEn; en.SetValByKey("OID", this.OIDPKVal); int i = en.RetrieveFromDBSources(); en = this.UCEn1.Copy(en) as GEEntity; FrmEvents fes = md.FrmEvents; //new FrmEvents(this.FK_MapData); fes.DoEventNode(FrmEventList.SaveBefore, en); if (i == 0) { en.Insert(); } else { en.Update(); } fes.DoEventNode(FrmEventList.SaveAfter, en); //this.Response.Redirect("Frm.aspx?OID=" + en.GetValStringByKey("OID") + "&FK_Node=" + this.FK_Node + "&FID=" + this.FID + "&FK_MapData=" + this.FK_MapData, true); } catch (Exception ex) { this.UCEn1.AddMsgOfWarning("error:", ex.Message); } }
/// <summary> /// 执行保存 /// </summary> /// <returns></returns> public string MyDict_SaveIt() { //执行保存. GEEntity rpt = new GEEntity(this.FrmID, this.WorkID); rpt = BP.Sys.PubClass.CopyFromRequest(rpt, context.Request) as GEEntity; Hashtable ht = GetMainTableHT(); foreach (string item in ht.Keys) { rpt.SetValByKey(item, ht[item]); } rpt.OID = this.WorkID; rpt.SetValByKey("BillState", (int)BillState.Editing); rpt.Update(); string str = BP.Frm.Dev2Interface.SaveWork(this.FrmID, this.WorkID); return(str); }
protected void Btn_Save_Click(object sender, EventArgs e) { try { MapData md = new MapData(this.FK_MapData); //判断与节点编号相同,并且是节点表单类型才可以保存 if (this.FK_MapData.Replace("ND", "") == this.FK_Node.ToString() && md.AppType == "1") { this.SaveNode(); return; } GEEntity en = md.HisGEEn; en.SetValByKey("OID", this.OIDPKVal); int i = en.RetrieveFromDBSources(); en = this.UCEn1.Copy(en) as GEEntity; FrmEvents fes = md.FrmEvents; //new FrmEvents(this.FK_MapData); fes.DoEventNode(FrmEventList.SaveBefore, en); //#region 检查是否有ca签名. //if (md.IsHaveCA == true) //{ // if (!string.IsNullOrEmpty(this.TB_SealData.Text)) // { // BP.Tools.WFSealData sealData = new BP.Tools.WFSealData(); // sealData.RetrieveByAttrAnd(BP.Tools.WFSealDataAttr.OID, WorkID, BP.Tools.WFSealDataAttr.FK_Node, FK_Node); // if (string.IsNullOrEmpty(sealData.OID)) // { // sealData.MyPK = DBAccess.GenerGUID(); // sealData.OID = WorkID; // sealData.FK_Node = FK_Node.ToString(); // sealData.SealData = this.TB_SealData.Text; // sealData.RDT = DataType.CurrentDataTime; // sealData.FK_MapData = this.FK_MapData; // sealData.Insert(); // } // else // { // sealData.SealData = this.TB_SealData.Text; // sealData.RDT = DataType.CurrentDataTime; // sealData.Update(); // } // byte[] data = System.Convert.FromBase64String(TB_SingData.Text); // if (data.Length != 0) // { // System.IO.MemoryStream MS = new System.IO.MemoryStream(data); // System.Drawing.Bitmap image = new System.Drawing.Bitmap(MS); // image.Save(TB_SealFile.Text, System.Drawing.Imaging.ImageFormat.Jpeg); // } // } //} //#endregion 检查是否有ca签名. if (i == 0) { en.Insert(); } else { en.Update(); } fes.DoEventNode(FrmEventList.SaveAfter, en); //this.Response.Redirect("Frm.aspx?OID=" + en.GetValStringByKey("OID") + "&FK_Node=" + this.FK_Node + "&FID=" + this.FID + "&FK_MapData=" + this.FK_MapData, true); } catch (Exception ex) { this.UCEn1.AddMsgOfWarning("error:", ex.Message); } }
protected void Page_Load(object sender, EventArgs e) { #region 属性 string sealName = null; #endregion 属性 #warning 没有缓存经常预览与设计不一致 MapData md = new MapData(); md.No = this.FK_MapData; if (this.Request.QueryString["IsTest"] == "1") { md.RepairMap(); BP.Sys.SystemConfig.DoClearCash_del(); } if (this.Request.QueryString["IsLoadData"] == "1") { this.UCEn1.IsLoadData = true; } if (md.RetrieveFromDBSources() == 0 && md.Name.Length > 3) { /*如果没有找到,就可能是 dtl 。*/ if (md.HisFrmType == FrmType.Url || md.HisFrmType == FrmType.SLFrm) { string no = Request.QueryString["NO"]; string urlParas = "OID=" + this.OID + "&NO=" + no + "&WorkID=" + this.WorkID + "&FK_Node=" + this.FK_Node + "&UserNo=" + WebUser.No + "&SID=" + this.SID; /*如果是URL.*/ if (md.Url.Contains("?") == true) { this.Response.Redirect(md.Url + "&" + urlParas, true); } else { this.Response.Redirect(md.Url + "?" + urlParas, true); } return; } /* 没有找到此map. */ MapDtl dtl = new MapDtl(this.FK_MapData); GEDtl dtlEn = dtl.HisGEDtl; dtlEn.SetValByKey("OID", this.FID); if (dtlEn.EnMap.Attrs.Count <= 0) { md.RepairMap(); this.Response.Redirect(this.Request.RawUrl, true); return; } int i = dtlEn.RetrieveFromDBSources(); string[] paras = this.RequestParas.Split('&'); foreach (string str in paras) { if (string.IsNullOrEmpty(str) || str.Contains("=") == false) { continue; } string[] kvs = str.Split('='); dtlEn.SetValByKey(kvs[0], kvs[1]); } Width = md.MaxRight + md.MaxLeft * 2 + 10 + ""; if (float.Parse(Width) < 500) { Width = "900"; } Height = md.MaxEnd > md.FrmH ? md.MaxEnd + "" : md.FrmH + ""; if (float.Parse(Height) <= 800) { Height = "800"; } this.UCEn1.Add("<div id=divCCForm style='width:" + Width + "px;height:" + Height + "px' >"); if (md.HisFrmType == FrmType.FreeFrm) { this.UCEn1.BindCCForm(dtlEn, this.FK_MapData, !this.IsEdit, 0, this.IsLoadData); } if (md.HisFrmType == FrmType.Column4Frm) { this.UCEn1.BindCCForm(dtlEn, this.FK_MapData, !this.IsEdit, 0, this.IsLoadData); } this.AddJSEvent(dtlEn); this.UCEn1.Add("</div>"); } else { /*如果没有找到,就可能是dtl。*/ if (md.HisFrmType == FrmType.Url || md.HisFrmType == FrmType.SLFrm) { string no = Request.QueryString["NO"]; string urlParas = "OID=" + this.OID + "&NO=" + no + "&WorkID=" + this.WorkID + "&FK_Node=" + this.FK_Node + "&IsEdit=" + this.IsEdit.ToString() + "&UserNo=" + WebUser.No + "&SID=" + this.SID; /*如果是URL.*/ if (md.Url.Contains("?") == true) { this.Response.Redirect(md.Url + "&" + urlParas, true); } else { this.Response.Redirect(md.Url + "?" + urlParas, true); } return; } if (md.HisFrmType == FrmType.WordFrm) { string no = Request.QueryString["NO"]; string urlParas = "OID=" + this.OID + "&NO=" + no + "&WorkID=" + this.WorkID + "&FK_Node=" + this.FK_Node + "&UserNo=" + WebUser.No + "&SID=" + this.SID + "&FK_MapData=" + this.FK_MapData + "&OIDPKVal=" + this.OIDPKVal + "&FID=" + this.FID + "&FK_Flow=" + this.FK_Flow; /*如果是URL.*/ string requestParas = this.RequestParas; string[] parasArrary = this.RequestParas.Split('&'); foreach (string str in parasArrary) { if (string.IsNullOrEmpty(str) || str.Contains("=") == false) { continue; } string[] kvs = str.Split('='); if (urlParas.Contains(kvs[0])) { continue; } urlParas += "&" + kvs[0] + "=" + kvs[1]; } if (md.Url.Contains("?") == true) { this.Response.Redirect("FrmWord.aspx?1=2" + "&" + urlParas, true); } else { this.Response.Redirect("FrmWord.aspx" + "?" + urlParas, true); } return; } if (md.HisFrmType == FrmType.ExcelFrm) { this.Response.Redirect("FrmExcel.aspx?1=2" + this.RequestParas, true); return; } GEEntity en = md.HisGEEn; #region 求出 who is pk 值. int pk = this.OID; string nodeid = this.FK_Node.ToString(); if (nodeid != "0" && string.IsNullOrEmpty(this.FK_Flow) == false) { /*说明是流程调用它, 就要判断谁是表单的PK.*/ FrmNode fn = new FrmNode(this.FK_Flow, this.FK_Node, this.FK_MapData); switch (fn.WhoIsPK) { case WhoIsPK.FID: pk = this.FID; if (pk == 0) { throw new Exception("@没有接收到参数FID"); } break; case WhoIsPK.CWorkID: /*延续流程ID*/ pk = this.CWorkID; if (pk == 0) { throw new Exception("@没有接收到参数CWorkID"); } break; case WhoIsPK.PWorkID: /*父流程ID*/ pk = this.PWorkID; if (pk == 0) { throw new Exception("@没有接收到参数PWorkID"); } break; case WhoIsPK.OID: default: break; } } en.SetValByKey("OID", pk); #endregion 求出pk 值. if (en.EnMap.Attrs.Count <= 0) { md.RepairMap(); //让他刷新一下,重新进入. this.Response.Redirect(this.Request.RawUrl, true); return; } //检查实体数据是否存在,并重新设置默认值 if (en.RetrieveFromDBSources() == 0) { en.ResetDefaultValAllAttr(); try { en.DirectInsert(); } catch (Exception ex) { md.RepairMap(); en.CheckPhysicsTable(); throw new Exception("@装载出现错误:如果是第一次出现该错误,请刷新一次,系统有可能自动修复了。技术信息:" + ex.Message); } } string[] paras = this.RequestParas.Split('&'); foreach (string str in paras) { if (string.IsNullOrEmpty(str) || str.Contains("=") == false) { continue; } string[] kvs = str.Split('='); en.SetValByKey(kvs[0], kvs[1]); } if (en.ToString() == "0") { en.SetValByKey("OID", pk); } this.OIDPKVal = pk; #region 处理表单权限控制方案 Width = md.FrmW.ToString();//md.MaxRight + md.MaxLeft * 2 + 10 + ""; if (float.Parse(Width) < 500) { Width = "900"; } Height = md.MaxEnd > md.FrmH ? md.MaxEnd + "" : md.FrmH + ""; if (float.Parse(Height) <= 800) { Height = "800"; } this.UCEn1.Add("<div id=divCCForm style='width:" + Width + "px;height:" + Height + "px' >"); if (nodeid != null) { this.UCEn1.FK_Node = this.FK_Node; /*处理表单权限控制方案*/ this.HisFrmNode = new FrmNode(); int ii = this.HisFrmNode.Retrieve(FrmNodeAttr.FK_Frm, this.FK_MapData, FrmNodeAttr.FK_Node, int.Parse(nodeid)); if (ii == 0 || this.HisFrmNode.FrmSln == 0) { /*说明没有配置,或者方案编号为默认就不用处理,*/ this.UCEn1.BindCCForm(en, this.FK_MapData, !this.IsEdit, 0, this.IsLoadData); } else { FrmFields fls = new FrmFields(this.FK_MapData, this.HisFrmNode.FrmSln); //求出集合. MapAttrs mattrs = new MapAttrs(this.FK_MapData); foreach (FrmField item in fls) { foreach (MapAttr attr in mattrs) { if (attr.KeyOfEn != item.KeyOfEn) { continue; } if (item.IsSigan) { item.UIIsEnable = false; } if (attr.SignType == SignType.CA) { long workId = Convert.ToInt64(this.OID); FrmField keyOfEn = new FrmField(); QueryObject info = new QueryObject(keyOfEn); info.AddWhere(FrmFieldAttr.FK_Node, this.FK_Node); info.addAnd(); info.AddWhere(FrmFieldAttr.FK_MapData, attr.FK_MapData); info.addAnd(); info.AddWhere(FrmFieldAttr.KeyOfEn, attr.KeyOfEn); info.addAnd(); info.AddWhere(MapAttrAttr.UIIsEnable, "1"); if (info.DoQuery() > 0) { sealName = en.GetValStrByKey(attr.KeyOfEn); } } attr.UIIsEnable = item.UIIsEnable; attr.UIVisible = item.UIVisible; attr.IsSigan = item.IsSigan; attr.DefValReal = item.DefVal; } } #region 设置默认值. if (this.IsEdit == true) { bool isHave = false; foreach (MapAttr attr in mattrs) { //if (attr.UIIsEnable) // continue; if (attr.DefValReal.Contains("@") == false) { continue; } en.SetValByKey(attr.KeyOfEn, attr.DefVal); isHave = true; } if (isHave) { en.DirectUpdate(); //让其直接更新. } } #endregion 设置默认值. //按照当前方案绑定表单. /* * 修改说明:如果是自定义方案,就不要装载填充了. */ ////是否要重新装载数据. bool isLoadData = this.IsLoadData; if (this.HisFrmNode.IsEnableLoadData == true) { /*如果允许启用.*/ } else { isLoadData = false; } this.UCEn1.BindCCForm(en, md, mattrs, this.FK_MapData, !this.IsEdit, Int64.Parse(Width), isLoadData); #region 检查必填项 string scriptCheckFrm = ""; scriptCheckFrm += "\t\n<script type='text/javascript' >"; scriptCheckFrm += "\t\n function CheckFrmSlnIsNull(){ "; scriptCheckFrm += "\t\n var isPass = true;"; scriptCheckFrm += "\t\n var alloweSave = true;"; scriptCheckFrm += "\t\n var erroMsg = '提示信息:';"; //表单权限设置为必填项 //查询出来,需要不为空的 Paras ps = new Paras(); ps.SQL = "SELECT KeyOfEn, Name FROM Sys_FrmSln WHERE FK_MapData=" + ps.DBStr + "FK_MapData AND FK_Node=" + ps.DBStr + "FK_Node AND IsNotNull=" + ps.DBStr + "IsNotNull"; ps.Add(FrmFieldAttr.FK_MapData, this.FK_MapData); ps.Add(FrmFieldAttr.FK_Node, this.FK_Node); ps.Add(FrmFieldAttr.IsNotNull, 1); //查询 System.Data.DataTable dtKeys = DBAccess.RunSQLReturnTable(ps); // 检查数据是否完整. foreach (System.Data.DataRow dr in dtKeys.Rows) { string key = dr[0].ToString(); string name = dr[1].ToString(); BP.Web.Controls.TB TB_NotNull = this.UCEn1.GetTBByID("TB_" + key); if (TB_NotNull != null) { scriptCheckFrm += "\t\n try{ "; scriptCheckFrm += "\t\n var element = document.getElementById('" + TB_NotNull.ClientID + "');"; //验证输入的正则格式 scriptCheckFrm += "\t\n if(element && element.readOnly == true) return;"; scriptCheckFrm += "\t\n isPass = EleSubmitCheck(element,'.{1}','" + name + ",不能为空。');"; scriptCheckFrm += "\t\n if(isPass == false){"; scriptCheckFrm += "\t\n alloweSave = false;"; scriptCheckFrm += "\t\n erroMsg += '" + name + ",不能为空。';"; scriptCheckFrm += "\t\n }"; scriptCheckFrm += "\t\n } catch(e) { "; scriptCheckFrm += "\t\n alert(e.name + e.message); return false;"; scriptCheckFrm += "\t\n } "; } } scriptCheckFrm += "\t\n return alloweSave; } "; scriptCheckFrm += "\t\n</script>"; #endregion //检查必填项 this.UCEn1.Add(scriptCheckFrm); } } else { this.UCEn1.BindCCForm(en, this.FK_MapData, !this.IsEdit, 0, this.IsLoadData); } this.UCEn1.Add("</div>"); #endregion if (!IsPostBack) { if (md.IsHaveCA) { #region 检查是否有ca签名. //if (md.IsHaveCA == true) //{ // if (string.IsNullOrEmpty(sealName)) // sealName = WebUser.No; // string basePath = Server.MapPath("~/DataUser/Siganture/" + WorkID); // if (!System.IO.Directory.Exists(basePath)) // { // System.IO.Directory.CreateDirectory(basePath); // } // // basePath = "C:\\"; // this.TB_SealFile.Text = basePath + "\\" + sealName + ".jpg"; // #region 获取存储的 签名信息 // BP.Tools.WFSealData sealData = new BP.Tools.WFSealData(); // sealData.RetrieveByAttrAnd(BP.Tools.WFSealDataAttr.OID, WorkID, BP.Tools.WFSealDataAttr.FK_Node, FK_Node); // //sealData.RetrieveFromDBSources(); // if (!string.IsNullOrEmpty(sealData.SealData)) // { // this.TB_SealData.Text = sealData.SealData; // } // #endregion // //this.TB_SealData.Text = en.GetValStringByKey("SealData"); //} #endregion 检查是否有ca签名. } } this.AddJSEvent(en); } Session["Count"] = null; this.Btn_Save.Visible = this.HisFrmNode.IsEdit; this.Btn_Save.Enabled = this.HisFrmNode.IsEdit; this.Btn_Save.BackColor = System.Drawing.Color.White; Node curNd = new Node(); curNd.NodeID = this.FK_Node; curNd.RetrieveFromDBSources(); if (curNd.FormType == NodeFormType.SheetTree) { this.Btn_Save.Visible = true; this.Btn_Save.Enabled = true; this.Btn_Print.Enabled = false; this.Btn_Print.Visible = false; } else { this.Btn_Print.Visible = this.HisFrmNode.IsPrint; this.Btn_Print.Enabled = this.HisFrmNode.IsPrint; this.Btn_Print.Attributes["onclick"] = "window.open('Print.aspx?FK_Node=" + this.FK_Node + "&FID=" + this.FID + "&FK_MapData=" + this.FK_MapData + "&WorkID=" + this.OID + "', '', 'dialogHeight: 350px; dialogWidth:450px; center: yes; help: no'); return false;"; } }
protected void Page_Load(object sender, EventArgs e) { #warning 没有缓存经常预览与设计不一致 if (this.Request.QueryString["IsTest"] == "1") { BP.SystemConfig.DoClearCash_del(); } if (this.Request.QueryString["IsLoadData"] == "1") { this.UCEn1.IsLoadData = true; } MapData md = new MapData(); md.No = this.FK_MapData; if (md.RetrieveFromDBSources() == 0 && md.Name.Length > 3) { if (md.HisFrmType == FrmType.Url) { this.Response.Redirect(md.PTable, true); return; } /* 没有找到此map. */ MapDtl dtl = new MapDtl(this.FK_MapData); GEDtl dtlEn = dtl.HisGEDtl; dtlEn.SetValByKey("OID", this.FID); if (dtlEn.EnMap.Attrs.Count < 2) { md.RepairMap(); this.Response.Redirect(this.Request.RawUrl, true); return; } int i = dtlEn.RetrieveFromDBSources(); string[] paras = this.RequestParas.Split('&'); foreach (string str in paras) { if (string.IsNullOrEmpty(str) || str.Contains("=") == false) { continue; } string[] kvs = str.Split('='); dtlEn.SetValByKey(kvs[0], kvs[1]); } if (md.HisFrmType == FrmType.CCForm) { this.UCEn1.BindCCForm(dtlEn, this.FK_MapData, !this.IsEdit); } if (md.HisFrmType == FrmType.Column4Frm) { this.UCEn1.BindCCForm(dtlEn, this.FK_MapData, !this.IsEdit); } this.AddJSEvent(dtlEn); } else { GEEntity en = md.HisGEEn; int pk = this.OID; if (this.Request.QueryString["NodeID"] != null) { /*说明是流程调用它.*/ Node nd = new Node(int.Parse(this.Request.QueryString["NodeID"])); if (nd.HisRunModel == RunModel.SubThread && nd.HisSubThreadType == SubThreadType.UnSameSheet && this.FK_MapData != "ND" + nd.NodeID) { /*如果是子线程, 并且是异表单节点.*/ pk = this.FID; // 是子线程,并且是异表单的子线程,并且不是节点表单。这样设置是为了到合流点上能够按FID进行表单数据汇总. } } en.SetValByKey("OID", pk); if (en.EnMap.Attrs.Count < 2) { md.RepairMap(); this.Response.Redirect(this.Request.RawUrl, true); return; } int i = en.RetrieveFromDBSources(); if (i == 0) { en.DirectInsert(); } string[] paras = this.RequestParas.Split('&'); foreach (string str in paras) { if (string.IsNullOrEmpty(str) || str.Contains("=") == false) { continue; } string[] kvs = str.Split('='); en.SetValByKey(kvs[0], kvs[1]); } en.ResetDefaultVal(); if (en.ToString() == "0") { en.SetValByKey("OID", pk); } this.OIDPKVal = pk; this.UCEn1.BindCCForm(en, this.FK_MapData, !this.IsEdit); this.AddJSEvent(en); } Session["Count"] = null; this.Btn_Save.Click += new EventHandler(Btn_Save_Click); this.Btn_Save.Visible = this.IsEdit; this.Btn_Save.Enabled = this.IsEdit; this.Btn_Save.BackColor = System.Drawing.Color.White; this.Btn_Print.Visible = this.IsPrint; this.Btn_Print.Enabled = this.IsPrint; this.Btn_Print.Attributes["onclick"] = "window.showModalDialog('./CCForm/Print.aspx?FK_Node=" + this.FK_Node + "&FID=" + this.FID + "&FK_MapData=" + this.FK_MapData + "&WorkID=" + this.OID + "', '', 'dialogHeight: 350px; dialogWidth:450px; center: yes; help: no'); return false;"; }
/// <summary> /// 获取从表数据,用于显示dtl.htm /// </summary> /// <param name="frmID">表单ID</param> /// <param name="pkval">主键</param> /// <param name="atParas">参数</param> /// <param name="specDtlFrmID">指定明细表的参数,如果为空就标识主表数据,否则就是从表数据.</param> /// <returns>数据</returns> public static DataSet GenerDBForCCFormDtl(string frmID, MapDtl dtl, int pkval, string atParas) { //数据容器,就是要返回的对象. DataSet myds = new DataSet(); //映射实体. MapData md = new MapData(frmID); //实体. GEEntity wk = new GEEntity(frmID); wk.OID = pkval; if (wk.RetrieveFromDBSources() == 0) { wk.Insert(); } //把参数放入到 En 的 Row 里面。 if (DataType.IsNullOrEmpty(atParas) == false) { AtPara ap = new AtPara(atParas); foreach (string key in ap.HisHT.Keys) { try { if (wk.Row.ContainsKey(key) == true) //有就该变. { wk.Row[key] = ap.GetValStrByKey(key); } else { wk.Row.Add(key, ap.GetValStrByKey(key)); //增加他. } } catch (Exception ex) { throw new Exception(key); } } } #region 加载从表表单模版信息. DataTable Sys_MapDtl = dtl.ToDataTableField("Sys_MapDtl"); myds.Tables.Add(Sys_MapDtl); //明细表的表单描述 DataTable Sys_MapAttr = dtl.MapAttrs.ToDataTableField("Sys_MapAttr"); myds.Tables.Add(Sys_MapAttr); //明细表的配置信息. DataTable Sys_MapExt = dtl.MapExts.ToDataTableField("Sys_MapExt"); myds.Tables.Add(Sys_MapExt); #region 把从表的- 外键表/枚举 加入 DataSet. MapExts mes = dtl.MapExts; MapExt me = null; foreach (DataRow dr in Sys_MapAttr.Rows) { string lgType = dr["LGType"].ToString(); //不是枚举/外键字段 if (lgType.Equals("0")) { continue; } string uiBindKey = dr["UIBindKey"].ToString(); var mypk = dr["MyPK"].ToString(); #region 枚举字段 if (lgType.Equals("1")) { // 如果是枚举值, 判断是否存在. if (myds.Tables.Contains(uiBindKey) == true) { continue; } string mysql = "SELECT IntKey AS No, Lab as Name FROM Sys_Enum WHERE EnumKey='" + uiBindKey + "' ORDER BY IntKey "; DataTable dtEnum = DBAccess.RunSQLReturnTable(mysql); dtEnum.TableName = uiBindKey; dtEnum.Columns[0].ColumnName = "No"; dtEnum.Columns[1].ColumnName = "Name"; myds.Tables.Add(dtEnum); continue; } #endregion #region 外键字段 string UIIsEnable = dr["UIIsEnable"].ToString(); if (UIIsEnable.Equals("0")) //字段未启用 { continue; } // 检查是否有下拉框自动填充。 string keyOfEn = dr["KeyOfEn"].ToString(); #region 处理下拉框数据范围. for 小杨. me = mes.GetEntityByKey(MapExtAttr.ExtType, MapExtXmlList.AutoFullDLL, MapExtAttr.AttrOfOper, keyOfEn) as MapExt; if (me != null) //有范围限制时 { string fullSQL = me.Doc.Clone() as string; fullSQL = fullSQL.Replace("~", ","); fullSQL = BP.WF.Glo.DealExp(fullSQL, wk, null); DataTable dt = DBAccess.RunSQLReturnTable(fullSQL); dt.TableName = uiBindKey; dt.Columns[0].ColumnName = "No"; dt.Columns[1].ColumnName = "Name"; myds.Tables.Add(dt); continue; } #endregion 处理下拉框数据范围. // 判断是否存在. if (myds.Tables.Contains(uiBindKey) == true) { continue; } myds.Tables.Add(BP.Sys.PubClass.GetDataTableByUIBineKey(uiBindKey)); #endregion 外键字段 } #endregion 把从表的- 外键表/枚举 加入 DataSet. #endregion 加载从表表单模版信息. #region 把主表数据放入. if (BP.Sys.SystemConfig.IsBSsystem == true) { // 处理传递过来的参数。 foreach (string k in System.Web.HttpContext.Current.Request.QueryString.AllKeys) { wk.SetValByKey(k, System.Web.HttpContext.Current.Request.QueryString[k]); } } //重设默认值. wk.ResetDefaultVal(); //增加主表数据. DataTable mainTable = wk.ToDataTableField(md.No); mainTable.TableName = "MainTable"; myds.Tables.Add(mainTable); #endregion 把主表数据放入. #region 把从表的数据放入. GEDtls dtls = new GEDtls(dtl.No); QueryObject qo = null; try { qo = new QueryObject(dtls); switch (dtl.DtlOpenType) { case DtlOpenType.ForEmp: // 按人员来控制. qo.AddWhere(GEDtlAttr.RefPK, pkval); qo.addAnd(); qo.AddWhere(GEDtlAttr.Rec, WebUser.No); break; case DtlOpenType.ForWorkID: // 按工作ID来控制 qo.AddWhere(GEDtlAttr.RefPK, pkval); break; case DtlOpenType.ForFID: // 按流程ID来控制. qo.AddWhere(GEDtlAttr.FID, pkval); break; } } catch (Exception ex) { dtls.GetNewEntity.CheckPhysicsTable(); throw ex; } //条件过滤. if (dtl.FilterSQLExp != "") { string[] strs = dtl.FilterSQLExp.Split('='); qo.addAnd(); qo.AddWhere(strs[0], strs[1]); } //增加排序. // qo.addOrderByDesc( dtls.GetNewEntity.PKField ); //从表 DataTable dtDtl = qo.DoQueryToTable(); //查询所有动态SQL查询类型的字典表记录 SFTable sftable = null; DataTable dtsftable = null; DataRow[] drs = null; SFTables sftables = new SFTables(); sftables.Retrieve(SFTableAttr.SrcType, (int)SrcType.SQL); // 为明细表设置默认值. MapAttrs dtlAttrs = new MapAttrs(dtl.No); foreach (MapAttr attr in dtlAttrs) { #region 修改区分大小写. if (BP.DA.DBType.Oracle == SystemConfig.AppCenterDBType) { foreach (DataColumn dr in dtDtl.Columns) { var a = attr.KeyOfEn; var b = dr.ColumnName; if (attr.KeyOfEn.ToUpper().Equals(dr.ColumnName)) { dr.ColumnName = attr.KeyOfEn; continue; } if (attr.LGType == FieldTypeS.Enum || attr.LGType == FieldTypeS.FK) { if (dr.ColumnName.Equals(attr.KeyOfEn.ToUpper() + "TEXT")) { dr.ColumnName = attr.KeyOfEn + "Text"; } } } foreach (DataRow dr in dtDtl.Rows) { //本身是大写的不进行修改 if (DataType.IsNullOrEmpty(dr[attr.KeyOfEn] + "")) { dr[attr.KeyOfEn] = dr[attr.KeyOfEn.ToUpper()]; dr[attr.KeyOfEn.ToUpper()] = null; } } } #endregion 修改区分大小写. //处理增加动态SQL查询类型的下拉框选中值Text值,added by liuxc,2017-9-22 if (attr.LGType == FieldTypeS.FK && attr.UIIsEnable == false) { sftable = sftables.GetEntityByKey(attr.UIBindKey) as SFTable; if (sftable != null) { dtsftable = sftable.GenerHisDataTable; //为Text赋值 foreach (DataRow dr in dtDtl.Rows) { drs = dtsftable.Select("No='" + dr[attr.KeyOfEn] + "'"); if (drs.Length == 0) { continue; } dr[attr.KeyOfEn + "Text"] = drs[0]["Name"]; } } } //处理它的默认值. if (attr.DefValReal.Contains("@") == false) { continue; } foreach (DataRow dr in dtDtl.Rows) { dr[attr.KeyOfEn] = attr.DefVal; } } dtDtl.TableName = "DBDtl"; //修改明细表的名称. myds.Tables.Add(dtDtl); //加入这个明细表, 如果没有数据,xml体现为空. #endregion 把从表的数据放入. //放入一个空白的实体,用与获取默认值. GEDtl dtlBlank = dtls.GetNewEntity as GEDtl; dtlBlank.ResetDefaultVal(); myds.Tables.Add(dtlBlank.ToDataTableField("Blank")); return(myds); }
/// <summary> /// 仅获取表单数据 /// </summary> /// <param name="frmID">表单ID</param> /// <param name="pkval">主键</param> /// <param name="atParas">参数</param> /// <param name="specDtlFrmID">指定明细表的参数,如果为空就标识主表数据,否则就是从表数据.</param> /// <returns>数据</returns> public static DataSet GenerDBForVSTOExcelFrmModel(string frmID, object pkval, string atParas, string specDtlFrmID = null) { //如果是一个实体类. if (frmID.Contains("BP.")) { // 执行map同步. Entities ens = BP.En.ClassFactory.GetEns(frmID + "s"); Entity en = ens.GetNewEntity; en.DTSMapToSys_MapData(); return(GenerDBForVSTOExcelFrmModelOfEntity(frmID, pkval, atParas, specDtlFrmID = null)); //上面这行代码的解释(2017-04-25): //若不加上这行,代码执行到“ MapData md = new MapData(frmID); ”会报错: //@没有找到记录[表单注册表 Sys_MapData, [ 主键=No 值=BP.LI.BZQX ]记录不存在,请与管理员联系, 或者确认输入错误.@在Entity(BP.Sys.MapData)查询期间出现错误@ 在 BP.En.Entity.Retrieve() 位置 D:\ccflow\Components\BP.En30\En\Entity.cs:行号 1051 //即使加上: //frmID = frmID.Substring(0, frmID.Length - 1); //也会出现该问题 //2017-04-25 15:26:34:new MapData(frmID)应传入“BZQX”,但考虑到 GenerDBForVSTOExcelFrmModelOfEntity()运行稳定,暂不采用『统一执行下方代码』的方案。 } //数据容器,就是要返回的对象. DataSet myds = new DataSet(); //映射实体. MapData md = new MapData(frmID); //实体. GEEntity wk = new GEEntity(frmID); wk.OID = int.Parse(pkval.ToString()); if (wk.RetrieveFromDBSources() == 0) { wk.Insert(); } //加载事件. md.DoEvent(FrmEventList.FrmLoadBefore, wk, null); //把参数放入到 En 的 Row 里面。 if (DataType.IsNullOrEmpty(atParas) == false) { AtPara ap = new AtPara(atParas); foreach (string key in ap.HisHT.Keys) { if (wk.Row.ContainsKey(key) == true) //有就该变. { wk.Row[key] = ap.GetValStrByKey(key); } else { wk.Row.Add(key, ap.GetValStrByKey(key)); //增加他. } } } //属性. MapExt me = null; DataTable dtMapAttr = null; MapExts mes = null; #region 表单模版信息.(含主、从表的,以及从表的枚举/外键相关数据). //增加表单字段描述. string sql = "SELECT * FROM Sys_MapData WHERE No='" + frmID + "' "; DataTable dt = BP.DA.DBAccess.RunSQLReturnTable(sql); dt.TableName = "Sys_MapData"; myds.Tables.Add(dt); //增加表单字段描述. sql = "SELECT * FROM Sys_MapAttr WHERE FK_MapData='" + frmID + "' "; dt = BP.DA.DBAccess.RunSQLReturnTable(sql); dt.TableName = "Sys_MapAttr"; myds.Tables.Add(dt); //增加从表信息. sql = "SELECT * FROM Sys_MapDtl WHERE FK_MapData='" + frmID + "' "; dt = BP.DA.DBAccess.RunSQLReturnTable(sql); dt.TableName = "Sys_MapDtl"; myds.Tables.Add(dt); //主表的配置信息. sql = "SELECT * FROM Sys_MapExt WHERE FK_MapData='" + frmID + "'"; dt = BP.DA.DBAccess.RunSQLReturnTable(sql); dt.TableName = "Sys_MapExt"; myds.Tables.Add(dt); #region 加载 从表表单模版信息.(含 从表的枚举/外键相关数据) foreach (MapDtl item in md.MapDtls) { #region 返回指定的明细表的数据. if (DataType.IsNullOrEmpty(specDtlFrmID) == true) { } else { if (item.No != specDtlFrmID) { continue; } } #endregion 返回指定的明细表的数据. //明细表的主表描述 sql = "SELECT * FROM Sys_MapDtl WHERE No='" + item.No + "'"; dt = BP.DA.DBAccess.RunSQLReturnTable(sql); dt.TableName = "Sys_MapDtl_For_" + (string.IsNullOrWhiteSpace(item.Alias) ? item.No : item.Alias); myds.Tables.Add(dt); //明细表的表单描述 sql = "SELECT * FROM Sys_MapAttr WHERE FK_MapData='" + item.No + "'"; dtMapAttr = BP.DA.DBAccess.RunSQLReturnTable(sql); dtMapAttr.TableName = "Sys_MapAttr_For_" + (string.IsNullOrWhiteSpace(item.Alias) ? item.No : item.Alias); myds.Tables.Add(dtMapAttr); //明细表的配置信息. sql = "SELECT * FROM Sys_MapExt WHERE FK_MapData='" + item.No + "'"; dt = BP.DA.DBAccess.RunSQLReturnTable(sql); dt.TableName = "Sys_MapExt_For_" + (string.IsNullOrWhiteSpace(item.Alias) ? item.No : item.Alias); myds.Tables.Add(dt); #region 从表的 外键表/枚举 mes = new MapExts(item.No); foreach (DataRow dr in dtMapAttr.Rows) { string lgType = dr["LGType"].ToString(); //不是枚举/外键字段 if (lgType.Equals("0")) { continue; } string uiBindKey = dr["UIBindKey"].ToString(); var mypk = dr["MyPK"].ToString(); #region 枚举字段 if (lgType.Equals("1")) { // 如果是枚举值, 判断是否存在. if (myds.Tables.Contains(uiBindKey) == true) { continue; } string mysql = "SELECT IntKey AS No, Lab as Name FROM Sys_Enum WHERE EnumKey='" + uiBindKey + "' ORDER BY IntKey "; DataTable dtEnum = DBAccess.RunSQLReturnTable(mysql); dtEnum.TableName = uiBindKey; myds.Tables.Add(dtEnum); continue; } #endregion string UIIsEnable = dr["UIIsEnable"].ToString(); if (UIIsEnable.Equals("0")) //字段未启用 { continue; } #region 外键字段 // 检查是否有下拉框自动填充。 string keyOfEn = dr["KeyOfEn"].ToString(); #region 处理下拉框数据范围. for 小杨. me = mes.GetEntityByKey(MapExtAttr.ExtType, MapExtXmlList.AutoFullDLL, MapExtAttr.AttrOfOper, keyOfEn) as MapExt; if (me != null) //有范围限制时 { string fullSQL = me.Doc.Clone() as string; fullSQL = fullSQL.Replace("~", ","); fullSQL = BP.WF.Glo.DealExp(fullSQL, wk, null); dt = DBAccess.RunSQLReturnTable(fullSQL); dt.TableName = mypk; myds.Tables.Add(dt); continue; } #endregion 处理下拉框数据范围. else //无范围限制时 { // 判断是否存在. if (myds.Tables.Contains(uiBindKey) == true) { continue; } myds.Tables.Add(BP.Sys.PubClass.GetDataTableByUIBineKey(uiBindKey)); } #endregion 外键字段 } #endregion 从表的 外键表/枚举 } #endregion 加载 从表表单模版信息.(含 从表的枚举/外键相关数据) #endregion 表单模版信息.(含主、从表的,以及从表的枚举/外键相关数据). #region 主表数据 if (BP.Sys.SystemConfig.IsBSsystem == true) { // 处理传递过来的参数。 foreach (string k in System.Web.HttpContext.Current.Request.QueryString.AllKeys) { wk.SetValByKey(k, System.Web.HttpContext.Current.Request.QueryString[k]); } } // 执行表单事件.. string msg = md.DoEvent(FrmEventList.FrmLoadBefore, wk); if (DataType.IsNullOrEmpty(msg) == false) { throw new Exception("err@错误:" + msg); } //重设默认值. wk.ResetDefaultVal(); //执行装载填充. me = new MapExt(); if (me.Retrieve(MapExtAttr.ExtType, MapExtXmlList.PageLoadFull, MapExtAttr.FK_MapData, frmID) == 1) { //执行通用的装载方法. MapAttrs attrs = new MapAttrs(frmID); MapDtls dtls = new MapDtls(frmID); wk = BP.WF.Glo.DealPageLoadFull(wk, me, attrs, dtls) as GEEntity; } //增加主表数据. DataTable mainTable = wk.ToDataTableField(md.No); mainTable.TableName = "MainTable"; myds.Tables.Add(mainTable); #endregion 主表数据 #region 从表数据 foreach (MapDtl dtl in md.MapDtls) { #region 返回指定的明细表的数据. if (DataType.IsNullOrEmpty(specDtlFrmID) == true) { } else { if (dtl.No != specDtlFrmID) { continue; } } #endregion 返回指定的明细表的数据. GEDtls dtls = new GEDtls(dtl.No); QueryObject qo = null; try { qo = new QueryObject(dtls); switch (dtl.DtlOpenType) { case DtlOpenType.ForEmp: // 按人员来控制. qo.AddWhere(GEDtlAttr.RefPK, pkval); qo.addAnd(); qo.AddWhere(GEDtlAttr.Rec, WebUser.No); break; case DtlOpenType.ForWorkID: // 按工作ID来控制 qo.AddWhere(GEDtlAttr.RefPK, pkval); break; case DtlOpenType.ForFID: // 按流程ID来控制. qo.AddWhere(GEDtlAttr.FID, pkval); break; } } catch { dtls.GetNewEntity.CheckPhysicsTable(); } //条件过滤. if (dtl.FilterSQLExp != "") { string[] strs = dtl.FilterSQLExp.Split('='); qo.addAnd(); qo.AddWhere(strs[0], strs[1]); } //从表 DataTable dtDtl = qo.DoQueryToTable(); // 为明细表设置默认值. MapAttrs dtlAttrs = new MapAttrs(dtl.No); foreach (MapAttr attr in dtlAttrs) { //处理它的默认值. if (attr.DefValReal.Contains("@") == false) { continue; } foreach (DataRow dr in dtDtl.Rows) { dr[attr.KeyOfEn] = attr.DefVal; } } dtDtl.TableName = string.IsNullOrWhiteSpace(dtl.Alias) ? dtl.No : dtl.Alias; //edited by liuxc,2017-10-10.如果有别名,则使用别名,没有则使用No myds.Tables.Add(dtDtl); //加入这个明细表, 如果没有数据,xml体现为空. } #endregion 从表数据 #region 主表的 外键表/枚举 dtMapAttr = myds.Tables["Sys_MapAttr"]; mes = md.MapExts; foreach (DataRow dr in dtMapAttr.Rows) { string uiBindKey = dr["UIBindKey"].ToString(); string myPK = dr["MyPK"].ToString(); string lgType = dr["LGType"].ToString(); if (lgType.Equals("1")) { // 如果是枚举值, 判断是否存在., if (myds.Tables.Contains(uiBindKey) == true) { continue; } string mysql = "SELECT IntKey AS No, Lab as Name FROM Sys_Enum WHERE EnumKey='" + uiBindKey + "' ORDER BY IntKey "; DataTable dtEnum = DBAccess.RunSQLReturnTable(mysql); dtEnum.TableName = uiBindKey; myds.Tables.Add(dtEnum); continue; } if (lgType.Equals("2") == false) { continue; } string UIIsEnable = dr["UIIsEnable"].ToString(); if (UIIsEnable.Equals("0")) { continue; } // 检查是否有下拉框自动填充。 string keyOfEn = dr["KeyOfEn"].ToString(); string fk_mapData = dr["FK_MapData"].ToString(); #region 处理下拉框数据范围. for 小杨. me = mes.GetEntityByKey(MapExtAttr.ExtType, MapExtXmlList.AutoFullDLL, MapExtAttr.AttrOfOper, keyOfEn) as MapExt; if (me != null) { string fullSQL = me.Doc.Clone() as string; fullSQL = fullSQL.Replace("~", ","); fullSQL = BP.WF.Glo.DealExp(fullSQL, wk, null); dt = DBAccess.RunSQLReturnTable(fullSQL); dt.TableName = myPK; //可能存在隐患,如果多个字段,绑定同一个表,就存在这样的问题. myds.Tables.Add(dt); continue; } #endregion 处理下拉框数据范围. dt = BP.Sys.PubClass.GetDataTableByUIBineKey(uiBindKey); dt.TableName = uiBindKey; myds.Tables.Add(dt); } #endregion 主表的 外键表/枚举 //返回生成的dataset. return(myds); }