Esempio n. 1
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. 2
0
        /// <summary>
        /// Abre la ventana detalle en modo Add
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <history>
        /// [emoguel] created 10/06/2016
        /// </history>
        private async void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            frmPersonnelDetail frmPersonnelDetail = new frmPersonnelDetail();

            frmPersonnelDetail.Owner    = this;
            frmPersonnelDetail.enumMode = EnumMode.Add;
            if (frmPersonnelDetail.ShowDialog() == true)
            {
                var persons = await BRPersonnel.GetPersonnel(idPersonnel : frmPersonnelDetail.personnel.peID);

                if (persons.Count > 0)
                {
                    List <PersonnelShort> lstPersonnel = (List <PersonnelShort>)dgrPersonnels.ItemsSource;
                    PersonnelShort        person       = persons.FirstOrDefault();
                    lstPersonnel.Add(person);                                   //Agregamos el registro
                    lstPersonnel.Sort((x, y) => string.Compare(x.peN, y.peN));  //Ordenamos la lista
                    int nIndex = lstPersonnel.IndexOf(person);                  //Obtenemos la posición del 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
                }
            }
        }