protected void CreateChildrenFromTemplate(XElement node, Hashtable boundFields, ref BindList <FormObject> children) { children.Clear(); foreach (XElement child in node.Elements()) { CreateChild(boundFields, children, child); } }
private void DeleteGridRow(int i) { if (!grid.EditedCell.IsValid) { return; } if (itemShortcuts.Count > 1) { int col = grid.EditedCell.Column; int row = grid.EditedCell.Row; int newRow; if (row == itemShortcuts.Count - 1) { // If we are deleting the last row move one row up itemShortcuts.RemoveAt(row); newRow = row - 1; } else { // If we are deleting row from somewhere in between stay on the same line itemShortcuts.RemoveAt(row); newRow = row; } EditGridCell(newRow, col); } else { itemShortcuts.Clear(); itemShortcuts.Add(new ItemShortcut()); EditGridCell(0, 0); } }
public void SetTotal(double total) { list.Clear(); for (int i = allButtons.Count - 1; i >= 0; i--) { double value = (double)allButtons [i].Data ["Value"]; if (value <= total) { AddMoney(value, 1, false); total = Math.Round(total - value, 2, MidpointRounding.AwayFromZero); i++; } if (total.IsZero()) { break; } } RefreshGrid(); }
protected virtual void DeleteGridRow(bool keepRowPos) { if (!grid.EditedCell.IsValid) { return; } if (selectedDetails.Count > 1) { int col = grid.EditedCell.Column; int row = grid.EditedCell.Row; int newRow; if (row == selectedDetails.Count - 1) { // If we are deleting the last row move one row up selectedDetails.RemoveAt(row); newRow = row - 1; } else { // If we are deleting row from somewhere in between stay on the same line selectedDetails.RemoveAt(row); newRow = row; } EditGridCell(newRow, col); } else { selectedDetails.Clear(); selectedDetails.Add(new SaleDetail()); EditGridCell(0, 0); } }
public override void CreateFromTemplate(XElement node, Hashtable boundFields) { XAttribute tempAttr = node.Attribute("style"); if (tempAttr != null) { style.LoadFromString(tempAttr.Value); itemStyle.LoadFromString(tempAttr.Value); } tempAttr = node.Attribute("font"); if (tempAttr != null) { itemFont.LoadFromString(tempAttr.Value); } TextBox tb; tempAttr = node.Attribute("text"); if (tempAttr != null) { tb = DocumentHelper.FormObjectCreator.CreateTextBox(); tb.Text = tempAttr.Value; tb.Style = (ObjectStyle)itemStyle.Clone(); tb.Font = (ObjectFont)itemFont.Clone(); itemTemplate.Clear(); itemTemplate.Add(tb); } tempAttr = node.Attribute("sourceField"); if (tempAttr != null) { tb = DocumentHelper.FormObjectCreator.CreateTextBox(); tb.SourceField = tempAttr.Value; if (boundFields [tempAttr.Value] != null) { tb.Text = boundFields [tempAttr.Value].ToString(); } tb.Style = (ObjectStyle)itemStyle.Clone(); tb.Font = (ObjectFont)itemFont.Clone(); itemTemplate.Clear(); itemTemplate.Add(tb); } foreach (XElement child in node.Elements()) { XAttribute styleAttr; switch (child.Name.LocalName.ToLowerInvariant()) { case "template": styleAttr = child.Attribute("style"); if (styleAttr != null) { itemStyle.LoadFromString(styleAttr.Value); } if (child.HasElements) { CreateChildrenFromTemplate(child, boundFields, ref itemTemplate); } break; case "header": styleAttr = child.Attribute("style"); if (styleAttr != null) { headerStyle.LoadFromString(styleAttr.Value); } tempAttr = node.Attribute("font"); if (tempAttr != null) { headerFont.LoadFromString(tempAttr.Value); } tempAttr = child.Attribute("text"); if (tempAttr != null) { tb = DocumentHelper.FormObjectCreator.CreateTextBox(); tb.Text = tempAttr.Value; tb.Style = (ObjectStyle)headerStyle.Clone(); tb.Font = (ObjectFont)headerFont.Clone(); headerTemplate.Clear(); headerTemplate.Add(tb); } tempAttr = child.Attribute("sourceField"); if (tempAttr != null) { tb = DocumentHelper.FormObjectCreator.CreateTextBox(); tb.SourceField = tempAttr.Value; tb.Text = boundFields [tempAttr.Value].ToString(); tb.Style = (ObjectStyle)headerStyle.Clone(); tb.Font = (ObjectFont)headerFont.Clone(); headerTemplate.Clear(); headerTemplate.Add(tb); } if (child.HasElements) { CreateChildrenFromTemplate(child, boundFields, ref headerTemplate); } break; case "footer": styleAttr = child.Attribute("style"); if (styleAttr != null) { footerStyle.LoadFromString(styleAttr.Value); } tempAttr = node.Attribute("font"); if (tempAttr != null) { footerFont.LoadFromString(tempAttr.Value); } tempAttr = child.Attribute("text"); if (tempAttr != null) { tb = DocumentHelper.FormObjectCreator.CreateTextBox(); tb.Text = tempAttr.Value; tb.Style = (ObjectStyle)footerStyle.Clone(); tb.Font = (ObjectFont)footerFont.Clone(); footerTemplate.Clear(); footerTemplate.Add(tb); } tempAttr = child.Attribute("sourceField"); if (tempAttr != null) { tb = DocumentHelper.FormObjectCreator.CreateTextBox(); tb.SourceField = tempAttr.Value; tb.Text = boundFields [tempAttr.Value].ToString(); tb.Style = (ObjectStyle)footerStyle.Clone(); tb.Font = (ObjectFont)footerFont.Clone(); footerTemplate.Clear(); footerTemplate.Add(tb); } if (child.HasElements) { CreateChildrenFromTemplate(child, boundFields, ref footerTemplate); } break; } } }
protected virtual void RefreshStructure(Hashtable boundFields) { bindableFields = boundFields; int i; if (boundFields.ContainsKey(sourceTableHasFooterSource)) { bool.TryParse(boundFields [sourceTableHasFooterSource].ToString(), out sourceTableHasFooter); } if (!boundFields.ContainsKey(sourceTable)) { return; } BindManager bManager = new BindManager(boundFields [sourceTable], true, ColumnNameResolver); // bManager.Columns may be null when the source table is a dictionary // the check below simply prevents crashing but the binding manager should be extended later if (columns.Count == 0 && bManager.Columns != null) { autoColumns = true; if (bManager.Columns.NamedColumns) { for (i = 0; i < bManager.Columns.Count; i++) { columns.Add(new TableColumn(bManager.Columns [i].Name, bManager.Columns [i].Caption)); } } else { for (i = 0; i < bManager.Columns.Count; i++) { columns.Add(new TableColumn(i.ToString(), i.ToString())); } } TableColumn tableColumn; if (hasHeader) { header = DocumentHelper.FormObjectCreator.CreateRow(columns.Count); header.BindableFields = boundFields; for (i = 0; i < columns.Count; i++) { tableColumn = columns [i]; TableCell headerCell = (TableCell)header.Children [i]; headerCell.Template.AddRange(tableColumn.HeaderTemplate); headerCell.Style = (ObjectStyle)tableColumn.HeaderStyle.Clone(); } } if (sourceTableHasFooter) { footer = DocumentHelper.FormObjectCreator.CreateRow(columns.Count); footer.BindableFields = boundFields; BindRow <object> footerRow = null; if (!string.IsNullOrEmpty(sourceTableHasFooterSource) && bManager.Rows.Count > 0) { footerRow = bManager.Rows [bManager.Rows.Count - 1]; } for (i = 0; i < columns.Count; i++) { tableColumn = columns [i]; TextBox tb = DocumentHelper.FormObjectCreator.CreateTextBox(); tb.Text = footerRow == null ? string.Empty : footerRow [i].ToString(); TableCell footerCell = (TableCell)footer.Children [i]; footerCell.Template.Add(tb); footerCell.Style = (ObjectStyle)tableColumn.FooterStyle.Clone(); } } else { footer = null; } } RefreshRowStyles(); rows.Clear(); if (header != null) { rows.Add(header); } for (i = 0; i < bManager.Rows.Count - (sourceTableHasFooter && !string.IsNullOrEmpty(sourceTableHasFooterSource) ? 1 : 0); i++) { TableRow tableRow = DocumentHelper.FormObjectCreator.CreateRow(Columns, GetBoundFields(bManager, i)); tableRow.Style = (ObjectStyle)itemStyle.Clone(); rows.Add(tableRow); if (style.InnerVerticalBorder.HasValue) { tableRow.Style.InnerVerticalBorder = style.InnerVerticalBorder; } } bindableFields = boundFields; if (sourceTableHasFooter && footer != null) { rows.Add(footer); } }