public void getTemplateHtml() { string tableName = HttpUtil.GetReqStrValue("tableName"); string templateName = HttpUtil.GetReqStrValue("templateName"); if (templateName.Equals("默认")) { //默认,根据tableName取获取模板 ITableImplement itable = new ITableImplement(); itable.setConn(conn).setModule(tableName); int i = 0; string html = ""; string tr = "<tr>"; foreach (AttributeItem attr in itable.af_AttributeItemList) { if (i % 2 == 0) { html += tr + "</tr>"; tr = "<tr>"; } TF_TB_FIELD conf2 = new TF_TB_FIELD(); conf2.FIELD_NAME = attr.FieldName; TF_TB_FIELD val = BLLTable <TF_TB_FIELD> .GetRowData(conf2); if (val != null) { tr += "<td>" + val.NOTE + "</td><td>[" + tableName + "." + attr.FieldName + "]</td>"; } else { tr += "<td>" + (string.IsNullOrEmpty(attr.ZhName) ? attr.FieldName : attr.ZhName) + "</td><td>[" + tableName + "." + attr.FieldName + "]</td>"; } i++; } Response.Write(DEFAULT_TEMPLATE_START + html + DEFAULT_TEMPLATE_END); return; } TF_CUSTOM_TEMPLATE conf = new TF_CUSTOM_TEMPLATE(); conf.TEMPLATE_NAME = templateName; conf.TABLE_NAME = tableName; conf.USER_ID = Convert.ToInt32(userBase.StaffID); conf.TYPE = 0; TF_CUSTOM_TEMPLATE valObj = BLLTable <TF_CUSTOM_TEMPLATE> .GetRowData(conf); if (valObj == null) { Response.Write(""); } else { Response.Write(valObj.TEMPLATE_HTML); } }
public void getTemplateHtml() { string tableName = HttpUtil.GetReqStrValue("tableName"); string templateName = HttpUtil.GetReqStrValue("templateName"); if (templateName.Equals("默认")) { //默认,根据tableName取获取模板 ITableImplement itable = new ITableImplement(); itable.setConn(conn).setModule(tableName); int i = 0; string html = ""; string tr = "<tr>"; foreach(AttributeItem attr in itable.af_AttributeItemList){ if (i % 2 == 0) { html += tr+"</tr>"; tr = "<tr>"; } TF_TB_FIELD conf2 = new TF_TB_FIELD(); conf2.FIELD_NAME = attr.FieldName; TF_TB_FIELD val = BLLTable<TF_TB_FIELD>.GetRowData(conf2); if (val != null) { tr += "<td>" + val.NOTE + "</td><td>[" + tableName + "." + attr.FieldName + "]</td>"; } else { tr += "<td>" + (string.IsNullOrEmpty(attr.ZhName) ? attr.FieldName : attr.ZhName )+ "</td><td>[" + tableName + "." + attr.FieldName + "]</td>"; } i++; } Response.Write(DEFAULT_TEMPLATE_START + html + DEFAULT_TEMPLATE_END); return; } TF_CUSTOM_TEMPLATE conf = new TF_CUSTOM_TEMPLATE(); conf.TEMPLATE_NAME = templateName; conf.TABLE_NAME = tableName; conf.USER_ID = Convert.ToInt32(userBase.StaffID); conf.TYPE = 0; TF_CUSTOM_TEMPLATE valObj=BLLTable<TF_CUSTOM_TEMPLATE>.GetRowData(conf); if (valObj == null) { Response.Write(""); } else { Response.Write(valObj.TEMPLATE_HTML); } }
private void getTemplateOptionsAndField() { string tableName = HttpUtil.GetReqStrValue("tableName"); TF_CUSTOM_TEMPLATE conf = new TF_CUSTOM_TEMPLATE(); conf.TABLE_NAME = tableName; conf.USER_ID = Convert.ToInt32(userBase.StaffID); conf.TYPE = 0; List <TF_CUSTOM_TEMPLATE> templateList = BLLTable <TF_CUSTOM_TEMPLATE> .Select(new TF_CUSTOM_TEMPLATE(), conf); string html = "<option value='-1'>--无--</option>"; if (tableName.Equals("-1")) { Response.Write("{\"html\":\"" + html + "\"}"); return; } foreach (TF_CUSTOM_TEMPLATE template in templateList) { html += "<option value='" + template.ID + "'>" + template.TEMPLATE_NAME + "</option>"; } ITableImplement itable = new ITableImplement(); itable.setConn(conn).setModule(tableName); DataBaseField[] dataBaseFields = itable.af_GetAvailableDataBaseField(); string fieldHtml = "<ul>"; foreach (DataBaseField dataBaseField in dataBaseFields) { TF_TB_FIELD conf2 = new TF_TB_FIELD(); conf2.FIELD_NAME = dataBaseField.FieldName; TF_TB_FIELD val2 = BLLTable <TF_TB_FIELD> .GetRowData(conf2); if (val2 != null) { fieldHtml += "<li><div fieldname='" + dataBaseField.FieldName + "'>" + (string.IsNullOrEmpty(val2.NOTE)? dataBaseField.FieldName : val2.NOTE) + "</div></li>"; } else { fieldHtml += "<li><div fieldname='" + dataBaseField.FieldName + "'>" + dataBaseField.FieldName + "</div></li>"; } } fieldHtml += "</ul>"; Response.Write("{\"html\":\"" + html + "\",\"fieldHtml\":\"" + fieldHtml + "\"}"); }
private void getTemplateNameOptions() { V_TF_TEMPLATE_TABLENAME conf = new V_TF_TEMPLATE_TABLENAME(); conf.Distinct = true; conf.USER_ID = Convert.ToInt32(userBase.StaffID); List <V_TF_TEMPLATE_TABLENAME> templateList = BLLTable <V_TF_TEMPLATE_TABLENAME> .Select(new V_TF_TEMPLATE_TABLENAME(), conf); string html = "<option value='-1'>--无--</option>"; foreach (V_TF_TEMPLATE_TABLENAME temp in templateList) { ITableImplement itable = new ITableImplement(); itable.setConn(conn).setModule(temp.TABLE_NAME); html += "<option value='" + temp.TABLE_NAME + "'>" + temp.CH_NAME + "</option>"; } Response.Write("{\"html\":\"" + html + "\"}"); }
/// <summary> /// retFlag /// retFlag:0 成功返回 1:失败 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { string action = HttpUtil.GetReqStrValue("action"); tableName = HttpUtil.GetReqStrValue("tableName"); valObj.setConn(conn).setModule(tableName, false, true); finderObj.setConn(conn).setModule(tableName, false, true); condObj.setConn(conn).setModule(tableName, false, true); try { fileds = getFieldList(valObj, true, false); } catch (Exception ex) { //报错则表名错误 retFlag = 1; Response.Write("{\"response\":{\"retFlag\":1,\"message\":\"表名错误\",\"method\":\"" + action + "\",\"tableName\":\"" + tableName + "\"},\"data\":{}}"); return; } switch (action) { case "save": save(); break; case "delete": delete(); break; case "select": select(); break; case "update": update(); break; } }
//递归遍历 public List <Dictionary <string, object> > selectReverse(Dictionary <string, object> map, List <Dictionary <string, object> > mapList, ITableImplement table) { string tableName = ""; //取值视图配置 ITableImplement valObj = new ITableImplement(); //条件视图配置 ITableImplement condObj = new ITableImplement(); Dictionary <string, object> flagMap = new Dictionary <string, object>(); Dictionary <string, Dictionary <string, object> > nextMap = new Dictionary <string, Dictionary <string, object> >(); foreach (var item in map) { // Dictionary<string, object> temp2List = new Dictionary<string, object>(); if (item.Key.Equals("tableName")) { tableName = item.Value.ToString(); valObj.setConn(conn).setModule(item.Value.ToString(), false, true); condObj.setConn(conn).setModule(item.Value.ToString(), false, true); } else if (item.Key.Equals("condition")) { condObj.af_WhereSQL = " " + item.Value; } else { if (item.Value is string) { valObj[item.Key] = item.Value; flagMap[item.Key] = item.Value; } else { flagMap[item.Key] = new object(); // valObj[item.Key] = temp3List; nextMap.Add(item.Key, (Dictionary <string, object>)item.Value); } } } if (table != null) { // foreach(ITableImplement table in tableList){ //条件视图配置 (这里要每次都new 一个 因为循环 每次都要同的条件) ITableImplement condObj2 = new ITableImplement(); condObj2.setConn(conn).setModule(tableName.ToString(), false, true); condObj2.af_WhereSQL = condObj.af_WhereSQL; DataBaseField[] dataBaseFields = table.af_GetAvailableDataBaseField(); foreach (DataBaseField dataBaseField in dataBaseFields) { condObj2.af_WhereSQL = condObj2.af_WhereSQL.Replace("{" + dataBaseField.FieldName + "}", "'" + table[dataBaseField.FieldName].ToString() + "'"); } condObj = condObj2; } List <ITableImplement> temp4List = BLLTable <ITableImplement> .Factory(conn).Select(valObj, condObj); foreach (ITableImplement itable in temp4List) { Dictionary <string, object> tempMap = new Dictionary <string, object>(); foreach (var flag in flagMap) { if (flag.Value is string) { tempMap.Add(flag.Key, itable[flag.Key]); } else { tempMap.Add(flag.Key, selectReverse(nextMap[flag.Key], new List <Dictionary <string, object> >(), itable)); } } mapList.Add(tempMap); } return(mapList); }
private void getTemplateOptionsAndField() { string tableName = HttpUtil.GetReqStrValue("tableName"); TF_CUSTOM_TEMPLATE conf = new TF_CUSTOM_TEMPLATE(); conf.TABLE_NAME = tableName; conf.USER_ID = Convert.ToInt32(userBase.StaffID); conf.TYPE = 0; List<TF_CUSTOM_TEMPLATE> templateList = BLLTable<TF_CUSTOM_TEMPLATE>.Select(new TF_CUSTOM_TEMPLATE(), conf); string html = "<option value='-1'>--无--</option>"; if (tableName.Equals("-1")) { Response.Write("{\"html\":\"" + html + "\"}"); return; } foreach(TF_CUSTOM_TEMPLATE template in templateList){ html += "<option value='"+template.ID+"'>"+template.TEMPLATE_NAME+"</option>"; } ITableImplement itable = new ITableImplement(); itable.setConn(conn).setModule(tableName); DataBaseField[] dataBaseFields = itable.af_GetAvailableDataBaseField(); string fieldHtml = "<ul>"; foreach (DataBaseField dataBaseField in dataBaseFields) { TF_TB_FIELD conf2 = new TF_TB_FIELD(); conf2.FIELD_NAME = dataBaseField.FieldName; TF_TB_FIELD val2 = BLLTable<TF_TB_FIELD>.GetRowData(conf2); if (val2 != null) { fieldHtml += "<li><div fieldname='" + dataBaseField.FieldName + "'>" + (string.IsNullOrEmpty(val2.NOTE)? dataBaseField.FieldName : val2.NOTE) + "</div></li>"; } else { fieldHtml += "<li><div fieldname='" + dataBaseField.FieldName + "'>" + dataBaseField.FieldName + "</div></li>"; } } fieldHtml += "</ul>"; Response.Write("{\"html\":\"" + html + "\",\"fieldHtml\":\"" + fieldHtml + "\"}"); }
private void getTemplateNameOptions() { V_TF_TEMPLATE_TABLENAME conf = new V_TF_TEMPLATE_TABLENAME(); conf.Distinct= true; conf.USER_ID =Convert.ToInt32(userBase.StaffID); List<V_TF_TEMPLATE_TABLENAME> templateList = BLLTable<V_TF_TEMPLATE_TABLENAME>.Select(new V_TF_TEMPLATE_TABLENAME(), conf); string html = "<option value='-1'>--无--</option>"; foreach (V_TF_TEMPLATE_TABLENAME temp in templateList) { ITableImplement itable = new ITableImplement(); itable.setConn(conn).setModule(temp.TABLE_NAME); html += "<option value='" + temp.TABLE_NAME + "'>" + temp.CH_NAME + "</option>"; } Response.Write("{\"html\":\"" + html + "\"}"); }
//递归遍历 public List<Dictionary<string, object>> selectReverse(Dictionary<string, object> map, List<Dictionary<string, object>> mapList,ITableImplement table) { string tableName = ""; //取值视图配置 ITableImplement valObj = new ITableImplement(); //条件视图配置 ITableImplement condObj = new ITableImplement(); Dictionary<string, object> flagMap = new Dictionary<string, object>(); Dictionary<string, Dictionary<string, object>> nextMap = new Dictionary<string, Dictionary<string, object>>(); foreach(var item in map){ // Dictionary<string, object> temp2List = new Dictionary<string, object>(); if (item.Key.Equals("tableName")) { tableName = item.Value.ToString(); valObj.setConn(conn).setModule(item.Value.ToString(), false, true); condObj.setConn(conn).setModule(item.Value.ToString(), false, true); }else if (item.Key.Equals("condition")){ condObj.af_WhereSQL = " " + item.Value; } else{ if (item.Value is string) { valObj[item.Key] = item.Value; flagMap[item.Key]= item.Value; } else { flagMap[item.Key]= new object(); // valObj[item.Key] = temp3List; nextMap.Add(item.Key, (Dictionary<string, object>)item.Value); } } } if (table != null) { // foreach(ITableImplement table in tableList){ //条件视图配置 (这里要每次都new 一个 因为循环 每次都要同的条件) ITableImplement condObj2 = new ITableImplement(); condObj2.setConn(conn).setModule(tableName.ToString(), false, true); condObj2.af_WhereSQL = condObj.af_WhereSQL; DataBaseField[] dataBaseFields = table.af_GetAvailableDataBaseField(); foreach (DataBaseField dataBaseField in dataBaseFields) { condObj2.af_WhereSQL = condObj2.af_WhereSQL.Replace("{" + dataBaseField.FieldName + "}", "'" + table[dataBaseField.FieldName].ToString() + "'"); } condObj = condObj2; } List<ITableImplement> temp4List = BLLTable<ITableImplement>.Factory(conn).Select(valObj, condObj); foreach (ITableImplement itable in temp4List) { Dictionary<string, object> tempMap = new Dictionary<string, object>(); foreach (var flag in flagMap) { if (flag.Value is string) { tempMap.Add(flag.Key, itable[flag.Key]); } else { tempMap.Add(flag.Key, selectReverse(nextMap[flag.Key], new List<Dictionary<string, object>>(), itable)); } } mapList.Add(tempMap); } return mapList; }
protected void Page_Load(object sender, EventArgs e) { ////id=1612&pid=161&no=1&name=%u8BE6%u7EC6%u5E03%u5C40&sc=0&ntype=TF_DESIGN_DETAIL&level=0111& // string id = HttpUtil.GetReqStrValue("id"); string pid = HttpUtil.GetReqStrValue("pid"); // string no = HttpUtil.GetReqStrValue("no"); // string name = HttpUtil.GetReqStrValue("name"); // string sc = HttpUtil.GetReqStrValue("sc"); // string ntype = HttpUtil.GetReqStrValue("ntype"); //DataBase db = DataBase.Factory(conn); //foreach (DataBaseTable dt1 in db.DataTables_USER) //{ // tableMap.Add(dt1.TableName,dt1.ZhName); //} TF_FORM conf1 = new TF_FORM(); conf1.FORM_ID = Convert.ToInt32(pid); TF_FORM val1 = new TF_FORM(); val1.TB_ID = 1; TF_FORM valObj1 = BLLTable <TF_FORM> .GetRowData(val1, conf1); TF_TABLE conf2 = new TF_TABLE(); conf2.TB_ID = valObj1.TB_ID; TF_TABLE val2 = new TF_TABLE(); val2.TB_NAME = ""; val2.CH_NAME = ""; val2.TB_ID = 0; TF_TABLE valObj2 = BLLTable <TF_TABLE> .GetRowData(val2, conf2); currTable = valObj2.TB_NAME; currZhTable = valObj2.CH_NAME; currTableId = valObj2.TB_ID; V_TF_TEMPLATE_TABLENAME conf = new V_TF_TEMPLATE_TABLENAME(); conf.Distinct = true; conf.USER_ID = Convert.ToInt32(userBase.StaffID); List <V_TF_TEMPLATE_TABLENAME> templateList = BLLTable <V_TF_TEMPLATE_TABLENAME> .Select(new V_TF_TEMPLATE_TABLENAME(), conf); foreach (V_TF_TEMPLATE_TABLENAME temp in templateList) { ITableImplement itable = new ITableImplement(); itable.setConn(conn).setModule(temp.TABLE_NAME); if (!tableMap.ContainsKey(temp.TABLE_NAME)) { tableMap.Add(temp.TABLE_NAME, temp.CH_NAME); } } TF_CUSTOM_TEMPLATE conf3 = new TF_CUSTOM_TEMPLATE(); conf3.TABLE_NAME = valObj2.TB_NAME; conf3.USER_ID = Convert.ToInt32(userBase.StaffID); conf3.TYPE = 0; List <TF_CUSTOM_TEMPLATE> templateList2 = BLLTable <TF_CUSTOM_TEMPLATE> .Select(new TF_CUSTOM_TEMPLATE(), conf3); html = "<option value='-1'>--无--</option>"; foreach (TF_CUSTOM_TEMPLATE template in templateList2) { if (template.STATUS == 1)//被选中 { selectedTempName = template.TEMPLATE_NAME; html += "<option value='" + template.ID + "' selected='selected'>" + template.TEMPLATE_NAME + "</option>"; } else { html += "<option value='" + template.ID + "'>" + template.TEMPLATE_NAME + "</option>"; } } ITableImplement itable2 = new ITableImplement(); itable2.setConn(conn).setModule(valObj2.TB_NAME); DataBaseField[] dataBaseFields = itable2.af_GetAvailableDataBaseField(); fieldHtml = "<ul>"; foreach (DataBaseField dataBaseField in dataBaseFields) { TF_TB_FIELD conf4 = new TF_TB_FIELD(); conf4.FIELD_NAME = dataBaseField.FieldName; TF_TB_FIELD val4 = BLLTable <TF_TB_FIELD> .GetRowData(conf4); if (val4 != null) { fieldHtml += "<li><div fieldname='" + dataBaseField.FieldName + "'>" + (string.IsNullOrEmpty(val4.NOTE)? dataBaseField.FieldName : val4.NOTE) + "</div></li>"; } else { fieldHtml += "<li><div fieldname='" + dataBaseField.FieldName + "'>" + dataBaseField.FieldName + "</div></li>"; } } fieldHtml += "</ul>"; // Response.Write("{\"html\":\"" + html + "\",\"fieldHtml\":\"" + fieldHtml + "\"}"); }
protected void Page_Load(object sender, EventArgs e) { ////id=1612&pid=161&no=1&name=%u8BE6%u7EC6%u5E03%u5C40&sc=0&ntype=TF_DESIGN_DETAIL&level=0111& // string id = HttpUtil.GetReqStrValue("id"); string pid = HttpUtil.GetReqStrValue("pid"); // string no = HttpUtil.GetReqStrValue("no"); // string name = HttpUtil.GetReqStrValue("name"); // string sc = HttpUtil.GetReqStrValue("sc"); // string ntype = HttpUtil.GetReqStrValue("ntype"); //DataBase db = DataBase.Factory(conn); //foreach (DataBaseTable dt1 in db.DataTables_USER) //{ // tableMap.Add(dt1.TableName,dt1.ZhName); //} TF_FORM conf1 = new TF_FORM(); conf1.FORM_ID = Convert.ToInt32(pid); TF_FORM val1 = new TF_FORM(); val1.TB_ID = 1; TF_FORM valObj1 = BLLTable<TF_FORM>.GetRowData(val1, conf1); TF_TABLE conf2 = new TF_TABLE(); conf2.TB_ID = valObj1.TB_ID; TF_TABLE val2 = new TF_TABLE(); val2.TB_NAME = ""; val2.CH_NAME = ""; val2.TB_ID = 0; TF_TABLE valObj2 = BLLTable<TF_TABLE>.GetRowData(val2, conf2); currTable = valObj2.TB_NAME; currZhTable = valObj2.CH_NAME; currTableId = valObj2.TB_ID; V_TF_TEMPLATE_TABLENAME conf = new V_TF_TEMPLATE_TABLENAME(); conf.Distinct = true; conf.USER_ID = Convert.ToInt32(userBase.StaffID); List<V_TF_TEMPLATE_TABLENAME> templateList = BLLTable<V_TF_TEMPLATE_TABLENAME>.Select(new V_TF_TEMPLATE_TABLENAME(), conf); foreach (V_TF_TEMPLATE_TABLENAME temp in templateList) { ITableImplement itable = new ITableImplement(); itable.setConn(conn).setModule(temp.TABLE_NAME); if (!tableMap.ContainsKey(temp.TABLE_NAME)) { tableMap.Add(temp.TABLE_NAME, temp.CH_NAME); } } TF_CUSTOM_TEMPLATE conf3 = new TF_CUSTOM_TEMPLATE(); conf3.TABLE_NAME = valObj2.TB_NAME; conf3.USER_ID = Convert.ToInt32(userBase.StaffID); conf3.TYPE = 0; List<TF_CUSTOM_TEMPLATE> templateList2 = BLLTable<TF_CUSTOM_TEMPLATE>.Select(new TF_CUSTOM_TEMPLATE(), conf3); html = "<option value='-1'>--无--</option>"; foreach (TF_CUSTOM_TEMPLATE template in templateList2) { if (template.STATUS == 1)//被选中 { selectedTempName = template.TEMPLATE_NAME; html += "<option value='" + template.ID + "' selected='selected'>" + template.TEMPLATE_NAME + "</option>"; } else { html += "<option value='" + template.ID + "'>" + template.TEMPLATE_NAME + "</option>"; } } ITableImplement itable2 = new ITableImplement(); itable2.setConn(conn).setModule(valObj2.TB_NAME); DataBaseField[] dataBaseFields = itable2.af_GetAvailableDataBaseField(); fieldHtml = "<ul>"; foreach (DataBaseField dataBaseField in dataBaseFields) { TF_TB_FIELD conf4 = new TF_TB_FIELD(); conf4.FIELD_NAME = dataBaseField.FieldName; TF_TB_FIELD val4 = BLLTable<TF_TB_FIELD>.GetRowData(conf4); if (val4 != null) { fieldHtml += "<li><div fieldname='" + dataBaseField.FieldName + "'>" + (string.IsNullOrEmpty(val4.NOTE)? dataBaseField.FieldName : val4.NOTE) + "</div></li>"; } else { fieldHtml += "<li><div fieldname='" + dataBaseField.FieldName + "'>" + dataBaseField.FieldName + "</div></li>"; } } fieldHtml += "</ul>"; // Response.Write("{\"html\":\"" + html + "\",\"fieldHtml\":\"" + fieldHtml + "\"}"); }