Ejemplo n.º 1
0
        /// <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);
            }
        }
Ejemplo n.º 2
0
        /// <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
            }
        }