Exemple #1
0
        /// <summary>
        /// Muestra la ventada computerDetail dependiendo de los permisos
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <history>
        /// [Emoguel] created 16/03/2016
        /// </history>
        private void Cell_DoubleClick(object sender, RoutedEventArgs e)
        {
            Computer          computer     = (Computer)dtgComputers.SelectedItem;
            frmComputerDetail frmComDetail = new frmComputerDetail();

            frmComDetail.Owner       = this;
            frmComDetail.mode        = EnumMode.Edit;
            frmComDetail.oldComputer = computer;
            frmComDetail.ShowDialog();
            if (frmComDetail.DialogResult == true)
            {
                List <Computer> lstComputers = (List <Computer>)dtgComputers.ItemsSource;
                int             nIndex       = 0;
                if (!ValidateFilters(frmComDetail.computer)) //Validamos que cumpla con los filtros
                {
                    lstComputers.Remove(computer);           //Quitamos el registro de la lista
                }
                else
                {
                    ObjectHelper.CopyProperties(computer, frmComDetail.computer);
                    lstComputers.Sort((x, y) => string.Compare(x.cpN, y.cpN));//ordenamos la lista
                    nIndex = lstComputers.IndexOf(computer);
                }
                dtgComputers.Items.Refresh();//refrescamos la lista
                GridHelper.SelectRow(dtgComputers, nIndex);
                StatusBarReg.Content = lstComputers.Count + " Computers.";
            }
        }
Exemple #2
0
        /// <summary>
        /// Abre la centana computerDetail en modo add
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <history>
        /// [emoguel] created 16/03/2016
        /// </history>
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            frmComputerDetail frmComputerDetail = new frmComputerDetail();

            frmComputerDetail.Owner = this;
            frmComputerDetail.mode  = EnumMode.Add;
            if (frmComputerDetail.ShowDialog() == true)
            {
                if (ValidateFilters(frmComputerDetail.computer))//Validamos que cumpla con los filtros
                {
                    List <Computer> lstComputers = (List <Computer>)dtgComputers.ItemsSource;
                    lstComputers.Add(frmComputerDetail.computer);                  //Agregamos el registro nuevo
                    lstComputers.Sort((x, y) => string.Compare(x.cpN, y.cpN));     //ordenamos la lista
                    int nIndex = lstComputers.IndexOf(frmComputerDetail.computer); //obtenemos el index del registro nuevo
                    dtgComputers.Items.Refresh();                                  //refrescamos la lista
                    GridHelper.SelectRow(dtgComputers, nIndex);
                    StatusBarReg.Content = lstComputers.Count + " Computers.";
                }
            }
        }