Пример #1
0
        /// <summary>
        /// Muestra la ventana detalle en modo ReadOnly|edicion
        /// </summary>
        /// <history>
        /// [emoguel] 01/04/2016
        /// </history>
        private void Cell_DoubleClick(object sender, RoutedEventArgs e)
        {
            MaritalStatus          maritalStatus = (MaritalStatus)dgrMaritalStatus.SelectedItem;
            frmMaritalStatusDetail frmMarStatus  = new frmMaritalStatusDetail();

            frmMarStatus.Owner            = this;
            frmMarStatus.oldMaritalStatus = maritalStatus;
            frmMarStatus.enumMode         = (_blnEdit == true)?EnumMode.Edit:EnumMode.ReadOnly;
            if (frmMarStatus.ShowDialog() == true)
            {
                int nIndex = 0;
                List <MaritalStatus> lstMaritalStatus = (List <MaritalStatus>)dgrMaritalStatus.ItemsSource;
                if (!ValidateFilter(frmMarStatus.maritalStatus))
                {
                    lstMaritalStatus.Remove(maritalStatus);//Quitamos el registro de la lista
                    StatusBarReg.Content = lstMaritalStatus.Count + " Marital Status.";
                }
                else
                {
                    ObjectHelper.CopyProperties(maritalStatus, frmMarStatus.maritalStatus); //Le asignamos los nuevos valores
                    lstMaritalStatus.Sort((x, y) => string.Compare(x.msN, y.msN));          //ordenamos la lista
                    nIndex = lstMaritalStatus.IndexOf(maritalStatus);                       //obtenemos la posicion del registro
                }
                dgrMaritalStatus.Items.Refresh();
                GridHelper.SelectRow(dgrMaritalStatus, nIndex);
            }
        }
Пример #2
0
        /// <summary>
        /// Abre la ventana detalle en modo Add
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <history>
        /// [emoguel] created 01/04/2016
        /// </history>
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            frmMaritalStatusDetail frmMarStatusDet = new frmMaritalStatusDetail();

            frmMarStatusDet.Owner    = this;
            frmMarStatusDet.enumMode = EnumMode.Add;
            if (frmMarStatusDet.ShowDialog() == true)
            {
                MaritalStatus maritalStatus = frmMarStatusDet.maritalStatus;
                if (ValidateFilter(maritalStatus))//validamos que cumpla con los filtros
                {
                    List <MaritalStatus> lstMaritalStatus = (List <MaritalStatus>)dgrMaritalStatus.ItemsSource;
                    lstMaritalStatus.Add(maritalStatus);                           //Agregamos el registro a la lista
                    lstMaritalStatus.Sort((x, y) => string.Compare(x.msN, y.msN)); //ordenamos la lista
                    int nIndex = lstMaritalStatus.IndexOf(maritalStatus);          //Obtenemos la posicion del nuevo registro
                    dgrMaritalStatus.Items.Refresh();                              //Actualizamos la vista del grid
                    GridHelper.SelectRow(dgrMaritalStatus, nIndex);                //Seleccionamos el nuevo registro
                    StatusBarReg.Content = lstMaritalStatus.Count + " Marital Status.";
                }
            }
        }