Exemplo 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 02/06/2016
        /// </history>
        private void Cell_DoubleClick(object sender, RoutedEventArgs e)
        {
            SegmentByLeadSource          segmentByLS    = (SegmentByLeadSource)dgrSegments.SelectedItem;
            frmSegmentByLeadSourceDetail frmSegmentByLS = new frmSegmentByLeadSourceDetail();

            frmSegmentByLS.Owner = this;
            frmSegmentByLS.oldSegmentByLeadSource = segmentByLS;
            frmSegmentByLS.enumMode = (_blnEdit) ? EnumMode.Edit : EnumMode.ReadOnly;
            if (frmSegmentByLS.ShowDialog() == true)
            {
                int nIndex = 0;
                List <SegmentByLeadSource> lstSegmentByLS = (List <SegmentByLeadSource>)dgrSegments.ItemsSource;
                if (ValidateFilter(frmSegmentByLS.segmentByLeadSource))                           //Validar que cumpla con los filtros
                {
                    ObjectHelper.CopyProperties(segmentByLS, frmSegmentByLS.segmentByLeadSource); //Actualizamos los datos
                    lstSegmentByLS.Sort((x, y) => string.Compare(x.soN, y.soN));                  //Ordenamos la lista
                    nIndex = lstSegmentByLS.IndexOf(segmentByLS);                                 //Obtenemos la posición del registro
                }
                else
                {
                    lstSegmentByLS.Remove(segmentByLS);                     //Quitamos el registro
                }
                dgrSegments.Items.Refresh();                                //Actualizamos la vista
                GridHelper.SelectRow(dgrSegments, nIndex);                  //Seleccionamos el registro
                StatusBarReg.Content = lstSegmentByLS.Count + " Segments."; //Actualizamos el contador
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Abre la ventana detalle en modo add
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <history>
        /// [emoguel] created 02/06/2016
        /// </history>
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            frmSegmentByLeadSourceDetail frmSegmentsByLS = new frmSegmentByLeadSourceDetail();

            frmSegmentsByLS.Owner    = this;
            frmSegmentsByLS.enumMode = EnumMode.Add;
            if (frmSegmentsByLS.ShowDialog() == true)
            {
                if (ValidateFilter(frmSegmentsByLS.segmentByLeadSource))//Verificar si cumple con los filtros
                {
                    List <SegmentByLeadSource> lstSegments = new List <SegmentByLeadSource>();
                    lstSegments.Add(frmSegmentsByLS.segmentByLeadSource);                  //Agregamos el objeto
                    lstSegments.Sort((x, y) => string.Compare(x.soN, y.soN));              //Ordenamos la lista
                    int nIndex = lstSegments.IndexOf(frmSegmentsByLS.segmentByLeadSource); //Buscamos la posición del registro
                    dgrSegments.Items.Refresh();                                           //Actualizamos la vista
                    GridHelper.SelectRow(dgrSegments, nIndex);                             //Seleccionamos el registro
                    StatusBarReg.Content = lstSegments.Count + " Segments.";               //Actualizamos el contador
                }
            }
        }