/// <summary> /// This function iterates through all the dynamically added controls, checks their values, and returns a list of column and values mapped as KeyValuePair<column_name, value>. /// </summary> /// <param name="skipSerial">Skip the PostgreSQL serial column. There is no need to explicity set the value for the serial column. This value should be <strong>true</strong> if you are obtaining the form to insert the record. Set this paramter to <b>false</b> if you want to update the form based on the serial's columns value.</param> /// <returns>Returns a list of column and values mapped as KeyValuePair<column_name, value></returns> private System.Collections.ObjectModel.Collection <KeyValuePair <string, string> > GetFormCollection(bool skipSerial) { System.Collections.ObjectModel.Collection <KeyValuePair <string, string> > list = new System.Collections.ObjectModel.Collection <KeyValuePair <string, string> >(); using (System.Data.DataTable table = MixERP.Net.BusinessLayer.Helpers.TableHelper.GetTable(this.TableSchema, this.Table, this.Exclude)) { if (table.Rows.Count > 0) { foreach (System.Data.DataRow row in table.Rows) { string columnName = MixERP.Net.Common.Conversion.TryCastString(row["column_name"]); string defaultValue = MixERP.Net.Common.Conversion.TryCastString(row["column_default"]); bool isSerial = defaultValue.StartsWith("nextval", StringComparison.OrdinalIgnoreCase); string parentTableColumn = MixERP.Net.Common.Conversion.TryCastString(row["references_field"]); string dataType = MixERP.Net.Common.Conversion.TryCastString(row["data_type"]); if (skipSerial) { if (isSerial) { continue; } } if (string.IsNullOrWhiteSpace(parentTableColumn)) { switch (dataType) { case "national character varying": case "character varying": case "national character": case "character": case "char": case "varchar": case "nvarchar": case "text": case "date": case "smallint": case "integer": case "bigint": case "numeric": case "money": case "double": case "double precision": case "float": case "real": case "currency": //TextBox TextBox t = (TextBox)FormContainer.FindControl(columnName + "_textbox"); if (t != null) { list.Add(new KeyValuePair <string, string>(columnName, t.Text)); } break; case "boolean": RadioButtonList r = (RadioButtonList)FormContainer.FindControl(columnName + "_radiobuttonlist"); list.Add(new KeyValuePair <string, string>(columnName, r.Text)); break; case "bytea": FileUpload f = (FileUpload)FormContainer.FindControl(columnName + "_fileupload"); string file = this.UploadFile(f); list.Add(new KeyValuePair <string, string>(columnName, file)); imageColumn = columnName; break; } } else { //DropDownList DropDownList d = (DropDownList)FormContainer.FindControl(columnName + "_dropdownlist"); list.Add(new KeyValuePair <string, string>(columnName, d.Text)); } } } } return(list); }