protected void lbUndo_Click(object sender, EventArgs e) { LinkButton lbUndo = sender as LinkButton; if (lbUndo.CommandArgument.Length > 1) { Entities.PalletDelivery pd = PalletDeliveries.SingleOrDefault(lpd => lpd.Identifier == lbUndo.CommandArgument); if (pd != null) { Entities.PalletDelivery foundUpdatedPalletDelivery = UpdatedPalletDeliveries.FirstOrDefault(fupd => fupd.PalletOrder.OrderID == pd.PalletOrder.OrderID); if (foundUpdatedPalletDelivery != null) { UpdatedPalletDeliveries.Remove(foundUpdatedPalletDelivery); } pd.UpdatedNoPallets = 0; pd.IsDirty = false; pd.ToBeRemoved = false; Rebind(null); btnGenerateUpdate.Visible = !PalletDeliveries.Exists(lpds => lpds.IsDirty || lpds.PalletOrder.OrderID < 1); } } }
private void GetSelectedPallets() { Entities.Instruction palletHandlingInstruction = new Entities.Instruction(); eInstructionType selectedPalletAction = (eInstructionType)int.Parse(rcbPalletHandlingAction.SelectedValue); foreach (ListViewDataItem lvdi in lvEmptyPallets.Items) { CheckBox chkResourceSelected = lvdi.FindControl("chkResourceSelected") as CheckBox; if (chkResourceSelected != null && chkResourceSelected.Checked) { HiddenField hdnResource = lvdi.FindControl("hdnResource") as HiddenField; HiddenField hidResourceID = lvdi.FindControl("hidResourceID") as HiddenField; HiddenField hidIsFixedUnit = lvdi.FindControl("hidIsFixedUnit") as HiddenField; ListView lvItems = lvdi.FindControl("lvItems") as ListView; int resourceID = 0; int.TryParse(hidResourceID.Value, out resourceID); bool isFixedUnit = false; int isFixedUnitValue = 0; int.TryParse(hidIsFixedUnit.Value, out isFixedUnitValue); isFixedUnit = isFixedUnitValue > 0; foreach (ListViewDataItem ilvdi in lvItems.Items) { #region Generate Pallet Orders RadNumericTextBox rntNoOfPallets = ilvdi.FindControl("rntNoOfPallets") as RadNumericTextBox; if (rntNoOfPallets != null && rntNoOfPallets.Value.Value > 0) { HiddenField hdnPalletTypeID = ilvdi.FindControl("hdnPalletTypeID") as HiddenField; HiddenField hdnPalletType = ilvdi.FindControl("hdnPalletType") as HiddenField; HiddenField hdnIdentifier = ilvdi.FindControl("hdnIdentifier") as HiddenField; string destination = string.Empty; Entities.Order palletDelivery = null; Entities.PalletDelivery pd = null; if (hdnIdentifier != null && hdnIdentifier.Value != string.Empty) { #region Update Order pd = SelectedPalletDelivery; if (pd.PalletOrder.OrderID > 0) { Entities.PalletDelivery updatedDelivery = null; if (UpdatedPalletDeliveries.Count > 0) { updatedDelivery = UpdatedPalletDeliveries.Find(upd => upd.PalletOrder.OrderID == pd.PalletOrder.OrderID); } if (updatedDelivery == null) { updatedDelivery = new Entities.PalletDelivery(); } else { UpdatedPalletDeliveries.Remove(updatedDelivery); } if (updatedDelivery.PalletOrder == null || updatedDelivery.PalletOrder.OrderID < 1) { updatedDelivery.PalletOrder = GeneratePalletOrder(int.Parse(hdnPalletTypeID.Value), (int)rntNoOfPallets.Value.Value, selectedPalletAction, ref destination); updatedDelivery.PalletOrder.OrderID = pd.PalletOrder.OrderID; } else { updatedDelivery.PalletOrder.NoPallets = (int)rntNoOfPallets.Value.Value; } updatedDelivery.PalletAction = selectedPalletAction; updatedDelivery.PalletActionDescription = Utilities.UnCamelCase(selectedPalletAction.ToString()); updatedDelivery.ResourceID = resourceID; updatedDelivery.IsFixedUnit = isFixedUnit; updatedDelivery.PalletType = hdnPalletType.Value; updatedDelivery.Resource = hdnResource.Value; updatedDelivery.Destination = destination; updatedDelivery.UpdatedNoPallets = updatedDelivery.PalletOrder.NoPallets; //pd.UpdatedNoPallets = updatedDelivery.PalletOrder.NoPallets; updatedDelivery.IsDirty = true; UpdatedPalletDeliveries.Add(updatedDelivery); } //pd.PalletOrder.NoPallets = (int)rntNoOfPallets.Value.Value; pd.UpdatedNoPallets = (int)rntNoOfPallets.Value.Value; pd.IsDirty = true; #endregion } else { #region Generate Order palletDelivery = GeneratePalletOrder(int.Parse(hdnPalletTypeID.Value), (int)rntNoOfPallets.Value.Value, selectedPalletAction, ref destination); pd = new Entities.PalletDelivery(); pd.PalletOrder = palletDelivery; pd.PalletAction = selectedPalletAction; pd.PalletActionDescription = Utilities.UnCamelCase(selectedPalletAction.ToString()); pd.ResourceID = resourceID; pd.IsFixedUnit = isFixedUnit; pd.PalletType = hdnPalletType.Value; pd.Resource = hdnResource.Value; pd.Destination = destination; #endregion } PalletDeliveries.Add(pd); } #endregion } } } }