public static ChildTable CreateChildTable(int ID) { ChildTable childTable = new ChildTable(); childTable.Id = ID; return(childTable); }
public ActionResult DeleteConfirmed(int id) { ChildTable childTable = db.ChildTables.Find(id); db.ChildTables.Remove(childTable); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ID,PID,thing1,thing2")] ChildTable childTable) { if (ModelState.IsValid) { db.Entry(childTable).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(childTable)); }
public string GetChildrenPath(string action, object row) { // If there is no row, we can't get a path if (row == null) { return(String.Empty); } return(ChildTable.GetActionPath(action, GetRouteValues(row))); }
public IEnumerable GetNestedItems(RelationDescriptor rd, ChildTable childTable, object[] keys, out object totals) { if (NestedQueryHandler == null) { totals = null; return(null); } return(NestedQueryHandler(keys, out totals)); }
public ActionResult Create([Bind(Include = "ID,PID,thing1,thing2")] ChildTable childTable) { if (ModelState.IsValid) { db.ChildTables.Add(childTable); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(childTable)); }
/// <summary> /// Perform initialization logic for this column /// </summary> internal protected override void Initialize() { base.Initialize(); AssociationProvider a = this.Provider.Association; ChildTable = Model.GetTable(a.ToTable.Name, Table.DataContextType); if (a.ToColumn != null) { ColumnInOtherTable = ChildTable.GetColumn(a.ToColumn.Name); } }
// GET: ChildTables/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ChildTable childTable = db.ChildTables.Find(id); if (childTable == null) { return(HttpNotFound()); } return(View(childTable)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Transient public Object clone(boolean cloneAssembly, boolean cloneChild) public virtual object Clone(bool cloneAssembly, bool cloneChild) { AssemblyAssemblyTable obj = new AssemblyAssemblyTable(); obj.AssemblyChildId = AssemblyChildId; obj.LastUpdate = LastUpdate; //obj.setFinalRate(getFinalRate()); obj.Factor1 = this.Factor1; obj.Factor2 = Factor2; obj.Factor3 = Factor3; obj.QuantityPerUnit = QuantityPerUnit; obj.QuantityPerUnitFormula = QuantityPerUnitFormula; obj.QuantityPerUnitFormulaState = QuantityPerUnitFormulaState; obj.LocalFactor = LocalFactor; obj.LocalCountry = LocalCountry; obj.LocalStateProvince = LocalStateProvince; obj.ExchangeRate = ExchangeRate; obj.FixedCost = FixedCost; obj.Comment = Comment; obj.PvVars = PvVars; obj.ChildTableId = ChildTableId; obj.ProjectId = ProjectId; try { obj.FinalRate = calculateFinalRate(); obj.FinalFixedCost = calculateFinalFixedCost(); } catch (System.NullReferenceException) { // ignore! } if (cloneAssembly && ParentTable != null) { obj.ParentTable = (AssemblyTable)ParentTable.clone(); } if (cloneChild && ChildTable != null) { obj.ChildTable = (AssemblyTable)ChildTable.clone(); } return(obj); }
public virtual decimal calculateFinalFixedCost() { if (ParentTable != null && ChildTable != null) { finalFixedCost = ChildTable.calculateFinalFixedCost(); finalFixedCost = BigDecimalMath.mult(finalFixedCost, ExchangeRate); finalFixedCost = BigDecimalMath.mult(finalFixedCost, Factor1); finalFixedCost = BigDecimalMath.mult(finalFixedCost, Factor2); finalFixedCost = BigDecimalMath.mult(finalFixedCost, Factor3); finalFixedCost = BigDecimalMath.mult(finalFixedCost, LocalFactor); } //finalFixedCost.setScale(10, decimal.ROUND_HALF_UP); finalFixedCost = Math.Round(finalFixedCost, 10, MidpointRounding.AwayFromZero); return(finalFixedCost); }
public virtual decimal calculateFinalRate() { if (ParentTable != null && ChildTable != null) { ChildTable.calculateRate(); finalRate = ChildTable.Rate * Factor1; finalRate = finalRate * Factor2; finalRate = finalRate * Factor3; finalRate = finalRate * ExchangeRate; finalRate = finalRate * LocalFactor; finalRate = finalRate * QuantityPerUnit; //finalRate = finalRate.setScale(10, decimal.ROUND_HALF_UP); finalRate = Math.Round(finalRate, 10, MidpointRounding.AwayFromZero); } return(finalRate); }
internal void CheckNestedRelations() { Debug.Assert(DataSet == null || !nested, "this relation supposed to be not in dataset or not nested"); // 1. There is no other relation (R) that has this.ChildTable as R.ChildTable if (ChildTable.FindNestedParent() != null) { throw ExceptionBuilder.TableCantBeNestedInTwoTables(ChildTable.TableName); } // 2. There is no loop in nested relations #if DEBUG int numTables = ParentTable.DataSet.Tables.Count; #endif DataTable dt = ParentTable; if (ChildTable == ParentTable) { if (ChildTable.TableName == ChildTable.DataSet.DataSetName) { throw ExceptionBuilder.SelfnestedDatasetConflictingName(ChildTable.TableName); } return; //allow self join tables. } while (true) { #if DEBUG Debug.Assert(0 < (numTables--), "We already have a loop in nested relations"); #endif if (dt == ChildTable) { throw ExceptionBuilder.LoopInNestedRelations(ChildTable.TableName); } if (dt.nestedParentRelation != null && dt != dt.nestedParentRelation.ParentTable) { dt = dt.nestedParentRelation.ParentTable; } else { break; } } }// CheckNestedRelationss
private static IFurniture CreateRandomFurniture(Random random) { IFurniture f = null; int a = random.Next(1, 6); switch (a) { case 1: f = new AdultBed(); ((IBed)f).SeatPlacesNumber = random.Next(1, 2); break; case 2: f = new AdultCabinet(); ((ICabinet)f).SectionsNumber = random.Next(2, 10); break; case 3: f = new AdultTable(); break; case 4: f = new ChildBed(); ((IBed)f).SeatPlacesNumber = random.Next(1, 3); ((IChild)f).CertificateNumber = "N-" + random.Next(1000, 30000); break; case 5: f = new ChildCabinet(); ((ICabinet)f).SectionsNumber = random.Next(1, 5); ((IChild)f).CertificateNumber = "N-" + random.Next(1000, 30000); break; case 6: f = new ChildTable(); ((IChild)f).CertificateNumber = "N-" + random.Next(1000, 30000); break; } return(f); }
/// <summary> /// Refreshes the internal SQL statement to reflect any property value changes /// within the child entity. This method should be called whenever a foreign key /// value changes. /// </summary> public void Refresh() { // Create new WHERE Statement Statement = new SelectWhereStatement(); // Fill up the WhereStatement with joining keys specific to this Child // entities instance for (int i = 0; i < Constraint.ForeignKey.Attributes.Length; i++) { // Grab attribute names string childColName = Constraint.ForeignKey.Attributes[i]; string parentColName = Constraint.InverseKey.Attributes[i]; // Get the value of the child attribute on this Entity instance AttributeInfo info = ChildTable.GetAttribute(childColName); object val = info.Property.GetValue(ChildEntity); // Add the key => value to the where statement Statement.And(parentColName, Comparison.Equals, val); } }
/// <summary> /// Setting Maual relation to the GridGroupingControl. /// </summary> private void SampleCustomization() { #region DataTable DataSet ds = new DataSet(); ReadXml(ds, @"Expand.xml"); ds.Tables[1].TableName = "Products"; ds.Tables[2].TableName = "OrderDetails"; ds.Tables[3].TableName = "Suppliers"; ds.Relations.Add( ds.Tables[0].Columns["CategoryID"], ds.Tables[1].Columns["CategoryID"]); ds.Relations[0].RelationName = "Category_Products"; ds.Relations.Add( ds.Tables[1].Columns["ProductID"], ds.Tables[2].Columns["ProductID"]); ds.Relations[1].RelationName = "Products_OrderDetails"; #endregion this.groupingGrid1.DataSource = ds.Tables[0]; GridEngine engine = this.groupingGrid1.Engine; engine.TopLevelGroupOptions.ShowCaption = true; // Record summary for Categories Tables GridTableDescriptor categoriesTableDescriptor = (GridTableDescriptor)engine.TableDescriptor; categoriesTableDescriptor.Columns.Clear(); categoriesTableDescriptor.Columns.Add("CategoryID"); categoriesTableDescriptor.Columns.Add("CategoryName"); categoriesTableDescriptor.Columns.Add("Description"); categoriesTableDescriptor.Columns["CategoryName"].Width = 200; //Creating a new SummaryColumnDescriptor. GridSummaryColumnDescriptor countCat = new GridSummaryColumnDescriptor("RecordCount"); //Setting it's properties. countCat.SummaryType = SummaryType.Count; countCat.Style = GridSummaryStyle.FillRow; //Initializing it to the Column it is associated with. countCat.DataMember = "CategoryID"; //Mentioning the format of display. countCat.Format = " {Count} Records."; //Adding the SummaryColumnDescriptor to the SummaryRowDescriptor. GridSummaryRowDescriptor categoriesSummaryRow = new GridSummaryRowDescriptor("RecordCountRow"); categoriesSummaryRow.SummaryColumns.Add(countCat); //Adding the SummaryRowDescriptor to the TableDesriptor. categoriesTableDescriptor.SummaryRows.Add(categoriesSummaryRow); // Group Products table by "SupplierID" RelationDescriptor productsRelationDescriptor = categoriesTableDescriptor.Relations["Products"]; GridTableDescriptor productsTableDescriptor = (GridTableDescriptor)productsRelationDescriptor.ChildTableDescriptor; productsTableDescriptor.GroupedColumns.Add("SupplierID"); // Group OrderDetails table by "Discount" // Add Total = "[UnitPrice]*[Quantity]" expression field // Add Summaries for Total and Average for UnitPrice. RelationDescriptor orderDetailsRelationDescriptor = productsTableDescriptor.Relations["OrderDetails"]; GridTableDescriptor orderDetailsTableDescriptor = (GridTableDescriptor)orderDetailsRelationDescriptor.ChildTableDescriptor; ExpressionFieldDescriptor ed = new ExpressionFieldDescriptor("Total", "[UnitPrice]*[Quantity]"); ed.DefaultValue = ""; orderDetailsTableDescriptor.ExpressionFields.Add(ed); orderDetailsTableDescriptor.GroupedColumns.Add("Discount"); //Adding the SummaryColumnDescriptor to the SummaryRowDescriptor. GridSummaryRowDescriptor orderDetailsSummaryRow = new GridSummaryRowDescriptor("Total"); orderDetailsTableDescriptor.SummaryRows.Add(orderDetailsSummaryRow); //Creating a new SummaryColumnDescriptor. GridSummaryColumnDescriptor totalSum = new GridSummaryColumnDescriptor("Total"); //Setting it's properties. totalSum.SummaryType = SummaryType.DoubleAggregate; totalSum.Style = GridSummaryStyle.Column; //Initializing it to the Column it is associated with. totalSum.DataMember = "Total"; totalSum.DisplayColumn = "Total"; totalSum.Format = "Sum={Sum}"; orderDetailsSummaryRow.SummaryColumns.Add(totalSum); orderDetailsTableDescriptor.Columns["Total"].Width = 70; //Creating a new SummaryColumnDescriptor. GridSummaryColumnDescriptor avgUnitPrice = new GridSummaryColumnDescriptor("AvgUnitPrice"); //Setting it's properties. avgUnitPrice.SummaryType = SummaryType.DoubleAggregate; avgUnitPrice.Style = GridSummaryStyle.Column; avgUnitPrice.DataMember = "UnitPrice"; avgUnitPrice.DisplayColumn = "UnitPrice"; avgUnitPrice.Format = "Avg={Average:#.0}"; orderDetailsSummaryRow.SummaryColumns.Add(avgUnitPrice); // expand a specific record, search for groups etc. Table categoriesTable = engine.Table;//.RelatedTables["Categories"]; Console.WriteLine(categoriesTable.ToString()); Table productsTable = categoriesTable.RelatedTables["Products"]; Console.WriteLine(productsTable.ToString()); // Get the child table in the products table that is assocuated with category "1" ChildTable product1 = (ChildTable)productsTable.TopLevelGroup.Groups["1"]; Console.WriteLine(product1.ToString()); Console.WriteLine(product1.Groups[0].ToString()); // Get the child table in the products table that is assocuated with category "1" ChildTable product21 = (ChildTable)productsTable.TopLevelGroup.Groups["8"]; Console.WriteLine(product21.ToString()); Console.WriteLine(product21.Groups[0].Records[0].ToString()); // Show me the associated "NestedTable" element of the categories table (the NestedTable // element established the link between parent table and a nested child table) Console.WriteLine(product21.Groups[0].Records[0].ParentChildTable.ParentNestedTable); // Expand the product for category 8 product21.IsExpanded = true; product21.ParentNestedTable.IsExpanded = true; product21.ParentNestedTable.ParentRecord.IsExpanded = true; // When you assign a "DataSet" as a datasource, the DataSet is a list with one record (not allowing AddNew) with nested tables. // Expand the first record so that tables are shown. engine.Table.TopLevelGroup.Records[0].IsExpanded = true; // Sort product table by ProductName product21.ParentTable.TableDescriptor.SortedColumns.Add("ProductName"); // Find group for supplier id 21 Group supplier21Group = product21.Groups["21"]; // Find productname Spegesild in that group int index = supplier21Group.Records.FindRecord("Spegesild"); // Print out the row index and record index Record r = supplier21Group.Records[index]; Console.WriteLine("Found: " + r.ToString()); Console.WriteLine("RowIndex " + engine.Table.NestedDisplayElements.IndexOf(r).ToString()); Console.WriteLine("Record Index " + engine.Table.Records.IndexOf(r).ToString()); // Dump out nested display elements to console this.groupingGrid1.Table.Records[0].IsExpanded = true; this.groupingGrid1.Table.TopLevelGroup.IsExpanded = true; engine.ChildGroupOptions.ShowCaption = true; engine.NestedTableGroupOptions.ShowCaption = true; // Adding GroupDropAreas for nested tables. groupingGrid1.AddGroupDropArea((GridTable)productsTable); groupingGrid1.AddGroupDropArea((GridTable)productsTable.RelatedTables[0]); groupingGrid1.ShowGroupDropArea = true; //Navigate to other control using tabkey navigation groupingGrid1.WantTabKey = false; // Make Spegesild current record if (r != null) { r.SetCurrent(); // Expand record and nested tables r.IsExpanded = true; r.NestedTables[0].IsExpanded = true; Record orderDetailsRecords = r.NestedTables[0].ChildTable.GetFirstRecord(); // Expand Group record belongs to orderDetailsRecords.ParentGroup.IsExpanded = true; // Scroll this record in view. groupingGrid1.TableControl.ScrollInView(orderDetailsRecords); groupingGrid1.TableControl.LeftColIndex = 1; } }
public void AddToChildTables(ChildTable childTable) { base.AddObject("ChildTables", childTable); }
public string GetChildrenPath(string action, object row, string path) { return(ChildTable.GetActionPath(action, row, path)); }
public string GetChildrenListPath(object row) { return(ChildTable.GetActionPath(PageAction.List, row)); }
public static ChildTable CreateChildTable(int ID) { ChildTable childTable = new ChildTable(); childTable.Id = ID; return childTable; }