private void LabelInvoke() { //1,获取主表与次表的表名,然后替换为 A. B. //{table1}.dbo.ZL_CommonModel left join {table1}.dbo.ZL_C_Article on {table1}.dbo.ZL_CommonModel.ArticleID={table1}.dbo.ZL_C_Article.aabbb M_Label labelMod = labelBll.GetLabelXML(LabelID); if (string.IsNullOrEmpty(labelMod.ProceParam)) { return; } M_SubLabel subMod = JsonConvert.DeserializeObject <M_SubLabel>(labelMod.ProceParam); Alias_T.Text = labelMod.LableName; T1_T.Text = subMod.PureT1; T2_T.Text = subMod.PureT2; labelMod.LabelField = PureStr(labelMod.LabelField, subMod); labelMod.LabelWhere = PureStr(labelMod.LabelWhere, subMod); labelMod.LabelOrder = PureStr(labelMod.LabelOrder, subMod); if (!string.IsNullOrEmpty(subMod.OnField2)) { //标签添加时,左边必定是主表,右边必定是次表 ONStr_T.Text = "A." + subMod.OnField1 + "=B." + subMod.OnField2; } Fields_T.Text = labelMod.LabelField; WhereStr_T.Text = labelMod.LabelWhere; OrderStr_T.Text = labelMod.LabelOrder; ReMark_T.Text = "调用标签" + labelMod.LableName; MyPK_T.Text = "A." + SqlHelper.ExecuteTable("SELECT TOP 1 * FROM " + subMod.PureT1 + " WHERE 1=2").Columns[0].ColumnName; //--------------- if (labelMod.ParamList.Count > 0) { Params_Hid.Value = JsonConvert.SerializeObject(labelMod.ParamList); } }
private string PureStr(string label, M_SubLabel subMod) { label = label.Replace("{table1}.dbo.", "").Replace("{table2}.dbo.", ""); return(label.Replace(subMod.PureT1, "A").Replace(subMod.PureT2, "B")); }