Exemple #1
0
        /// <summary>
        /// Llena el grid de personnels
        /// </summary>
        /// <param name="personnel">Objeto a seleccionar</param>
        /// <history>
        /// [emoguel] created 07/05/2016
        /// </history>
        private async void LoadPrs(PersonnelShort personnel = null)
        {
            try
            {
                status.Visibility = Visibility.Visible;
                int nIndex = 0;
                List <PersonnelShort> lstPersonnel = await BRFoliosInvitationsOuthousePR.GetPRbyFolioOuthouse(_prFilter);

                dgrPRs.ItemsSource = lstPersonnel;
                if (lstPersonnel.Count > 0 && personnel != null)
                {
                    personnel = lstPersonnel.Where(pe => pe.peID == personnel.peID).FirstOrDefault();
                    nIndex    = lstPersonnel.IndexOf(personnel);
                }
                GridHelper.SelectRow(dgrPRs, nIndex);
                StatusBarReg.Content = lstPersonnel.Count + " PRs.";
                status.Visibility    = Visibility.Collapsed;
            }
            catch (Exception ex)
            {
                UIHelper.ShowMessage(ex);
            }
        }
Exemple #2
0
        /// <summary>
        /// Agrega|Actualiza Folios
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <history>
        /// [emoguel] created 07/05/2016
        /// </history>
        private async void btnAccept_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                btnAccept.Focus();
                #region Save
                if (enumMode != EnumMode.Search)
                {
                    #region ValidateChanges
                    List <FolioInvitationOuthousePR>             lstFoliosPR  = (List <FolioInvitationOuthousePR>)dgrAssigned.ItemsSource;
                    List <FolioInvitationOuthousePRCancellation> lstFoliosCan = (List <FolioInvitationOuthousePRCancellation>)dgrCancelled.ItemsSource;
                    bool blnHasChanged = ValidateChanges(lstFoliosPR, lstFoliosCan);

                    #endregion
                    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 = "";

                            #region ListFolios
                            if (enumMode == EnumMode.Add)
                            {
                                var folio = await BRFoliosInvitationsOuthousePR.GetPRbyFolioOuthouse(personnelSave);

                                if (folio.FirstOrDefault() != 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;
                                }
                            }
                            #endregion
                            #region FoliosPR
                            strMsj = ValidateFolioOuthouse(lstFoliosPR);
                            if (strMsj != "")
                            {
                                UIHelper.ShowMessage(strMsj);
                                return;
                            }
                            strMsj = ValidateCancelled(lstFoliosCan, lstFoliosPR);
                            if (strMsj != "")
                            {
                                UIHelper.ShowMessage(strMsj);
                                return;
                            }

                            int nRes = await BRFoliosInvitationsOuthousePR.SaveFoliosOuthousePR(personnelSave.peID, lstFoliosPR, lstFoliosCan);

                            UIHelper.ShowMessageResult("Folios", nRes);
                            if (nRes > 0)
                            {
                                blnClosing   = true;
                                DialogResult = true;
                                Close();
                            }

                            #endregion
                        }
                        skpStatus.Visibility = Visibility.Collapsed;
                    }
                }
                #endregion
                #region Search
                else
                {
                    #region Search
                    if (cmbPersonnel.SelectedItem != null)
                    {
                        personnel    = (PersonnelShort)cmbPersonnel.SelectedItem;
                        DialogResult = true;
                        Close();
                    }
                    else if (!string.IsNullOrWhiteSpace(personnel.peID))
                    {
                        cmbPersonnel.Focus();
                        UIHelper.ShowMessage("Please select a PR.");
                    }
                    else
                    {
                        Close();
                    }
                    #endregion
                }
                #endregion
            }
            catch (Exception ex)
            {
                UIHelper.ShowMessage(ex);
            }
        }