예제 #1
0
        /// <summary>
        /// Muestra la ventada detalle
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <history>
        /// [emoguel] created 16/03/2016
        /// </history>
        private void Cell_DoubleClick(object sender, RoutedEventArgs e)
        {
            Desk          desk          = (Desk)dgrDesks.SelectedItem;
            frmDeskDetail frmDeskDetail = new frmDeskDetail();

            frmDeskDetail.enumMode = EnumMode.Edit;
            frmDeskDetail.Owner    = this;
            frmDeskDetail.oldDesk  = desk;
            if (frmDeskDetail.ShowDialog() == true)
            {
                List <Desk> lstDesk = (List <Desk>)dgrDesks.ItemsSource;
                int         nIndex  = 0;
                if (!ValidateFilters(frmDeskDetail.desk))
                {
                    lstDesk.Remove(desk);//Quitamos el registro de la lista
                }
                else
                {
                    ObjectHelper.CopyProperties(desk, frmDeskDetail.desk);
                    lstDesk.Sort((x, Y) => string.Compare(x.dkN, Y.dkN));//Ordenamos la lista
                    nIndex = lstDesk.IndexOf(desk);
                }
                dgrDesks.Items.Refresh();                         //Actualizamos la vista del grid
                GridHelper.SelectRow(dgrDesks, nIndex);
                StatusBarReg.Content = lstDesk.Count + " Desks."; //Actualizamos el contador
            }
        }
예제 #2
0
        /// <summary>
        /// Abre la ventana detalle 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)
        {
            frmDeskDetail frmDeskDetail = new frmDeskDetail();

            frmDeskDetail.enumMode = EnumMode.Add;
            frmDeskDetail.Owner    = this;
            if (frmDeskDetail.ShowDialog() == true)
            {
                Desk desk = frmDeskDetail.desk;
                if (ValidateFilters(desk))//Valida si el registro nuevo cumple con los filtros
                {
                    List <Desk> lstDesk = (List <Desk>)dgrDesks.ItemsSource;
                    lstDesk.Add(desk);                                    //Agregamos el registro nuevo
                    lstDesk.Sort((x, Y) => string.Compare(x.dkN, Y.dkN)); //Ordenamos la lista
                    dgrDesks.Items.Refresh();                             //Actualizamos la vista del grid
                    int nIndex = dgrDesks.Items.IndexOf(desk);            //Obtenemos el index del registro nuevo
                    GridHelper.SelectRow(dgrDesks, nIndex);               //Seleccionamos el registro nuevo
                    StatusBarReg.Content = lstDesk.Count + " Desks.";     //Actualizamos el contador
                }
            }
        }