protected void bt_Save_Click(object sender, EventArgs e) { if ((Guid)ViewState["ID"] != Guid.Empty) { Rpt_DataSetBLL datasetbll = new Rpt_DataSetBLL((Guid)ViewState["ID"]); string _text = ""; string _value = ""; foreach (ListItem lt in lbx_search.Items) { if (lt.Value != "") { _text += lt.Text + "||"; _value += lt.Value + "||"; } } datasetbll.Model.ConditionText = _text; datasetbll.Model.ConditionValue = _value; datasetbll.Model.ConditionSQL = GenarateSQL(); datasetbll.Update(); new Rpt_DataSetBLL((Guid)ViewState["ID"]).ClearCache(); MessageBox.Show(this.Page, "高级条件保存成功!"); } }
private void BindData() { Rpt_DataSet m = new Rpt_DataSetBLL((Guid)ViewState["ID"]).Model; if (m != null) { pl_detail.BindData(m); pl_detail.SetPanelVisible("Panel_Rpt_DataSet_Detail_SQL", m.CommandType != 3); #region 根据数据集类型控制Tab可见 switch (m.CommandType) { case 1: case 2: MCSTabControl1.Items[2].Visible = false; MCSTabControl1.Items[3].Visible = false; MCSTabControl1.Items[5].Visible = false; break; case 3: break; default: break; } #endregion } }
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(); }
private void BindDataSetFields() { Rpt_ReportBLL report = new Rpt_ReportBLL((Guid)ViewState["ID"]); IList <Rpt_DataSetFields> fields = new Rpt_DataSetBLL((Guid)ViewState["DataSet"]).GetFields(); foreach (Rpt_ReportColumnGroups col in report.GetColumnGroups()) { Rpt_DataSetFields f = fields.FirstOrDefault(p => p.ID == col.DataSetField); if (f != null) { fields.Remove(f); } } foreach (Rpt_ReportRowGroups col in report.GetRowGroups()) { Rpt_DataSetFields f = fields.FirstOrDefault(p => p.ID == col.DataSetField); if (f != null) { fields.Remove(f); } } foreach (Rpt_ReportValueGroups col in report.GetValueGroups()) { Rpt_DataSetFields f = fields.FirstOrDefault(p => p.ID == col.DataSetField); if (f != null) { fields.Remove(f); } } cbxl_Fields.DataSource = fields; cbxl_Fields.DataBind(); }
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 Page_Load(object sender, System.EventArgs e) { // 在此处放置用户代码以初始化页面 if (!Page.IsPostBack) { #region 获取页面参数 ViewState["ID"] = Request.QueryString["ID"] != null ? new Guid(Request.QueryString["ID"]) : Guid.Empty; #endregion BindDropDown(); if ((Guid)ViewState["ID"] != Guid.Empty) { #region 绑定页面数据集信息 Rpt_DataSet m = new Rpt_DataSetBLL((Guid)ViewState["ID"]).Model; if (m != null) { lb_DataSetName.Text = m.Name; #region 根据数据集类型控制Tab可见 switch (m.CommandType) { case 1: case 2: MCSTabControl1.Items[2].Visible = false; MCSTabControl1.Items[3].Visible = false; MCSTabControl1.Items[5].Visible = false; break; case 3: break; default: break; } #endregion if (m.CommandType == 3) { bt_Refresh.Visible = false; } else { td_TableFields.Visible = false; gv_List.Columns[gv_List.Columns.Count - 1].Visible = false; } } #endregion BindGrid(); } else { Response.Redirect("Rpt_DataSetList.aspx"); } } }
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_OK_Click(object sender, EventArgs e) { Rpt_DataSetBLL _bll; if ((Guid)ViewState["ID"] != Guid.Empty) { //修改 _bll = new Rpt_DataSetBLL((Guid)ViewState["ID"]); } else { //新增 _bll = new Rpt_DataSetBLL(); } pl_detail.GetData(_bll.Model); #region 判断必填项 if (_bll.Model.CommandType == 0) { MessageBox.Show(this, "语句类型必填!"); return; } if (_bll.Model.DataSource == Guid.Empty) { MessageBox.Show(this, "数据源必填!"); return; } #endregion if ((Guid)ViewState["ID"] != Guid.Empty) { //修改 _bll.Model.UpdateStaff = (int)Session["UserID"]; if (_bll.Update() == 0) { _bll.ClearCache(); MessageBox.ShowAndRedirect(this, "修改成功!", "Rpt_DataSetDetail.aspx?ID=" + _bll.Model.ID.ToString()); } } else { //新增 _bll.Model.InsertStaff = (int)Session["UserID"]; if (_bll.Add() == 0) { MessageBox.ShowAndRedirect(this, "新增成功!", "Rpt_DataSetDetail.aspx?ID=" + _bll.Model.ID.ToString()); } } }
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_ViewSQL_Click(object sender, EventArgs e) { Rpt_DataSetBLL m = new Rpt_DataSetBLL((Guid)ViewState["ID"]); if (m.Model.CommandType == 1 || m.Model.CommandType == 2) { lb_ViewSQL.Text = m.Model.CommandText; } else { if (m.GetFields().Count > 0) { lb_ViewSQL.Text = m.GetDataSetSQL(); } } }
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 BindDropDown(); if ((Guid)ViewState["ID"] != Guid.Empty) { //修改 BindData(); td_TemParam.Visible = false; } else { //新增 if ((Guid)ViewState["DataSet"] == Guid.Empty) { Response.Redirect("Rpt_DataSetList.aspx"); } bt_Delete.Visible = false; TextBox tbx_ParamSortID = (TextBox)pl_detail.FindControl("Rpt_DataSetParams_ParamSortID"); if (tbx_ParamSortID != null) { int maxsortid = 0; IList <Rpt_DataSetParams> paramlist = new Rpt_DataSetBLL((Guid)ViewState["DataSet"]).GetParams(); if (paramlist.Count > 0) { maxsortid = paramlist.Max(p => p.ParamSortID); } tbx_ParamSortID.Text = (++maxsortid).ToString(); ViewState["MaxSortID"] = maxsortid; } } } }
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 gv_List_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { IList <Rpt_DataSetFields> fields = new Rpt_DataSetBLL((Guid)ViewState["ID"]).GetFields(); if (fields.Count > 0) { Guid id = (Guid)gv_List.DataKeys[e.Row.RowIndex][0]; if (id == fields[0].ID) { e.Row.FindControl("bt_Decrease").Visible = false; } if (id == fields[fields.Count - 1].ID) { e.Row.FindControl("bt_Increase").Visible = false; } } } }
/// <summary> /// 载入高级查询条件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void LoadCondition() { lbx_search.Items.Clear(); if ((Guid)ViewState["ID"] != Guid.Empty) { Rpt_DataSet dataset = new Rpt_DataSetBLL((Guid)ViewState["ID"]).Model; if (dataset != null && !string.IsNullOrEmpty(dataset.ConditionText)) { string[] charSeparators = new string[] { "||" }; string[] _texts = dataset.ConditionText.Split(charSeparators, StringSplitOptions.RemoveEmptyEntries); string[] _values = dataset.ConditionValue.Split(charSeparators, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < _texts.Length; i++) { if (!string.IsNullOrEmpty(_texts[i])) { lbx_search.Items.Add(new ListItem(_texts[i], _values[i])); } } } } }
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, "数据集字段刷新成功!"); }
/// <summary> /// Init the components of the panel through the special pageid /// </summary> private void InitComponents() { if (DataSet == Guid.Empty) return; IList<Rpt_DataSetParams> paramfields = new Rpt_DataSetBLL(DataSet, true).GetParams(); if (paramfields.Count == 0) return; //无参数 HtmlTable T_Content = new HtmlTable(); string[] tablestyles = new string[] { "tabForm", "dataLabel", "dataField" }; T_Content.CellPadding = 0; T_Content.CellSpacing = 0; T_Content.Width = "100%"; T_Content.Border = 0; T_Content.ID = "T_Content_" + ID; this.Controls.Add(T_Content); HtmlTableRow tr_panel = new HtmlTableRow();//Create one TableRow for a panel tr_panel.ID = "DataSetParamPanel"; HtmlTableCell tc_panel = new HtmlTableCell(); #region The title of the panel HtmlTable tb_panel_title = new HtmlTable(); tb_panel_title.CellPadding = 0; tb_panel_title.CellSpacing = 0; tb_panel_title.Width = "100%"; tb_panel_title.Height = "28px"; tb_panel_title.Border = 0; tb_panel_title.Attributes["class"] = "h3Row"; HtmlTableRow tr_panel_title = new HtmlTableRow(); HtmlTableCell tc_panel_title = new HtmlTableCell(); tc_panel_title.InnerHtml = "<h3>请设置统计报表参数信息</h3>"; tr_panel_title.Cells.Add(tc_panel_title); tb_panel_title.Rows.Add(tr_panel_title); tc_panel.Controls.Add(tb_panel_title); #endregion #region The content of the panel int FieldCount = 3; HtmlTable tb_panel_content = new HtmlTable(); tb_panel_content.Width = "100%"; tb_panel_content.Attributes["class"] = tablestyles[0]; int i = 0; foreach (Rpt_DataSetParams param in paramfields) { string ControlID = "Param_" + param.ParamName.Replace("@", ""); //判断该控件是否已存在 if (ParamControlsInfo.ContainsKey(ControlID)) continue; ParamControlsInfo.Add(ControlID, param); if (param.Visible == "Y") { #region 判断是否要增加新行 HtmlTableRow tr_panel_detail; if (i >= FieldCount || i == 0) { tr_panel_detail = new HtmlTableRow(); tb_panel_content.Rows.Add(tr_panel_detail); i = 0; } else { tr_panel_detail = tb_panel_content.Rows[tb_panel_content.Rows.Count - 1]; } #endregion #region 增加Label Cell HtmlTableCell tc_displayname = new HtmlTableCell(); tc_displayname.Attributes["Class"] = tablestyles[1]; tc_displayname.InnerText = param.DisplayName; if (tc_displayname.InnerText.Length <= 6) tc_displayname.Attributes["Style"] = "width: 80px; height: 18px;"; else tc_displayname.Attributes["Style"] = "width: 100px; height: 18px;"; tc_displayname.Attributes["nowrap"] = "nowrap"; tr_panel_detail.Cells.Add(tc_displayname); #endregion #region 增加Field Cell HtmlTableCell tc_control = new HtmlTableCell(); tc_control.Attributes["Class"] = tablestyles[2]; i++; WebControl control = null; int RelationType = param.RelationType; string RelationTableName = param.RelationTableName; string RelationValueField = param.RelationValueField; string RelationTextField = param.RelationTextField; #region 根据控件类型生成相应的控件 switch (param.ControlType) { case 1://Label control = new Label(); ((Label)control).Text = GetDefaule(param.DefaultValue); break; case 2://TextBox control = new TextBox(); if (param.DataType == 4) { control.Attributes["onfocus"] = "WdatePicker();"; } ((TextBox)control).Text = GetDefaule(param.DefaultValue); break; case 3://DropDownList control = new DropDownList(); if (RelationType == 1)//Relation to the dictionary { ((DropDownList)control).DataSource = DictionaryBLL.GetDicCollections(RelationTableName, true); } else if (RelationType == 2)//Relation to the model table { ((DropDownList)control).DataSource = TreeTableBLL.GetRelationTableSourceData(RelationTableName, RelationValueField, RelationTextField); } else break; ((DropDownList)control).DataTextField = "Value"; ((DropDownList)control).DataValueField = "Key"; ((DropDownList)control).DataBind(); if (param.DataType != 5) ((DropDownList)control).Items.Insert(0, new ListItem("请选择...", "0")); else ((DropDownList)control).Items.Insert(0, new ListItem("请选择...", Guid.Empty.ToString())); if (param.DefaultValue != "") { if (((DropDownList)control).Items.FindByValue(GetDefaule(param.DefaultValue)) != null) ((DropDownList)control).SelectedValue = GetDefaule(param.DefaultValue); } break; case 4://RadioButtonList control = new RadioButtonList(); if (RelationType == 1)//Relation to the dictionary { ((RadioButtonList)control).DataSource = DictionaryBLL.GetDicCollections(RelationTableName, true); } else if (RelationType == 2)//Relation to the model table { ((RadioButtonList)control).DataSource = TreeTableBLL.GetRelationTableSourceData(RelationTableName, RelationValueField, RelationTextField); } else break; ((RadioButtonList)control).RepeatColumns = 6; ((RadioButtonList)control).RepeatDirection = RepeatDirection.Horizontal; ((RadioButtonList)control).DataTextField = "Value"; ((RadioButtonList)control).DataValueField = "Key"; ((RadioButtonList)control).DataBind(); if (((RadioButtonList)control).Items.Count != 0) ((RadioButtonList)control).SelectedIndex = 0; if (param.DefaultValue != "") { if (((RadioButtonList)control).Items.FindByValue(GetDefaule(param.DefaultValue)) != null) ((RadioButtonList)control).SelectedValue = GetDefaule(param.DefaultValue); } break; case 5://MutiLinesTextBox control = new TextBox(); ((TextBox)control).TextMode = TextBoxMode.MultiLine; ((TextBox)control).Text = GetDefaule(param.DefaultValue); break; case 6://TextBox supports search control = new MCSSelectControl(); control.ID = ControlID; if (param.SearchPageURL != "") ((MCSSelectControl)control).PageUrl = param.SearchPageURL; if (param.DefaultValue != "") { control.Init += new EventHandler(control_Init); } break; case 7://MCSTreeControl control = new MCSTreeControl(); control.ID = ControlID; if (param.RelationTableName == "MCS_SYS.dbo.Addr_OrganizeCity") { #region 如果为管理片区字段,则取员工所能管辖的片区 Org_StaffBLL staff = new Org_StaffBLL((int)System.Web.HttpContext.Current.Session["UserID"]); ((MCSTreeControl)control).DataSource = staff.GetStaffOrganizeCity(); ((MCSTreeControl)control).IDColumnName = "ID"; ((MCSTreeControl)control).NameColumnName = "Name"; ((MCSTreeControl)control).ParentColumnName = "SuperID"; if (((MCSTreeControl)control).DataSource.Select("ID = 1").Length > 0 || staff.Model.OrganizeCity == 0) { ((MCSTreeControl)control).RootValue = "0"; if (!Page.IsPostBack) ((MCSTreeControl)control).SelectValue = "0"; } else { ((MCSTreeControl)control).RootValue = new Addr_OrganizeCityBLL(staff.Model.OrganizeCity).Model.SuperID.ToString(); if (!Page.IsPostBack) ((MCSTreeControl)control).SelectValue = staff.Model.OrganizeCity.ToString(); } #endregion } else { ((MCSTreeControl)control).TableName = RelationTableName; ((MCSTreeControl)control).IDColumnName = RelationValueField; ((MCSTreeControl)control).NameColumnName = RelationTextField; ((MCSTreeControl)control).ParentColumnName = "SuperID"; ((MCSTreeControl)control).RootValue = "0"; if (!Page.IsPostBack) ((MCSTreeControl)control).SelectValue = "0"; } if (param.DefaultValue != "") { if (((MCSTreeControl)control).SelectValue == "0" || ((MCSTreeControl)control).SelectValue == "") ((MCSTreeControl)control).SelectValue = GetDefaule(param.DefaultValue); } break; } #endregion control.ID = ControlID; control.Enabled = param["Enable"] != "N"; int controlwidth = 0; if (int.TryParse(param["ControlWidth"], out controlwidth)) control.Width = new Unit(controlwidth); tc_control.Controls.Add(control); #region 如果是文本框时,加上输入验证控件 if (param["IsRequireField"] == "Y") { Label lbl_reqinfo = new Label(); lbl_reqinfo.Text = " *"; lbl_reqinfo.ForeColor = System.Drawing.Color.Red; tc_control.Controls.Add(lbl_reqinfo); } if (param.ControlType == 2 || param.ControlType == 5) { if (param["IsRequireField"] == "Y") { RequiredFieldValidator _requiredfieldvalidator = new RequiredFieldValidator(); _requiredfieldvalidator.ControlToValidate = control.ID; _requiredfieldvalidator.Display = ValidatorDisplay.Dynamic; _requiredfieldvalidator.ErrorMessage = "必填"; _requiredfieldvalidator.ForeColor = System.Drawing.Color.Red; tc_control.Controls.Add(_requiredfieldvalidator); } if (param.DataType == 1 || param.DataType == 2 || param.DataType == 4) //非varchar 字符串 { CompareValidator _comparevalidator = new CompareValidator(); _comparevalidator.ControlToValidate = control.ID; _comparevalidator.Operator = ValidationCompareOperator.DataTypeCheck; _comparevalidator.Display = ValidatorDisplay.Dynamic; _comparevalidator.ForeColor = System.Drawing.Color.Red; if (param.DataType == 1)//int { _comparevalidator.Type = ValidationDataType.Integer; _comparevalidator.ErrorMessage = "应为整数"; } if (param.DataType == 2)//decimal { _comparevalidator.Type = ValidationDataType.Double; _comparevalidator.ErrorMessage = "应为数字"; } if (param.DataType == 4)//datetime { _comparevalidator.Type = ValidationDataType.Date; _comparevalidator.ErrorMessage = "日期格式不正确"; } tc_control.Controls.Add(_comparevalidator); } else { if (param.RegularExpression != "") { RegularExpressionValidator _regularexpressionvalidator = new RegularExpressionValidator(); _regularexpressionvalidator.ControlToValidate = control.ID; _regularexpressionvalidator.ErrorMessage = "数据格式不正确"; _regularexpressionvalidator.ForeColor = System.Drawing.Color.Red; _regularexpressionvalidator.ValidationExpression = param.RegularExpression; _regularexpressionvalidator.Display = ValidatorDisplay.Dynamic; tc_control.Controls.Add(_regularexpressionvalidator); } } } #endregion tr_panel_detail.Cells.Add(tc_control); #endregion } } #endregion tc_panel.Controls.Add(tb_panel_content); tr_panel.Cells.Add(tc_panel); T_Content.Rows.Add(tr_panel); }
/// <summary> /// Init the components of the panel through the special pageid /// </summary> private void InitComponents() { if (DataSet == Guid.Empty) { return; } IList <Rpt_DataSetParams> paramfields = new Rpt_DataSetBLL(DataSet, true).GetParams(); if (paramfields.Count == 0) { return; //无参数 } HtmlTable T_Content = new HtmlTable(); string[] tablestyles = new string[] { "tabForm", "dataLabel", "dataField" }; T_Content.CellPadding = 0; T_Content.CellSpacing = 0; T_Content.Width = "100%"; T_Content.Border = 0; T_Content.ID = "T_Content_" + ID; this.Controls.Add(T_Content); HtmlTableRow tr_panel = new HtmlTableRow();//Create one TableRow for a panel tr_panel.ID = "DataSetParamPanel"; HtmlTableCell tc_panel = new HtmlTableCell(); #region The title of the panel HtmlTable tb_panel_title = new HtmlTable(); tb_panel_title.CellPadding = 0; tb_panel_title.CellSpacing = 0; tb_panel_title.Width = "100%"; tb_panel_title.Height = "28px"; tb_panel_title.Border = 0; tb_panel_title.Attributes["class"] = "h3Row"; HtmlTableRow tr_panel_title = new HtmlTableRow(); HtmlTableCell tc_panel_title = new HtmlTableCell(); tc_panel_title.InnerHtml = "<h3>请设置统计报表参数信息</h3>"; tr_panel_title.Cells.Add(tc_panel_title); tb_panel_title.Rows.Add(tr_panel_title); tc_panel.Controls.Add(tb_panel_title); #endregion #region The content of the panel int FieldCount = 3; HtmlTable tb_panel_content = new HtmlTable(); tb_panel_content.Width = "100%"; tb_panel_content.Attributes["class"] = tablestyles[0]; int i = 0; foreach (Rpt_DataSetParams param in paramfields) { string ControlID = "Param_" + param.ParamName.Replace("@", ""); //判断该控件是否已存在 if (ParamControlsInfo.ContainsKey(ControlID)) { continue; } ParamControlsInfo.Add(ControlID, param); if (param.Visible == "Y") { #region 判断是否要增加新行 HtmlTableRow tr_panel_detail; if (i >= FieldCount || i == 0) { tr_panel_detail = new HtmlTableRow(); tb_panel_content.Rows.Add(tr_panel_detail); i = 0; } else { tr_panel_detail = tb_panel_content.Rows[tb_panel_content.Rows.Count - 1]; } #endregion #region 增加Label Cell HtmlTableCell tc_displayname = new HtmlTableCell(); tc_displayname.Attributes["Class"] = tablestyles[1]; tc_displayname.InnerText = param.DisplayName; if (tc_displayname.InnerText.Length <= 6) { tc_displayname.Attributes["Style"] = "width: 80px; height: 18px;"; } else { tc_displayname.Attributes["Style"] = "width: 100px; height: 18px;"; } tc_displayname.Attributes["nowrap"] = "nowrap"; tr_panel_detail.Cells.Add(tc_displayname); #endregion #region 增加Field Cell HtmlTableCell tc_control = new HtmlTableCell(); tc_control.Attributes["Class"] = tablestyles[2]; i++; WebControl control = null; int RelationType = param.RelationType; string RelationTableName = param.RelationTableName; string RelationValueField = param.RelationValueField; string RelationTextField = param.RelationTextField; #region 根据控件类型生成相应的控件 switch (param.ControlType) { case 1: //Label control = new Label(); ((Label)control).Text = GetDefaule(param.DefaultValue); break; case 2: //TextBox control = new TextBox(); if (param.DataType == 4) { control.Attributes["onfocus"] = "WdatePicker();"; } ((TextBox)control).Text = GetDefaule(param.DefaultValue); break; case 3: //DropDownList control = new DropDownList(); if (RelationType == 1) //Relation to the dictionary { ((DropDownList)control).DataSource = DictionaryBLL.GetDicCollections(RelationTableName, true); } else if (RelationType == 2) //Relation to the model table { ((DropDownList)control).DataSource = TreeTableBLL.GetRelationTableSourceData(RelationTableName, RelationValueField, RelationTextField); } else { break; } ((DropDownList)control).DataTextField = "Value"; ((DropDownList)control).DataValueField = "Key"; ((DropDownList)control).DataBind(); if (param.DataType != 5) { ((DropDownList)control).Items.Insert(0, new ListItem("请选择...", "0")); } else { ((DropDownList)control).Items.Insert(0, new ListItem("请选择...", Guid.Empty.ToString())); } if (param.DefaultValue != "") { if (((DropDownList)control).Items.FindByValue(GetDefaule(param.DefaultValue)) != null) { ((DropDownList)control).SelectedValue = GetDefaule(param.DefaultValue); } } break; case 4: //RadioButtonList control = new RadioButtonList(); if (RelationType == 1) //Relation to the dictionary { ((RadioButtonList)control).DataSource = DictionaryBLL.GetDicCollections(RelationTableName, true); } else if (RelationType == 2) //Relation to the model table { ((RadioButtonList)control).DataSource = TreeTableBLL.GetRelationTableSourceData(RelationTableName, RelationValueField, RelationTextField); } else { break; } ((RadioButtonList)control).RepeatColumns = 6; ((RadioButtonList)control).RepeatDirection = RepeatDirection.Horizontal; ((RadioButtonList)control).DataTextField = "Value"; ((RadioButtonList)control).DataValueField = "Key"; ((RadioButtonList)control).DataBind(); if (((RadioButtonList)control).Items.Count != 0) { ((RadioButtonList)control).SelectedIndex = 0; } if (param.DefaultValue != "") { if (((RadioButtonList)control).Items.FindByValue(GetDefaule(param.DefaultValue)) != null) { ((RadioButtonList)control).SelectedValue = GetDefaule(param.DefaultValue); } } break; case 5: //MutiLinesTextBox control = new TextBox(); ((TextBox)control).TextMode = TextBoxMode.MultiLine; ((TextBox)control).Text = GetDefaule(param.DefaultValue); break; case 6: //TextBox supports search control = new MCSSelectControl(); control.ID = ControlID; if (param.SearchPageURL != "") { ((MCSSelectControl)control).PageUrl = param.SearchPageURL; } if (param.DefaultValue != "") { control.Init += new EventHandler(control_Init); } break; case 7: //MCSTreeControl control = new MCSTreeControl(); control.ID = ControlID; if (param.RelationTableName == "MCS_SYS.dbo.Addr_OrganizeCity") { #region 如果为管理片区字段,则取员工所能管辖的片区 Org_StaffBLL staff = new Org_StaffBLL((int)System.Web.HttpContext.Current.Session["UserID"]); ((MCSTreeControl)control).DataSource = staff.GetStaffOrganizeCity(); ((MCSTreeControl)control).IDColumnName = "ID"; ((MCSTreeControl)control).NameColumnName = "Name"; ((MCSTreeControl)control).ParentColumnName = "SuperID"; if (((MCSTreeControl)control).DataSource.Select("ID = 1").Length > 0 || staff.Model.OrganizeCity == 0) { ((MCSTreeControl)control).RootValue = "0"; if (!Page.IsPostBack) { ((MCSTreeControl)control).SelectValue = "0"; } } else { ((MCSTreeControl)control).RootValue = new Addr_OrganizeCityBLL(staff.Model.OrganizeCity).Model.SuperID.ToString(); if (!Page.IsPostBack) { ((MCSTreeControl)control).SelectValue = staff.Model.OrganizeCity.ToString(); } } #endregion } else { ((MCSTreeControl)control).TableName = RelationTableName; ((MCSTreeControl)control).IDColumnName = RelationValueField; ((MCSTreeControl)control).NameColumnName = RelationTextField; ((MCSTreeControl)control).ParentColumnName = "SuperID"; ((MCSTreeControl)control).RootValue = "0"; if (!Page.IsPostBack) { ((MCSTreeControl)control).SelectValue = "0"; } } if (param.DefaultValue != "") { if (((MCSTreeControl)control).SelectValue == "0" || ((MCSTreeControl)control).SelectValue == "") { ((MCSTreeControl)control).SelectValue = GetDefaule(param.DefaultValue); } } break; } #endregion control.ID = ControlID; control.Enabled = param["Enable"] != "N"; int controlwidth = 0; if (int.TryParse(param["ControlWidth"], out controlwidth)) { control.Width = new Unit(controlwidth); } tc_control.Controls.Add(control); #region 如果是文本框时,加上输入验证控件 if (param["IsRequireField"] == "Y") { Label lbl_reqinfo = new Label(); lbl_reqinfo.Text = " *"; lbl_reqinfo.ForeColor = System.Drawing.Color.Red; tc_control.Controls.Add(lbl_reqinfo); } if (param.ControlType == 2 || param.ControlType == 5) { if (param["IsRequireField"] == "Y") { RequiredFieldValidator _requiredfieldvalidator = new RequiredFieldValidator(); _requiredfieldvalidator.ControlToValidate = control.ID; _requiredfieldvalidator.Display = ValidatorDisplay.Dynamic; _requiredfieldvalidator.ErrorMessage = "必填"; _requiredfieldvalidator.ForeColor = System.Drawing.Color.Red; tc_control.Controls.Add(_requiredfieldvalidator); } if (param.DataType == 1 || param.DataType == 2 || param.DataType == 4) //非varchar 字符串 { CompareValidator _comparevalidator = new CompareValidator(); _comparevalidator.ControlToValidate = control.ID; _comparevalidator.Operator = ValidationCompareOperator.DataTypeCheck; _comparevalidator.Display = ValidatorDisplay.Dynamic; _comparevalidator.ForeColor = System.Drawing.Color.Red; if (param.DataType == 1)//int { _comparevalidator.Type = ValidationDataType.Integer; _comparevalidator.ErrorMessage = "应为整数"; } if (param.DataType == 2)//decimal { _comparevalidator.Type = ValidationDataType.Double; _comparevalidator.ErrorMessage = "应为数字"; } if (param.DataType == 4)//datetime { _comparevalidator.Type = ValidationDataType.Date; _comparevalidator.ErrorMessage = "日期格式不正确"; } tc_control.Controls.Add(_comparevalidator); } else { if (param.RegularExpression != "") { RegularExpressionValidator _regularexpressionvalidator = new RegularExpressionValidator(); _regularexpressionvalidator.ControlToValidate = control.ID; _regularexpressionvalidator.ErrorMessage = "数据格式不正确"; _regularexpressionvalidator.ForeColor = System.Drawing.Color.Red; _regularexpressionvalidator.ValidationExpression = param.RegularExpression; _regularexpressionvalidator.Display = ValidatorDisplay.Dynamic; tc_control.Controls.Add(_regularexpressionvalidator); } } } #endregion tr_panel_detail.Cells.Add(tc_control); #endregion } } #endregion tc_panel.Controls.Add(tb_panel_content); tr_panel.Cells.Add(tc_panel); T_Content.Rows.Add(tr_panel); }
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_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 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 BindDropDown(); if ((Guid)ViewState["ID"] != Guid.Empty) { //修改 BindData(); td_TemParam.Visible = false; } else { //新增 if ((Guid)ViewState["DataSet"] == Guid.Empty) Response.Redirect("Rpt_DataSetList.aspx"); bt_Delete.Visible = false; TextBox tbx_ParamSortID = (TextBox)pl_detail.FindControl("Rpt_DataSetParams_ParamSortID"); if (tbx_ParamSortID != null) { int maxsortid = 0; IList<Rpt_DataSetParams> paramlist = new Rpt_DataSetBLL((Guid)ViewState["DataSet"]).GetParams(); if (paramlist.Count > 0) maxsortid = paramlist.Max(p => p.ParamSortID); tbx_ParamSortID.Text = (++maxsortid).ToString(); ViewState["MaxSortID"] = maxsortid; } } } }
protected void Page_Load(object sender, System.EventArgs e) { // 在此处放置用户代码以初始化页面 if (!Page.IsPostBack) { #region 获取页面参数 ViewState["ID"] = Request.QueryString["ID"] != null ? new Guid(Request.QueryString["ID"]) : Guid.Empty; #endregion BindDropDown(); if ((Guid)ViewState["ID"] != Guid.Empty) { #region 绑定页面数据集信息 Rpt_DataSet m = new Rpt_DataSetBLL((Guid)ViewState["ID"]).Model; if (m != null) { lb_DataSetName.Text = m.Name; #region 根据数据集类型控制Tab可见 switch (m.CommandType) { case 1: case 2: MCSTabControl1.Items[2].Visible = false; MCSTabControl1.Items[3].Visible = false; MCSTabControl1.Items[5].Visible = false; break; case 3: break; default: break; } #endregion if (m.CommandType == 3) bt_Refresh.Visible = false; else { td_TableFields.Visible = false; gv_List.Columns[gv_List.Columns.Count - 1].Visible = false; } } #endregion BindGrid(); } else Response.Redirect("Rpt_DataSetList.aspx"); } }
protected void gv_List_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { IList<Rpt_DataSetFields> fields = new Rpt_DataSetBLL((Guid)ViewState["ID"]).GetFields(); if (fields.Count > 0) { Guid id = (Guid)gv_List.DataKeys[e.Row.RowIndex][0]; if (id == fields[0].ID) e.Row.FindControl("bt_Decrease").Visible = false; if (id == fields[fields.Count - 1].ID) e.Row.FindControl("bt_Increase").Visible = false; } } }
private void BindDataSetFields() { Rpt_ReportBLL report = new Rpt_ReportBLL((Guid)ViewState["ID"]); IList<Rpt_ReportGridColumns> columns = report.GetGridColumns(); IList<Rpt_DataSetFields> fields = new Rpt_DataSetBLL((Guid)ViewState["DataSet"]).GetFields(); foreach (Rpt_ReportGridColumns col in columns) { Rpt_DataSetFields f = fields.FirstOrDefault(p => p.ID == col.DataSetField); if (f != null) fields.Remove(f); } cbxl_Fields.DataSource = fields; cbxl_Fields.DataBind(); }
private void BindDataSetFields() { Rpt_ReportBLL report = new Rpt_ReportBLL((Guid)ViewState["ID"]); IList<Rpt_DataSetFields> fields = new Rpt_DataSetBLL((Guid)ViewState["DataSet"]).GetFields(); foreach (Rpt_ReportColumnGroups col in report.GetColumnGroups()) { Rpt_DataSetFields f = fields.FirstOrDefault(p => p.ID == col.DataSetField); if (f != null) fields.Remove(f); } foreach (Rpt_ReportRowGroups col in report.GetRowGroups()) { Rpt_DataSetFields f = fields.FirstOrDefault(p => p.ID == col.DataSetField); if (f != null) fields.Remove(f); } foreach (Rpt_ReportValueGroups col in report.GetValueGroups()) { Rpt_DataSetFields f = fields.FirstOrDefault(p => p.ID == col.DataSetField); if (f != null) fields.Remove(f); } cbxl_Fields.DataSource = fields; cbxl_Fields.DataBind(); }
protected void Page_Load(object sender, System.EventArgs e) { // 在此处放置用户代码以初始化页面 if (!Page.IsPostBack) { #region 获取页面参数 ViewState["ID"] = Request.QueryString["ID"] != null ? new Guid(Request.QueryString["ID"]) : Guid.Empty; ViewState["Folder"] = Request.QueryString["Folder"] != null?int.Parse(Request.QueryString["Folder"]) : 0; #endregion BindDropDown(); if ((Guid)ViewState["ID"] != Guid.Empty) { //修改 BindData(); } else { //新增 MCSTabControl1.Items[1].Visible = false; MCSTabControl1.Items[2].Visible = false; MCSTabControl1.Items[3].Visible = false; #region 限制报表目录为参数值 if ((int)ViewState["Folder"] == 0) { Response.Redirect("Rpt_ReportList.aspx"); } MCSTreeControl tr_Folder = (MCSTreeControl)pl_detail.FindControl("Rpt_Report_Folder"); DropDownList ddl_DataSet = (DropDownList)pl_detail.FindControl("Rpt_Report_DataSet"); if (tr_Folder != null && ddl_DataSet != null) { tr_Folder.SelectValue = ViewState["Folder"].ToString(); tr_Folder.Enabled = false; ddl_DataSet.DataValueField = "ID"; ddl_DataSet.DataTextField = "Name"; ddl_DataSet.DataSource = Rpt_DataSetBLL.GetDataByFolder((int)ViewState["Folder"], true); ddl_DataSet.DataBind(); ddl_DataSet.Items.Insert(0, new ListItem("请选择...", Guid.Empty.ToString())); } #endregion RadioButtonList rbl_AddRowTotal = (RadioButtonList)pl_detail.FindControl("Rpt_Report_AddRowTotal"); if (rbl_AddRowTotal != null) { rbl_AddRowTotal.SelectedValue = "N"; } RadioButtonList rbl_AddColumnTotal = (RadioButtonList)pl_detail.FindControl("Rpt_Report_AddColumnTotal"); if (rbl_AddColumnTotal != null) { rbl_AddColumnTotal.SelectedValue = "N"; } bt_ViewReport.Visible = false; bt_Delete.Visible = false; } } }
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; } } }