Exemple #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 02/05/2016
        /// </history>
        private void Cell_DoubleClick(object sender, RoutedEventArgs e)
        {
            Club          club          = (Club)dtgClubs.SelectedItem;
            frmClubDetail frmClubDetail = new frmClubDetail();

            frmClubDetail.Owner    = this;
            frmClubDetail.enumMode = EnumMode.Edit;
            frmClubDetail.oldClub  = club;
            if (frmClubDetail.ShowDialog() == true)
            {
                List <Club> lstClubs = (List <Club>)dtgClubs.ItemsSource;
                int         nIndex   = 0;
                if (ValidateFilter(frmClubDetail.club))                    //Validamos que cumpla con los filtros
                {
                    ObjectHelper.CopyProperties(club, frmClubDetail.club); //Actualizamos los datos
                    lstClubs.Sort((x, y) => string.Compare(x.clN, y.clN)); //Ordenamos la lista
                    nIndex = lstClubs.IndexOf(club);                       //Buscamos la posición del registro
                }
                else
                {
                    lstClubs.Remove(club);                         //Quitamos el registro
                }
                dtgClubs.Items.Refresh();                          //Actualizamos la vista
                GridHelper.SelectRow(dtgClubs, nIndex);            //Seleccionamos el registro
                StatusBarReg.Content = lstClubs.Count + " Clubs."; //Actualizamos el contador
            }
        }
Exemple #2
0
        /// <summary>
        /// Abre la ventana detalle en modo Add
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <history>
        /// [emoguel] created 02/05/2016
        /// </history>
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            frmClubDetail frmClubDetail = new frmClubDetail();

            frmClubDetail.Owner    = this;
            frmClubDetail.enumMode = EnumMode.Add;
            if (frmClubDetail.ShowDialog() == true)
            {
                if (ValidateFilter(frmClubDetail.club))//Verificar que cumpla con los filtros
                {
                    List <Club> lstClubs = (List <Club>)dtgClubs.ItemsSource;
                    lstClubs.Add(frmClubDetail.club);                      //Agregamos el registro
                    lstClubs.Sort((x, y) => string.Compare(x.clN, y.clN)); //Ordenamos la lista
                    int nIndex = lstClubs.IndexOf(frmClubDetail.club);     //Ordenamos lal ista
                    dtgClubs.Items.Refresh();                              //Actualizamos la vista
                    GridHelper.SelectRow(dtgClubs, nIndex);                //Seleccionamos el registro
                    StatusBarReg.Content = lstClubs.Count + " Clubs.";     //Actualizamos el contador
                }
            }
        }