//------------------------------------------------------------------------------------------- public string GetName(Guid nameId) { using (WeavverEntityContainer data = new WeavverEntityContainer()) { return data.GetName(nameId); } }
protected void Page_Load(object sender, EventArgs e) { if (Request["LedgerType"] == null) { Visible = false; return; } TextBox dateStart = BasePage.FindControlR<TextBox>("txbDateFrom"); TextBox dateEnd = BasePage.FindControlR<TextBox>("txbDateThrough"); Guid accountId = Guid.Empty; Guid.TryParse(Request["AccountId"], out accountId); if (accountId != Guid.Empty) { using (WeavverEntityContainer data = new WeavverEntityContainer()) { string ledgerType = Request["LedgerType"]; DateTime? startAt = null; DateTime startAt2; DateTime? endAt = null; DateTime endAt2; if (DateTime.TryParse(dateStart.Text, out startAt2)) startAt = startAt2; if (DateTime.TryParse(dateEnd.Text, out endAt2)) endAt = endAt2; string x = data.GetName(Guid.Empty); decimal credits = data.Total_ForLedger(BasePage.SelectedOrganization.Id, accountId, ledgerType, true, false, false, null, null); decimal debits = data.Total_ForLedger(BasePage.SelectedOrganization.Id, accountId, ledgerType, false, true, false, null, null); decimal balance = data.Total_ForLedger(BasePage.SelectedOrganization.Id, accountId, ledgerType, true, true, false, null, null); FundsIn.Text = String.Format("{0,10:C}", credits); FundsOut.Text = String.Format("{0,10:C}", debits); Balance.Text = String.Format("{0,10:C}", balance); AvailableBalance.Text = String.Format("{0,10:C}", data.Total_ForLedger(BasePage.SelectedOrganization.OrganizationId, accountId, ledgerType, true, true, true, null, null)); if (startAt != null || endAt != null) { FilteredTotals.Visible = true; decimal filteredStartingBalance = data.Total_ForLedger(BasePage.SelectedOrganization.Id, accountId, ledgerType, true, true, true, null, startAt); decimal filteredCredits = data.Total_ForLedger(BasePage.SelectedOrganization.Id, accountId, ledgerType, true, false, true, startAt, endAt); decimal filteredDebits = data.Total_ForLedger(BasePage.SelectedOrganization.Id, accountId, ledgerType, false, true, true, startAt, endAt); decimal filteredBalance = data.Total_ForLedger(BasePage.SelectedOrganization.Id, accountId, ledgerType, true, true, true, startAt, endAt); decimal filteredEndingBalance = data.Total_ForLedger(BasePage.SelectedOrganization.Id, accountId, ledgerType, true, true, true, null, endAt); VisibleStartingBalance.Text = String.Format("{0,10:C}", filteredStartingBalance); VisibleCredits.Text = String.Format("{0,10:C}", filteredCredits); VisibleDebits.Text = String.Format("{0,10:C}", filteredDebits); VisibleBalance.Text = String.Format("{0,10:C}", filteredBalance); VisibleEndingBalance.Text = String.Format("{0,10:C}", filteredEndingBalance); VisibleAvailableBalance.Text = String.Format("{0,10:C}", data.Total_ForLedger(BasePage.SelectedOrganization.Id, accountId, ledgerType, true, true, true, startAt, endAt)); } } } }
protected string GetDisplayString() { object value = FieldValue; if (value == null) { string fkey = FormatFieldValue(ForeignKeyColumn.GetForeignKeyString(Row)); if (fkey.Length == 36) { using (WeavverEntityContainer data = new WeavverEntityContainer()) { fkey = data.GetName(new Guid(fkey)); requiredCustomLookUp = true; } } return fkey; } else { return FormatFieldValue(ForeignKeyColumn.ParentTable.GetDisplayString(value)); } }
//------------------------------------------------------------------------------------------- protected override void OnInit(EventArgs e) { base.OnInit(e); table = DynamicDataRouteHandler.GetRequestMetaTable(Context); ScriptManager.RegisterStartupScript(UpdatePanel1, typeof(string), "RunScripts", "run();", true); Controls_ColumnPicker obj = (Controls_ColumnPicker) SecureContent.FindControl("ColumnPicker1"); if (obj != null) { obj.DataSaved += new DataSavedHandler(obj_DataSaved); GridView1.ColumnsGenerator = obj.FieldManager; } ((IQueryableDataSource)this.GridDataSource).QueryCreated += new EventHandler<QueryCreatedEventArgs>(List_QueryCreated); GridView1.DataBound += new EventHandler(GridView1_DataBound); GridView1.PageIndexChanging += new GridViewPageEventHandler(GridView1_PageIndexChanging); GridView1.RowDataBound += new GridViewRowEventHandler(GridView1_RowDataBound); GridView1.RowCreated += new GridViewRowEventHandler(GridView1_RowCreated); GridDataSource.Selected += new EventHandler<EntityDataSourceSelectedEventArgs>(GridDataSource_Selected); GridView1.SetMetaTable(table, table.GetColumnValuesFromRoute(Context)); //if (!IsPostBack) //{ GridDataSource.EntityTypeFilter = table.EntityType.Name; //} //GenerateMenu(TableActions.List, table.EntityType.GetType()); GridDataSource.WhereParameters.Add(new Parameter("OrganizationId", DbType.Guid, BasePage.SelectedOrganization.Id.ToString())); //set the default sort if (table.DisplayColumn != null) { GridDataSource.AutoGenerateOrderByClause = true; GridDataSource.OrderByParameters.Add(new Parameter(table.DisplayColumn.Name)); } if (Request["ObjectId"] != null) GridDataSource.WhereParameters.Add(new Parameter("ObjectId", DbType.Guid, Request["ObjectId"])); if (Request["AccountId"] != null) { GridDataSource.WhereParameters.Add(new Parameter("AccountId", DbType.Guid, Request["AccountId"])); using (WeavverEntityContainer data = new WeavverEntityContainer()) { string title = data.GetName(new Guid(Request["AccountId"])); if (Request["LedgerType"] != null) { title += " - " + Request["LedgerType"]; } BasePage.WeavverMaster.FormTitle = title; } } DataAccess insertPermissions = table.EntityType.InsertPermissions(); if (insertPermissions.HasAnyRole(Roles.GetRolesForUser())) { newObjectLink.Visible = true; newObjectLink.Title = "Accessible to: " + String.Join(", ", insertPermissions.AllowedRoles); string newLink = "javascript:createPopup('/{0}/Details.aspx', {1}, {2});"; newObjectLink.HRef = String.Format(newLink, table.EntityType.Name, insertPermissions.Width, insertPermissions.Height); } MethodInfo tableMenu = table.EntityType.GetMethod("GetTableMenu"); if (tableMenu != null && tableMenu.IsStatic) { var x = tableMenu.Invoke(null, null); if (x != null) { List<WeavverMenuItem> items = (List<WeavverMenuItem>)x; foreach (WeavverMenuItem item in items) { if (item.Link.StartsWith("control://")) { string controlPath = item.Link.Substring(10); if (File.Exists(Server.MapPath(controlPath))) { WeavverUserControl customControl = (WeavverUserControl)LoadControl(controlPath); //quickAdd.DataSaved += new DataSavedHandler(QuickAdd_DataSaved); AvailableActions.Controls.Add(customControl); } } else { LinkButton webMethod = new LinkButton(); webMethod.ID = "DynamicWebMethod_" + item.Name; webMethod.Text = item.Name; webMethod.CommandName = item.Name; webMethod.CssClass = "attachmentLink"; webMethod.Click += new EventHandler(DynamicWebMethod_Click); AvailableActions.Controls.Add(webMethod); } } } } if (Request["TransactionId"] != null) GridDataSource.WhereParameters.Add(new Parameter("TransactionId", DbType.Guid, Request["TransactionId"])); // TODO: Repurpose this block to add a customizable "TOP panel" string quickAddPath = "~/DynamicData/QuickAdd/" + table.EntityType.ToString().Replace("Weavver.Data.", "") + ".ascx"; if (File.Exists(Server.MapPath(quickAddPath))) { WeavverUserControl quickAdd = (WeavverUserControl)LoadControl(quickAddPath); quickAdd.DataSaved += new DataSavedHandler(QuickAdd_DataSaved); QuickAdd.Controls.Add(quickAdd); } string projectionPath = "~/DynamicData/Projections/" + table.EntityType.Name + ".ascx"; if (File.Exists(Server.MapPath(projectionPath))) { Control projection = LoadControl(projectionPath); Projections.Controls.Add(projection); } if (!IsPostBack) { // set default sort if (table.SortColumn != null) { var order = new OrderByExpression() { DataField = table.SortColumn.Name, Direction = table.SortDescending ? SortDirection.Descending : SortDirection.Ascending, }; GridQueryExtender.Expressions.Add(order); } } //newObjectLink.HRef = String.Format("javascript:createPopup('{0}', {1}, {2});", table.Name, 1000, 500); }
//------------------------------------------------------------------------------------------- protected void Next_Click(object sender, EventArgs e) { string notes = item.BillingNotes; if (!String.IsNullOrEmpty(notes)) { notes += "\r\n"; } using (WeavverEntityContainer data = new WeavverEntityContainer()) { var features = from x in data.Logistics_Features where x.OrganizationId == SelectedOrganization.Id && x.ParentId == item.Id orderby x.Name select x; int idPos = 0; Sales_ShoppingCartItems shoppingCartItem = Sales_ShoppingCartItems.GetInstance(Server.MapPath("~/bin"), item.PluginURL); int i = 0; foreach (Logistics_Features feature in features) { DropDownList ddl = (DropDownList)UpdatePanel1.ContentTemplateContainer.FindControl("OrderFormControls").FindControl("feature-" + i.ToString()); Guid featureOptionId = new Guid(ddl.SelectedValue); Logistics_FeatureOptions option = (from x in data.Logistics_FeatureOptions where x.Id == featureOptionId select x).First(); notes += "- " + data.GetName(option.ParentId) + ": " + option.Name; if (i < features.Count() - 1) { notes += "\r\n"; } i++; } shoppingCartItem.SessionId = Session.SessionID; shoppingCartItem.OrganizationId = SelectedOrganization.Id; shoppingCartItem.ProductId = item.Id; if (LoggedInUser != null) { shoppingCartItem.UserId = LoggedInUser.Id; } shoppingCartItem.Name = item.Name; shoppingCartItem.Notes = notes; shoppingCartItem.Deposit = item.Deposit; shoppingCartItem.SetUp = item.SetUp; // TODO: add set-up summing for sub features - add provisioning time tracking to sub-features shoppingCartItem.UnitCost = CalculateOneTimeCosts(); shoppingCartItem.Monthly = CalculateMonthlyTotal(); shoppingCartItem.Quantity = Int32.Parse(Quantity.Text); shoppingCartItem.RequiresOrganizationId = true; shoppingCartItem.BackLink = Request.Url.ToString(); var customForm = (ISales_OrderForm) OrderFormCell.FindControlR<Control>("CustomOrderForm"); if (customForm != null) { customForm.BeforeAddingToCart(shoppingCartItem); } data.Sales_ShoppingCartItems.AddObject(shoppingCartItem); data.SaveChanges(); string reviewurl = "~/workflows/sales_orderreview"; if (Request["IFrame"] == "true") reviewurl += "?IFrame=true"; Response.Redirect(reviewurl); } }