/// <summary> /// Changes the screen to modify the selected item in the receipt. /// </summary> /// <param name="sender">The listbox.</param> /// <param name="e">The event arguments.</param> private void ModifyItem(object sender, SelectionChangedEventArgs e) { if (sender is ListBox listBox) { if (listBox.SelectedItem == null) { return; } if (OrderComponent.screenContainer.Child is CashPaymentComponent cashPayment) { cashPayment.Cleanup(); } ItemModification customization = new ItemModification(); CustomizationScreen screen = Helper.GetCustomizationScreen(listBox.SelectedItem as IOrderItem, out string text); customization.customizeItemLabel.Text = text; customization.customizationContainer.Child = screen; OrderComponent.ChangeScreen(customization); listBox.SelectedItem = null; OrderComponent.CollapseButtons(false); } }
public ActionResult Edit(string Parameters) { // Get Query string in Encrypted mode and decrypt Query string and set Parameters if (!string.IsNullOrEmpty(Parameters)) { Parameters = StringCipher.Decrypt(Parameters.Replace(Utility.Utility.urlseparator, "+"), General.passPhrase); } int id = Convert.ToInt32(Parameters); TicketFacade tac = new TicketFacade(StringCipher.Decrypt(Helper.GetMasterConnctionstring(), General.passPhrase)); TicketEntity model = new TicketEntity(); TicketEntity objTicket = new TicketEntity(); if (id > 0) { //Get ticket Details for given ticket Id model = tac.GetLastTicketAuditByTicketIdByClient(id); // MP-846 Admin database cleanup and code cleanup.-CLIENT objTicket = tac.GetTicketByIDByClients(id); // MP-846 Admin database cleanup and code cleanup.-CLIENT //Store Files in tempdata SessionHelper.ImageName = Convert.ToString(model.Files); } #region Ticket History List <TicketAuditEntity> ticketAuditList = new List <TicketAuditEntity>(); //Get All Ticket Audit for given ticket Id ticketAuditList = tac.GetTicketAuditByTicketIdByClient(id); // MP-846 Admin database cleanup and code cleanup.-CLIENT List <TicketHistory> ticketHistoryList = new List <TicketHistory>(); if (ticketAuditList.Any()) { #region History for Main Record TicketHistory ticketHistoryMain = new TicketHistory(); List <ItemModification> itemModificationMainList = new List <ItemModification>(); ticketHistoryMain.ChangedByName = ticketAuditList.First().ChangedByUser; #region Property Info Type elementNewMain = ticketAuditList.First().GetType(); Type elementOldMain = objTicket.GetType(); PropertyInfo[] propertyInfosNewMain = elementNewMain.GetProperties(); PropertyInfo[] propertyInfosOldMain = elementOldMain.GetProperties(); //Set the Value for the Priority for the Ticket for (int j = 0; j < propertyInfosNewMain.Length; j++) { var fieldName = propertyInfosNewMain[j].Name; if (fieldName == "StatusValue" || fieldName == "PriorityValue" || fieldName == "AssignedToName") { #region Set OldFieldName string oldFieldName = string.Empty; switch (fieldName) { case "StatusValue": oldFieldName = "CurrentStatusValue"; break; case "PriorityValue": oldFieldName = "PriorityValue"; break; case "AssignedToName": oldFieldName = "AssignedToName"; break; case "Notes": oldFieldName = "IssueDescription"; break; } #endregion if (fieldName == "StatusValue") { fieldName = "Status"; } else if (fieldName == "PriorityValue") { fieldName = "Priority"; } else if (fieldName == "AssignedToName") { fieldName = "AssignedTo"; } var newValue = propertyInfosNewMain[j].GetValue(ticketAuditList.First()); var oldValue = elementOldMain.GetProperty(oldFieldName).GetValue(objTicket); string strNewValue = newValue == null ? null : newValue.ToString(); string strOldValue = oldValue == null ? null : oldValue.ToString(); if (strNewValue != strOldValue) { ItemModification itemModification = new ItemModification(); itemModification.FieldName = fieldName; itemModification.OldValue = strOldValue; itemModification.NewValue = strNewValue; itemModificationMainList.Add(itemModification); } } } #endregion ticketHistoryMain.itemModification = itemModificationMainList; ticketHistoryMain.ModificationDate = ticketAuditList.First().AuditDateTime; ticketHistoryMain.Note = ticketAuditList.First().Notes; ticketHistoryList.Add(ticketHistoryMain); #endregion for (int i = 0; i < ticketAuditList.Count - 1; i++) { TicketHistory ticketHistory = new TicketHistory(); List <ItemModification> itemModificationList = new List <ItemModification>(); ticketHistory.ChangedByName = ticketAuditList[i + 1].ChangedByUser; #region Property Info Type elementNew = ticketAuditList[i + 1].GetType(); Type elementOld = ticketAuditList[i].GetType(); PropertyInfo[] propertyInfosNew = elementNew.GetProperties(); PropertyInfo[] propertyInfosOld = elementOld.GetProperties(); for (int j = 0; j < propertyInfosNew.Length; j++) { var fieldName = propertyInfosNew[j].Name; if (fieldName == "StatusValue" || fieldName == "PriorityValue" || fieldName == "AssignedToName") { if (fieldName == "StatusValue") { fieldName = "Status"; } else if (fieldName == "PriorityValue") { fieldName = "Priority"; } else if (fieldName == "AssignedToName") { fieldName = "AssignedTo"; } var newValue = propertyInfosNew[j].GetValue(ticketAuditList[i + 1]); var oldValue = propertyInfosOld[j].GetValue(ticketAuditList[i]); string strNewValue = newValue == null ? null : newValue.ToString(); string strOldValue = oldValue == null ? null : oldValue.ToString(); if (strNewValue != strOldValue) { ItemModification itemModification = new ItemModification(); itemModification.FieldName = fieldName; itemModification.OldValue = strOldValue; itemModification.NewValue = strNewValue; itemModificationList.Add(itemModification); } } } #endregion ticketHistory.itemModification = itemModificationList; ticketHistory.ModificationDate = ticketAuditList[i + 1].AuditDateTime; ticketHistory.Note = ticketAuditList[i + 1].Notes; ticketHistoryList.Add(ticketHistory); } } SessionHelper.TicketHistory = JsonConvert.SerializeObject(ticketHistoryList); #endregion return(View(model)); }