Esempio n. 1
0
 /// <summary>
 ///Valida el TextBox Cuando Pierde el Focus
 /// </summary>
 /// <history>
 /// [jorcanche] created 07/04/2016
 /// </history>
 private void txtpnPR_LostFocus(object sender, RoutedEventArgs e)
 {
     _searchPRbyTxt = true;
     if (txtpnPR.Text != string.Empty)
     {
         // validamos que el motivo de indisponibilidad exista en los activos
         var pr = BRPersonnel.GetPersonnelById(txtpnPR.Text);
         if (pr == null)
         {
             UIHelper.ShowMessage("The PR not exist");
             txtpnPR.Text = string.Empty;
             txtpnPR.Focus();
         }
         else
         {
             cbopnPR.SelectedValue = txtpnPR.Text;
         }
     }
     else
     {
         cbopnPR.SelectedIndex = -1;
     }
     //Si es el mismo usuario que esta actualmente logueado y si puso autosing entonces le agregamos la contraseña y la desencriptamos
     //de no ser así lo dejamos vacio
     Pass();
     _searchPRbyTxt = false;
 }
Esempio n. 2
0
        /// <summary>
        /// Abre la ventana detalle en modo "detalle" o "edición" dependiendo de sus permisos
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <history>
        /// [emoguel] created 10/06/2016
        /// </history>
        private async void Cell_DoubleClick(object sender, RoutedEventArgs e)
        {
            PersonnelShort     personnelShort     = (PersonnelShort)dgrPersonnels.SelectedItem;
            Personnel          personnel          = BRPersonnel.GetPersonnelById(personnelShort.peID);
            frmPersonnelDetail frmPersonnelDetail = new frmPersonnelDetail();

            frmPersonnelDetail.Owner        = this;
            frmPersonnelDetail.enumMode     = (_blnEdit) ? EnumMode.Edit : EnumMode.ReadOnly;
            frmPersonnelDetail.oldPersonnel = personnel;
            if (frmPersonnelDetail.ShowDialog() == true)
            {
                int nIndex = 0;
                List <PersonnelShort> lstPersonnel = (List <PersonnelShort>)dgrPersonnels.ItemsSource;
                var persons = await BRPersonnel.GetPersonnel(idPersonnel : frmPersonnelDetail.personnel.peID);

                if (persons.Count > 0)
                {
                    PersonnelShort person = persons.FirstOrDefault();
                    ObjectHelper.CopyProperties(personnelShort, person);       //Actualizamos los datos
                    lstPersonnel.Sort((x, y) => string.Compare(x.peN, y.peN)); //Ordenamos la lista
                    nIndex = lstPersonnel.IndexOf(personnelShort);             //Obtenemos la posición del registro
                }
                else
                {
                    lstPersonnel.Remove(personnelShort);//Quitamos el registro
                }
                btnDel.IsEnabled = (lstPersonnel.Count > 0) ? _blnDel : false;
                dgrPersonnels.Items.Refresh();                              //Actualizamos la vista
                GridHelper.SelectRow(dgrPersonnels, nIndex);                //Seleccionamos el registro
                StatusBarReg.Content = lstPersonnel.Count + " Personnels."; //Actualizamos el contador
            }
        }
Esempio n. 3
0
        public bool Validate()
        {
            // validamos el PR
            if (!ValidateHelper.ValidateRequired(cboguPRFollow, "Unavailable PR", condition: true))
            {
                return(false);
            }

            // validamos que el motivo de indisponibilidad exista
            Personnel PR = BRPersonnel.GetPersonnelById(cboguPRFollow.SelectedValue.ToString());

            if (PR == null)
            {
                UIHelper.ShowMessage("The PR not exist");
                cboguPRFollow.Focus();
                return(false);
            }
            return(true);
        }
Esempio n. 4
0
        /// <summary>
        /// Verifica si hubo algun cambio en el combobox, si hubo cambio agrega un salesmenchaged a la lista
        /// </summary>
        /// <param name="entity">Objeto con los datos anteriores</param>
        /// <param name="comboBox">Combobox a validar</param>
        /// <param name="position">posicion del salesmen (Liner1,Closer3,etc..)</param>
        /// <param name="lstSalesmenChanges">Lista para guardar los cambios que se hayan generado</param>
        /// <param name="role">Role del personnel seleccionado en el combobox/param>
        /// <history>
        /// [emoguel] 10/11/2016 created
        /// </history>
        public static void GetSalesmenChanges(object entity, ComboBox comboBox, byte position, List <SalesmenChanges> lstSalesmenChanges, string role)
        {
            var propertyName = comboBox.GetBindingExpression(ComboBox.SelectedValueProperty).ResolvedSourcePropertyName;
            var propertyOld  = entity.GetType().GetProperty(propertyName).GetValue(entity)?.ToString() ?? string.Empty;                                     //Valor anterior
            var propertyNew  = comboBox.SelectedValue?.ToString() ?? string.Empty;                                                                          //Valor nuevo

            if (propertyOld != propertyNew && !propertyOld.Equals(propertyNew))                                                                             //verificamos que tenga algun cambio
            {
                var    lstNames   = comboBox.ItemsSource.OfType <object>().ToList();                                                                        //Obtenemos la lista de personnel del combobox
                var    objOldName = lstNames.FirstOrDefault(p => (p.GetType().GetProperty("peID").GetValue(p)?.ToString() ?? string.Empty) == propertyOld); //Buscamos si está el nombre en la lista
                var    objNewName = lstNames.FirstOrDefault(p => (p.GetType().GetProperty("peID").GetValue(p)?.ToString() ?? string.Empty) == propertyNew); //Buscamos si está el nombre en la lista
                string oldName    = objOldName?.GetType().GetProperty("peN").GetValue(objOldName)?.ToString() ?? string.Empty;                              //Verificamos si tiene el nombre
                string newName    = objNewName?.GetType().GetProperty("peN").GetValue(objNewName)?.ToString() ?? string.Empty;                              //Verificamos si tiene el nombre
                //Agregamos el salesmenChanges
                lstSalesmenChanges.Add(new SalesmenChanges
                {
                    schNewSalesman = propertyNew,
                    schOldSalesman = propertyOld,
                    schPosition    = position,
                    roN            = role,
                    OldSalesmanN   = (string.IsNullOrWhiteSpace(propertyOld)) ? string.Empty : (string.IsNullOrWhiteSpace(oldName)) ? string.Empty : BRPersonnel.GetPersonnelById(propertyOld).peN,
                    NewSalesmanN   = (string.IsNullOrWhiteSpace(propertyNew)) ? string.Empty : (string.IsNullOrWhiteSpace(newName)) ? string.Empty : BRPersonnel.GetPersonnelById(propertyNew).peN
                });
            }
        }