/// <summary> /// Llena el combo de assigment /// </summary> /// <param name="prID">Id del PR</param> /// <history> /// [emoguel] created 05/05/2016 /// </history> private async void LoadFoliosAssigned(string prID) { try { List <FolioCxCPR> lstFoliosCXCPR = await BRFoliosCXCPR.GetFoliosCXCPR(prID); _lstFolios = await BRFoliosCXCPR.GetFoliosCXCPR(prID); dgrAssigned.ItemsSource = lstFoliosCXCPR; } catch (Exception ex) { UIHelper.ShowMessage(ex); } }
/// <summary> /// Valida los datos de los folios cancelados /// </summary> /// <param name="lstFoliosCancell">Lista a validar</param> /// <returns>Cadena de texto</returns> /// <history> /// [emoguel] created 06/05/2016 /// </history> private string ValidateCancelled(List <FolioCxCCancellation> lstFoliosCancell, List <FolioCxCPR> lstFoliosPR) { string strMsj = ""; int nIndex = 0; ValidationFolioData validate; foreach (FolioCxCCancellation folio in lstFoliosCancell) { nIndex = lstFoliosCancell.IndexOf(folio); if (folio.fccrcf == null) { GridHelper.SelectRow(dgrCancelled, nIndex, 2, true); strMsj = "Reason is a required value, cannot be empty."; break; } else if (folio.fccFrom == 0 || folio.fccTo == 0) { GridHelper.SelectRow(dgrCancelled, nIndex, 0, true); strMsj = "Values must be greatter than 0"; break; } else if (folio.fccTo <= folio.fccFrom) { GridHelper.SelectRow(dgrCancelled, nIndex, 1, true); strMsj = "From value must be greatter or equal than To value."; break; } else if (!ValidateFoliosRange(lstFoliosPR, folio)) { GridHelper.SelectRow(dgrCancelled, nIndex, 0, true); strMsj = "The range of the canceled folios must be in the range of the asigned folios."; break; } validate = BRFoliosCXCPR.ValidateFolio(personnel.peID, folio.fccFrom, folio.fccTo, true); if (validate.Result == 1) { GridHelper.SelectRow(dgrAssigned, nIndex, 0, true); strMsj = "There is a PR with same Folio, check PR: " + validate.PR.ToString(); break; } } return(strMsj); }
/// <summary> /// Llena el grid de Prs /// </summary> /// <param name="personnelShort">Objeto a seleccionar</param> /// <history> /// [emoguel] created 05/05/2016 /// [emoguel] modified se volvió async /// </history> private async void LoadPR(PersonnelShort personnelShort = null) { try { status.Visibility = Visibility.Visible; int nIndex = 0; List <PersonnelShort> lstPrs = await BRFoliosCXCPR.GetPRByFoliosCXC(_prFilter); dgrPRs.ItemsSource = lstPrs; if (lstPrs.Count > 0 && personnelShort != null) { personnelShort = lstPrs.Where(pe => pe.peID == personnelShort.peID).FirstOrDefault(); nIndex = lstPrs.IndexOf(personnelShort); } GridHelper.SelectRow(dgrPRs, nIndex); StatusBarReg.Content = lstPrs.Count + " PRs."; status.Visibility = Visibility.Collapsed; } catch (Exception ex) { UIHelper.ShowMessage(ex); } }
/// <summary> /// Valida que todos los FoliosByPR cumplan con los requisitos /// </summary> /// <param name="lstFolios">Lista a validar</param> /// <returns>Cadena de texto</returns> /// <history> /// [emoguel] created 06/05/2016 /// </history> private string ValidateFoliosPR(List <FolioCxCPR> lstFolios) { string strMsj = ""; int nIndex = 0; ValidationFolioData validate; foreach (FolioCxCPR folio in lstFolios) { nIndex = lstFolios.IndexOf(folio); if (folio.fcpFrom == 0 || folio.fcpTo == 0) { GridHelper.SelectRow(dgrAssigned, nIndex, 0, true); strMsj = "Values must be greatter than 0."; break; } else if (folio.fcpTo < folio.fcpFrom) { GridHelper.SelectRow(dgrAssigned, nIndex, 1, true); strMsj = "From value must be greatter or equal than To value."; break; } else if (!BRFoliosCXCPR.ValidateFolioRange(folio.fcpFrom, folio.fcpTo)) { GridHelper.SelectRow(dgrAssigned, nIndex, 0, true); strMsj = "The assigned range does not exists in the Folios CxC catalog."; break; } validate = BRFoliosCXCPR.ValidateFolio(personnel.peID, folio.fcpFrom, folio.fcpTo, false); if (validate.Result == 1) { GridHelper.SelectRow(dgrAssigned, nIndex, 0, true); strMsj = "There is a PR with same Folio , check PR: " + validate.PR.ToString(); break; } } return(strMsj); }
/// <summary> /// Agrega|Actualiza un folioCxcPR /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <history> /// [emoguel] created 05/05/2016 /// </history> private async void btnAccept_Click(object sender, RoutedEventArgs e) { btnAccept.Focus(); if (enumMode != EnumMode.Search) { List <FolioCxCPR> lstFoliosPR = (List <FolioCxCPR>)dgrAssigned.ItemsSource; List <FolioCxCCancellation> lstFoliosCan = (List <FolioCxCCancellation>)dgrCancelled.ItemsSource; bool blnHasChanged = ValidateChanged(lstFoliosPR, lstFoliosCan); if (enumMode != EnumMode.Add && !blnHasChanged) { blnClosing = true; Close(); } else { txtStatus.Text = "Saving Data..."; skpStatus.Visibility = Visibility.Visible; PersonnelShort personnelSave = (PersonnelShort)cmbPersonnel.SelectedItem; if (personnelSave != null) { string strMsj = ""; if (enumMode == EnumMode.Add) { var lstFolioCXC = await BRFoliosCXCPR.GetPRByFoliosCXC(personnelSave); var folioCxC = lstFolioCXC.FirstOrDefault(); if (folioCxC != null) { UIHelper.ShowMessage("The current PR already has folios, edit the correspoding PR."); return; } if (lstFoliosPR.Count == 0) { UIHelper.ShowMessage("Cannot save an empty record, please add folios.."); return; } } #region FoliosPR strMsj = ValidateFoliosPR(lstFoliosPR); if (strMsj != "") { UIHelper.ShowMessage(strMsj); return; } strMsj = ValidateCancelled(lstFoliosCan, lstFoliosPR); if (strMsj != "") { UIHelper.ShowMessage(strMsj); return; } int nRes = await BRFoliosCXCPR.SaveFoliosCxCByPR(personnelSave, lstFoliosPR, lstFoliosCan); UIHelper.ShowMessageResult("Folios", nRes); if (nRes > 0) { blnClosing = true; DialogResult = true; Close(); } #endregion } else { UIHelper.ShowMessage("Select a PR."); } skpStatus.Visibility = Visibility.Collapsed; } } else { #region Search if (cmbPersonnel.SelectedItem != null) { blnClosing = true; personnel = (PersonnelShort)cmbPersonnel.SelectedItem; DialogResult = true; Close(); } else if (!string.IsNullOrWhiteSpace(personnel.peID)) { cmbPersonnel.Focus(); UIHelper.ShowMessage("Please select a PR."); } else { blnClosing = true; Close(); } #endregion } }