protected void bt_Decrease_Click(object sender, EventArgs e) { int rowindex = ((GridViewRow)((Button)sender).Parent.Parent).RowIndex; Guid id = (Guid)gv_List.DataKeys[rowindex][0]; Rpt_DataSetFieldsBLL bll = new Rpt_DataSetFieldsBLL(id); if (bll.Model.ColumnSortID > 0) { bll.Model.ColumnSortID--; } bll.Update(); IList <Rpt_DataSetFields> fields = new Rpt_DataSetBLL((Guid)ViewState["ID"]).GetFields(); Rpt_DataSetFields pre = fields.FirstOrDefault(p => p.ColumnSortID == bll.Model.ColumnSortID && p.ID != id); if (pre != null) { bll = new Rpt_DataSetFieldsBLL(pre.ID); if (bll.Model.ColumnSortID > 0) { bll.Model.ColumnSortID++; } bll.Update(); } BindGrid(); }
protected void Page_Load(object sender, System.EventArgs e) { // 在此处放置用户代码以初始化页面 if (!Page.IsPostBack) { #region 获取页面参数 ViewState["DataSet"] = Request.QueryString["DataSet"] != null ? new Guid(Request.QueryString["DataSet"]) : Guid.Empty; ViewState["ID"] = Request.QueryString["ID"] != null ? new Guid(Request.QueryString["ID"]) : Guid.Empty; #endregion #region 获取字段对应的数据集ID if ((Guid)ViewState["ID"] != Guid.Empty) { Rpt_DataSetFieldsBLL _bll = new Rpt_DataSetFieldsBLL((Guid)ViewState["ID"]); ViewState["DataSet"] = _bll.Model.DataSet; } if ((Guid)ViewState["DataSet"] == Guid.Empty) { Response.Redirect("Rpt_DataSetList.aspx"); } Rpt_DataSet dataset = new Rpt_DataSetBLL((Guid)ViewState["DataSet"]).Model; ViewState["DataSet_CommandType"] = dataset.CommandType; #endregion BindDropDown(); if ((Guid)ViewState["ID"] != Guid.Empty) { //修改 BindData(); } else { //新增 ddl_IsComputeField.SelectedValue = "Y"; ddl_IsComputeField.Enabled = false; ddl_IsComputeField_SelectedIndexChanged(null, null); int maxsortid = 0; IList <Rpt_DataSetFields> fields = new Rpt_DataSetBLL((Guid)ViewState["DataSet"]).GetFields(); if (fields.Count > 0) { maxsortid = fields.Max(p => p.ColumnSortID); } tbx_SortID.Text = (++maxsortid).ToString(); tbx_FieldName.Visible = true; ddl_DisplayMode.Enabled = false; tbx_TreeLevel.Enabled = false; bt_Delete.Visible = false; } } }
protected void bt_AddToDataSet_Click(object sender, EventArgs e) { IList <Rpt_DataSetFields> datasetfields = new Rpt_DataSetBLL((Guid)ViewState["ID"]).GetFields(); int maxsortid = 0; if (datasetfields.Count > 0) { maxsortid = datasetfields.Max(p => p.ColumnSortID); } foreach (ListItem item in cbxl_Fields.Items) { if (item.Selected) { Guid fieldid = new Guid(item.Value); UD_ModelFields f = new UD_ModelFieldsBLL(fieldid).Model; if (f != null) { string fieldname = new UD_TableListBLL(f.TableID).Model.ModelClassName + "_" + f.FieldName; if (datasetfields.FirstOrDefault(p => p.FieldName == fieldname) != null) { continue; } maxsortid++; Rpt_DataSetFieldsBLL fieldbll = new Rpt_DataSetFieldsBLL(); fieldbll.Model.DataSet = (Guid)ViewState["ID"]; fieldbll.Model.FieldID = f.ID; fieldbll.Model.FieldName = fieldname; fieldbll.Model.DisplayName = f.DisplayName; fieldbll.Model.DataType = f.DataType; fieldbll.Model.IsComputeField = "N"; fieldbll.Model.ColumnSortID = maxsortid; if (f.RelationType == 1 || f.RelationType == 2) { fieldbll.Model.DisplayMode = 2; } else { fieldbll.Model.DisplayMode = 1; } fieldbll.Model.Description = f.Description; fieldbll.Add(); } } } BindGrid(); new Rpt_DataSetBLL((Guid)ViewState["ID"]).ClearCache(); }
protected void bt_Expand_Click(object sender, EventArgs e) { Rpt_DataSetFields m = new Rpt_DataSetFieldsBLL((Guid)ViewState["ID"]).Model; if (m == null || m.TreeLevel != 0) return; UD_ModelFields field = new UD_ModelFieldsBLL(m.FieldID).Model; if (field == null) return; //如果关联表是树形结构,则允许设定树表层次 if (field.RelationType == 2 && new UD_TableListBLL(field.RelationTableName).Model.TreeFlag == "Y") { int maxsortid = 0; IList<Rpt_DataSetFields> datasetfields = new Rpt_DataSetBLL((Guid)ViewState["DataSet"]).GetFields(); if (datasetfields.Count > 0) maxsortid = datasetfields.Max(p => p.ColumnSortID); Dictionary<string, Dictionary_Data> levels; if (field.RelationTableName == "MCS_SYS.dbo.Addr_OrganizeCity") levels = DictionaryBLL.GetDicCollections("Addr_OrganizeCityLevel");//关联至管理片区 else if (field.RelationTableName == "MCS_SYS.dbo.Addr_OfficialCity") levels = DictionaryBLL.GetDicCollections("Addr_OfficialCityLevel"); //关联至行政城市 else return; foreach (string level in levels.Keys) { string fieldname = m.FieldName + level; if (datasetfields.FirstOrDefault(p => p.FieldName == fieldname) == null) { maxsortid++; Rpt_DataSetFieldsBLL fieldbll = new Rpt_DataSetFieldsBLL(); fieldbll.Model.DataSet = (Guid)ViewState["DataSet"]; fieldbll.Model.FieldID = field.ID; fieldbll.Model.FieldName = fieldname; fieldbll.Model.DisplayName = levels[level].Name; fieldbll.Model.DataType = 3; //固定为字符串型 fieldbll.Model.IsComputeField = "N"; fieldbll.Model.ColumnSortID = maxsortid; fieldbll.Model.DisplayMode = 2; fieldbll.Model.TreeLevel = int.Parse(level); fieldbll.Model.Description = field.Description; fieldbll.Add(); } } MessageBox.ShowAndRedirect(this, "展开级别成功!", "Rpt_DataSetFieldsList.aspx?ID=" + ViewState["DataSet"].ToString()); } }
protected void bt_AddToDataSet_Click(object sender, EventArgs e) { IList<Rpt_DataSetFields> datasetfields = new Rpt_DataSetBLL((Guid)ViewState["ID"]).GetFields(); int maxsortid = 0; if (datasetfields.Count > 0) maxsortid = datasetfields.Max(p => p.ColumnSortID); foreach (ListItem item in cbxl_Fields.Items) { if (item.Selected) { Guid fieldid = new Guid(item.Value); UD_ModelFields f = new UD_ModelFieldsBLL(fieldid).Model; if (f != null) { string fieldname = new UD_TableListBLL(f.TableID).Model.ModelClassName + "_" + f.FieldName; if (datasetfields.FirstOrDefault(p => p.FieldName == fieldname) != null) continue; maxsortid++; Rpt_DataSetFieldsBLL fieldbll = new Rpt_DataSetFieldsBLL(); fieldbll.Model.DataSet = (Guid)ViewState["ID"]; fieldbll.Model.FieldID = f.ID; fieldbll.Model.FieldName = fieldname; fieldbll.Model.DisplayName = f.DisplayName; fieldbll.Model.DataType = f.DataType; fieldbll.Model.IsComputeField = "N"; fieldbll.Model.ColumnSortID = maxsortid; if (f.RelationType == 1 || f.RelationType == 2) fieldbll.Model.DisplayMode = 2; else fieldbll.Model.DisplayMode = 1; fieldbll.Model.Description = f.Description; fieldbll.Add(); } } } BindGrid(); new Rpt_DataSetBLL((Guid)ViewState["ID"]).ClearCache(); }
protected void bt_Decrease_Click(object sender, EventArgs e) { int rowindex = ((GridViewRow)((Button)sender).Parent.Parent).RowIndex; Guid id = (Guid)gv_List.DataKeys[rowindex][0]; Rpt_DataSetFieldsBLL bll = new Rpt_DataSetFieldsBLL(id); if (bll.Model.ColumnSortID > 0) bll.Model.ColumnSortID--; bll.Update(); IList<Rpt_DataSetFields> fields = new Rpt_DataSetBLL((Guid)ViewState["ID"]).GetFields(); Rpt_DataSetFields pre = fields.FirstOrDefault(p => p.ColumnSortID == bll.Model.ColumnSortID && p.ID != id); if (pre != null) { bll = new Rpt_DataSetFieldsBLL(pre.ID); if (bll.Model.ColumnSortID > 0) bll.Model.ColumnSortID++; bll.Update(); } BindGrid(); }
protected void bt_Refresh_Click(object sender, EventArgs e) { Rpt_DataSetBLL bll = new Rpt_DataSetBLL((Guid)ViewState["ID"]); bll.ClearCache(); #region 初始化参数 Dictionary<string, object> prams = new Dictionary<string, object>(); foreach (Rpt_DataSetParams p in bll.GetParams()) { object value; switch (p.DataType) { case 1: //整型(int) case 2: //小数(decimal) case 7: //位(bit) value = 0; break; case 3: //字符串(varchar) case 6: //字符串(nvarchar) case 8: //ntext value = ""; break; case 4: //日期(datetime) value = "1900-1-1"; break; case 5: //GUID(uniqueidentifier) value = Guid.Empty.ToString(); break; default: value = ""; break; } prams.Add(p.ParamName, value); } #endregion DateTime t; DataTable dt = bll.GetData(prams, false, out t); IList<Rpt_DataSetFields> fields = bll.GetFields(); #region 加入数据集中不包括的列 foreach (DataColumn column in dt.Columns) { if (fields.FirstOrDefault(p => p.FieldName == column.ColumnName) == null) { Rpt_DataSetFieldsBLL field = new Rpt_DataSetFieldsBLL(); field.Model.DataSet = (Guid)ViewState["ID"]; field.Model.FieldName = column.ColumnName; field.Model.DisplayName = column.ColumnName; field.Model.ColumnSortID = column.Ordinal + 1; field.Model.DisplayMode = 1; field.Model.TreeLevel = 0; field.Model.IsComputeField = "N"; #region 数据类型 switch (column.DataType.FullName) { case "System.Int16": case "System.Int32": case "System.Int64": field.Model.DataType = 1; //整形 break; case "System.String": field.Model.DataType = 3; //字符串 break; case "System.Decimal": field.Model.DataType = 2; //小数 break; case "System.DateTime": field.Model.DataType = 4; //日期 break; case "System.Guid": field.Model.DataType = 5; //GUID break; default: field.Model.DataType = 3; //字符串 break; } #endregion field.Add(); } } #endregion #region 删除数据表中不存在的列 foreach (Rpt_DataSetFields f in fields) { if (f.IsComputeField == "Y") continue; if (!dt.Columns.Contains(f.FieldName)) { new Rpt_DataSetFieldsBLL(f.ID).Delete(); } } #endregion gv_List.PageIndex = 0; BindGrid(); MessageBox.Show(this, "数据集字段刷新成功!"); }
protected void bt_Expand_Click(object sender, EventArgs e) { Rpt_DataSetFields m = new Rpt_DataSetFieldsBLL((Guid)ViewState["ID"]).Model; if (m == null || m.TreeLevel != 0) { return; } UD_ModelFields field = new UD_ModelFieldsBLL(m.FieldID).Model; if (field == null) { return; } //如果关联表是树形结构,则允许设定树表层次 if (field.RelationType == 2 && new UD_TableListBLL(field.RelationTableName).Model.TreeFlag == "Y") { int maxsortid = 0; IList <Rpt_DataSetFields> datasetfields = new Rpt_DataSetBLL((Guid)ViewState["DataSet"]).GetFields(); if (datasetfields.Count > 0) { maxsortid = datasetfields.Max(p => p.ColumnSortID); } Dictionary <string, Dictionary_Data> levels; if (field.RelationTableName == "MCS_SYS.dbo.Addr_OrganizeCity") { levels = DictionaryBLL.GetDicCollections("Addr_OrganizeCityLevel");//关联至管理片区 } else if (field.RelationTableName == "MCS_SYS.dbo.Addr_OfficialCity") { levels = DictionaryBLL.GetDicCollections("Addr_OfficialCityLevel"); //关联至行政城市 } else { return; } foreach (string level in levels.Keys) { string fieldname = m.FieldName + level; if (datasetfields.FirstOrDefault(p => p.FieldName == fieldname) == null) { maxsortid++; Rpt_DataSetFieldsBLL fieldbll = new Rpt_DataSetFieldsBLL(); fieldbll.Model.DataSet = (Guid)ViewState["DataSet"]; fieldbll.Model.FieldID = field.ID; fieldbll.Model.FieldName = fieldname; fieldbll.Model.DisplayName = levels[level].Name; fieldbll.Model.DataType = 3; //固定为字符串型 fieldbll.Model.IsComputeField = "N"; fieldbll.Model.ColumnSortID = maxsortid; fieldbll.Model.DisplayMode = 2; fieldbll.Model.TreeLevel = int.Parse(level); fieldbll.Model.Description = field.Description; fieldbll.Add(); } } MessageBox.ShowAndRedirect(this, "展开级别成功!", "Rpt_DataSetFieldsList.aspx?ID=" + ViewState["DataSet"].ToString()); } }
protected void bt_OK_Click(object sender, EventArgs e) { Rpt_DataSetFieldsBLL _bll; if ((Guid)ViewState["ID"] != Guid.Empty) { _bll = new Rpt_DataSetFieldsBLL((Guid)ViewState["ID"]); } else { _bll = new Rpt_DataSetFieldsBLL(); } _bll.Model.DataSet = (Guid)ViewState["DataSet"]; _bll.Model.FieldName = tbx_FieldName.Text; _bll.Model.DisplayName = tbx_DisplayName.Text; _bll.Model.DataType = int.Parse(ddl_DataType.SelectedValue); _bll.Model.Description = tbx_Description.Text; if (ddl_IsComputeField.SelectedValue == "Y") { _bll.Model.IsComputeField = "Y"; _bll.Model.Expression = tbx_Expression.Text.Trim(); if (_bll.Model.Expression == "") { tbx_Expression.Focus(); MessageBox.Show(this, "请正确录入计算列的表达式!"); return; } } else { _bll.Model.IsComputeField = "N"; _bll.Model.Expression = ""; } if (tbx_SortID.Text != "") { _bll.Model.ColumnSortID = int.Parse(tbx_SortID.Text); } _bll.Model.DisplayMode = int.Parse(ddl_DisplayMode.SelectedValue); #region 树形字段有指定层次时,重设字段名 //要与查询条件生成的字段要一致,以便支持多同一树形字段多列显示 if (tbx_TreeLevel.Enabled) { UD_ModelFields f = new UD_ModelFieldsBLL(_bll.Model.FieldID).Model; if (new UD_TableListBLL(f.RelationTableName).Model.TreeFlag == "Y") { int level = 0; int.TryParse(tbx_TreeLevel.Text, out level); _bll.Model.TreeLevel = level; UD_TableList t = new UD_TableListBLL(f.TableID).Model; if (level > 0) { _bll.Model.FieldName = t.ModelClassName + "_" + f.FieldName + level.ToString(); } else { _bll.Model.FieldName = t.ModelClassName + "_" + f.FieldName; } } } #endregion if (Rpt_DataSetFieldsBLL.GetModelList("DataSet='" + _bll.Model.DataSet.ToString() + "' AND FieldName='" + _bll.Model.FieldName + "' AND ID <>'" + _bll.Model.ID.ToString() + "'").Count > 0) { MessageBox.Show(this, "对不起,字段名已重复,请更改字段名称!"); return; } if ((Guid)ViewState["ID"] != Guid.Empty) { _bll.Update(); } else { _bll.Add(); } new Rpt_DataSetBLL((Guid)ViewState["DataSet"]).ClearCache(); Response.Redirect("Rpt_DataSetFieldsList.aspx?ID=" + ViewState["DataSet"].ToString()); }
private void BindData() { Rpt_DataSetFieldsBLL _bll = new Rpt_DataSetFieldsBLL((Guid)ViewState["ID"]); ViewState["DataSet"] = _bll.Model.DataSet; ddl_IsComputeField.SelectedValue = _bll.Model.IsComputeField; ddl_IsComputeField_SelectedIndexChanged(null, null); tbx_Expression.Text = _bll.Model.Expression; if (_bll.Model.FieldID != Guid.Empty) { #region 设置关联字段界面控件属性 UD_ModelFields field = new UD_ModelFieldsBLL(_bll.Model.FieldID).Model; if (field == null) { return; } if (field.RelationType == 1 || field.RelationType == 2) { ddl_DisplayMode.Enabled = true; //如果关联表是树形结构,则允许设定树表层次 if (field.RelationType == 2 && new UD_TableListBLL(field.RelationTableName).Model.TreeFlag == "Y") { tbx_TreeLevel.Enabled = true; if (_bll.Model.TreeLevel == 0 && (field.RelationTableName == "MCS_SYS.dbo.Addr_OrganizeCity" || field.RelationTableName == "MCS_SYS.dbo.Addr_OfficialCity")) { bt_Expand.Visible = true; //如果字段关联于管理片区或行政城市,显示"展开层级"按钮 } } else { tbx_TreeLevel.Text = ""; tbx_TreeLevel.Enabled = false; } } else { ddl_DisplayMode.Enabled = false; ddl_DisplayMode.SelectedValue = "1"; tbx_TreeLevel.Text = ""; tbx_TreeLevel.Enabled = false; } #endregion } tbx_FieldName.Text = _bll.Model.FieldName; tbx_DisplayName.Text = _bll.Model.DisplayName; ddl_DataType.SelectedValue = _bll.Model.DataType.ToString(); tbx_Description.Text = _bll.Model.Description; tbx_SortID.Text = _bll.Model.ColumnSortID.ToString(); tbx_TreeLevel.Text = _bll.Model.TreeLevel.ToString(); ddl_DisplayMode.SelectedValue = _bll.Model.DisplayMode.ToString(); tbx_FieldName.Enabled = false; ddl_IsComputeField.Enabled = false; bt_OK.Text = "修 改"; bt_OK.ForeColor = System.Drawing.Color.Red; if ((int)ViewState["DataSet_CommandType"] == 1 || (int)ViewState["DataSet_CommandType"] == 2) { tbx_FieldName.Visible = true; ddl_DisplayMode.Enabled = false; tbx_TreeLevel.Enabled = false; if (_bll.Model.IsComputeField != "Y") { bt_Delete.Visible = false; } } }
protected void bt_Refresh_Click(object sender, EventArgs e) { Rpt_DataSetBLL bll = new Rpt_DataSetBLL((Guid)ViewState["ID"]); bll.ClearCache(); #region 初始化参数 Dictionary <string, object> prams = new Dictionary <string, object>(); foreach (Rpt_DataSetParams p in bll.GetParams()) { object value; switch (p.DataType) { case 1: //整型(int) case 2: //小数(decimal) case 7: //位(bit) value = 0; break; case 3: //字符串(varchar) case 6: //字符串(nvarchar) case 8: //ntext value = ""; break; case 4: //日期(datetime) value = "1900-1-1"; break; case 5: //GUID(uniqueidentifier) value = Guid.Empty.ToString(); break; default: value = ""; break; } prams.Add(p.ParamName, value); } #endregion DateTime t; DataTable dt = bll.GetData(prams, false, out t); IList <Rpt_DataSetFields> fields = bll.GetFields(); #region 加入数据集中不包括的列 foreach (DataColumn column in dt.Columns) { if (fields.FirstOrDefault(p => p.FieldName == column.ColumnName) == null) { Rpt_DataSetFieldsBLL field = new Rpt_DataSetFieldsBLL(); field.Model.DataSet = (Guid)ViewState["ID"]; field.Model.FieldName = column.ColumnName; field.Model.DisplayName = column.ColumnName; field.Model.ColumnSortID = column.Ordinal + 1; field.Model.DisplayMode = 1; field.Model.TreeLevel = 0; field.Model.IsComputeField = "N"; #region 数据类型 switch (column.DataType.FullName) { case "System.Int16": case "System.Int32": case "System.Int64": field.Model.DataType = 1; //整形 break; case "System.String": field.Model.DataType = 3; //字符串 break; case "System.Decimal": field.Model.DataType = 2; //小数 break; case "System.DateTime": field.Model.DataType = 4; //日期 break; case "System.Guid": field.Model.DataType = 5; //GUID break; default: field.Model.DataType = 3; //字符串 break; } #endregion field.Add(); } } #endregion #region 除数据表中不存在的列 foreach (Rpt_DataSetFields f in fields) { if (f.IsComputeField == "Y") { continue; } if (!dt.Columns.Contains(f.FieldName)) { new Rpt_DataSetFieldsBLL(f.ID).Delete(); } } #endregion gv_List.PageIndex = 0; BindGrid(); MessageBox.Show(this, "数据集字段刷新成功!"); }
protected void bt_OK_Click(object sender, EventArgs e) { Rpt_DataSetFieldsBLL _bll; if ((Guid)ViewState["ID"] != Guid.Empty) _bll = new Rpt_DataSetFieldsBLL((Guid)ViewState["ID"]); else _bll = new Rpt_DataSetFieldsBLL(); _bll.Model.DataSet = (Guid)ViewState["DataSet"]; _bll.Model.FieldName = tbx_FieldName.Text; _bll.Model.DisplayName = tbx_DisplayName.Text; _bll.Model.DataType = int.Parse(ddl_DataType.SelectedValue); _bll.Model.Description = tbx_Description.Text; if (ddl_IsComputeField.SelectedValue == "Y") { _bll.Model.IsComputeField = "Y"; _bll.Model.Expression = tbx_Expression.Text.Trim(); if (_bll.Model.Expression == "") { tbx_Expression.Focus(); MessageBox.Show(this, "请正确录入计算列的表达式!"); return; } } else { _bll.Model.IsComputeField = "N"; _bll.Model.Expression = ""; } if (tbx_SortID.Text != "") _bll.Model.ColumnSortID = int.Parse(tbx_SortID.Text); _bll.Model.DisplayMode = int.Parse(ddl_DisplayMode.SelectedValue); #region 树形字段有指定层次时,重设字段名 //要与查询条件生成的字段要一致,以便支持多同一树形字段多列显示 if (tbx_TreeLevel.Enabled) { UD_ModelFields f = new UD_ModelFieldsBLL(_bll.Model.FieldID).Model; if (new UD_TableListBLL(f.RelationTableName).Model.TreeFlag == "Y") { int level = 0; int.TryParse(tbx_TreeLevel.Text, out level); _bll.Model.TreeLevel = level; UD_TableList t = new UD_TableListBLL(f.TableID).Model; if (level > 0) _bll.Model.FieldName = t.ModelClassName + "_" + f.FieldName + level.ToString(); else _bll.Model.FieldName = t.ModelClassName + "_" + f.FieldName; } } #endregion if (Rpt_DataSetFieldsBLL.GetModelList("DataSet='" + _bll.Model.DataSet.ToString() + "' AND FieldName='" + _bll.Model.FieldName + "' AND ID <>'" + _bll.Model.ID.ToString() + "'").Count > 0) { MessageBox.Show(this, "对不起,字段名已重复,请更改字段名称!"); return; } if ((Guid)ViewState["ID"] != Guid.Empty) { _bll.Update(); } else { _bll.Add(); } new Rpt_DataSetBLL((Guid)ViewState["DataSet"]).ClearCache(); Response.Redirect("Rpt_DataSetFieldsList.aspx?ID=" + ViewState["DataSet"].ToString()); }
private void BindData() { Rpt_DataSetFieldsBLL _bll = new Rpt_DataSetFieldsBLL((Guid)ViewState["ID"]); ViewState["DataSet"] = _bll.Model.DataSet; ddl_IsComputeField.SelectedValue = _bll.Model.IsComputeField; ddl_IsComputeField_SelectedIndexChanged(null, null); tbx_Expression.Text = _bll.Model.Expression; if (_bll.Model.FieldID != Guid.Empty) { #region 设置关联字段界面控件属性 UD_ModelFields field = new UD_ModelFieldsBLL(_bll.Model.FieldID).Model; if (field == null) return; if (field.RelationType == 1 || field.RelationType == 2) { ddl_DisplayMode.Enabled = true; //如果关联表是树形结构,则允许设定树表层次 if (field.RelationType == 2 && new UD_TableListBLL(field.RelationTableName).Model.TreeFlag == "Y") { tbx_TreeLevel.Enabled = true; if (_bll.Model.TreeLevel == 0 && (field.RelationTableName == "MCS_SYS.dbo.Addr_OrganizeCity" || field.RelationTableName == "MCS_SYS.dbo.Addr_OfficialCity")) { bt_Expand.Visible = true; //如果字段关联于管理片区或行政城市,显示"展开层级"按钮 } } else { tbx_TreeLevel.Text = ""; tbx_TreeLevel.Enabled = false; } } else { ddl_DisplayMode.Enabled = false; ddl_DisplayMode.SelectedValue = "1"; tbx_TreeLevel.Text = ""; tbx_TreeLevel.Enabled = false; } #endregion } tbx_FieldName.Text = _bll.Model.FieldName; tbx_DisplayName.Text = _bll.Model.DisplayName; ddl_DataType.SelectedValue = _bll.Model.DataType.ToString(); tbx_Description.Text = _bll.Model.Description; tbx_SortID.Text = _bll.Model.ColumnSortID.ToString(); tbx_TreeLevel.Text = _bll.Model.TreeLevel.ToString(); ddl_DisplayMode.SelectedValue = _bll.Model.DisplayMode.ToString(); tbx_FieldName.Enabled = false; ddl_IsComputeField.Enabled = false; bt_OK.Text = "修 改"; bt_OK.ForeColor = System.Drawing.Color.Red; if ((int)ViewState["DataSet_CommandType"] == 1 || (int)ViewState["DataSet_CommandType"] == 2) { tbx_FieldName.Visible = true; ddl_DisplayMode.Enabled = false; tbx_TreeLevel.Enabled = false; if (_bll.Model.IsComputeField != "Y") bt_Delete.Visible = false; } }
protected void Page_Load(object sender, System.EventArgs e) { // 在此处放置用户代码以初始化页面 if (!Page.IsPostBack) { #region 获取页面参数 ViewState["DataSet"] = Request.QueryString["DataSet"] != null ? new Guid(Request.QueryString["DataSet"]) : Guid.Empty; ViewState["ID"] = Request.QueryString["ID"] != null ? new Guid(Request.QueryString["ID"]) : Guid.Empty; #endregion #region 获取字段对应的数据集ID if ((Guid)ViewState["ID"] != Guid.Empty) { Rpt_DataSetFieldsBLL _bll = new Rpt_DataSetFieldsBLL((Guid)ViewState["ID"]); ViewState["DataSet"] = _bll.Model.DataSet; } if ((Guid)ViewState["DataSet"] == Guid.Empty) { Response.Redirect("Rpt_DataSetList.aspx"); } Rpt_DataSet dataset = new Rpt_DataSetBLL((Guid)ViewState["DataSet"]).Model; ViewState["DataSet_CommandType"] = dataset.CommandType; #endregion BindDropDown(); if ((Guid)ViewState["ID"] != Guid.Empty) { //修改 BindData(); } else { //新增 ddl_IsComputeField.SelectedValue = "Y"; ddl_IsComputeField.Enabled = false; ddl_IsComputeField_SelectedIndexChanged(null, null); int maxsortid = 0; IList<Rpt_DataSetFields> fields = new Rpt_DataSetBLL((Guid)ViewState["DataSet"]).GetFields(); if (fields.Count > 0) maxsortid = fields.Max(p => p.ColumnSortID); tbx_SortID.Text = (++maxsortid).ToString(); tbx_FieldName.Visible = true; ddl_DisplayMode.Enabled = false; tbx_TreeLevel.Enabled = false; bt_Delete.Visible = false; } } }