public static RuleColumn FromDataColumn(DataColumn column) { RuleColumn rcolumn = new RuleColumn(column.ColumnName); rcolumn.Label = column.Caption; rcolumn.DataType = DataTypes.ToDataType(column.DataType); return(rcolumn); }
private object GetDefaultValue(DataRow row, RuleColumn rc) { if (OnDefaultValueEvent != null) { return(OnDefaultValueEvent(row, rc)); } else { return(null); } }
public RuleColumns GetRuleColumns() { if (mRuleColumns == null) { mRuleColumns = new RuleColumns(); DataTable table = GetFieldRule(); foreach (DataRow row in table.Rows) { mRuleColumns.Add(RuleColumn.FromDataRow(row)); } } return(mRuleColumns); }
private object GetDefaultValue(DataRow row, RuleColumn rc) { if (rc.HasDefValue) { object value = mSysDefaultValue.GetDefaultValue(rc); if (value == null && OnDefaultValueEvent != null) { value = OnDefaultValueEvent(row, rc); } return(value); } return(null); }
public RuleColumn Remove(int index) { if (index >= 0 && index < m_column_names.Count) { string name = m_column_names[index]; if (name != null) { RuleColumn rc = m_columns[name]; m_column_names.RemoveAt(index); m_columns.Remove(name); return(rc); } } return(null); }
public RuleColumn Remove(String name) { if (name != null && !name.Equals("")) { String code = name.ToUpper(); if (m_column_names.Remove(code)) { RuleColumn rc = m_columns[code]; m_columns.Remove(code); return(rc); } else { return(null); } } else { throw new Exception("列名不能为空!"); } }
public RuleColumn clone() { RuleColumn column = new RuleColumn(m_columnName); column.TableName = this.TableName; column.Label = this.Label; column.Order = this.Order; column.EditIndex = this.EditIndex; column.DataType = this.DataType; column.Size = this.Size; column.Width = this.Width; column.Scale = this.Scale; column.Precision = this.Precision; column.FieldName = this.FieldName; column.Nullable = this.Nullable; column.RWOpt = this.RWOpt; column.CtrlOpt = this.CtrlOpt; column.VisionOpt = this.VisionOpt; column.WhereOpt = this.WhereOpt; column.ReadOnly = this.ReadOnly; column.Visible = this.Visible; column.IsSerializable = this.IsSerializable; column.DefaultValue = this.DefaultValue; column.MapInfo = this.MapInfo; column.Mask = this.Mask; column.Ime = this.Ime; column.DisplayFormat = this.DisplayFormat; column.EditFormat = this.EditFormat; column.Hint = this.Hint; column.CanInsert = this.CanInsert; column.CanUpdate = this.CanUpdate; column.CanDelete = this.CanDelete; column.Constraints = this.Constraints; column.ErrorMessage = this.ErrorMessage; column.RefFieldName = this.RefFieldName; column.AnalogyFieldName = this.AnalogyFieldName; column.IsDynamicRef = this.IsDynamicRef; return(column); }
public static RuleColumn FromDataRow(DataRow row) { RuleRow rrow = new RuleRow(row); RuleColumn rcolumn = new RuleColumn(rrow.GetStrField("f_name")); rcolumn.Label = rrow.GetStrField("f_label"); rcolumn.Hint = rrow.GetStrField("f_hint"); rcolumn.Order = rrow.GetIntField("f_order"); rcolumn.EditIndex = rrow.GetIntField("f_edit_index"); rcolumn.DataType = DataTypes.ToDataType(rrow.GetStrField("f_type")); rcolumn.Size = rrow.GetIntField("f_size"); rcolumn.Precision = rrow.GetIntField("f_precision"); rcolumn.Scale = rrow.GetIntField("f_scale"); rcolumn.Width = rrow.GetIntField("f_width"); rcolumn.TableName = rrow.GetStrField("f_table_name"); rcolumn.FieldName = rrow.GetStrField("f_field_name"); rcolumn.CanInsert = rrow.GetBoolField("f_insert"); rcolumn.CanUpdate = rrow.GetBoolField("f_update"); rcolumn.CanDelete = rrow.GetBoolField("f_delete"); rcolumn.Nullable = rrow.GetIntField("f_nullable"); rcolumn.VisionOpt = rrow.GetStrField("f_vision_opt"); rcolumn.WhereOpt = rrow.GetStrField("f_where_opt"); rcolumn.CtrlOpt = rrow.GetIntField("f_ctrl_opt"); rcolumn.RWOpt = rrow.GetStrField("f_rw_opt"); rcolumn.Mask = rrow.GetStrField("f_mask"); rcolumn.Ime = rrow.GetStrField("f_ime"); rcolumn.DisplayFormat = rrow.GetStrField("f_disp_format"); rcolumn.EditFormat = rrow.GetStrField("f_edit_format"); rcolumn.Constraints = rrow.GetStrField("f_check_info"); rcolumn.ErrorMessage = rrow.GetStrField("f_check_msg"); rcolumn.DefaultValue = rrow.GetStrField("f_def_value"); rcolumn.MapInfo = rrow.GetStrField("f_map_info"); return(rcolumn); }
public int Add(RuleColumn column) { String code = column.ColumnCode; if (!Exist(code)) { m_columns.Add(code, column); m_column_names.Add(code); //if(column.getTableName().Equals("")) // column.setTableName(m_tablename); //if (this.isEnableDefault()) { // initRefField(column, false); // initAnalogyField(column, false); //} return(m_column_names.IndexOf(code)); } else { throw new Exception(code + " 列名重复,无法增加列!"); } }
public void OnColumnChanged(object sender, DataColumnChangeEventArgs e) { if (TableUtil.InConstraint(e.Row.Table)) { RuleColumn column = TableUtil.GetRuleColumn(e.Column); if (column != null && column.HasConstraints) { string message = ""; if (!DataUtil.CheckConstraints(e.Row[column.ColumnName], column, ref message)) { if (message != null && !message.Equals("")) { throw new RuleColumnConstraintException(this, e.Row, column, message); } //SendRuleExceptionEvent(sender, new RuleColumnConstraintException(this, e.Row, column, message)); else { throw new RuleColumnConstraintException(this, e.Row, column); } //SendRuleExceptionEvent(sender, new RuleColumnConstraintException(this, e.Row, column)); } } } }