Example #1
0
        protected void btnGrabar_Click(object sender, EventArgs e)
        {
            FuncionDTO obj = new FuncionDTO();

            if (this.txtId.Text == "")
            {
                obj.NombreFuncion = this.txtNombre.Text;
                obj.Funcion = this.txtFuncion.Text;
                if (this.chkEstado.Checked)
                    obj.Estado = "1";
                else
                    obj.Estado = "0";

                int id = objFuncionDAO.Agregar(obj);

                this.txtId.Text = id.ToString();
                //this.lblMensaje.Text = "Se registro el Usuario";

                this.panRegistro.Visible = true;
                this.panLista.Visible = false;

                this.btnGrabar.Visible = false;
                this.btnActualizar.Visible = true;
                this.btnEliminar.Visible = true;
                this.btnCancelar.Visible = true;

             }
        }
Example #2
0
        public List<FuncionDTO> Listar()
        {
            List<FuncionDTO> Lista = new List<FuncionDTO>();
            Database db = DatabaseFactory.CreateDatabase("ApplicationConnectionString");
            DbCommand dbCommand = db.GetStoredProcCommand(C_LISTAR);

            using (IDataReader dr = db.ExecuteReader(dbCommand))
            {
                while (dr.Read())
                {
                    FuncionDTO obj = new FuncionDTO();

                    obj.IdFuncion = (int)dr["id_funcion"];

                    if (dr["nombre_funcion"] != System.DBNull.Value)
                        obj.NombreFuncion = (string)dr["nombre_funcion"];

                    if (dr["funcion"] != System.DBNull.Value)
                        obj.Funcion = (string)dr["funcion"];

                    if (dr["estado"] != System.DBNull.Value)
                        obj.Estado = (string)dr["estado"];

                    Lista.Add(obj);
                }
            }

            return Lista;
        }
Example #3
0
 public void Actualizar(FuncionDTO obj)
 {
     Database db = DatabaseFactory.CreateDatabase("ApplicationConnectionString");
     DbCommand dbCommand = db.GetStoredProcCommand(C_ACTUALIZAR);
     db.AddInParameter(dbCommand, "@id_funcion", DbType.Int32 , obj.IdFuncion);
     db.AddInParameter(dbCommand, "@nombre_funcion", DbType.String, obj.NombreFuncion);
     db.AddInParameter(dbCommand, "@funcion", DbType.String, obj.Funcion);
     db.AddInParameter(dbCommand, "@estado", DbType.String, obj.Estado);
     db.ExecuteNonQuery(dbCommand);
 }
Example #4
0
        protected void btnActualizar_Click(object sender, EventArgs e)
        {
            FuncionDTO obj = new FuncionDTO();

            obj = objFuncionDAO.ListarPorClave(Convert.ToInt32(this.txtId.Text));

            obj.NombreFuncion = this.txtNombre.Text;
            obj.Funcion = this.txtFuncion.Text;

            if (this.chkEstado.Checked)
                obj.Estado = "1";
            else
                obj.Estado = "0";

            objFuncionDAO.Actualizar(obj);
        }
Example #5
0
        public int Agregar(FuncionDTO obj)
        {
            Database db = DatabaseFactory.CreateDatabase("ApplicationConnectionString");
            DbCommand dbCommand = db.GetStoredProcCommand(C_AGREGAR);
            db.AddInParameter(dbCommand, "@nombre_funcion", DbType.String, obj.NombreFuncion);
            db.AddInParameter(dbCommand, "@funcion", DbType.String, obj.Funcion);
            db.AddInParameter(dbCommand, "@estado", DbType.String, obj.Estado);

            db.ExecuteNonQuery(dbCommand);

            dbCommand = db.GetSqlStringCommand("SELECT MAX(id_funcion) FROM SEG_FUNCION");

            int Id = Convert.ToInt32(db.ExecuteScalar(dbCommand));

            return Id;
        }
Example #6
0
        protected void btnEliminar_Click(object sender, EventArgs e)
        {
            FuncionDTO obj = new FuncionDTO();

            if (this.txtId.Text != "")
            {
                objFuncionDAO.Eliminar(Convert.ToInt32(this.txtId.Text));

                this.txtId.Text = "";
                this.txtNombre.Text  = "";
                this.txtFuncion.Text = "";
                this.chkEstado.Checked = true;

            }
            this.panRegistro.Visible = false;
            this.panLista.Visible = true;

            this.btnGrabar.Visible = false;
            this.btnActualizar.Visible = false;
            this.btnEliminar.Visible = false;
            this.btnCancelar.Visible = false;

            Listar();
        }
Example #7
0
        public FuncionDTO ListarPorClave(int id)
        {
            FuncionDTO obj = new FuncionDTO();
            Database db = DatabaseFactory.CreateDatabase("ApplicationConnectionString");
            DbCommand dbCommand = db.GetStoredProcCommand(C_BUSCAR_POR_CLAVE);
            db.AddInParameter(dbCommand, "@id_funcion", DbType.Int32, id);

            using (IDataReader dr = db.ExecuteReader(dbCommand))
            {
                if (dr.Read())
                {
                    obj.IdFuncion = (int)dr["id_funcion"];

                    if (dr["nombre_funcion"] != System.DBNull.Value)
                        obj.NombreFuncion = (string)dr["nombre_funcion"];

                    if (dr["funcion"] != System.DBNull.Value)
                        obj.Funcion = (string)dr["funcion"];

                    if (dr["estado"] != System.DBNull.Value)
                        obj.Estado = (string)dr["estado"];

                }
            }
            return obj;
        }
Example #8
0
        public List<FuncionDTO> ListarFuncionPorPerfil(int IdPerfil)
        {
            List<FuncionDTO> Lista = new List<FuncionDTO>();
              Database db = DatabaseFactory.CreateDatabase("ApplicationConnectionString");
              DbCommand dbCommand = db.GetSqlStringCommand(C_LISTAR_FUNCION_POR_PERFIL);
              db.AddInParameter(dbCommand, "@id_perfil", DbType.Int32, IdPerfil);

              using (IDataReader dr = db.ExecuteReader(dbCommand))
              {
              while (dr.Read())
              {
                  FuncionDTO obj = new FuncionDTO();

                  obj.IdFuncion = (int)dr["id_funcion"];

                  if (dr["nombre_funcion"] != System.DBNull.Value)
                      obj.NombreFuncion = (string)dr["nombre_funcion"];

                  if (dr["funcion"] != System.DBNull.Value)
                      obj.Funcion = (string)dr["funcion"];

                  if (dr["estado"] != System.DBNull.Value)
                      obj.Estado = (string)dr["estado"];

                  Lista.Add(obj);
              }
              }

              return Lista;
        }