protected void bt_Increase_Click(object sender, EventArgs e) { Guid id = (Guid)gv_List.DataKeys[((GridViewRow)((Button)sender).Parent.Parent).RowIndex][0]; UD_Panel_ModelFieldsBLL bll = new UD_Panel_ModelFieldsBLL(id); bll.Model.SortID++; bll.Update(); BindGrid(); }
private void BindData() { Guid _id = (Guid)ViewState["ID"]; UD_Panel_ModelFieldsBLL _modelfieldsbll = new UD_Panel_ModelFieldsBLL(_id); lbl_ID.Text = _modelfieldsbll.Model.ID.ToString(); ddl_TableName.SelectedValue = new UD_ModelFieldsBLL(_modelfieldsbll.Model.FieldID).Model.TableID.ToString(); ddl_TableName_SelectedIndexChanged(null, null); ddl_FieldID.SelectedValue = _modelfieldsbll.Model.FieldID.ToString(); ddl_FieldID_SelectedIndexChanged(null, null); tbx_LabelText.Text = _modelfieldsbll.Model.LabelText; rbl_ReadOnly.SelectedValue = _modelfieldsbll.Model.ReadOnly; ddl_ControlType.SelectedValue = _modelfieldsbll.Model.ControlType.ToString(); ddl_ControlType_SelectedIndexChanged(null, null); tbx_ControlWidth.Text = _modelfieldsbll.Model.ControlWidth.ToString(); tbx_ControlHeight.Text = _modelfieldsbll.Model.ControlHeight.ToString(); tbx_ControlStyle.Text = _modelfieldsbll.Model.ControlStyle; tbx_Description.Text = _modelfieldsbll.Model.Description; rbl_Enable.SelectedValue = _modelfieldsbll.Model.Enable; rbl_Visible.SelectedValue = _modelfieldsbll.Model.Visible; rbl_IsRequireField.SelectedValue = _modelfieldsbll.Model.IsRequireField; tbx_SortID.Text = _modelfieldsbll.Model.SortID.ToString(); tbx_VisibleActionCode.Text = _modelfieldsbll.Model.VisibleActionCode; tbx_EnableActionCode.Text = _modelfieldsbll.Model.EnableActionCode; ddl_DisplayMode.SelectedValue = _modelfieldsbll.Model.DisplayMode.ToString(); tbx_ColSpan.Text = _modelfieldsbll.Model.ColSpan.ToString(); tbx_RegularExpression.Text = _modelfieldsbll.Model.RegularExpression; tbx_FormatString.Text = _modelfieldsbll.Model.FormatString; tbx_SearchPageURL.Text = _modelfieldsbll.Model.SearchPageURL; if (_modelfieldsbll.Model.TreeLevel > 0) { tbx_TreeLevel.Text = _modelfieldsbll.Model.TreeLevel.ToString(); } bt_OK.Text = "修改"; bt_OK.ForeColor = System.Drawing.Color.Red; }
protected void bt_OK_Click(object sender, EventArgs e) { UD_Panel_ModelFieldsBLL _modelfieldsbll; if (ViewState["ID"] != null) _modelfieldsbll = new UD_Panel_ModelFieldsBLL((Guid)ViewState["ID"]); else _modelfieldsbll = new UD_Panel_ModelFieldsBLL(); _modelfieldsbll.Model.PanelID = (Guid)ViewState["PanelID"]; _modelfieldsbll.Model.FieldID = new Guid(ddl_FieldID.SelectedValue); _modelfieldsbll.Model.LabelText = tbx_LabelText.Text; _modelfieldsbll.Model.ReadOnly = rbl_ReadOnly.SelectedValue; _modelfieldsbll.Model.ControlType = int.Parse(ddl_ControlType.SelectedValue); if (tbx_ControlWidth.Text != "") _modelfieldsbll.Model.ControlWidth = int.Parse(tbx_ControlWidth.Text); if (tbx_ControlHeight.Text != "") _modelfieldsbll.Model.ControlHeight = int.Parse(tbx_ControlHeight.Text); _modelfieldsbll.Model.ControlStyle = tbx_ControlStyle.Text; _modelfieldsbll.Model.Description = tbx_Description.Text; _modelfieldsbll.Model.Enable = rbl_Enable.SelectedValue; _modelfieldsbll.Model.Visible = rbl_Visible.SelectedValue; _modelfieldsbll.Model.IsRequireField = rbl_IsRequireField.SelectedValue; _modelfieldsbll.Model.SortID = int.Parse(tbx_SortID.Text); _modelfieldsbll.Model.DisplayMode = int.Parse(ddl_DisplayMode.SelectedValue); if (tbx_ColSpan.Text != "") _modelfieldsbll.Model.ColSpan = int.Parse(tbx_ColSpan.Text); _modelfieldsbll.Model.RegularExpression = tbx_RegularExpression.Text.Trim(); _modelfieldsbll.Model.FormatString = tbx_FormatString.Text.Trim(); if (tbx_VisibleActionCode.Text != "") _modelfieldsbll.Model.VisibleActionCode = tbx_VisibleActionCode.Text; if (tbx_EnableActionCode.Text != "") _modelfieldsbll.Model.EnableActionCode = tbx_EnableActionCode.Text; _modelfieldsbll.Model.SearchPageURL = tbx_SearchPageURL.Text; if (tbx_TreeLevel.Text != "") _modelfieldsbll.Model.TreeLevel = int.Parse(tbx_TreeLevel.Text); if (ViewState["ID"] != null) _modelfieldsbll.Update(); else _modelfieldsbll.Add(); Response.Redirect("FieldsInPanel.aspx?PanelID=" + ViewState["PanelID"].ToString()); }
/// <summary> /// Bind data to the control from the special model /// </summary> /// <param name="_model"></param> public void BindData(IModel _model) { if (_model == null || _model["ID"] == string.Empty) { return; } foreach (object _key in FieldControlsInfo.Keys) { FieldControlInfo fieldcontrolinfo = (FieldControlInfo)FieldControlsInfo[_key]; string fieldname = fieldcontrolinfo.FieldName; if (fieldcontrolinfo.ModelName == _model.ModelName) { try { UD_Panel_ModelFields _panelfield = new UD_Panel_ModelFieldsBLL(fieldcontrolinfo.Panel_Field_ID, true).Model; UD_ModelFields _modelfield = new UD_ModelFieldsBLL(fieldcontrolinfo.FieldID, true).Model; string _formatstring = _panelfield.FormatString; switch (fieldcontrolinfo.ControlType) { case 1: //Label控件 //判断是否显示关联表的文本值 if (fieldcontrolinfo.DisplayMode == 1) { if (_modelfield.DataType == 1) ((Label)this.FindControl((string)_key)).Text = int.Parse(_model[fieldname]).ToString(_formatstring); else if (_modelfield.DataType == 2) ((Label)this.FindControl((string)_key)).Text = decimal.Parse(_model[fieldname]).ToString(_formatstring); else if (_modelfield.DataType == 4) { if (DateTime.Parse(_model[fieldname]) != new DateTime(1900, 1, 1)) ((Label)this.FindControl((string)_key)).Text = DateTime.Parse(_model[fieldname]).ToString(_formatstring); } else ((Label)this.FindControl((string)_key)).Text = _model[fieldname]; } else { if (_panelfield.TreeLevel > 0 && new UD_TableListBLL(_modelfield.RelationTableName).Model.TreeFlag == "Y") { #region 字段关联到树形结构表,且要显示上层父结点信息 int value = 0; if (int.TryParse(_model[fieldname], out value)) { if (_panelfield.TreeLevel == 100) { //显示全路径 ((Label)this.FindControl((string)_key)).Text = TreeTableBLL.GetFullPathName(_modelfield.RelationTableName, value); } else { //显示父级 ((Label)this.FindControl((string)_key)).Text = TreeTableBLL.GetSuperNameByLevel(_modelfield.RelationTableName, value, _panelfield.TreeLevel); } } #endregion } else { ((Label)this.FindControl((string)_key)).Text = GetRelateTextByValue(_modelfield, _model[fieldname]); } } break; case 2: //TextBox case 5: //MultiRowTextBox if (_modelfield.DataType == 1) ((TextBox)this.FindControl((string)_key)).Text = int.Parse(_model[fieldname]).ToString(_formatstring); else if (_modelfield.DataType == 2) ((TextBox)this.FindControl((string)_key)).Text = decimal.Parse(_model[fieldname]).ToString(_formatstring); else if (_modelfield.DataType == 4) { if (DateTime.Parse(_model[fieldname]) != new DateTime(1900, 1, 1)) ((TextBox)this.FindControl((string)_key)).Text = DateTime.Parse(_model[fieldname]).ToString(_formatstring); } else ((TextBox)this.FindControl((string)_key)).Text = _model[fieldname]; break; case 3: //DropDownList if (_model[fieldname] != "") ((DropDownList)this.FindControl((string)_key)).SelectedValue = _model[fieldname]; break; case 4: //RadioButtonList if (_model[fieldname] != "") ((RadioButtonList)this.FindControl((string)_key)).SelectedValue = _model[fieldname]; break; case 6: //带选择功能的控件 if (_model[fieldname] != "") { ((MCSSelectControl)this.FindControl((string)_key)).SelectValue = _model[fieldname]; ((MCSSelectControl)this.FindControl((string)_key)).SelectText = GetRelateTextByValue(_modelfield, _model[fieldname]); } break; case 7: //树形选择控件 if (_model[fieldname] != "") ((MCSTreeControl)this.FindControl((string)_key)).SelectValue = _model[fieldname]; break; } } catch { } } } }
private void BindGrid() { gv_List.BindGrid <UD_Panel_ModelFields>(UD_Panel_ModelFieldsBLL.GetModelList("PanelID='" + ViewState["PanelID"].ToString() + "'")); }
protected void bt_OK_Click(object sender, EventArgs e) { UD_Panel_ModelFieldsBLL _modelfieldsbll; if (ViewState["ID"] != null) { _modelfieldsbll = new UD_Panel_ModelFieldsBLL((Guid)ViewState["ID"]); } else { _modelfieldsbll = new UD_Panel_ModelFieldsBLL(); } _modelfieldsbll.Model.PanelID = (Guid)ViewState["PanelID"]; _modelfieldsbll.Model.FieldID = new Guid(ddl_FieldID.SelectedValue); _modelfieldsbll.Model.LabelText = tbx_LabelText.Text; _modelfieldsbll.Model.ReadOnly = rbl_ReadOnly.SelectedValue; _modelfieldsbll.Model.ControlType = int.Parse(ddl_ControlType.SelectedValue); if (tbx_ControlWidth.Text != "") { _modelfieldsbll.Model.ControlWidth = int.Parse(tbx_ControlWidth.Text); } if (tbx_ControlHeight.Text != "") { _modelfieldsbll.Model.ControlHeight = int.Parse(tbx_ControlHeight.Text); } _modelfieldsbll.Model.ControlStyle = tbx_ControlStyle.Text; _modelfieldsbll.Model.Description = tbx_Description.Text; _modelfieldsbll.Model.Enable = rbl_Enable.SelectedValue; _modelfieldsbll.Model.Visible = rbl_Visible.SelectedValue; _modelfieldsbll.Model.IsRequireField = rbl_IsRequireField.SelectedValue; _modelfieldsbll.Model.SortID = int.Parse(tbx_SortID.Text); _modelfieldsbll.Model.DisplayMode = int.Parse(ddl_DisplayMode.SelectedValue); if (tbx_ColSpan.Text != "") { _modelfieldsbll.Model.ColSpan = int.Parse(tbx_ColSpan.Text); } _modelfieldsbll.Model.RegularExpression = tbx_RegularExpression.Text.Trim(); _modelfieldsbll.Model.FormatString = tbx_FormatString.Text.Trim(); if (tbx_VisibleActionCode.Text != "") { _modelfieldsbll.Model.VisibleActionCode = tbx_VisibleActionCode.Text; } if (tbx_EnableActionCode.Text != "") { _modelfieldsbll.Model.EnableActionCode = tbx_EnableActionCode.Text; } _modelfieldsbll.Model.SearchPageURL = tbx_SearchPageURL.Text; if (tbx_TreeLevel.Text != "") { _modelfieldsbll.Model.TreeLevel = int.Parse(tbx_TreeLevel.Text); } if (ViewState["ID"] != null) { _modelfieldsbll.Update(); } else { _modelfieldsbll.Add(); } Response.Redirect("FieldsInPanel.aspx?PanelID=" + ViewState["PanelID"].ToString()); }
private void BindData() { Guid _id = (Guid)ViewState["ID"]; UD_Panel_ModelFieldsBLL _modelfieldsbll = new UD_Panel_ModelFieldsBLL(_id); lbl_ID.Text = _modelfieldsbll.Model.ID.ToString(); ddl_TableName.SelectedValue = new UD_ModelFieldsBLL(_modelfieldsbll.Model.FieldID).Model.TableID.ToString(); ddl_TableName_SelectedIndexChanged(null, null); ddl_FieldID.SelectedValue = _modelfieldsbll.Model.FieldID.ToString(); ddl_FieldID_SelectedIndexChanged(null, null); tbx_LabelText.Text = _modelfieldsbll.Model.LabelText; rbl_ReadOnly.SelectedValue = _modelfieldsbll.Model.ReadOnly; ddl_ControlType.SelectedValue = _modelfieldsbll.Model.ControlType.ToString(); ddl_ControlType_SelectedIndexChanged(null, null); tbx_ControlWidth.Text = _modelfieldsbll.Model.ControlWidth.ToString(); tbx_ControlHeight.Text = _modelfieldsbll.Model.ControlHeight.ToString(); tbx_ControlStyle.Text = _modelfieldsbll.Model.ControlStyle; tbx_Description.Text = _modelfieldsbll.Model.Description; rbl_Enable.SelectedValue = _modelfieldsbll.Model.Enable; rbl_Visible.SelectedValue = _modelfieldsbll.Model.Visible; rbl_IsRequireField.SelectedValue = _modelfieldsbll.Model.IsRequireField; tbx_SortID.Text = _modelfieldsbll.Model.SortID.ToString(); tbx_VisibleActionCode.Text = _modelfieldsbll.Model.VisibleActionCode; tbx_EnableActionCode.Text = _modelfieldsbll.Model.EnableActionCode; ddl_DisplayMode.SelectedValue = _modelfieldsbll.Model.DisplayMode.ToString(); tbx_ColSpan.Text = _modelfieldsbll.Model.ColSpan.ToString(); tbx_RegularExpression.Text = _modelfieldsbll.Model.RegularExpression; tbx_FormatString.Text = _modelfieldsbll.Model.FormatString; tbx_SearchPageURL.Text = _modelfieldsbll.Model.SearchPageURL; if (_modelfieldsbll.Model.TreeLevel > 0) tbx_TreeLevel.Text = _modelfieldsbll.Model.TreeLevel.ToString(); bt_OK.Text = "修改"; bt_OK.ForeColor = System.Drawing.Color.Red; }
/// <summary> /// Bind data to the control from the special model /// </summary> /// <param name="_model"></param> public void BindData(IModel _model) { if (_model == null || _model["ID"] == string.Empty) { return; } foreach (object _key in FieldControlsInfo.Keys) { FieldControlInfo fieldcontrolinfo = (FieldControlInfo)FieldControlsInfo[_key]; string fieldname = fieldcontrolinfo.FieldName; if (fieldcontrolinfo.ModelName == _model.ModelName) { try { UD_Panel_ModelFields _panelfield = new UD_Panel_ModelFieldsBLL(fieldcontrolinfo.Panel_Field_ID, true).Model; UD_ModelFields _modelfield = new UD_ModelFieldsBLL(fieldcontrolinfo.FieldID, true).Model; string _formatstring = _panelfield.FormatString; switch (fieldcontrolinfo.ControlType) { case 1: //Label控件 //判断是否显示关联表的文本值 if (fieldcontrolinfo.DisplayMode == 1) { if (_modelfield.DataType == 1) { ((Label)this.FindControl((string)_key)).Text = int.Parse(_model[fieldname]).ToString(_formatstring); } else if (_modelfield.DataType == 2) { ((Label)this.FindControl((string)_key)).Text = decimal.Parse(_model[fieldname]).ToString(_formatstring); } else if (_modelfield.DataType == 4) { if (DateTime.Parse(_model[fieldname]) != new DateTime(1900, 1, 1)) { ((Label)this.FindControl((string)_key)).Text = DateTime.Parse(_model[fieldname]).ToString(_formatstring); } } else { ((Label)this.FindControl((string)_key)).Text = _model[fieldname]; } } else { if (_panelfield.TreeLevel > 0 && new UD_TableListBLL(_modelfield.RelationTableName).Model.TreeFlag == "Y") { #region 字段关联到树形结构表,且要显示上层父结点信息 int value = 0; if (int.TryParse(_model[fieldname], out value)) { if (_panelfield.TreeLevel == 100) { //显示全路径 ((Label)this.FindControl((string)_key)).Text = TreeTableBLL.GetFullPathName(_modelfield.RelationTableName, value); } else { //显示父级 ((Label)this.FindControl((string)_key)).Text = TreeTableBLL.GetSuperNameByLevel(_modelfield.RelationTableName, value, _panelfield.TreeLevel); } } #endregion } else { ((Label)this.FindControl((string)_key)).Text = GetRelateTextByValue(_modelfield, _model[fieldname]); } } break; case 2: //TextBox case 5: //MultiRowTextBox if (_modelfield.DataType == 1) { ((TextBox)this.FindControl((string)_key)).Text = int.Parse(_model[fieldname]).ToString(_formatstring); } else if (_modelfield.DataType == 2) { ((TextBox)this.FindControl((string)_key)).Text = decimal.Parse(_model[fieldname]).ToString(_formatstring); } else if (_modelfield.DataType == 4) { if (DateTime.Parse(_model[fieldname]) != new DateTime(1900, 1, 1)) { ((TextBox)this.FindControl((string)_key)).Text = DateTime.Parse(_model[fieldname]).ToString(_formatstring); } } else { ((TextBox)this.FindControl((string)_key)).Text = _model[fieldname]; } break; case 3: //DropDownList if (_model[fieldname] != "") { ((DropDownList)this.FindControl((string)_key)).SelectedValue = _model[fieldname]; } break; case 4: //RadioButtonList if (_model[fieldname] != "") { ((RadioButtonList)this.FindControl((string)_key)).SelectedValue = _model[fieldname]; } break; case 6: //带选择功能的控件 if (_model[fieldname] != "") { ((MCSSelectControl)this.FindControl((string)_key)).SelectValue = _model[fieldname]; ((MCSSelectControl)this.FindControl((string)_key)).SelectText = GetRelateTextByValue(_modelfield, _model[fieldname]); } break; case 7: //树形选择控件 if (_model[fieldname] != "") { ((MCSTreeControl)this.FindControl((string)_key)).SelectValue = _model[fieldname]; } break; } } catch { } } } }