private WbapList CreatePageList(DataListBindSchema listSchema) { WbapList webList = new WbapList(); webList.Id = listSchema.Id; webList.DataRow = listSchema.DataRow; for (int j = 0; j < listSchema.Columns.Count; j++) { FieldBindSchema fieldSchema = listSchema.Columns[j]; webList.Columns.Add(fieldSchema.Id); } DataTable table = this.DataSet.Tables[listSchema.TableId]; if (table == null) { throw new E_WbdlDataSourceNotFindTable(listSchema.TableId); } DataColumn[] keys = table.PrimaryKey; foreach (DataColumn key in keys) { string colName = key.ColumnName + WbdlConst._Key.ToString(); if (!webList.Columns.Contains(colName)) { webList.Columns.Add(colName); } } return(webList); }
private void SetElementDataValue(FieldBindSchema fieldSchema, string value) { if (!DataSet.Tables.Contains(fieldSchema.TableId)) { throw new E_WbdlDataSourceNotFindTable(fieldSchema.TableId); } DataTable dataTable = DataSet.Tables[fieldSchema.TableId]; if (!dataTable.Columns.Contains(fieldSchema.FieldId)) { throw new E_WbdlDatasourceNotFindField(fieldSchema.TableId + "." + fieldSchema.FieldId); } int RowIndex = dataSource.Tables[fieldSchema.TableId].RowIndex; if (RowIndex > -1) { DataRow dataRow = dataTable.Rows[RowIndex]; dataRow[fieldSchema.FieldId] = value; } else { throw new E_WbdlDataTableNotRowForEdit(fieldSchema.TableId); } }
internal FieldBindSchema FindFieldSchema(string tableName, string fieldName) { for (int i = 0; i < Schame.FieldBinds.Count; i++) { FieldBindSchema fieldBind = Schame.FieldBinds[i]; if (tableName.Equals(fieldBind.TableId, StringComparison.OrdinalIgnoreCase)) { if (fieldName.Equals(fieldBind.FieldId, StringComparison.OrdinalIgnoreCase)) { return(fieldBind); } } } foreach (DataListBindSchema listBind in Schame.DataListBinds) { foreach (FieldBindSchema fieldBind in listBind.Columns) { if (tableName.Equals(fieldBind.TableId, StringComparison.OrdinalIgnoreCase)) { if (fieldName.Equals(fieldBind.FieldId, StringComparison.OrdinalIgnoreCase)) { return(fieldBind); } } } } return(null); }
internal bool IsDataBindElement(FieldBindSchema fieldSchema) { return(fieldSchema != null && !string.IsNullOrEmpty(fieldSchema.TableId) && !string.IsNullOrEmpty(fieldSchema.FieldId) ); }
internal void SetRequestData(WbapDataBody wbapElementBinds) { PageForms forms = Page.PageForms; foreach (KeyValuePair <string, object> keyValue in wbapElementBinds) { var elementId = keyValue.Key; var Value = keyValue.Value; if (Value is WbapList) { SetWbapList(elementId, (WbapList)Value); } else if (Value is string) { PageDataForm form; FieldBindSchema schema = this.Schame.FieldBinds.FindItem(elementId); if (IsDataBindElement(schema)) { form = forms.FindForm(schema.TableId); if (form == null) { InitFieldBinds(); } form = forms.FindForm(schema.TableId); if (form == null) { throw new E_WbdlPageControllerException("not Initialize form " + schema.TableId); } form.CacheValue(schema.FieldId, (string)Value); } else { if (elementId.EndsWith(WbdlConst._Key.ToString())) { form = Page.PageForms.FindFormByKeyElement(elementId); if (form == null) { InitFieldBinds(); } form = Page.PageForms.FindFormByKeyElement(elementId); if (form != null) { form.PutKeyValue(elementId, (string)Value); } else { Page.StringElements.Add(elementId, (string)Value); } } } } } foreach (PageDataForm form in forms) { form.UpdateCache(); } }
internal bool IsDataBindElement(string elementId) { FieldBindSchema fieldSchema = Schame.FieldBinds.FindItem(elementId); if (fieldSchema == null) { throw new E_WbdlPageCannotGetFieldSchame(elementId); } return(fieldSchema != null && !string.IsNullOrEmpty(fieldSchema.TableId) && !string.IsNullOrEmpty(fieldSchema.FieldId) ); }
internal string GetStringElement(string elementId) { FieldBindSchema fieldSchema = Schame.FieldBinds.FindItem(elementId); if (IsDataBindElement(fieldSchema)) { return(GetElementDataValue(fieldSchema)); } if (Page.StringElements.ContainsKey(elementId)) { return(Page.StringElements[elementId]); } throw new E_WbdlPageNotHaveFieldElement(elementId); }
internal List <FieldBindSchema> GetDataBindSchemas(string tableName) { List <FieldBindSchema> fieldBinds = new List <FieldBindSchema>(); for (int i = 0; i < Schame.FieldBinds.Count; i++) { FieldBindSchema fieldBind = Schame.FieldBinds[i]; if (tableName.Equals(fieldBind.TableId, StringComparison.OrdinalIgnoreCase)) { fieldBinds.Add(fieldBind); } } return(fieldBinds); }
private string GetElementDataValue(FieldBindSchema fieldSchema) { if (!DataSet.Tables.Contains(fieldSchema.TableId)) { throw new E_WbdlDataSourceNotFindTable(fieldSchema.TableId); } DataTable dataTable = DataSet.Tables[fieldSchema.TableId]; if (!dataTable.Columns.Contains(fieldSchema.FieldId)) { throw new E_WbdlDatasourceNotFindField(fieldSchema.TableId + "." + fieldSchema.FieldId); } int RowIndex = dataSource.Tables[fieldSchema.TableId].RowIndex; if (RowIndex > -1) { DataRow dataRow = dataTable.Rows[RowIndex]; return(dataRow[fieldSchema.FieldId].ToString()); } return(""); }
private void InitualElement(WbapResponse resp, FieldBindSchema fieldBindSchema) { string tableName = fieldBindSchema.TableId; if (tableName == null) { throw (new E_WbdlPageFieldBindSchemaNotAssignedFieldId(fieldBindSchema.Id)); } XTableSchema tableSchema = this.pageCtr.GetTableSchema(tableName); // XTableAdapter tableAdapter = new XTableAdapter(tableSchema); if (tableSchema == null) { return; } FieldSchema fieldSchame = tableSchema.Fields.FindItem(fieldBindSchema.FieldId); if (fieldSchame == null) { return; //throw (new E_CannotGetFieldSchame(fieldBindSchema.TableId + "." + fieldBindSchema.FieldId)); } //fieldSchame.DisplayName = fieldBindSchema.DisplayName; //捆绑初始值 //if (fieldSchame.DefaultValue != null && fieldSchame.DefaultValue != "") //{ // if (!resp.ElementBinds.ContainsKey(fieldBindSchema.Id)) // resp.ElementBinds.Add(fieldBindSchema.Id, fieldSchame.DefaultValue); //} //捆绑下拉列表 string codeTableName = fieldSchame.CodeTableName; if (codeTableName != null && codeTableName != "") { // XData xData = new XData(); //try //{ // CodeTable codeTable = xData.GetCodeTable(codeTableName); // Dictionary<string, string> option = new Dictionary<string, string>(); // foreach (CodeTableData codeTableData in codeTable.Datas) // { // option.Add(codeTableData.Id, codeTableData.Text); // } // resp.ElementBinds.AddOption(fieldBindSchema.Id, option); //} //catch (Exception e) //{ // throw (new Exception("Bind Element CodeTable Error Element Id is'" + fieldBindSchema.Id + "' CodeTable is '" + codeTableName + "'," + e.Message)); //} } //捆绑Lookup LookupFieldSchema lookupField = tableSchema.LookupFields.FindItem(fieldBindSchema.FieldId); if (lookupField != null) { //WbapEvent wbapEvent = new WbapEvent(); //wbapEvent.EventName = "onpropertychange"; //string actionId= "GetLookup(" // + fieldBindSchema.TableId // + "," + fieldBindSchema.FieldId // + ","+field; //wbapEvent.Action.Request.ActionId =actionId; //wbapEvent.Action.Request.PageName = schema.Id; //wbapEvent.Action.Request.ElementBinds.Add("fieldName", fieldBindSchema.TableId); //wbapEvent.Action.Request.ElementBinds.Add("fieldName", fieldBindSchema.FieldId); //wbapEvent.Action.Request.ElementBinds.Add("fieldValue", "@" + fieldBindSchema.Id); //wbapEvent.Action.Request.ElementBinds.Add("ReturnValue", "@" + fieldBindSchema.Id + "_Lookup"); //fieldBindSchema. //resp.ElementBinds.AddEvent(fieldBindSchema.Id, wbapEvent); } }
public PageDataField(FieldBindSchema fieldSchema) { this.fieldSchema = fieldSchema; }