Ejemplo 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 31/05/2016
        /// </history>
        private void Cell_DoubleClick(object sender, RoutedEventArgs e)
        {
            SegmentByAgency          segmentByAgency    = (SegmentByAgency)dgrSegments.SelectedItem;
            frmSegmentByAgencyDetail frmSegmentByAgency = new frmSegmentByAgencyDetail();

            frmSegmentByAgency.Owner              = this;
            frmSegmentByAgency.enumMode           = (_blnEdit) ? EnumMode.Edit : EnumMode.Add;
            frmSegmentByAgency.oldSegmentByAgency = segmentByAgency;
            if (frmSegmentByAgency.ShowDialog() == true)
            {
                int nIndex = 0;
                List <SegmentByAgency> lstSegmentsByAgency = (List <SegmentByAgency>)dgrSegments.ItemsSource;
                if (ValidateFilter(frmSegmentByAgency.segmentByAgency))                               //Verificamos que cumpla con los filtros
                {
                    ObjectHelper.CopyProperties(segmentByAgency, frmSegmentByAgency.segmentByAgency); //Actualizamos los datos
                    lstSegmentsByAgency.Sort((x, y) => string.Compare(x.seN, y.seN));                 //Ordenamos la lista
                    nIndex = lstSegmentsByAgency.IndexOf(segmentByAgency);                            //Obtenemos la posición del registro
                }
                else
                {
                    lstSegmentsByAgency.Remove(segmentByAgency);                //Quitamos el registro
                }
                dgrSegments.Items.Refresh();                                    //Actualizamos la vista
                GridHelper.SelectRow(dgrSegments, nIndex);                      //Seleccionamos el registro
                StatusBarReg.Content = lstSegmentsByAgency.Count + " Segments"; //Actualizamos el contador
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Abre la ventana detalle en modo Add
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <history>
        /// [emoguel] created 31/05/2016
        /// </history>
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            frmSegmentByAgencyDetail frmSegmentByAgency = new frmSegmentByAgencyDetail();

            frmSegmentByAgency.Owner    = this;
            frmSegmentByAgency.enumMode = EnumMode.Add;
            if (frmSegmentByAgency.ShowDialog() == true)
            {
                if (ValidateFilter(frmSegmentByAgency.segmentByAgency))//Verificamos que cumpla con los filtros
                {
                    List <SegmentByAgency> lstSegmentByAgency = (List <SegmentByAgency>)dgrSegments.ItemsSource;
                    lstSegmentByAgency.Add(frmSegmentByAgency.segmentByAgency);                  //Agregamos el registro
                    lstSegmentByAgency.Sort((x, y) => string.Compare(x.seN, y.seN));             //Ordenamos la lista
                    int nIndex = lstSegmentByAgency.IndexOf(frmSegmentByAgency.segmentByAgency); //Buscamos la posición del registro
                    dgrSegments.Items.Refresh();                                                 //Actualizamos la vista
                    GridHelper.SelectRow(dgrSegments, nIndex);                                   //Seleccionamos el registro
                    StatusBarReg.Content = lstSegmentByAgency.Count + " Segments";
                }
            }
        }