예제 #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 bool salvar(object sender, EventArgs e)
        {
            if (epValidaDados.Validar())
            {
                Tipo_Lente Tipo_Lente = new Tipo_Lente();
                Tipo_LenteBLL = new Tipo_LenteBLL();

                Tipo_LenteBLL.UsuarioLogado = Program.usuario_logado;

                Tipo_Lente = LoadFromControls();

                if (Id != null)
                {
                    Tipo_LenteBLL.AlterarTipo_Lente(Tipo_Lente);
                }
                else
                {
                    Tipo_LenteBLL.AdicionarTipo_Lente(Tipo_Lente);
                }

                if (Tipo_Lente.Id != 0)
                {
                    Id         = Tipo_Lente.Id;
                    txtId.Text = Tipo_Lente.Id.ToString();
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #3
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;
        }
예제 #4
0
        protected override void LoadToControls()
        {
            base.LoadToControls();

            if (Id != null)
            {
                Tipo_LenteBLL = new Tipo_LenteBLL();
                Tipo_Lente Tipo_Lente = Tipo_LenteBLL.Localizar(Id);

                if (Tipo_Lente != null)
                {
                    txtId.Text         = Tipo_Lente.Id.ToString();
                    txtNumero.Text     = Tipo_Lente.descricao;
                    chkInativo.Checked = Tipo_Lente.inativo == "S";
                }
            }
        }
예제 #5
0
 protected override void excluirRegistro(int Id)
 {
     base.excluirRegistro(Id);
     Tipo_LenteBLL = new Tipo_LenteBLL();
     try
     {
         if (Convert.ToInt32(dgvDados[0, dgvDados.CurrentRow.Index].Value) > 0)
         {
             Tipo_Lente Tipo_Lente = Tipo_LenteBLL.Localizar(Convert.ToInt32(dgvDados[0, dgvDados.CurrentRow.Index].Value));
             if (MessageBox.Show("Deseja realmente excluir o registro : " + Tipo_Lente.Id.ToString() + " - " + Tipo_Lente.descricao, Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
             {
                 Tipo_LenteBLL.ExcluirTipo_Lente(Tipo_Lente);
             }
         }
     }
     finally
     {
         Tipo_LenteBLL.Dispose();
     }
 }
예제 #6
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;
        }