コード例 #1
0
ファイル: frmAreas.xaml.cs プロジェクト: jackjet870/IM-2
        /// <summary>
        /// Muestra la ventana de AreaDetalle en modo ReadOnly
        /// </summary>
        /// <history>
        /// [emoguel] 26/Feb/2016 Created
        /// </history>
        private void Cell_DoubleClick(object sender, RoutedEventArgs e)
        {
            Area           Area           = (Area)dtgAreas.SelectedItem;
            frmAreaDetalle frmAreaDetalle = new frmAreaDetalle();

            frmAreaDetalle.Owner   = this;
            frmAreaDetalle.oldArea = Area;
            frmAreaDetalle.mode    = ((_blnEdit == true) ? EnumMode.Edit : EnumMode.ReadOnly);
            if (frmAreaDetalle.ShowDialog() == true)
            {
                List <Area> lstAreas = (List <Area>)dtgAreas.ItemsSource;
                int         nIndex   = 0;
                if (!ValidateFilters(frmAreaDetalle.area)) //VAlidamos si cumple con los filtros
                {
                    lstAreas.Remove(Area);                 //quitamos el registro de la lista
                }
                else
                {
                    ObjectHelper.CopyProperties(Area, frmAreaDetalle.area);
                    lstAreas.Sort((x, y) => string.Compare(x.arN, y.arN));//Ordenamos la lista
                    nIndex = lstAreas.IndexOf(Area);
                }

                dtgAreas.Items.Refresh();                          //Refrescamos la lista
                GridHelper.SelectRow(dtgAreas, nIndex);
                StatusBarReg.Content = lstAreas.Count + " Areas."; //Actualizamos el contador
            }
        }
コード例 #2
0
ファイル: frmAreas.xaml.cs プロジェクト: jackjet870/IM-2
        /// <summary>
        /// Muestra la ventana de AreaDetalle para agregar un registro nuevo
        /// </summary>
        /// <history>
        /// [emoguel] 26/Feb/2016 Created
        /// </history>
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            frmAreaDetalle frmAreaDetalle = new frmAreaDetalle();

            frmAreaDetalle.Owner   = this;
            frmAreaDetalle.oldArea = new Area();
            frmAreaDetalle.mode    = EnumMode.Add;//Agregar
            if (frmAreaDetalle.ShowDialog() == true)
            {
                if (ValidateFilters(frmAreaDetalle.area))//Validamos si cumple con los filtros
                {
                    List <Area> lstAreas = (List <Area>)dtgAreas.ItemsSource;
                    lstAreas.Add(frmAreaDetalle.area);                     //Agregamos el registro nuevo
                    lstAreas.Sort((x, y) => string.Compare(x.arN, y.arN)); //Ordenamos la lista
                    int nIndex = lstAreas.IndexOf(frmAreaDetalle.area);    //Obetenemos el index nuevo
                    dtgAreas.Items.Refresh();                              //Refrescamos la lista
                    GridHelper.SelectRow(dtgAreas, nIndex);
                    StatusBarReg.Content = lstAreas.Count + " Areas.";     //Actualizamos el contador
                }
            }
        }