Ejemplo n.º 1
0
        /// <summary>
        /// Valida los datos
        /// </summary>
        /// <history>
        /// [jorcanche]  12/Mar/2016 Created
        /// </history>
        private bool Validate()
        {
            // validamos el motivo de indisponibilidad
            if (!ValidateHelper.ValidateRequired(txtguum, "Unavailable Motive", condition: !chkguAvail.IsChecked.Value))
            {
                return(false);
            }

            // validamos que el motivo de indisponibilidad exista
            if (!chkguAvail.IsChecked.Value)
            {
                UnavailableMotive motive = BRUnavailableMotives.GetUnavailableMotive(Convert.ToInt16(txtguum.Text), true);
                if (motive == null)
                {
                    UIHelper.ShowMessage("The unavailable motive does not exist");
                    txtguum.Focus();
                    return(false);
                }
            }
            // validamos los permisos
            if (!ValidatePermissions())
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 2
0
        private async void LoadControls()
        {
            _guest = await BRGuests.GetGuest(_guestId);

            cboguum.ItemsSource = await BRUnavailableMotives.GetUnavailableMotives(1);

            cboguPRAvail.ItemsSource = await BRPersonnel.GetPersonnel(Context.User.Location.loID, "ALL", "PR");

            if (_guest.guPRAvail != null)
            {
                cboguPRAvail.SelectedValue = _guest.guPRAvail;
            }
            if (_guest.guum != 0)
            {
                cboguum.SelectedValue = _guest.guum;
                txtguum.Text          = _guest.guum.ToString();
            }
            chkguOriginAvail.IsChecked         = _guest.guOriginAvail;
            chkguAvail.IsChecked               = _guest.guAvail;
            chkguAvailBySystem.IsChecked       = _guest.guAvailBySystem;
            txtguum.IsEnabled                  = cboguum.IsEnabled = cboguPRAvail.IsEnabled = btnCancel.IsEnabled =
                btnSave.IsEnabled              =
                    chkguOriginAvail.IsEnabled = chkguAvail.IsEnabled = txtguum.IsEnabled = cboguum.IsEnabled = false;
            btnEdit.IsEnabled                  = true;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Carga el combobox de unavailable motives
        /// </summary>
        /// <history>
        /// [emoguel] created 15/03/2016
        /// </history>
        private async void loadUnavailableMotives()
        {
            try
            {
                List <UnavailableMotive> lstUnavailableMotives = await BRUnavailableMotives.GetUnavailableMotives();

                cmbUnvMot.ItemsSource = lstUnavailableMotives;
            }
            catch (Exception ex)
            {
                UIHelper.ShowMessage(ex);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Llena el combobox de Unavailable Motive
        /// </summary>
        /// <history>
        /// [emoguel] created 11/03/2016
        /// [emoguel] modified 30/05/2016 sel volvió async
        /// </history>
        protected async void LoadUnavailableMotives()
        {
            try
            {
                List <UnavailableMotive> lstUnavailableMotive = await BRUnavailableMotives.GetUnavailableMotives();

                cmbagum.ItemsSource = lstUnavailableMotive;
            }
            catch (Exception ex)
            {
                UIHelper.ShowMessage(ex);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Guarda los cambios de la ventana
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <history>
        /// [emoguel] created 06/06/2016
        /// </history>
        private async void btnAccept_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                btnAccept.Focus();
                List <Agency>   lstAgenciesAdd  = new List <Agency>();
                List <Country>  lstCountriesAdd = new List <Country>();
                List <Contract> lstContractsAdd = new List <Contract>();
                getNewItems(ref lstAgenciesAdd, ref lstCountriesAdd, ref lstContractsAdd);
                if (ObjectHelper.IsEquals(unavailableMotive, oldUnavailableMotive) && lstAgenciesAdd.Count == 0 && lstContractsAdd.Count == 0 && lstCountriesAdd.Count == 0)
                {
                    _isClosing = true;
                    Close();
                }
                else
                {
                    skpStatus.Visibility = Visibility.Visible;
                    txtStatus.Text       = "Saving Data...";
                    btnAccept.Visibility = Visibility.Collapsed;
                    string strMsj = ValidateHelper.ValidateForm(this, "Unavailable Motives", blnDatagrids: true);
                    if (unavailableMotive.umID == 0)
                    {
                        strMsj += (strMsj == "") ? "" : " \n " + "ID can not be 0";
                    }
                    if (strMsj == "")
                    {
                        int nRes = await BRUnavailableMotives.SaveUnavailableMotives(unavailableMotive, lstAgenciesAdd, lstContractsAdd, lstCountriesAdd, (enumMode == EnumMode.Edit));

                        UIHelper.ShowMessageResult("Unavailable Motives", nRes);
                        if (nRes > 0)
                        {
                            _isClosing   = true;
                            DialogResult = true;
                            Close();
                        }
                    }
                    else
                    {
                        UIHelper.ShowMessage(strMsj);
                    }
                    skpStatus.Visibility = Visibility.Collapsed;
                    btnAccept.Visibility = Visibility.Visible;
                }
            }
            catch (Exception ex)
            {
                UIHelper.ShowMessage(ex);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Llena el grid de unavailableMotives
        /// </summary>
        /// <param name="unavailableMotive">Objeto a seleccionar</param>
        /// <history>
        /// [emogue] created 06/06/2016
        /// </history>
        private async void LoadUnavailableMotives(UnavailableMotive unavailableMotive = null)
        {
            try
            {
                status.Visibility = Visibility.Visible;
                int nIndex = 0;
                List <UnavailableMotive> lstUnavailableMotives = await BRUnavailableMotives.GetUnavailableMotives(_nStatus, _unavailableMotive);

                dgrUnavailableMotives.ItemsSource = lstUnavailableMotives;
                if (lstUnavailableMotives.Count > 0 && unavailableMotive != null)
                {
                    unavailableMotive = lstUnavailableMotives.Where(um => um.umID == unavailableMotive.umID).FirstOrDefault();
                    nIndex            = lstUnavailableMotives.IndexOf(unavailableMotive);
                }
                GridHelper.SelectRow(dgrUnavailableMotives, nIndex);
                StatusBarReg.Content = lstUnavailableMotives.Count + " Unavailable Motives.";
                status.Visibility    = Visibility.Collapsed;
            }
            catch (Exception ex)
            {
                UIHelper.ShowMessage(ex);
            }
        }
Ejemplo n.º 7
0
        private void txtguum_LostFocus(object sender, RoutedEventArgs e)
        {
            _searchUmByTxt = true;
            int umid;

            if (txtguum.Text != string.Empty)
            {
                //validosmos q no ingrese datos numericos
                if (!int.TryParse(txtguum.Text, out umid))
                {
                    UIHelper.ShowMessage("you must enter a numeric value");
                    txtguum.Text = string.Empty;
                    txtguum.Focus();
                }
                else
                {
                    // validamos que el motivo de indisponibilidad exista en los activos
                    UnavailableMotive motive = BRUnavailableMotives.GetUnavailableMotive(Convert.ToInt32(txtguum.Text), true);
                    if (motive == null)
                    {
                        UIHelper.ShowMessage("The unavailable motive does not exist");
                        txtguum.Text = string.Empty;
                        txtguum.Focus();
                    }
                    else
                    {
                        cboguum.SelectedValue = txtguum.Text;
                    }
                }
            }
            else
            {
                cboguum.SelectedIndex = -1;
            }
            _searchUmByTxt = false;
        }