protected void txtTm_TextChanged(object sender, EventArgs e) { PropertyInfo property = dataSource.GetType().GetProperty(column.Text); TextBox txt = (TextBox)sender; try { object oValue; if (txt.Text.Trim() == string.Empty) { oValue = NullFinder.GetNullValue(column.DataType); } else { DateTime oldValue = (DateTime)property.GetValue(dataSource, null); string newValue = string.Format("{0} {1}", oldValue.ToShortDateString(), txt.Text); oValue = DateTime.Parse(newValue); } property.SetValue(dataSource, oValue, null); } catch (Exception) { txtTm_DataBinding(txt, null); } }
//binding a readonly field to the associated property of the datasource protected void lbl_DataBinding(object sender, EventArgs e) { Label lbl = (Label)sender; if (column.IsStatic) { lbl.Text = column.Text; } else { object oValue = dataSource.GetType().GetProperty(column.Text).GetValue(dataSource, null); if (NullFinder.IsNull(oValue, column.DataType) || (oValue == null)) { lbl.Text = string.Empty; } else { if (column.IsLookup) { lbl.Text = lookup.GetLookup(column.Lookup)[oValue]; } else { if ((column.Format != null) && (column.Format != string.Empty)) { lbl.Text = string.Format("{0:" + column.Format + "}", oValue); } else { lbl.Text = oValue.ToString(); } } } } }
//updating the datasource in accordance to the users selection from the //dropdown list protected void ddl_SelectedIndexChanged(object sender, EventArgs e) { if (dataSource != null) { PropertyInfo property = dataSource.GetType().GetProperty(column.Text); string selectedValue = ((DropDownList)sender).SelectedValue; object oValue = NullFinder.Parse(selectedValue, property.PropertyType); property.SetValue(dataSource, oValue, null); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { GINDataEditor.DataSource = GINInformation; GINInfo ginInfo = (GINInfo)GINDataEditor.DataSource; if (NullFinder.IsNull(ginInfo.DateApproved, "System.DateTime")) { ginInfo.DateApproved = DateTime.Now; } GINDataEditor.DataBind(); } }
protected void txtTm_DataBinding(object sender, EventArgs e) { object oValue = dataSource.GetType().GetProperty(column.Text).GetValue(dataSource, null); TextBox txt = (TextBox)sender; if (NullFinder.IsNull(oValue, column.DataType)) { txt.Text = string.Empty; } else { txt.Text = ((DateTime)oValue).ToShortTimeString(); } }
protected void txtDt_DataBinding(object sender, EventArgs e) { object oValue = dataSource.GetType().GetProperty(column.Text).GetValue(dataSource, null); TextBox txt = (TextBox)sender; if (NullFinder.IsNull(oValue, column.DataType)) { txt.Text = string.Empty; } else { txt.Text = string.Format("{0:MM-dd-yyyy}", (DateTime)oValue); } }
//mapping the associated property of the datasource to its text in the dropdown list protected void ddl_DataBinding(object sender, EventArgs e) { object dataValue = dataSource.GetType().GetProperty(column.Text).GetValue(dataSource, null); if (!NullFinder.IsNull(dataValue, column.DataType)) { try { ((DropDownList)sender).SelectedValue = dataValue.ToString(); } catch { } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { try { GINDataEditor.DataSource = new LeavingTruck(GINTruckInformation); LeavingTruck lt = (LeavingTruck)GINDataEditor.DataSource; if (NullFinder.IsNull(lt.TruckCheckedOutOn, "System.DateTime")) { lt.TruckCheckedOutOn = DateTime.Now; } GINDataEditor.DataBind(); } catch (Exception ex) { throw ex; } } }
//binding an editable field to the associated property of the datasource protected void txt_DataBinding(object sender, EventArgs e) { object oValue = dataSource.GetType().GetProperty(column.Text).GetValue(dataSource, null); TextBox txt = (TextBox)sender; if (NullFinder.IsNull(oValue, column.DataType) || (oValue == null)) { txt.Text = string.Empty; } else { if ((column.Format != null) && (column.Format != string.Empty)) { txt.Text = string.Format("{0:" + column.Format + "}", oValue); } else { txt.Text = oValue.ToString(); } } }
public override void OnInspectorGUI() { find = target as NullFinder; GUILayout.BeginHorizontal(); GUILayout.Label("ToFindClassName"); find.toFindclassName = EditorGUILayout.TextField(find.toFindclassName); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("ToFindMethodName"); find.toFindMethodName = EditorGUILayout.TextField(find.toFindMethodName); GUILayout.EndHorizontal(); EditorGUILayout.BeginVertical(); if (GUILayout.Button("Find")) { find.Find(); } if (find != null) { if (find.missingList != null) { int length = find.missingList.Count; for (int index = 0; index < length; index++) { find.missingList[index] = (GameObject)EditorGUILayout.ObjectField(find.missingList[index], typeof(Object), false); } } } EditorGUILayout.EndVertical(); }
//when the value of the field is changed (by the user), and is valid //the handler updates the associated property of the datasource. protected void txt_TextChanged(object sender, EventArgs e) { PropertyInfo property = dataSource.GetType().GetProperty(column.Text); TextBox txt = (TextBox)sender; try { object oValue; if (txt.Text.Trim() == string.Empty) { oValue = NullFinder.GetNullValue(column.DataType); } else { oValue = NullFinder.Parse(txt.Text, property.PropertyType); } property.SetValue(dataSource, oValue, null); } catch (Exception) { txt_DataBinding(txt, null); } }
protected void Page_Load(object sender, EventArgs e) { ReturnedBagsGridViewer.DataSource = from returnedBags in GINTruckInformation.Weight.ReturnedBags select new ReturnedBagsWrapper(returnedBags, ginProcess.GINProcessInformation.CommodityGradeId, ginProcess.GINProcessInformation.ProductionYear); ReturnedBagsGridViewer.DataBind(); AddedBagsGridViewer.DataSource = from addedBags in GINTruckInformation.Weight.AddedBags select new ReturnedBagsWrapper(addedBags, ginProcess.GINProcessInformation.CommodityGradeId, ginProcess.GINProcessInformation.ProductionYear); AddedBagsGridViewer.DataBind(); var gridCommands = from command in ReturnedBagsGridViewer.Driver.Columns where command.IsCommand select command.AttachedRenderer; foreach (LinkGINColumnRenderer linkCommand in gridCommands) { linkCommand.Command += new CommandEventHandler(linkCommand_Command); } var addedGridCommands = from command in AddedBagsGridViewer.Driver.Columns where command.IsCommand select command.AttachedRenderer; foreach (LinkGINColumnRenderer linkCommand in addedGridCommands) { linkCommand.Command += new CommandEventHandler(linkCommand_Command); } if (!IsPostBack) { try { GINDataEditor.DataSource = ginProcess.GetGINReport(GINTruckInformation.TruckId); GINDataEditor.DataBind(); TruckWeightEditor.DataSource = GINTruckInformation.Weight; TruckWeightEditor.DataBind(); GINIssuanceEditor.DataSource = GINTruckInformation.GIN; GINInfo ginInfo = (GINInfo)GINIssuanceEditor.DataSource; if (NullFinder.IsNull(ginInfo.DateIssued, "System.DateTime")) { ginInfo.DateIssued = DateTime.Now; } GINIssuanceEditor.DataBind(); } catch (Exception ex) { throw ex; } } TruckWeightInfo newWeight = (TruckWeightInfo)TruckWeightEditor.DataSource; decimal truckWeight = GINTruckInformation.Weight.TruckWeight; decimal grossWeight = GINTruckInformation.Weight.GrossWeight; GINTruckInformation.Weight.TruckWeight = newWeight.TruckWeight; GINTruckInformation.Weight.GrossWeight = newWeight.GrossWeight; lblNetWeight.Text = ginProcess.CalculateNetWeight(newWeight.TruckId).ToString(); GINTruckInformation.Weight.TruckWeight = truckWeight; GINTruckInformation.Weight.GrossWeight = grossWeight; }
public virtual WebControl RenderInEditor() { if (column.IsCDDExtender || column.IsTextChangeExtender) { return(null); } if (!column.IsEditable || column.IsStatic) { Label lbl = new Label(); lbl.Width = new Unit(100, UnitType.Percentage); if (column.IsStatic) { lbl.Text = column.Text; } else { lbl.DataBinding += new EventHandler(lbl_DataBinding); } return(lbl); } if (column.IsLookup) { DropDownList ddl = new DropDownList(); ddl.Width = new Unit(100, UnitType.Percentage); ddl.DataBinding += new EventHandler(ddl_DataBinding); ddl.SelectedIndexChanged += new EventHandler(ddl_SelectedIndexChanged); IDictionary <object, string> dictionary = lookup.GetLookup(column.Lookup); foreach (object key in dictionary.Keys) { ListItem item = new ListItem(dictionary[key], key.ToString()); ddl.Items.Add(item); } var validationRule = from rule in column.Rules where (rule.ValidationType == "Required") && ((RequiredValidationRule)rule).IsRequired select rule; if (validationRule.Count() == 0) { ddl.Items.Add(new ListItem(string.Empty, NullFinder.GetNullValue(column.DataType).ToString())); } ddl.ID = string.Format("ddl{0}", column.Name); return(ddl); } if (column.IsCascadedLookup)// || column.IsCDDExtended) { DropDownList ddl = new DropDownList(); ddl.ID = string.Format("ddl{0}", column.Name); ddl.Width = new Unit(100, UnitType.Percentage); ddl.SelectedIndexChanged += new EventHandler(ddl_SelectedIndexChanged); return(ddl); } else { Panel ph = new Panel(); TextBox txt = new TextBox(); txt.Width = new Unit(100, UnitType.Percentage); txt.DataBinding += new EventHandler(txt_DataBinding); txt.TextChanged += new EventHandler(txt_TextChanged); txt.ID = string.Format("txt{0}", column.Name); if (column.IsLongText) { txt.TextMode = TextBoxMode.MultiLine; } ph.Controls.Add(txt); //for each rule specified in the column descriptor //the renderer attaches the appropriate validator control foreach (ValidationRule rule in column.Rules) { BaseValidator validationControl = null; switch (rule.ValidationType) { case "Required": if (((RequiredValidationRule)rule).IsRequired) { validationControl = new RequiredFieldValidator(); } break; case "Pattern": RegularExpressionValidator validator = new RegularExpressionValidator(); validator.ValidationExpression = ((PatternValidationRule)rule).Pattern; validationControl = validator; break; case "Range": RangeValidator rangeValidator = new RangeValidator(); RangeValidationRule rangeRule = (RangeValidationRule)rule; rangeValidator.MinimumValue = rangeRule.LeftBoundary; rangeValidator.MaximumValue = rangeRule.RightBoundary; validationControl = rangeValidator; break; case "Compare": CompareValidator compareValidator = new CompareValidator(); CompareValidationRule compareRule = (CompareValidationRule)rule; compareValidator.Operator = compareRule.CompareOperator; compareValidator.Type = compareRule.RuleDataType; compareValidator.ValueToCompare = compareRule.ValueToCompare; validationControl = compareValidator; break; } if (validationControl != null) { validationControl.ValidationGroup = "GINDataEditor"; validationControl.ControlToValidate = txt.ID; validationControl.ErrorMessage = rule.ErrorMessage; validationControl.Text = "*"; ph.Controls.Add(validationControl); } } return(ph); } }