예제 #1
0
        protected virtual Tipo_Lente LoadFromControls()
        {
            Tipo_Lente Tipo_Lente = new Tipo_Lente();

            if (Id != null)
            {
                Tipo_Lente.Id = Convert.ToInt32(txtId.Text);
            }

            Tipo_Lente.descricao = txtNumero.Text;

            Tipo_LenteBLL = new Tipo_LenteBLL();

            List <Tipo_Lente> lstTipo_Lente = Tipo_LenteBLL.getTipo_Lente(p => p.descricao == Tipo_Lente.descricao);

            if (lstTipo_Lente.Count() > 0)
            {
                Tipo_Lente = lstTipo_Lente.First();
                Id         = Tipo_Lente.Id;
                txtId.Text = Tipo_Lente.Id.ToString();
            }

            Tipo_Lente.inativo = chkInativo.Checked ? "S" : "N";

            return(Tipo_Lente);
        }
예제 #2
0
        protected override void carregaConsulta()
        {
            base.carregaConsulta();
            Tipo_LenteBLL = new Tipo_LenteBLL();
            List <Tipo_Lente> lstTipo_Lente = Tipo_LenteBLL.getTipo_Lente(p => p.Id.ToString(), false, deslocamento, tamanhoPagina, out totalReg);

            dgvDados.DataSource = Tipo_LenteBLL.ToList_Tipo_LenteView(lstTipo_Lente);
            colOrdem            = 0;
        }
예제 #3
0
        protected override void executeCellEndEditChild(object sender, DataGridViewCellEventArgs e)
        {
            base.executeCellEndEditChild(sender, e);

            int    id      = 0;
            string numero  = string.Empty;
            string inativo = string.Empty;


            if (dgvFiltro[COL_ID, e.RowIndex].Value != null)
            {
                id = Convert.ToInt32(dgvFiltro[COL_ID, e.RowIndex].Value);
            }

            if (dgvFiltro[COL_DESCRICAO, e.RowIndex].Value != null)
            {
                numero = dgvFiltro[COL_DESCRICAO, e.RowIndex].Value.ToString();
            }

            if (e.ColumnIndex == COL_INATIVO)
            {
                DataGridViewCheckBoxCell cell = dgvFiltro.CurrentCell as DataGridViewCheckBoxCell;
                if (cell != null)
                {
                    CheckState value = (CheckState)cell.EditedFormattedValue;
                    switch (value)
                    {
                    case CheckState.Checked:
                        inativo = "S";
                        break;

                    case CheckState.Unchecked:
                        inativo = "N";
                        break;

                    default:
                        inativo = string.Empty;
                        break;
                    }
                }
            }

            Expression <Func <Tipo_Lente, bool> > predicate = p => true;


            if (id > 0)
            {
                predicate = predicate = p => p.Id == id;
            }

            if (!string.IsNullOrEmpty(numero))
            {
                predicate = predicate.And(p => p.descricao.Contains(numero));
            }

            if (!string.IsNullOrEmpty(inativo))
            {
                predicate = predicate.And(p => p.inativo == inativo);
            }

            List <Tipo_Lente> Tipo_LenteList = Tipo_LenteBLL.getTipo_Lente(predicate.Expand(), t => t.Id.ToString(), false, deslocamento, tamanhoPagina, out totalReg);

            dgvDados.DataSource = Tipo_LenteBLL.ToList_Tipo_LenteView(Tipo_LenteList);
        }
예제 #4
0
        protected override void ordenaCelula(object sender, DataGridViewCellMouseEventArgs e)
        {
            base.ordenaCelula(sender, e);
            Tipo_LenteBLL = new Tipo_LenteBLL();

            DataGridViewColumn col    = dgvFiltro.Columns[e.ColumnIndex];
            DataGridViewColumn colAnt = dgvFiltro.Columns[colOrdem];

            ListSortDirection direction;

            switch (col.HeaderCell.SortGlyphDirection)
            {
            case SortOrder.None:
                direction = ListSortDirection.Ascending;
                break;

            case SortOrder.Ascending:
                direction = ListSortDirection.Ascending;
                break;

            case SortOrder.Descending:
                direction = ListSortDirection.Descending;
                break;

            default:
                direction = ListSortDirection.Ascending;
                break;
            }


            if (colOrdem == e.ColumnIndex)
            {
                if (direction == ListSortDirection.Ascending)
                {
                    direction = ListSortDirection.Descending;
                }
                else
                {
                    direction = ListSortDirection.Ascending;
                    col.HeaderCell.SortGlyphDirection = SortOrder.None;
                }
            }
            else
            {
                direction = ListSortDirection.Ascending;
                colAnt.HeaderCell.SortGlyphDirection = SortOrder.None;
            }

            switch (e.ColumnIndex)
            {
            case COL_DESCRICAO:
            {
                List <Tipo_Lente> Tipo_LenteList = Tipo_LenteBLL.getTipo_Lente(p => p.descricao, direction != ListSortDirection.Ascending, deslocamento, tamanhoPagina, out totalReg);
                dgvDados.DataSource = Tipo_LenteBLL.ToList_Tipo_LenteView(Tipo_LenteList);
            }
            break;

            //O default será executado quando o index for 0
            default:
            {
                List <Tipo_Lente> Tipo_LenteList = Tipo_LenteBLL.getTipo_Lente(p => p.Id.ToString(), direction != ListSortDirection.Ascending, deslocamento, tamanhoPagina, out totalReg);
                dgvDados.DataSource = Tipo_LenteBLL.ToList_Tipo_LenteView(Tipo_LenteList);
            }
            break;
            }

            colOrdem = e.ColumnIndex;

            col.HeaderCell.SortGlyphDirection = direction == ListSortDirection.Ascending ?
                                                SortOrder.Ascending : SortOrder.Descending;
        }