private void UpdatePalletNetworkBusinessType(List <int> orderIDs, int businessTypeID) { StringBuilder sb = new StringBuilder(); foreach (int orderID in orderIDs) { EF.VigoOrder vigoOrder = EF.DataContext.Current.VigoOrderSet.Include("VigoOrderExtras").FirstOrDefault(v => v.OrderId == orderID); if (vigoOrder == null) { //Get the BusinessType row for the selected BusinessType DataRow drOrderDetails = this.OrderCollectionDeliveryDataSet.Tables[0].Rows.Find(orderID); vigoOrder = new EF.VigoOrder(); EF.DataContext.Current.AddToVigoOrderSet(vigoOrder); if (!string.IsNullOrEmpty((string)drOrderDetails["ShortDescription"])) { vigoOrder.OrderServiceLevelReference.EntityKey = new EntityKey("DataContext.OrderServiceLevelSet", "OrderServiceLevelId", (int)drOrderDetails["OrderServiceLevelID"]); } else { vigoOrder.OrderServiceLevelReference.EntityKey = new EntityKey("DataContext.OrderServiceLevelSet", "OrderServiceLevelId", 1); //Check with steele as to the best course of action for a default vigo service level if one isn't present. } vigoOrder.FullPallets = (int)drOrderDetails["NoOfPallets"]; if (sb.Length > 0) { sb.Append(","); } sb.Append(orderID.ToString()); } } EF.DataContext.Current.SaveChanges(); Facade.IOrder facOrd = new Facade.Order(); facOrd.UpdateTrunkDateForOrderIDs(sb.ToString(), this.Page.User.Identity.Name); }
private List <Surcharge> GetSurcharges(int OrderID) { EF.VigoOrder vigoOrder = EF.DataContext.Current.VigoOrderSet.Include("VigoOrderExtras.ExtraType").FirstOrDefault(v => v.OrderId == OrderID); Orchestrator.Facade.ExtraType facExtraType = new Orchestrator.Facade.ExtraType(); List <Entities.ExtraType> extraTypes = facExtraType.GetForIsDisplayedOnAddUpdateOrder(); List <Surcharge> retVal = new List <Surcharge>(); foreach (var extraType in extraTypes) { var currentSurCharge = new Surcharge() { ExtraTypeID = extraType.ExtraTypeId, Description = extraType.ShortDescription }; if (vigoOrder.VigoOrderExtras.FirstOrDefault(e => e.ExtraType.ExtraTypeId == extraType.ExtraTypeId) != null) { currentSurCharge.IsSelected = true; } retVal.Add(currentSurCharge); } return(retVal); }
//----------------------------------------------------------------------------------------------------------- protected void grdOrders_ItemDataBound(object sender, GridItemEventArgs e) { if (e.Item is GridDataItem) { DataRowView row = (DataRowView)e.Item.DataItem; int orderId = int.Parse(row["OrderID"].ToString()); string runId = row["JobId"].ToString(); using (CheckBox chk = (CheckBox)e.Item.FindControl("chkSelectOrder")) { chk.Attributes.Add("onClick", string.Format("javascript:HandleSelection(this, {0});", e.Item.ItemIndex)); chk.Attributes.Add("OrderId", orderId.ToString()); } orderCount++; totalPalletCount += (int)row["NoPallets"]; totalPalletSpaces += Convert.ToDouble(row["PalletSpaces"]); totalWeight += Convert.ToDouble(row["Weight"]); QtrPalletsTotal += Convert.ToDouble(row["QtrPallets"]); HalfPalletsTotal += Convert.ToDouble(row["HalfPallets"]); FullPalletsTotal += Convert.ToDouble(row["FullPallets"]); OverPalletsTotal += Convert.ToDouble(row["OverPallets"]); OrderRateTotal += (row["ForeignRate"] != DBNull.Value) ? Convert.ToDouble(row["ForeignRate"]) : 0.00; SubContractCostTotal += (row["SubContractRate"] != DBNull.Value) ? Convert.ToDouble(row["SubContractRate"]) : 0.00; HubChargeTotal += (row["SubContractRate"] != DBNull.Value) ? Convert.ToDouble(row["HubCharge"]) : 0.00; // Delivery At column Label lblDeliverAt = (Label)e.Item.FindControl("lblDeliverAt"); DateTime delFrom = Convert.ToDateTime(row["DeliveryFromDateTime"].ToString()); DateTime delBy = Convert.ToDateTime(row["DeliveryDateTime"].ToString()); if (lblDeliverAt != null) { if (delFrom == delBy) { // Timed booking... only show a single date. lblDeliverAt.Text = GetDate(Convert.ToDateTime(row["DeliveryDateTime"].ToString()), false); } else { // If the times span from mignight to 23:59 on the same day then // it's an 'anytime' window. if (delFrom.Date == delBy.Date && delFrom.Hour == 0 && delFrom.Minute == 0 && delBy.Hour == 23 && delBy.Minute == 59) { // It's anytime lblDeliverAt.Text = GetDate(Convert.ToDateTime(row["DeliveryDateTime"].ToString()), true); } else { // It's a booking window lblDeliverAt.Text = GetDate(Convert.ToDateTime(row["DeliveryFromDateTime"].ToString()), false) + " to " + GetDate(Convert.ToDateTime(row["DeliveryDateTime"].ToString()), false); } } } //if (row["IsTariffOverride"] != DBNull.Value && Convert.ToBoolean(row["IsTariffOverride"])) // e.Item.Cells[grdOrders.Columns.FindByUniqueName("Rate").OrderIndex].BackColor = System.Drawing.Color.Yellow; if (row["MessageStateId"] != DBNull.Value) { eMessageState messageState = (eMessageState)row["MessageStateId"]; switch (messageState) { case eMessageState.Unprocessed: e.Item.BackColor = System.Drawing.Color.Pink; break; case eMessageState.Processed: case eMessageState.NotProcessed: e.Item.BackColor = System.Drawing.Color.Violet; break; case eMessageState.Error: e.Item.BackColor = System.Drawing.Color.Red; break; } } CheckBoxList cblsurcharges = e.Item.FindControl("cblSurcharges") as CheckBoxList; EF.VigoOrder vigoOrder = EF.DataContext.Current.VigoOrderSet.Include("VigoOrderExtras.ExtraType").FirstOrDefault(v => v.OrderId == orderId); Orchestrator.Facade.ExtraType facExtraType = new Orchestrator.Facade.ExtraType(); List <Entities.ExtraType> extraTypes = facExtraType.GetForIsDisplayedOnAddUpdateOrder(); cblsurcharges.DataSource = extraTypes.OrderBy(et => et.ShortDescription); cblsurcharges.DataTextField = "ShortDescription"; cblsurcharges.DataValueField = "ExtraTypeId"; cblsurcharges.DataBind(); //Tick the PalletForce Surcharge checkboxes for each VigoOrderExtra foreach (var extra in vigoOrder.VigoOrderExtras) { ListItem item = cblsurcharges.Items.FindByValue(extra.ExtraType.ExtraTypeId.ToString()); if (item != null) { item.Selected = true; } } } else if (e.Item is GridEditableItem) { DataRowView row = (DataRowView)e.Item.DataItem; RadNumericTextBox txtRate = e.Item.FindControl("txtRate") as RadNumericTextBox; if (txtRate != null) { CultureInfo culture = new CultureInfo(int.Parse(row["LCID"].ToString())); txtRate.Culture = culture; //if (row["TariffRateId"] == null) //{ // txtRate.BackColor = System.Drawing.Color.Yellow; //} } } }