Exemple #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);
        }
Exemple #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);
            }
        }
Exemple #3
0
 public virtual void AlterarTipo_Lente(Tipo_Lente Tipo_Lente)
 {
     try
     {
         _Tipo_LenteRepositorio.Atualizar(Tipo_Lente);
         _Tipo_LenteRepositorio.Commit();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #4
0
 public virtual void ExcluirTipo_Lente(Tipo_Lente Tipo_Lente)
 {
     try
     {
         _Tipo_LenteRepositorio.Deletar(c => c == Tipo_Lente);
         _Tipo_LenteRepositorio.Commit();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #5
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";
                }
            }
        }
Exemple #6
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();
     }
 }