예제 #1
0
        /// <summary>
        /// Muestra la ventana Detalle
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <history>
        /// [Emoguel] created 03/03/2016
        /// </history>
        private void Cell_DoubleClick(object sender, RoutedEventArgs e)
        {
            Contract           contract          = (Contract)dtgContracts.SelectedItem;
            frmContractsDetail frmContractDetail = new frmContractsDetail();

            frmContractDetail.mode        = ((_blnEdit == true) ? EnumMode.Edit : EnumMode.ReadOnly);
            frmContractDetail.oldContract = contract;
            frmContractDetail.Owner       = this;
            if (frmContractDetail.ShowDialog() == true)
            {
                List <Contract> lstContracts = (List <Contract>)dtgContracts.ItemsSource;
                int             nIndex       = 0;
                if (!ValidateFilters(frmContractDetail.contract))    //Validamos si cumple con los filtros
                {
                    lstContracts.Remove(frmContractDetail.contract); //lo quitamos de la lista
                }
                else
                {
                    ObjectHelper.CopyProperties(contract, frmContractDetail.contract);
                    lstContracts.Sort((x, y) => string.Compare(x.cnID, y.cnID));//ordenamos la lista
                    nIndex = lstContracts.IndexOf(contract);
                }
                dtgContracts.Items.Refresh();
                GridHelper.SelectRow(dtgContracts, nIndex);
                StatusBarReg.Content = lstContracts.Count + " Contracts.";
            }
        }
예제 #2
0
        /// <summary>
        /// Abre la ventana de detalle para agregar un nuevo registro
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <history>
        /// [emoguel] created
        /// </history>
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            frmContractsDetail frmContractDetail = new frmContractsDetail();

            frmContractDetail.mode  = EnumMode.Add;
            frmContractDetail.Owner = this;
            if (frmContractDetail.ShowDialog() == true)
            {
                if (ValidateFilters(frmContractDetail.contract))//Validamos que cumpla con los filtros actuales
                {
                    List <Contract> lstContracts = (List <Contract>)dtgContracts.ItemsSource;
                    lstContracts.Add(frmContractDetail.contract);                  //Agregamos el registro nuevo
                    lstContracts.Sort((x, y) => string.Compare(x.cnID, y.cnID));   //ordenamos la lista
                    int nIndex = lstContracts.IndexOf(frmContractDetail.contract); //obtenemos el index del registro nuevo
                    dtgContracts.Items.Refresh();                                  //refrescamos la lista
                    GridHelper.SelectRow(dtgContracts, nIndex);
                    StatusBarReg.Content = lstContracts.Count + " Contracts.";
                }
            }
        }